From 49f9841079ff1842621dc3dbff823e2a8e433a4e Mon Sep 17 00:00:00 2001 From: Elham Rababah Date: Thu, 30 Apr 2020 12:33:24 +0300 Subject: [PATCH] add patient route --- lib/config/shared_pref_kay.dart | 3 +- lib/models/patient/lab_orders_req_model.dart | 60 +++++++ lib/models/patient/lab_orders_res_model.dart | 96 +++++++++++ lib/providers/patients_provider.dart | 52 +++++- .../patients/patient_search_screen.dart | 8 +- .../profile/lab_result/lab_orders_screen.dart | 156 ++++++++++++++++++ .../profile/vital_sign/vital_sign_screen.dart | 33 ++-- .../profile/profile_medical_info_widget.dart | 23 ++- pubspec.lock | 32 ++-- 9 files changed, 411 insertions(+), 52 deletions(-) create mode 100644 lib/models/patient/lab_orders_req_model.dart create mode 100644 lib/models/patient/lab_orders_res_model.dart create mode 100644 lib/screens/patients/profile/lab_result/lab_orders_screen.dart diff --git a/lib/config/shared_pref_kay.dart b/lib/config/shared_pref_kay.dart index 9af0820f..3fe1f22d 100644 --- a/lib/config/shared_pref_kay.dart +++ b/lib/config/shared_pref_kay.dart @@ -1,2 +1,3 @@ final TOKEN = 'token'; -final PROJECT_ID="projectID"; \ No newline at end of file +final PROJECT_ID="projectID"; +final SLECTED_PATIENT_TYPE="slectedPatientType"; \ No newline at end of file diff --git a/lib/models/patient/lab_orders_req_model.dart b/lib/models/patient/lab_orders_req_model.dart new file mode 100644 index 00000000..dc0fb584 --- /dev/null +++ b/lib/models/patient/lab_orders_req_model.dart @@ -0,0 +1,60 @@ +class LabOrdersReqModel { + int patientID; + int patientTypeID; + int projectID; + int languageID; + String stamp; + String iPAdress; + double versionID; + int channel; + String tokenID; + String sessionID; + bool isLoginForDoctorApp; + bool patientOutSA; + + LabOrdersReqModel( + {this.patientID, + this.patientTypeID, + this.projectID, + this.languageID, + this.tokenID, + this.stamp = '2020-04-26T09:32:18.317Z', + this.iPAdress='11.11.11.11', + this.versionID=1.2, + this.channel=9, + this.sessionID='E2bsEeYEJo', + this.isLoginForDoctorApp =true, + this.patientOutSA=false}); + + LabOrdersReqModel.fromJson(Map json) { + patientID = json['PatientID']; + patientTypeID = json['PatientTypeID']; + projectID = json['ProjectID']; + languageID = json['LanguageID']; + stamp = json['stamp']; + iPAdress = json['IPAdress']; + versionID = json['VersionID']; + channel = json['Channel']; + tokenID = json['TokenID']; + sessionID = json['SessionID']; + isLoginForDoctorApp = json['IsLoginForDoctorApp']; + patientOutSA = json['PatientOutSA']; + } + + Map toJson() { + final Map data = new Map(); + data['PatientID'] = this.patientID; + data['PatientTypeID'] = this.patientTypeID; + data['ProjectID'] = this.projectID; + data['LanguageID'] = this.languageID; + data['stamp'] = this.stamp; + data['IPAdress'] = this.iPAdress; + data['VersionID'] = this.versionID; + data['Channel'] = this.channel; + data['TokenID'] = this.tokenID; + data['SessionID'] = this.sessionID; + data['IsLoginForDoctorApp'] = this.isLoginForDoctorApp; + data['PatientOutSA'] = this.patientOutSA; + return data; + } +} diff --git a/lib/models/patient/lab_orders_res_model.dart b/lib/models/patient/lab_orders_res_model.dart new file mode 100644 index 00000000..41d41125 --- /dev/null +++ b/lib/models/patient/lab_orders_res_model.dart @@ -0,0 +1,96 @@ +class LabOrdersResModel { + String setupID; + int projectID; + int patientID; + int patientType; + int orderNo; + String orderDate; + int invoiceTransactionType; + int invoiceNo; + int clinicId; + int doctorId; + int status; + String createdBy; + Null createdByN; + String createdOn; + String editedBy; + Null editedByN; + String editedOn; + String clinicName; + String doctorImageURL; + String doctorName; + String projectName; + + LabOrdersResModel( + {this.setupID, + this.projectID, + this.patientID, + this.patientType, + this.orderNo, + this.orderDate, + this.invoiceTransactionType, + this.invoiceNo, + this.clinicId, + this.doctorId, + this.status, + this.createdBy, + this.createdByN, + this.createdOn, + this.editedBy, + this.editedByN, + this.editedOn, + this.clinicName, + this.doctorImageURL, + this.doctorName, + this.projectName}); + + LabOrdersResModel.fromJson(Map json) { + setupID = json['SetupID']; + projectID = json['ProjectID']; + patientID = json['PatientID']; + patientType = json['PatientType']; + orderNo = json['OrderNo']; + orderDate = json['OrderDate']; + invoiceTransactionType = json['InvoiceTransactionType']; + invoiceNo = json['InvoiceNo']; + clinicId = json['ClinicId']; + doctorId = json['DoctorId']; + status = json['Status']; + createdBy = json['CreatedBy']; + createdByN = json['CreatedByN']; + createdOn = json['CreatedOn']; + editedBy = json['EditedBy']; + editedByN = json['EditedByN']; + editedOn = json['EditedOn']; + clinicName = json['ClinicName']; + doctorImageURL = json['DoctorImageURL']; + doctorName = json['DoctorName']; + projectName = json['ProjectName']; + } + + Map toJson() { + final Map data = new Map(); + data['SetupID'] = this.setupID; + data['ProjectID'] = this.projectID; + data['PatientID'] = this.patientID; + data['PatientType'] = this.patientType; + data['OrderNo'] = this.orderNo; + data['OrderDate'] = this.orderDate; + data['InvoiceTransactionType'] = this.invoiceTransactionType; + data['InvoiceNo'] = this.invoiceNo; + data['ClinicId'] = this.clinicId; + data['DoctorId'] = this.doctorId; + data['Status'] = this.status; + data['CreatedBy'] = this.createdBy; + data['CreatedByN'] = this.createdByN; + data['CreatedOn'] = this.createdOn; + data['EditedBy'] = this.editedBy; + data['EditedByN'] = this.editedByN; + data['EditedOn'] = this.editedOn; + data['ClinicName'] = this.clinicName; + data['DoctorImageURL'] = this.doctorImageURL; + data['DoctorName'] = this.doctorName; + data['ProjectName'] = this.projectName; + return data; + } +} diff --git a/lib/providers/patients_provider.dart b/lib/providers/patients_provider.dart index 69309178..2d97c48f 100644 --- a/lib/providers/patients_provider.dart +++ b/lib/providers/patients_provider.dart @@ -1,5 +1,6 @@ import 'dart:convert'; +import 'package:doctor_app_flutter/models/patient/lab_orders_res_model.dart'; import 'package:doctor_app_flutter/models/patient/patiant_info_model.dart'; import 'package:flutter/cupertino.dart'; import 'package:http/http.dart'; @@ -14,12 +15,14 @@ import '../util/helpers.dart'; const GET_PATIENT_VITAL_SIGN = BASE_URL + 'Doctors.svc/REST/Doctor_GetPatientVitalSign'; +const GET_PATIENT_LAB_OREDERS =BASE_URL + 'DoctorApplication.svc/REST/GetPatientLabOreders'; class PatientsProvider with ChangeNotifier { bool isLoading = true; bool isError = false; String error = ''; List patientVitalSignList = []; + List patientLabResultOrdersList = []; Client client = HttpClientWithInterceptor.build(interceptors: [HttpInterceptor()]); @@ -90,11 +93,10 @@ class PatientsProvider with ChangeNotifier { var res = json.decode(response.body); print('$res'); if (res['MessageStatus'] == 1) { - patientVitalSignList=[]; + patientVitalSignList = []; res['List_DoctorPatientVitalSign'].forEach((v) { - patientVitalSignList - .add(new VitalSignResModel.fromJson(v)); - }); + patientVitalSignList.add(new VitalSignResModel.fromJson(v)); + }); // patientVitalSignList = res['List_DoctorPatientVitalSign']; } else { isError = true; @@ -120,4 +122,46 @@ class PatientsProvider with ChangeNotifier { // return _selectedPatient; _selectedPatient = patient; } + +/*@author: Elham Rababah + *@Date:27/4/2020 + *@param: + *@return:Future + *@desc: getLabResult Orders + */ + getLabResultOrders(patient) async { + try { + if (await Helpers.checkConnection()) { + final response = await client.post(GET_PATIENT_LAB_OREDERS, + body: json.encode(patient)); + final int statusCode = response.statusCode; + isLoading = false; + + if (statusCode < 200 || statusCode >= 400 || json == null) { + isError = true; + error = 'Error While Fetching data'; + } else { + var res = json.decode(response.body); + print('$res'); + if (res['MessageStatus'] == 1) { + patientLabResultOrdersList = []; + print("res['List_GetLabOreders']"); + res['List_GetLabOreders'].forEach((v) { + patientLabResultOrdersList.add(new LabOrdersResModel.fromJson(v)); + }); + } else { + isError = true; + error = res['ErrorMessage'] ?? res['ErrorEndUserMessage']; + } + } + } else { + isLoading = false; + isError = true; + error = 'Please Check The Internet Connection'; + } + notifyListeners(); + } catch (error) { + throw error; + } + } } diff --git a/lib/screens/patients/patient_search_screen.dart b/lib/screens/patients/patient_search_screen.dart index 591d3059..f69a809d 100644 --- a/lib/screens/patients/patient_search_screen.dart +++ b/lib/screens/patients/patient_search_screen.dart @@ -37,8 +37,8 @@ class _PatientSearchScreenState extends State { var _patientSearchFormValues = PatientModel( ProjectID: 15, - ClinicID: 90, - DoctorID: 145642, + ClinicID: 14, + DoctorID: 243763, FirstName: "0", MiddleName: "0", LastName: "0", @@ -64,6 +64,9 @@ class _PatientSearchScreenState extends State { if (_formKey.currentState.validate()) { // If all data are correct then save data to out variables // _formKey.currentState.save(); + sharedPref.setString(TOKEN,'@dm!n'); + sharedPref.setString(SLECTED_PATIENT_TYPE,_selectedType); + print('_selectedType${_selectedType}'); String token = await sharedPref.getString(TOKEN); int projectID = await sharedPref.getInt(PROJECT_ID); _patientSearchFormValues.TokenID = token; @@ -85,7 +88,6 @@ class _PatientSearchScreenState extends State { Widget build(BuildContext context) { return AppScaffold( appBarTitle: "SEARCH FOR PATIENT", - current: 1, body: ListView( children: [ RoundedContainer( diff --git a/lib/screens/patients/profile/lab_result/lab_orders_screen.dart b/lib/screens/patients/profile/lab_result/lab_orders_screen.dart new file mode 100644 index 00000000..76d30856 --- /dev/null +++ b/lib/screens/patients/profile/lab_result/lab_orders_screen.dart @@ -0,0 +1,156 @@ +import 'package:flutter/material.dart'; +import 'package:provider/provider.dart'; + +import '../../../../config/shared_pref_kay.dart'; +import '../../../../config/size_config.dart'; +import '../../../../models/patient/lab_orders_req_model.dart'; +import '../../../../models/patient/patiant_info_model.dart'; +import '../../../../providers/patients_provider.dart'; +import '../../../../util/dr_app_shared_pref.dart'; +import '../../../../widgets/shared/app_scaffold_widget.dart'; +import '../../../../widgets/shared/app_texts_widget.dart'; +import '../../../../widgets/shared/card_with_bg_widget.dart'; +import '../../../../widgets/shared/dr_app_circular_progress_Indeicator.dart'; + +DrAppSharedPreferances sharedPref = new DrAppSharedPreferances(); + +/* + *@author: Elham Rababah + *@Date:26/4/2020 + *@param: + *@return:LabOrdersScreen + *@desc: LabOrdersScreen class + */ + +class LabOrdersScreen extends StatefulWidget { + @override + _LabOrdersScreenState createState() => _LabOrdersScreenState(); +} + +class _LabOrdersScreenState extends State { + PatientsProvider patientsProv; + var _isInit = true; + + /* + *@author: Elham Rababah + *@Date:28/4/2020 + *@param: context + *@return: + *@desc: getVitalSignList Function + */ + getLabResultOrders(context) async { + final routeArgs = ModalRoute.of(context).settings.arguments as Map; + PatiantInformtion patient = routeArgs['patient']; + String token = await sharedPref.getString(TOKEN); + // String type = await sharedPref.getString(SLECTED_PATIENT_TYPE); + // int inOutpatientType = 1; + // if (type == '0') { + // inOutpatientType = 2; + // } + // print(type); + LabOrdersReqModel labOrdersReqModel = LabOrdersReqModel( + patientID: patient.patientId, + projectID: patient.projectId, + tokenID: token, + patientTypeID: patient.patientType, + languageID: 2); + + patientsProv.getLabResultOrders(labOrdersReqModel.toJson()); + } + + @override + void didChangeDependencies() { + super.didChangeDependencies(); + if (_isInit) { + patientsProv = Provider.of(context); + getLabResultOrders(context); + } + _isInit = false; + } + + @override + Widget build(BuildContext context) { + return AppScaffold( + appBarTitle: "Lab Orders", + showAppDrawer: false, + showBottomBar: false, + body: patientsProv.isLoading + ? DrAppCircularProgressIndeicator() + : patientsProv.isError + ? Center( + child: Text( + patientsProv.error, + style: TextStyle(color: Theme.of(context).errorColor), + ), + ) + : patientsProv.patientLabResultOrdersList.length == 0 + ? Center( + child: Text( + 'You don\'t have any Orders', + style: TextStyle(color: Theme.of(context).errorColor), + ), + ) + : Container( + margin: EdgeInsets.fromLTRB( + SizeConfig.realScreenWidth * 0.05, + 0, + SizeConfig.realScreenWidth * 0.05, + 0), + child: ListView.builder( + itemCount: patientsProv.patientLabResultOrdersList.length, + itemBuilder: (BuildContext ctxt, int index) { + return InkWell( + child: CardWithBgWidget( + widget: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + children: [ + CircleAvatar( + radius: + SizeConfig.imageSizeMultiplier * + 12, + backgroundImage: NetworkImage( + patientsProv + .patientLabResultOrdersList[index] + .doctorImageURL), + backgroundColor: Colors.transparent, + ), + Padding( + padding: const EdgeInsets.fromLTRB( + 8, 0, 0, 0), + child: Column( + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + AppText( + '${patientsProv.patientLabResultOrdersList[index].doctorName}', + fontSize: 2.5 * + SizeConfig.textMultiplier, + ), + SizedBox( + height: 8, + ), + AppText( + ' ${patientsProv.patientLabResultOrdersList[index].clinicName}', + fontSize: 2.5 * + SizeConfig + .textMultiplier), + SizedBox( + height: 8, + ), + ], + ), + ) + ], + ), + ], + ), + ), + onTap: () {}, + ); + }), + ), + ); + } +} diff --git a/lib/screens/patients/profile/vital_sign/vital_sign_screen.dart b/lib/screens/patients/profile/vital_sign/vital_sign_screen.dart index 6510af35..61d13adf 100644 --- a/lib/screens/patients/profile/vital_sign/vital_sign_screen.dart +++ b/lib/screens/patients/profile/vital_sign/vital_sign_screen.dart @@ -43,12 +43,18 @@ class _VitalSignScreenState extends State { final routeArgs = ModalRoute.of(context).settings.arguments as Map; PatiantInformtion patient = routeArgs['patient']; String token = await sharedPref.getString(TOKEN); + String type = await sharedPref.getString(SLECTED_PATIENT_TYPE); + int inOutpatientType = 1; + if (type == '0') { + inOutpatientType = 2; + } + print(type); VitalSignReqModel vitalSignReqModel = VitalSignReqModel( patientID: patient.patientId, projectID: patient.projectId, tokenID: token, patientTypeID: patient.patientType, - inOutpatientType: 1, + inOutpatientType: inOutpatientType, languageID: 2, transNo: patient.admissionNo != null ? int.parse(patient.admissionNo) : 0); @@ -83,7 +89,7 @@ class _VitalSignScreenState extends State { : patientsProv.patientVitalSignList.length == 0 ? Center( child: Text( - 'You don\'t have any Schedule', + 'You don\'t have any Vital Sign', style: TextStyle(color: Theme.of(context).errorColor), ), ) @@ -114,9 +120,11 @@ class _VitalSignScreenState extends State { backgroundColor: Colors.transparent, ), Padding( - padding: const EdgeInsets.fromLTRB(8,0,0,0), + padding: const EdgeInsets.fromLTRB( + 8, 0, 0, 0), child: Column( - crossAxisAlignment: CrossAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, children: [ AppText( '${patientsProv.patientVitalSignList[index].doctorName}', @@ -129,7 +137,8 @@ class _VitalSignScreenState extends State { AppText( ' ${patientsProv.patientVitalSignList[index].clinicName}', fontSize: 2.5 * - SizeConfig.textMultiplier), + SizeConfig + .textMultiplier), SizedBox( height: 8, ), @@ -148,17 +157,3 @@ class _VitalSignScreenState extends State { ); } } - -// patientsProv.patientVitalSignList.map((VitalSignResModel item) { -// return InkWell( -// child: CardWithBgWidget( -// line1Text: 'DoctorName - ${item.doctorName}', -// line2Text: -// 'PainScoreDesc - ${item.painScoreDesc}', -// heightPercentage: 0.15, -// widthPercentage: 0.80), -// onTap: () { -// Navigator.of(context).pushNamed(VITAL_SIGN); -// }, -// ); -// }).toList() diff --git a/lib/widgets/patients/profile/profile_medical_info_widget.dart b/lib/widgets/patients/profile/profile_medical_info_widget.dart index 1621438c..272fa638 100644 --- a/lib/widgets/patients/profile/profile_medical_info_widget.dart +++ b/lib/widgets/patients/profile/profile_medical_info_widget.dart @@ -46,7 +46,7 @@ class ProfileMedicalInfoWidget extends StatelessWidget { children: [ InkWell( onTap: () { - navigator(context,VITAL_SIGN); + navigator(context, VITAL_SIGN); }, child: CircleAvatarWidget( des: 'Vital Sign', @@ -55,11 +55,16 @@ class ProfileMedicalInfoWidget extends StatelessWidget { height: (contWidth) / 3.5, ), ), - CircleAvatarWidget( - des: 'Lab Result', - url: url + 'lab.png', - width: (contWidth) / 3.5, - height: (contWidth) / 3.5, + InkWell( + onTap: () { + navigator(context, LAB_ORDERS); + }, + child: CircleAvatarWidget( + des: 'Lab Result', + url: url + 'lab.png', + width: (contWidth) / 3.5, + height: (contWidth) / 3.5, + ), ), CircleAvatarWidget( des: 'Prescription', @@ -85,9 +90,9 @@ class ProfileMedicalInfoWidget extends StatelessWidget { ); } - void navigator(BuildContext context,route) { - Navigator.of(context).pushNamed(VITAL_SIGN, - arguments: {'patient': patient}); + void navigator(BuildContext context, route) { + Navigator.of(context) + .pushNamed(route, arguments: {'patient': patient}); } } diff --git a/pubspec.lock b/pubspec.lock index f0f825ee..06391e01 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -7,14 +7,14 @@ packages: name: _fe_analyzer_shared url: "https://pub.dartlang.org" source: hosted - version: "2.0.0" + version: "3.0.0" analyzer: dependency: transitive description: name: analyzer url: "https://pub.dartlang.org" source: hosted - version: "0.39.5" + version: "0.39.8" archive: dependency: transitive description: @@ -84,21 +84,21 @@ packages: name: build_resolvers url: "https://pub.dartlang.org" source: hosted - version: "1.3.4" + version: "1.3.7" build_runner: dependency: "direct dev" description: name: build_runner url: "https://pub.dartlang.org" source: hosted - version: "1.8.1" + version: "1.9.0" build_runner_core: dependency: transitive description: name: build_runner_core url: "https://pub.dartlang.org" source: hosted - version: "5.0.0" + version: "5.1.0" build_web_compilers: dependency: "direct dev" description: @@ -119,7 +119,7 @@ packages: name: built_value url: "https://pub.dartlang.org" source: hosted - version: "7.0.9" + version: "7.1.0" charcode: dependency: transitive description: @@ -168,7 +168,7 @@ packages: name: connectivity_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "1.0.3" + version: "1.0.5" convert: dependency: transitive description: @@ -203,7 +203,7 @@ packages: name: dart_style url: "https://pub.dartlang.org" source: hosted - version: "1.3.4" + version: "1.3.6" fixnum: dependency: transitive description: @@ -236,7 +236,7 @@ packages: name: flutter_plugin_android_lifecycle url: "https://pub.dartlang.org" source: hosted - version: "1.0.6" + version: "1.0.7" flutter_test: dependency: "direct dev" description: flutter @@ -281,7 +281,7 @@ packages: name: http url: "https://pub.dartlang.org" source: hosted - version: "0.12.0+4" + version: "0.12.1" http_interceptor: dependency: "direct main" description: @@ -358,7 +358,7 @@ packages: name: local_auth url: "https://pub.dartlang.org" source: hosted - version: "0.6.1+3" + version: "0.6.2+1" logging: dependency: transitive description: @@ -428,7 +428,7 @@ packages: name: percent_indicator url: "https://pub.dartlang.org" source: hosted - version: "2.1.1+1" + version: "2.1.3" petitparser: dependency: transitive description: @@ -526,14 +526,14 @@ packages: name: shared_preferences url: "https://pub.dartlang.org" source: hosted - version: "0.5.6+3" + version: "0.5.7" shared_preferences_macos: dependency: transitive description: name: shared_preferences_macos url: "https://pub.dartlang.org" source: hosted - version: "0.0.1+6" + version: "0.0.1+7" shared_preferences_platform_interface: dependency: transitive description: @@ -650,7 +650,7 @@ packages: name: watcher url: "https://pub.dartlang.org" source: hosted - version: "0.9.7+14" + version: "0.9.7+15" web_socket_channel: dependency: transitive description: @@ -671,7 +671,7 @@ packages: name: yaml url: "https://pub.dartlang.org" source: hosted - version: "2.2.0" + version: "2.2.1" sdks: dart: ">=2.7.0 <3.0.0" flutter: ">=1.12.13+hotfix.5 <2.0.0"