From e75e7801aa2773ce83ad5240266c624247e23257 Mon Sep 17 00:00:00 2001 From: mosazaid Date: Tue, 5 Jan 2021 10:02:51 +0200 Subject: [PATCH] working on UCAF get data --- lib/client/base_app_client.dart | 2 + lib/config/localized_values.dart | 1 + lib/core/service/patient-ucaf-service.dart | 53 ++ .../service/patient-vital-signs-service.dart | 37 +- .../viewModel/patient-ucaf-viewmodel.dart | 21 + .../profile/UCAF/UCAF-input-screen.dart | 581 +++++++++--------- lib/util/translations_delegate_base.dart | 1 + pubspec.lock | 6 +- 8 files changed, 386 insertions(+), 316 deletions(-) diff --git a/lib/client/base_app_client.dart b/lib/client/base_app_client.dart index 83923ea7..3a39c5e9 100644 --- a/lib/client/base_app_client.dart +++ b/lib/client/base_app_client.dart @@ -42,6 +42,8 @@ class BaseAppClient { DoctorProfileModel doctorProfile = DoctorProfileModel.fromJson(profile); if (body['DoctorID'] == null) body['DoctorID'] = doctorProfile?.doctorID; + if (body['DoctorID'] == "") + body['DoctorID'] = null; body['EditedBy'] = doctorProfile?.doctorID; if (body['ProjectID'] == null) { body['ProjectID'] = doctorProfile?.projectID; diff --git a/lib/config/localized_values.dart b/lib/config/localized_values.dart index 10ac9856..d0cd8720 100644 --- a/lib/config/localized_values.dart +++ b/lib/config/localized_values.dart @@ -527,4 +527,5 @@ const Map> localizedValues = { 'covered': {'en': "Covered", 'ar':"مغطى" }, 'approvalRequired': {'en': "Approval Required", 'ar':"الموافقة مطلوبة" }, 'uncoveredByDoctor': {'en': "Uncovered By Doctor", 'ar':"غير مغطى من قبل الدكتور" }, + 'chiefComplaintEmptyMsg': {'en': "There is no Chief Complaint", 'ar':"ليس هناك شكوى رئيس" }, }; diff --git a/lib/core/service/patient-ucaf-service.dart b/lib/core/service/patient-ucaf-service.dart index e776720c..06fbce41 100644 --- a/lib/core/service/patient-ucaf-service.dart +++ b/lib/core/service/patient-ucaf-service.dart @@ -1,5 +1,58 @@ +import 'package:doctor_app_flutter/config/config.dart'; import 'package:doctor_app_flutter/core/service/base/base_service.dart'; +import 'package:doctor_app_flutter/models/SOAP/ChiefComplaint/GetChiefComplaintReqModel.dart'; +import 'package:doctor_app_flutter/models/SOAP/ChiefComplaint/GetChiefComplaintResModel.dart'; +import 'package:doctor_app_flutter/models/patient/patiant_info_model.dart'; +import 'package:doctor_app_flutter/models/patient/vital_sign/patient-vital-sign-data.dart'; class UcafService extends BaseService { + List patientChiefComplaintList = []; + VitalSignData patientVitalSigns; + + Future getPatientChiefComplaint(PatiantInformtion patient) async { + hasError = false; + Map body = Map(); + body['PatientMRN'] = patient.patientMRN; + body['AppointmentNo'] = patient.appointmentNo; + body['EpisodeID'] = patient.episodeNo; + body['DoctorID'] = ""; + + await baseAppClient.post (GET_CHIEF_COMPLAINT, + onSuccess: (dynamic response, int statusCode) { + print("Success"); + patientChiefComplaintList.clear(); + response['List_ChiefComplaint']['entityList'].forEach((v) { + patientChiefComplaintList.add(GetChiefComplaintResModel.fromJson(v)); + }); + }, onFailure: (String error, int statusCode) { + hasError = true; + super.error = error; + }, body: body); + } + + Future getPatientVitalSign(PatiantInformtion patient) async { + patientVitalSigns = null; + hasError = false; + Map body = Map(); + body['PatientMRN'] = patient.patientMRN; + body['AppointmentNo'] = patient.appointmentNo; + body['EpisodeID'] = patient.episodeNo; + + await baseAppClient.post( + GET_PATIENT_VITAL_SIGN_DATA, + onSuccess: (dynamic response, int statusCode) { + if(response['VitalSignsList'] != null){ + if(response['VitalSignsList']['entityList'] != null && (response['VitalSignsList']['entityList'] as List).length > 0){ + patientVitalSigns = VitalSignData.fromJson(response['VitalSignsList']['entityList'][0]); + } + } + }, + onFailure: (String error, int statusCode) { + hasError = true; + super.error = error.toString(); + }, + body: body, + ); + } } \ No newline at end of file diff --git a/lib/core/service/patient-vital-signs-service.dart b/lib/core/service/patient-vital-signs-service.dart index 43786ac0..8d0cfc31 100644 --- a/lib/core/service/patient-vital-signs-service.dart +++ b/lib/core/service/patient-vital-signs-service.dart @@ -11,43 +11,8 @@ class VitalSignsService extends BaseService{ List patientVitalSignOrderdSubList = []; VitalSignData patientVitalSigns; - /*Future getPatientVitalSign(patient) async { - hasError = false; - await baseAppClient.post( - GET_PATIENT_VITAL_SIGN, - onSuccess: (dynamic response, int statusCode) { - patientVitalSignList = []; - response['List_DoctorPatientVitalSign'].forEach((v) { - patientVitalSignList.add(new VitalSignResModel.fromJson(v)); - }); - - if (patientVitalSignList.length > 0) { - List patientVitalSignOrderdSubListTemp = []; - patientVitalSignOrderdSubListTemp = patientVitalSignList; - patientVitalSignOrderdSubListTemp - .sort((VitalSignResModel a, VitalSignResModel b) { - return b.vitalSignDate.microsecondsSinceEpoch - - a.vitalSignDate.microsecondsSinceEpoch; - }); - patientVitalSignOrderdSubList.clear(); - int length = patientVitalSignOrderdSubListTemp.length >= 20 - ? 20 - : patientVitalSignOrderdSubListTemp.length; - for (int x = 0; x < length; x++) { - patientVitalSignOrderdSubList - .add(patientVitalSignOrderdSubListTemp[x]); - } - } - }, - onFailure: (String error, int statusCode) { - hasError = true; - super.error = error; - }, - body: patient, - ); - } // Vit*/ - Future getPatientVitalSign(PatiantInformtion patient) async { + patientVitalSigns = null; hasError = false; Map body = Map(); body['PatientMRN'] = patient.patientMRN; diff --git a/lib/core/viewModel/patient-ucaf-viewmodel.dart b/lib/core/viewModel/patient-ucaf-viewmodel.dart index cf11854b..c120e2ab 100644 --- a/lib/core/viewModel/patient-ucaf-viewmodel.dart +++ b/lib/core/viewModel/patient-ucaf-viewmodel.dart @@ -1,9 +1,30 @@ +import 'package:doctor_app_flutter/core/enum/viewstate.dart'; import 'package:doctor_app_flutter/core/service/patient-ucaf-service.dart'; import 'package:doctor_app_flutter/core/viewModel/base_view_model.dart'; +import 'package:doctor_app_flutter/models/SOAP/ChiefComplaint/GetChiefComplaintResModel.dart'; +import 'package:doctor_app_flutter/models/patient/patiant_info_model.dart'; +import 'package:doctor_app_flutter/models/patient/vital_sign/patient-vital-sign-data.dart'; import '../../locator.dart'; class UcafViewModel extends BaseViewModel { UcafService _ucafService = locator(); + + List get patientChiefComplaintList => _ucafService.patientChiefComplaintList; + VitalSignData get patientVitalSigns => _ucafService.patientVitalSigns; + + Future getUCAFData(PatiantInformtion patient) async { + setState(ViewState.Busy); + await _ucafService.getPatientVitalSign(patient); + await _ucafService.getPatientChiefComplaint(patient); + + if (_ucafService.hasError) { + error = _ucafService.error; + setState(ViewState.Error); + } else { + setState(ViewState.Idle); + } + } + } \ No newline at end of file diff --git a/lib/screens/patients/profile/UCAF/UCAF-input-screen.dart b/lib/screens/patients/profile/UCAF/UCAF-input-screen.dart index e0c2f9a7..0116ce46 100644 --- a/lib/screens/patients/profile/UCAF/UCAF-input-screen.dart +++ b/lib/screens/patients/profile/UCAF/UCAF-input-screen.dart @@ -14,6 +14,7 @@ import 'package:flutter/services.dart'; import 'package:hexcolor/hexcolor.dart'; import '../../../../routes.dart'; +import '../../../QR_reader_screen.dart'; class UCAFInputScreen extends StatefulWidget { @override @@ -55,312 +56,338 @@ class _UCAFInputScreenState extends State { final screenSize = MediaQuery.of(context).size; return BaseView( + onModelReady: (model) => model.getUCAFData(patient), builder: (_, model, w) => AppScaffold( baseViewModel: model, appBarTitle: TranslationBase.of(context).ucaf, - body: SingleChildScrollView( - child: Column( - children: [ - PatientHeaderWidgetNoAvatar(patient), - Container( - margin: EdgeInsets.symmetric(vertical: 16, horizontal: 16), + body: model.patientVitalSigns != null && + model.patientChiefComplaintList != null && + model.patientChiefComplaintList.length > 0 + ? SingleChildScrollView( child: Column( - crossAxisAlignment: CrossAxisAlignment.start, children: [ - CheckboxListTile( - title: AppText( - TranslationBase.of(context).inPatient, - fontWeight: FontWeight.bold, - fontSize: SizeConfig.textMultiplier * 2.1, - ), - value: _inPatient, - onChanged: (newValue) { - setState(() { - _inPatient = newValue; - }); - }, - controlAffinity: ListTileControlAffinity.leading, - contentPadding: EdgeInsets.all(0), - ), - CheckboxListTile( - title: AppText( - TranslationBase.of(context).emergencyCase, - fontWeight: FontWeight.bold, - fontSize: SizeConfig.textMultiplier * 2.1, - ), - value: _emergencyCase, - onChanged: (newValue) { - setState(() { - _emergencyCase = newValue; - }); - }, - controlAffinity: ListTileControlAffinity.leading, - contentPadding: EdgeInsets.all(0), - ), + PatientHeaderWidgetNoAvatar(patient), Container( - height: screenSize.height * 0.070, - child: TextField( - decoration: Helpers.textFieldSelectorDecoration( - TranslationBase.of(context).durationOfIllness, - null, - false), - enabled: true, - controller: _durationOfIllnessController, - inputFormatters: [ - FilteringTextInputFormatter.allow( - RegExp(ONLY_NUMBERS)) - ], - keyboardType: TextInputType.number, - )), - SizedBox( - height: 10, - ), - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Row( - children: [ - AppText( - "BP (H/L)", - fontSize: SizeConfig.textMultiplier * 1.8, - color: Colors.black, - fontWeight: FontWeight.w700, - ), - SizedBox( - width: 8, - ), - AppText( - "120/80", - fontSize: SizeConfig.textMultiplier * 2, - color: Colors.grey.shade800, - fontWeight: FontWeight.normal, - ), - ], - ), - Row( - children: [ - AppText( - "${TranslationBase.of(context).temperature}", - fontSize: SizeConfig.textMultiplier * 1.8, - color: Colors.black, - fontWeight: FontWeight.w700, - ), - SizedBox( - width: 8, - ), - AppText( - "37.5(C), 98.6(F)", - fontSize: SizeConfig.textMultiplier * 2, - color: Colors.grey.shade800, - fontWeight: FontWeight.normal, - ), - ], - ), - ], - ), - SizedBox( - height: 4, - ), - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Row( - children: [ - AppText( - "${TranslationBase.of(context).pulseBeats} :", - fontSize: SizeConfig.textMultiplier * 1.8, - color: Colors.black, - fontWeight: FontWeight.w700, - ), - SizedBox( - width: 8, + margin: + EdgeInsets.symmetric(vertical: 16, horizontal: 16), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + CheckboxListTile( + title: AppText( + TranslationBase.of(context).inPatient, + fontWeight: FontWeight.bold, + fontSize: SizeConfig.textMultiplier * 2.1, ), - AppText( - "80", - fontSize: SizeConfig.textMultiplier * 2, - color: Colors.grey.shade800, - fontWeight: FontWeight.normal, + value: _inPatient, + onChanged: (newValue) { + setState(() { + _inPatient = newValue; + }); + }, + controlAffinity: ListTileControlAffinity.leading, + contentPadding: EdgeInsets.all(0), + ), + CheckboxListTile( + title: AppText( + TranslationBase.of(context).emergencyCase, + fontWeight: FontWeight.bold, + fontSize: SizeConfig.textMultiplier * 2.1, ), - ], - ), - ], - ), - SizedBox( - height: 16, - ), - AppText( - TranslationBase.of(context).chiefComplaintsAndSymptoms, - fontWeight: FontWeight.bold, - fontSize: SizeConfig.textMultiplier * 2.5, - ), - SizedBox( - height: 8, - ), - AppText( - TranslationBase.of(context) - .patientFeelsPainInHisBackAndCough, - fontWeight: FontWeight.normal, - fontSize: SizeConfig.textMultiplier * 2.0, - ), - SizedBox( - height: 8, - ), - Container( - child: TextField( - decoration: Helpers.textFieldSelectorDecoration( - TranslationBase.of(context).additionalTextComplaints, - null, - false), - enabled: true, - controller: _additionalComplaintsController, - keyboardType: TextInputType.text, - minLines: 4, - maxLines: 6, - )), - SizedBox( - height: 16, - ), - AppText( - TranslationBase.of(context).otherConditions, - fontWeight: FontWeight.bold, - fontSize: SizeConfig.textMultiplier * 2.0, - ), - ...List.generate( - conditionsData.length, - (index) => CheckboxListTile( - title: AppText( - conditionsData[index]['name'], - fontWeight: FontWeight.bold, - fontSize: SizeConfig.textMultiplier * 2.1, + value: _emergencyCase, + onChanged: (newValue) { + setState(() { + _emergencyCase = newValue; + }); + }, + controlAffinity: ListTileControlAffinity.leading, + contentPadding: EdgeInsets.all(0), + ), + Container( + height: screenSize.height * 0.070, + child: TextField( + decoration: Helpers.textFieldSelectorDecoration( + TranslationBase.of(context) + .durationOfIllness, + null, + false), + enabled: true, + controller: _durationOfIllnessController, + inputFormatters: [ + FilteringTextInputFormatter.allow( + RegExp(ONLY_NUMBERS)) + ], + keyboardType: TextInputType.number, + )), + SizedBox( + height: 10, + ), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Row( + children: [ + AppText( + "BP (H/L)", + fontSize: SizeConfig.textMultiplier * 1.8, + color: Colors.black, + fontWeight: FontWeight.w700, + ), + SizedBox( + width: 8, + ), + AppText( + "${model.patientVitalSigns.bloodPressureHigher}/${model.patientVitalSigns.bloodPressureLower}", + fontSize: SizeConfig.textMultiplier * 2, + color: Colors.grey.shade800, + fontWeight: FontWeight.normal, + ), + ], ), - value: conditionsData[index]['isChecked'], - onChanged: (newValue) { - setState(() { - conditionsData[index]['isChecked'] = newValue; - }); - }, - controlAffinity: ListTileControlAffinity.leading, - contentPadding: EdgeInsets.all(0), - )), - SizedBox( - height: 8, - ), - Container( - height: screenSize.height * 0.070, - child: TextField( - decoration: Helpers.textFieldSelectorDecoration( - TranslationBase.of(context).other, - null, - false), - enabled: true, - controller: _otherController, - keyboardType: TextInputType.text, - )), - SizedBox( - height: 8, - ), - Container( - height: screenSize.height * 0.070, - child: TextField( - decoration: Helpers.textFieldSelectorDecoration( - TranslationBase.of(context).how, - null, - false), - enabled: true, - controller: _howController, - keyboardType: TextInputType.text, - )), - SizedBox( - height: 8, - ), - Row( - children: [ - Expanded( - child: Container( + Row( + children: [ + AppText( + "${TranslationBase.of(context).temperature}", + fontSize: SizeConfig.textMultiplier * 1.8, + color: Colors.black, + fontWeight: FontWeight.w700, + ), + SizedBox( + width: 8, + ), + AppText( + "${model.patientVitalSigns.temperatureCelcius}(C), ${model.patientVitalSigns.temperatureCelcius * (9 / 5) + 32}(F)", + fontSize: SizeConfig.textMultiplier * 2, + color: Colors.grey.shade800, + fontWeight: FontWeight.normal, + ), + ], + ), + ], + ), + SizedBox( + height: 4, + ), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Row( + children: [ + AppText( + "${TranslationBase.of(context).pulseBeats} :", + fontSize: SizeConfig.textMultiplier * 1.8, + color: Colors.black, + fontWeight: FontWeight.w700, + ), + SizedBox( + width: 8, + ), + AppText( + "${model.patientVitalSigns.pulseBeatPerMinute}", + fontSize: SizeConfig.textMultiplier * 2, + color: Colors.grey.shade800, + fontWeight: FontWeight.normal, + ), + ], + ), + ], + ), + SizedBox( + height: 16, + ), + AppText( + TranslationBase.of(context) + .chiefComplaintsAndSymptoms, + fontWeight: FontWeight.bold, + fontSize: SizeConfig.textMultiplier * 2.5, + ), + SizedBox( + height: 8, + ), + AppText( + TranslationBase.of(context) + .patientFeelsPainInHisBackAndCough, + fontWeight: FontWeight.normal, + fontSize: SizeConfig.textMultiplier * 2.0, + ), + SizedBox( + height: 8, + ), + Container( + child: TextField( + decoration: Helpers.textFieldSelectorDecoration( + TranslationBase.of(context) + .additionalTextComplaints, + helpers.parseHtmlString(model + .patientChiefComplaintList[0] + .chiefComplaint), + false), + enabled: false, + controller: _additionalComplaintsController, + keyboardType: TextInputType.text, + /*minLines: 4, + maxLines: 6,*/ + )), + SizedBox( + height: 16, + ), + AppText( + TranslationBase.of(context).otherConditions, + fontWeight: FontWeight.bold, + fontSize: SizeConfig.textMultiplier * 2.0, + ), + ...List.generate( + conditionsData.length, + (index) => CheckboxListTile( + title: AppText( + conditionsData[index]['name'], + fontWeight: FontWeight.bold, + fontSize: SizeConfig.textMultiplier * 2.1, + ), + value: conditionsData[index]['isChecked'], + onChanged: (newValue) { + setState(() { + conditionsData[index]['isChecked'] = + newValue; + }); + }, + controlAffinity: + ListTileControlAffinity.leading, + contentPadding: EdgeInsets.all(0), + )), + SizedBox( + height: 8, + ), + Container( height: screenSize.height * 0.070, child: TextField( decoration: Helpers.textFieldSelectorDecoration( - TranslationBase.of(context).when, + TranslationBase.of(context).other, null, false), enabled: true, - controller: _whenController, + controller: _otherController, keyboardType: TextInputType.text, )), - ), - SizedBox( - width: 4, - ), - Expanded( - child: Container( + SizedBox( + height: 8, + ), + Container( height: screenSize.height * 0.070, child: TextField( decoration: Helpers.textFieldSelectorDecoration( - TranslationBase.of(context).where, + TranslationBase.of(context).how, null, false), enabled: true, - controller: _whereController, + controller: _howController, keyboardType: TextInputType.text, )), - ), - ], - ), - SizedBox( - height: 8, - ), - Container( - child: TextField( - decoration: Helpers.textFieldSelectorDecoration( - TranslationBase.of(context).specifyPossibleLineManagement, - null, - false), - enabled: true, - controller: _managementsLineController, - keyboardType: TextInputType.text, - minLines: 4, - maxLines: 6, - )), - SizedBox( - height: 16, - ), - AppText( - TranslationBase.of(context) - .significantSigns, - fontWeight: FontWeight.bold, - fontSize: SizeConfig.textMultiplier * 2.0, - ), - SizedBox( - height: 8, - ), - Container( - child: TextField( - decoration: Helpers.textFieldSelectorDecoration( - TranslationBase.of(context).backAbdomen, - null, - false), - enabled: true, - controller: _signsController, - keyboardType: TextInputType.text, - minLines: 4, - maxLines: 6, - )), - SizedBox( - height: 16, - ), - AppButton( - title: TranslationBase.of(context).next, - color: HexColor("#B8382B"), - onPressed: (){ - Navigator.of(context).pushNamed(PATIENT_UCAF_DETAIL, arguments: {'patient': patient}); - }, + SizedBox( + height: 8, + ), + Row( + children: [ + Expanded( + child: Container( + height: screenSize.height * 0.070, + child: TextField( + decoration: + Helpers.textFieldSelectorDecoration( + TranslationBase.of(context).when, + null, + false), + enabled: true, + controller: _whenController, + keyboardType: TextInputType.text, + )), + ), + SizedBox( + width: 4, + ), + Expanded( + child: Container( + height: screenSize.height * 0.070, + child: TextField( + decoration: + Helpers.textFieldSelectorDecoration( + TranslationBase.of(context).where, + null, + false), + enabled: true, + controller: _whereController, + keyboardType: TextInputType.text, + )), + ), + ], + ), + SizedBox( + height: 8, + ), + Container( + child: TextField( + decoration: Helpers.textFieldSelectorDecoration( + TranslationBase.of(context) + .specifyPossibleLineManagement, + null, + false), + enabled: true, + controller: _managementsLineController, + keyboardType: TextInputType.text, + minLines: 4, + maxLines: 6, + )), + SizedBox( + height: 16, + ), + AppText( + TranslationBase.of(context).significantSigns, + fontWeight: FontWeight.bold, + fontSize: SizeConfig.textMultiplier * 2.0, + ), + SizedBox( + height: 8, + ), + Container( + child: TextField( + decoration: Helpers.textFieldSelectorDecoration( + TranslationBase.of(context).backAbdomen, + null, + false), + enabled: true, + controller: _signsController, + keyboardType: TextInputType.text, + )), + SizedBox( + height: 16, + ), + AppButton( + title: TranslationBase.of(context).next, + color: HexColor("#B8382B"), + onPressed: () { + Navigator.of(context).pushNamed( + PATIENT_UCAF_DETAIL, + arguments: {'patient': patient}); + }, + ), + ], + ), ), ], ), + ) + : Container( + child: Center( + child: AppText( + model.patientVitalSigns == null + ? TranslationBase.of(context).vitalSignEmptyMsg + : TranslationBase.of(context).chiefComplaintEmptyMsg, + fontWeight: FontWeight.normal, + color: HexColor("#B8382B"), + fontSize: SizeConfig.textMultiplier * 2.5, + ), + ), ), - ], - ), - ), ), ); } diff --git a/lib/util/translations_delegate_base.dart b/lib/util/translations_delegate_base.dart index 37e39676..e2cba7f3 100644 --- a/lib/util/translations_delegate_base.dart +++ b/lib/util/translations_delegate_base.dart @@ -548,6 +548,7 @@ class TranslationBase { String get covered => localizedValues['covered'][locale.languageCode]; String get approvalRequired => localizedValues['approvalRequired'][locale.languageCode]; String get uncoveredByDoctor => localizedValues['uncoveredByDoctor'][locale.languageCode]; + String get chiefComplaintEmptyMsg => localizedValues['chiefComplaintEmptyMsg'][locale.languageCode]; } class TranslationBaseDelegate extends LocalizationsDelegate { diff --git a/pubspec.lock b/pubspec.lock index 5650f5f9..7f1d8c1d 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -503,7 +503,7 @@ packages: name: meta url: "https://pub.dartlang.org" source: hosted - version: "1.3.0-nullsafety.4" + version: "1.3.0-nullsafety.3" mime: dependency: transitive description: @@ -760,7 +760,7 @@ packages: name: stack_trace url: "https://pub.dartlang.org" source: hosted - version: "1.10.0-nullsafety.2" + version: "1.10.0-nullsafety.1" stream_channel: dependency: transitive description: @@ -895,5 +895,5 @@ packages: source: hosted version: "2.2.1" sdks: - dart: ">=2.10.0 <=2.11.0-213.1.beta" + dart: ">=2.10.0 <2.11.0" flutter: ">=1.22.0 <2.0.0"