diff --git a/lib/config/config.dart b/lib/config/config.dart index 2db3184a..de0a7b6a 100644 --- a/lib/config/config.dart +++ b/lib/config/config.dart @@ -1,5 +1,10 @@ const MAX_SMALL_SCREEN = 660; -const BASE_URL = 'https://hmgwebservices.com/Services/'; const ONLY_NUMBERS = "[0-9]"; const ONLY_LETTERS = "[a-zA-Z]"; const ONLY_DATE = "[0-9/]"; + + +//Ibrahim Albitar + +const BASE_URL = 'https://hmgwebservices.com/Services/'; +const PHARMACY_ITEMS_URL = "Lists.svc/REST/GetPharmcyItems"; \ No newline at end of file diff --git a/lib/models/medicine_model.dart b/lib/models/medicine_model.dart deleted file mode 100644 index e69de29b..00000000 diff --git a/lib/models/pharmacies_request_model.dart b/lib/models/pharmacies_request_model.dart new file mode 100644 index 00000000..e44c9be5 --- /dev/null +++ b/lib/models/pharmacies_request_model.dart @@ -0,0 +1,26 @@ +//Ibrahim Albitar + +class PharmaciesRequestModel { + String PHR_itemName; + int LanguageID; + String stamp; + String IPAdress; + double VersionID; + String TokenID; + String SessionID; + bool IsLoginForDoctorApp; + bool PatientOutSA; + int PatientTypeID; + + PharmaciesRequestModel( + {this.PHR_itemName, + this.PatientTypeID, + this.LanguageID, + this.stamp, + this.IPAdress, + this.VersionID, + this.TokenID, + this.SessionID, + this.IsLoginForDoctorApp, + this.PatientOutSA}); +} diff --git a/lib/providers/medicine_provider.dart b/lib/providers/medicine_provider.dart index e69de29b..759f6749 100644 --- a/lib/providers/medicine_provider.dart +++ b/lib/providers/medicine_provider.dart @@ -0,0 +1,30 @@ +import 'dart:convert'; + +import 'package:doctor_app_flutter/client/app_client.dart'; +import 'package:doctor_app_flutter/config/config.dart'; +import 'package:doctor_app_flutter/models/pharmacies_request_model.dart'; +import 'package:flutter/cupertino.dart'; + +class MedicineProvider with ChangeNotifier { + + Future getPharmacyList(PharmaciesRequestModel pharmacy) async { + try { + final response = await AppClient.post(PHARMACY_ITEMS_URL, + body: json.encode({ + "PHR_itemName": pharmacy.PHR_itemName, + "LanguageID": pharmacy.LanguageID, + "stamp": pharmacy.stamp, + "IPAdress": pharmacy.IPAdress, + "VersionID": pharmacy.VersionID, + "TokenID": pharmacy.TokenID, + "SessionID": pharmacy.SessionID, + "IsLoginForDoctorApp": pharmacy.IsLoginForDoctorApp, + "PatientOutSA": pharmacy.PatientOutSA, + "PatientTypeID": pharmacy.PatientTypeID + })); + return Future.value(json.decode(response.body)); + } catch (error) { + throw error; + } + } +} diff --git a/lib/routes.dart b/lib/routes.dart index be11ee52..5148f1e6 100644 --- a/lib/routes.dart +++ b/lib/routes.dart @@ -30,7 +30,7 @@ const String PATIENTS = 'patients/patients'; const String PATIENTS_PROFILE = 'patients/patients-profile'; const String BLOOD_BANK = 'blood-bank'; const String DOCTOR_REPLY = 'doctor-reply'; -const String MEDICINE_SEARCH = 'medicine-search'; +const String MEDICINE_SEARCH = 'medicine/medicine-search'; const String SETTINGS = 'settings'; var routes = { diff --git a/lib/screens/dashboard_screen.dart b/lib/screens/dashboard_screen.dart index b6502760..55cfcefd 100644 --- a/lib/screens/dashboard_screen.dart +++ b/lib/screens/dashboard_screen.dart @@ -23,217 +23,216 @@ class _DashboardScreenState extends State { @override Widget build(BuildContext context) { return AppScaffold( - appBarTitle:'Home', - body: Container( - + appBarTitle: 'Home', + body: Container( child: Column( - children: [ - Expanded( - flex: 1, - child: Container( - margin: EdgeInsets.all(10), - child: AppText( - "Today's Statistics", - fontWeight: FontWeight.bold, - ), - alignment: Alignment.centerLeft, - )), - Expanded( - flex: 3, - child: Row( - crossAxisAlignment: CrossAxisAlignment.stretch, - children: [ - Expanded( - flex: 2, - child: RoundedContainer(child:CircularPercentIndicator( - radius: 90.0, - animation: true, - animationDuration: 1200, - lineWidth: 7.0, - percent: .75, - center: Column( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - AppText( - "38", - fontWeight: FontWeight.bold, - fontSize: SizeConfig.textMultiplier * 4 - ), - AppText( - "Out-Patients", - fontWeight: FontWeight.normal, - fontSize: SizeConfig.textMultiplier * 1.5, - color: Colors.grey[800] - ), - ], - ), - circularStrokeCap: CircularStrokeCap.butt, - backgroundColor: Colors.blueGrey[100], - progressColor: Colors.red, - ))), - Expanded( - flex: 2, - child: Row( - children: [ - Expanded( - flex: 1, - child: Column( - crossAxisAlignment: - CrossAxisAlignment.stretch, - children: [ - Expanded( - child: DashboardItemTexts( - "Arrived", - "23", - )), - Expanded( - child: DashboardItemTexts( - "Not Arrived", - "23", - )), - ], - )), - Expanded( - child: Column( + children: [ + Expanded( + flex: 1, + child: Container( + margin: EdgeInsets.all(10), + child: AppText( + "Today's Statistics", + fontWeight: FontWeight.bold, + ), + alignment: Alignment.centerLeft, + )), + Expanded( + flex: 3, + child: Row( + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + Expanded( + flex: 2, + child: RoundedContainer( + child: CircularPercentIndicator( + radius: 90.0, + animation: true, + animationDuration: 1200, + lineWidth: 7.0, + percent: .75, + center: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + AppText("38", + fontWeight: FontWeight.bold, + fontSize: SizeConfig.textMultiplier * 4), + AppText("Out-Patients", + fontWeight: FontWeight.normal, + fontSize: SizeConfig.textMultiplier * 1.5, + color: Colors.grey[800]), + ], + ), + circularStrokeCap: CircularStrokeCap.butt, + backgroundColor: Colors.blueGrey[100], + progressColor: Colors.red, + ))), + Expanded( + flex: 2, + child: Row( + children: [ + Expanded( + flex: 1, + child: Column( crossAxisAlignment: CrossAxisAlignment.stretch, children: [ Expanded( child: DashboardItemTexts( - "ER", + "Arrived", "23", )), Expanded( child: DashboardItemTexts( - "Walk-in", + "Not Arrived", "23", )), ], )), + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + Expanded( + child: DashboardItemTexts( + "ER", + "23", + )), + Expanded( + child: DashboardItemTexts( + "Walk-in", + "23", + )), ], - )) - ])), - Expanded( - flex: 2, - child: Row( - crossAxisAlignment: CrossAxisAlignment.stretch, - children: [ - Expanded( - flex: 2, - child: new DashboardItemIconText( - DoctorApp.home_icon, - "08", - "Lab Result", - backgroundColor: Colors.red, - )), - Expanded( - flex: 2, - child: new DashboardItemIconText( - DoctorApp.home_icon, - "10", - "Radiology", - backgroundColor: Colors.red, - )), - Expanded( - flex: 2, - child: new DashboardItemIconText( - DoctorApp.home_icon, - "05", - "Referral", - backgroundColor: Colors.red, - )), - ], - )), - Expanded( - flex: 2, - child: Row( - crossAxisAlignment: CrossAxisAlignment.stretch, - children: [ - Expanded( - flex: 2, - child: new DashboardItemIconText( - DoctorApp.home_icon, - "23", - "In-Patient", - showBorder: true, - )), - Expanded( - flex: 2, - child: new DashboardItemIconText( - DoctorApp.home_icon, - "23", - "Operations", - showBorder: true, - )), - ], - )), - Expanded( - flex: 1, - child: Container( - margin: EdgeInsets.all(10), - child: AppText( - "Patient Services", - fontWeight: FontWeight.bold, - ), - alignment: Alignment.centerLeft, - )), - Expanded( - flex: 2, - child: Row( - crossAxisAlignment: CrossAxisAlignment.stretch, - children: [ - Expanded( - flex: 2, - child: InkWell( child: DashboardItemIconText( - DoctorApp.home_icon, - "", - "Search Patient", - showBorder: false, - backgroundColor: Colors.green[200], - ), - - onTap: () { - Navigator.of(context).pushNamed(PATIENT_SEARCH); - }, - - )), - Expanded( - flex: 2, - child: new DashboardItemIconText( - DoctorApp.home_icon, - "", - "Out Patient", - showBorder: false, - backgroundColor: Colors.deepPurple[300], - )), - ], - )), - Expanded( - flex: 2, - child: Row( - crossAxisAlignment: CrossAxisAlignment.stretch, - children: [ - Expanded( - flex: 2, - child: new DashboardItemIconText( - DoctorApp.home_icon, - "", - "In Patient", - showBorder: false, - backgroundColor: Colors.blueGrey[900], - )), - Expanded( - flex: 2, - child: new DashboardItemIconText( - DoctorApp.home_icon, - "", - "Discharge Patient", - showBorder: false, - backgroundColor: Colors.brown[400], - )), - ], - )), - ], - ))); + )), + ], + )) + ])), + Expanded( + flex: 2, + child: Row( + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + Expanded( + flex: 2, + child: new DashboardItemIconText( + DoctorApp.home_icon, + "08", + "Lab Result", + backgroundColor: Colors.red, + )), + Expanded( + flex: 2, + child: new DashboardItemIconText( + DoctorApp.home_icon, + "10", + "Radiology", + backgroundColor: Colors.red, + )), + Expanded( + flex: 2, + child: new DashboardItemIconText( + DoctorApp.home_icon, + "05", + "Referral", + backgroundColor: Colors.red, + )), + ], + )), + Expanded( + flex: 2, + child: Row( + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + Expanded( + flex: 2, + child: new DashboardItemIconText( + DoctorApp.home_icon, + "23", + "In-Patient", + showBorder: true, + )), + Expanded( + flex: 2, + child: new DashboardItemIconText( + DoctorApp.home_icon, + "23", + "Operations", + showBorder: true, + )), + ], + )), + Expanded( + flex: 1, + child: Container( + margin: EdgeInsets.all(10), + child: AppText( + "Patient Services", + fontWeight: FontWeight.bold, + ), + alignment: Alignment.centerLeft, + )), + Expanded( + flex: 2, + child: Row( + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + Expanded( + flex: 2, + child: InkWell( + child: DashboardItemIconText( + DoctorApp.home_icon, + "", + "Search Patient", + showBorder: false, + backgroundColor: Colors.green[200], + ), + onTap: () { + Navigator.of(context).pushNamed(PATIENT_SEARCH); + }, + )), + Expanded( + flex: 2, + child: InkWell( + child: DashboardItemIconText( + DoctorApp.home_icon, + "", + "Out Patient", + showBorder: false, + backgroundColor: Colors.deepPurple[300], + ), + onTap: () { + Navigator.of(context).pushNamed(MEDICINE_SEARCH); + }, + )), + ], + )), + Expanded( + flex: 2, + child: Row( + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + Expanded( + flex: 2, + child: new DashboardItemIconText( + DoctorApp.home_icon, + "", + "In Patient", + showBorder: false, + backgroundColor: Colors.blueGrey[900], + )), + Expanded( + flex: 2, + child: new DashboardItemIconText( + DoctorApp.home_icon, + "", + "Discharge Patient", + showBorder: false, + backgroundColor: Colors.brown[400], + )), + ], + )), + ], + ))); } } diff --git a/lib/screens/medicine/medicine_search_screen.dart b/lib/screens/medicine/medicine_search_screen.dart index 11e4d6ea..79ae48ff 100644 --- a/lib/screens/medicine/medicine_search_screen.dart +++ b/lib/screens/medicine/medicine_search_screen.dart @@ -1,9 +1,67 @@ +import 'package:doctor_app_flutter/models/pharmacies_request_model.dart'; +import 'package:doctor_app_flutter/providers/medicine_provider.dart'; +import 'package:doctor_app_flutter/util/dr_app_shared_pref.dart'; +import 'package:doctor_app_flutter/util/dr_app_toast_msg.dart'; +import 'package:doctor_app_flutter/widgets/shared/app_scaffold_widget.dart'; import 'package:flutter/material.dart'; -class MedicineSearchScreen extends StatelessWidget { +import 'package:provider/provider.dart'; + +DrAppSharedPreferances sharedPref = DrAppSharedPreferances(); + +class MedicineSearchScreen extends StatefulWidget with DrAppToastMsg { + MedicineSearchScreen({this.changeLoadingStata}); + final Function changeLoadingStata; + + @override + _MedicineSearchState createState() => _MedicineSearchState(); +} + +class _MedicineSearchState extends State { + var _medicineModel = PharmaciesRequestModel( + IsLoginForDoctorApp: true, + PHR_itemName: "Panadol", + PatientOutSA: false, + PatientTypeID: 1, + LanguageID: 2, + IPAdress: "11.11.11.11", + VersionID: 1.2, + TokenID: "2Fi7HoIHB0eDyekVa6tCJg==", + stamp: "2020-04-23T21:01:21.492Z", + SessionID: "e29zoooEJ4"); @override Widget build(BuildContext context) { - return Container( - - ); + return ChangeNotifierProvider( + create: (context) => MedicineProvider(), //change builder to create + child: Consumer( + builder: (context, provider, child) => AppScaffold( + appBarTitle: "Search Medicine", + body: RaisedButton( + onPressed: () { + MedicineProvider medicineProvider = + Provider.of(context); + searchMedicine(context, medicineProvider); + }, + )))); + } + + searchMedicine( + context, MedicineProvider medicineProvider) { + + medicineProvider.getPharmacyList(_medicineModel).then((res) { + + if (res['MessageStatus'] == 1) { + print("ListPharmcy " + res['ListPharmcy'].toString()); + + //Navigator.of(context).pushNamed(); + } else { + // handel error + // widget.showCenterShortLoadingToast("watting"); + //helpers.showErrorToast(res['ErrorEndUserMessage']); + } + // Navigator.of(context).pushNamed(HOME); + }).catchError((err) { + print('$err'); + //helpers.showErrorToast(); + }); } -} \ No newline at end of file +}