From 94093e775eaeb3fb1e7d124975afd92e2d131b38 Mon Sep 17 00:00:00 2001 From: mosazaid Date: Thu, 17 Dec 2020 15:16:08 +0200 Subject: [PATCH 1/3] add vital-sign files --- lib/core/service/base/base_service.dart | 2 + .../service/patient-vital-signs-service.dart | 45 +++++++++++++++++++ .../patient-vital-sign-viewModel.dart | 27 +++++++++++ lib/locator.dart | 4 ++ 4 files changed, 78 insertions(+) create mode 100644 lib/core/service/patient-vital-signs-service.dart create mode 100644 lib/core/viewModel/patient-vital-sign-viewModel.dart diff --git a/lib/core/service/base/base_service.dart b/lib/core/service/base/base_service.dart index c4cb240d..885398f5 100644 --- a/lib/core/service/base/base_service.dart +++ b/lib/core/service/base/base_service.dart @@ -1,8 +1,10 @@ import 'package:doctor_app_flutter/client/base_app_client.dart'; +import 'package:doctor_app_flutter/util/dr_app_shared_pref.dart'; class BaseService { String error; bool hasError = false; BaseAppClient baseAppClient = BaseAppClient(); + DrAppSharedPreferances sharedPref = new DrAppSharedPreferances(); //TODO add the user login model when we need it } diff --git a/lib/core/service/patient-vital-signs-service.dart b/lib/core/service/patient-vital-signs-service.dart new file mode 100644 index 00000000..72619fa4 --- /dev/null +++ b/lib/core/service/patient-vital-signs-service.dart @@ -0,0 +1,45 @@ +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/patient/vital_sign/vital_sign_res_model.dart'; + +class VitalSignsService extends BaseService{ + + List patientVitalSignList = []; + List patientVitalSignOrderdSubList = []; + + 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, + ); + } +} \ No newline at end of file diff --git a/lib/core/viewModel/patient-vital-sign-viewModel.dart b/lib/core/viewModel/patient-vital-sign-viewModel.dart new file mode 100644 index 00000000..255ab5bd --- /dev/null +++ b/lib/core/viewModel/patient-vital-sign-viewModel.dart @@ -0,0 +1,27 @@ +import 'package:doctor_app_flutter/core/enum/viewstate.dart'; +import 'package:doctor_app_flutter/core/service/patient-vital-signs-service.dart'; +import 'package:doctor_app_flutter/core/viewModel/base_view_model.dart'; +import 'package:doctor_app_flutter/models/patient/vital_sign/vital_sign_res_model.dart'; + +import '../../locator.dart'; + +class VitalSignsViewModel extends BaseViewModel{ + VitalSignsService _vitalSignService = locator(); + + List get patientVitalSignList => + _vitalSignService.patientVitalSignList; + + List get patientVitalSignOrderdSubList => + _vitalSignService.patientVitalSignOrderdSubList; + + Future getPatientVitalSign(patient) async { + setState(ViewState.Busy); + await _vitalSignService.getPatientVitalSign(patient); + if (_vitalSignService.hasError) { + error = _vitalSignService.error; + setState(ViewState.Error); + } else + setState(ViewState.Idle); + } + +} \ No newline at end of file diff --git a/lib/locator.dart b/lib/locator.dart index 550b4666..9ca9d8db 100644 --- a/lib/locator.dart +++ b/lib/locator.dart @@ -4,11 +4,13 @@ import 'package:get_it/get_it.dart'; import 'core/service/doctor_reply_service.dart'; import 'core/service/medicine_service.dart'; +import 'core/service/patient-vital-signs-service.dart'; import 'core/service/referral_patient_service.dart'; import 'core/service/referred_patient_service.dart'; import 'core/service/schedule_service.dart'; import 'core/viewModel/doctor_replay_view_model.dart'; import 'core/viewModel/medicine_view_model.dart'; +import 'core/viewModel/patient-vital-sign-viewModel.dart'; import 'core/viewModel/referral_view_model.dart'; import 'core/viewModel/referred_view_model.dart'; import 'core/viewModel/schedule_view_model.dart'; @@ -24,6 +26,7 @@ void setupLocator() { locator.registerLazySingleton(() => ReferredPatientService()); locator.registerLazySingleton(() => MedicineService()); locator.registerLazySingleton(() => PatientService()); + locator.registerLazySingleton(() => VitalSignsService()); /// View Model locator.registerFactory(() => DoctorReplayViewModel()); @@ -32,4 +35,5 @@ void setupLocator() { locator.registerFactory(() => ReferredPatientViewModel()); locator.registerFactory(() => MedicineViewModel()); locator.registerFactory(() => PatientViewModel()); + locator.registerFactory(() => VitalSignsViewModel()); } From a71da8e4ef3acb556a3149a0829cf541f3fdd66f Mon Sep 17 00:00:00 2001 From: mosazaid Date: Mon, 28 Dec 2020 13:38:13 +0200 Subject: [PATCH 2/3] working on vital signs --- .../service/patient-vital-signs-service.dart | 6 ++---- .../patient-vital-sign-viewModel.dart | 20 +++++++++++-------- .../vital_sign/patient-vital-sign-data.dart | 8 +++----- lib/routes.dart | 3 +++ .../referral/refer-patient-screen.dart | 10 ++-------- lib/screens/patients/vital-signs-screen.dart | 12 +++++++++++ lib/screens/patients/vital-signs.dart | 9 --------- lib/util/helpers.dart | 4 ++-- .../profile/profile_medical_info_widget.dart | 2 +- 9 files changed, 37 insertions(+), 37 deletions(-) create mode 100644 lib/screens/patients/vital-signs-screen.dart delete mode 100644 lib/screens/patients/vital-signs.dart diff --git a/lib/core/service/patient-vital-signs-service.dart b/lib/core/service/patient-vital-signs-service.dart index 2c7188a4..578aea88 100644 --- a/lib/core/service/patient-vital-signs-service.dart +++ b/lib/core/service/patient-vital-signs-service.dart @@ -45,12 +45,10 @@ class VitalSignsService extends BaseService{ ); } // Vit*/ - Future getPatientVitalSign(patient) async { + Future getPatientVitalSign(/*PatientArrivalEntity patientArrivalEntity*/) async { hasError = false; Map body = Map(); - body['PatientMRN'] = 1; - body['AppointmentNo'] = 1; - body['EpisodeID'] = 1; + body['PatientMRN'] = 50377782; await baseAppClient.post( GET_PATIENT_VITAL_SIGN_DATA, diff --git a/lib/core/viewModel/patient-vital-sign-viewModel.dart b/lib/core/viewModel/patient-vital-sign-viewModel.dart index 255ab5bd..30f979f3 100644 --- a/lib/core/viewModel/patient-vital-sign-viewModel.dart +++ b/lib/core/viewModel/patient-vital-sign-viewModel.dart @@ -1,6 +1,7 @@ import 'package:doctor_app_flutter/core/enum/viewstate.dart'; import 'package:doctor_app_flutter/core/service/patient-vital-signs-service.dart'; import 'package:doctor_app_flutter/core/viewModel/base_view_model.dart'; +import 'package:doctor_app_flutter/models/patient/vital_sign/patient-vital-sign-data.dart'; import 'package:doctor_app_flutter/models/patient/vital_sign/vital_sign_res_model.dart'; import '../../locator.dart'; @@ -8,20 +9,23 @@ import '../../locator.dart'; class VitalSignsViewModel extends BaseViewModel{ VitalSignsService _vitalSignService = locator(); - List get patientVitalSignList => - _vitalSignService.patientVitalSignList; + VitalSignData get patientVitalSigns => + _vitalSignService.patientVitalSigns; - List get patientVitalSignOrderdSubList => - _vitalSignService.patientVitalSignOrderdSubList; - - Future getPatientVitalSign(patient) async { + Future getPatientVitalSign() async { setState(ViewState.Busy); - await _vitalSignService.getPatientVitalSign(patient); + await _vitalSignService.getPatientVitalSign(); if (_vitalSignService.hasError) { error = _vitalSignService.error; setState(ViewState.Error); - } else + } else { + if(patientVitalSigns == null) { + _vitalSignService.patientVitalSigns = VitalSignData( + appointmentNo: 2016053265, bloodPressureCuffLocation: 0, bloodPressureCuffSize: 0, bloodPressureHigher: 38, + ); + } setState(ViewState.Idle); + } } } \ No newline at end of file diff --git a/lib/models/patient/vital_sign/patient-vital-sign-data.dart b/lib/models/patient/vital_sign/patient-vital-sign-data.dart index b5c46aa6..5d20e017 100644 --- a/lib/models/patient/vital_sign/patient-vital-sign-data.dart +++ b/lib/models/patient/vital_sign/patient-vital-sign-data.dart @@ -1,5 +1,4 @@ class VitalSignData { - int appointmentNo; int bloodPressureCuffLocation; int bloodPressureCuffSize; @@ -33,7 +32,7 @@ class VitalSignData { int weightKg; VitalSignData( - this.appointmentNo, + {this.appointmentNo, this.bloodPressureCuffLocation, this.bloodPressureCuffSize, this.bloodPressureHigher, @@ -63,7 +62,7 @@ class VitalSignData { this.temperatureCelcius, this.temperatureCelciusMethod, this.waistSizeInch, - this.weightKg); + this.weightKg}); VitalSignData.fromJson(Map json) { appointmentNo = json['appointmentNo']; @@ -134,5 +133,4 @@ class VitalSignData { data['weightKg'] = this.weightKg; return data; } - -} \ No newline at end of file +} diff --git a/lib/routes.dart b/lib/routes.dart index 5d8b730a..257db6fc 100644 --- a/lib/routes.dart +++ b/lib/routes.dart @@ -40,6 +40,7 @@ import 'screens/doctor/doctor_reply_screen.dart'; import 'screens/live_care/panding_list.dart'; import 'screens/patients/profile/referral/my-referral-detail-screen.dart'; import 'screens/patients/profile/referral/refer-patient-screen.dart'; +import 'screens/patients/vital-signs-screen.dart'; const String INIT_ROUTE = ROOT; const String ROOT = 'root'; @@ -74,6 +75,7 @@ const String PATIENT_ORDERS = 'patients/patient_orders'; const String PATIENT_INSURANCE_APPROVALS = 'patients/patient_insurance_approvals'; const String VITAL_SIGN_DETAILS = 'patients/vital-sign-details'; +const String PATIENT_VITAL_SIGN = 'patients/vital-sign-data'; const String CREATE_EPISODE = 'patients/create-episode'; const String BODY_MEASUREMENTS = 'patients/body-measurements'; @@ -113,6 +115,7 @@ var routes = { PATIENT_ORDERS: (_) => PatientsOrdersScreen(), PATIENT_INSURANCE_APPROVALS: (_) => InsuranceApprovalsScreen(), VITAL_SIGN_DETAILS: (_) => VitalSignDetailsScreen(), + PATIENT_VITAL_SIGN: (_) => PatientVitalSignScreen(), CREATE_EPISODE:(_)=>AddSOAPIndex(), BODY_MEASUREMENTS: (_) => VitalSignItemDetailsScreen(), IN_PATIENT_PRESCRIPTIONS_DETAILS: (_) => InpatientPrescriptionDetailsScreen(), diff --git a/lib/screens/patients/profile/referral/refer-patient-screen.dart b/lib/screens/patients/profile/referral/refer-patient-screen.dart index b6287cd9..2ab7cc18 100644 --- a/lib/screens/patients/profile/referral/refer-patient-screen.dart +++ b/lib/screens/patients/profile/referral/refer-patient-screen.dart @@ -6,6 +6,7 @@ import 'package:doctor_app_flutter/screens/base/base_view.dart'; import 'package:doctor_app_flutter/util/date-utils.dart'; import 'package:doctor_app_flutter/util/dr_app_toast_msg.dart'; import 'package:doctor_app_flutter/util/translations_delegate_base.dart'; +import 'package:doctor_app_flutter/widgets/patients/profile/patient-page-header-widget.dart'; import 'package:doctor_app_flutter/widgets/shared/app_buttons_widget.dart'; import 'package:doctor_app_flutter/widgets/shared/app_scaffold_widget.dart'; import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart'; @@ -64,14 +65,7 @@ class _PatientMakeReferralScreenState extends State { children: [ Column( children: [ - Container( - height: 75, - child: AppText( - "This is where upper view for avatar.. etc placed", - fontWeight: FontWeight.normal, - fontSize: 16, - ), - ), + PatientPageHeaderWidget(patient), const Divider( color: Color(0xffCCCCCC), height: 1, diff --git a/lib/screens/patients/vital-signs-screen.dart b/lib/screens/patients/vital-signs-screen.dart new file mode 100644 index 00000000..6aeb5b3e --- /dev/null +++ b/lib/screens/patients/vital-signs-screen.dart @@ -0,0 +1,12 @@ +import 'package:doctor_app_flutter/models/patient/patiant_info_model.dart'; +import 'package:flutter/material.dart'; + +class PatientVitalSignScreen extends StatelessWidget { + @override + Widget build(BuildContext context) { + final routeArgs = ModalRoute.of(context).settings.arguments as Map; + PatiantInformtion patient = routeArgs['patient']; + + return Container(); + } +} diff --git a/lib/screens/patients/vital-signs.dart b/lib/screens/patients/vital-signs.dart deleted file mode 100644 index b6df3236..00000000 --- a/lib/screens/patients/vital-signs.dart +++ /dev/null @@ -1,9 +0,0 @@ -import 'package:flutter/material.dart'; - -class PatientVitalSignScreen extends StatelessWidget { - @override - Widget build(BuildContext context) { - - return Container(); - } -} diff --git a/lib/util/helpers.dart b/lib/util/helpers.dart index 0c3f1b5f..5c2d6615 100644 --- a/lib/util/helpers.dart +++ b/lib/util/helpers.dart @@ -348,7 +348,7 @@ class Helpers { String lang = await sharedPref.getString(APP_Language); await clearSharedPref(); sharedPref.setString(APP_Language, lang); - // Navigator.of(AppGlobal.CONTEX).pushReplacementNamed(LOGIN); - Navigator.of(AppGlobal.CONTEX).popUntil((ModalRoute.withName(LOGIN))); + Navigator.of(AppGlobal.CONTEX).pushReplacementNamed(LOGIN); + // Navigator.of(AppGlobal.CONTEX).popUntil((ModalRoute.withName(LOGIN))); } } diff --git a/lib/widgets/patients/profile/profile_medical_info_widget.dart b/lib/widgets/patients/profile/profile_medical_info_widget.dart index d9c0f796..9d97a1ad 100644 --- a/lib/widgets/patients/profile/profile_medical_info_widget.dart +++ b/lib/widgets/patients/profile/profile_medical_info_widget.dart @@ -39,7 +39,7 @@ class ProfileMedicalInfoWidget extends StatelessWidget { patient: patient, nameLine1: TranslationBase.of(context).vital, nameLine2: TranslationBase.of(context).signs, - route: VITAL_SIGN_DETAILS, + route: PATIENT_VITAL_SIGN, icon: 'heartbeat.png'), PatientProfileButton( key: key, From 78e2c662c84994a517d5b5a9cc1a46287442a7fc Mon Sep 17 00:00:00 2001 From: mosazaid Date: Wed, 30 Dec 2020 11:33:19 +0200 Subject: [PATCH 3/3] finish vital sign feature, and adding makeReferralResponse --- lib/config/config.dart | 3 +++ .../patient-doctor-referral-service.dart | 25 +++++++++++++++++++ .../viewModel/patient-referral-viewmodel.dart | 10 ++++++++ .../referral/my-referral-detail-screen.dart | 8 ++++-- 4 files changed, 44 insertions(+), 2 deletions(-) diff --git a/lib/config/config.dart b/lib/config/config.dart index e5ed9690..4a4a2d1c 100644 --- a/lib/config/config.dart +++ b/lib/config/config.dart @@ -68,6 +68,9 @@ const GET_PENDING_REFERRAL_PATIENT = const CREATE_REFERRAL_PATIENT = 'Services/DoctorApplication.svc/REST/CreateReferral'; +const RESPONSE_PENDING_REFERRAL_PATIENT = + 'Services/DoctorApplication.svc/REST/CreateReferral'; + const GET_DOCTOR_WORKING_HOURS_TABLE = 'Services/Doctors.svc/REST/GetDoctorWorkingHoursTable'; diff --git a/lib/core/service/patient-doctor-referral-service.dart b/lib/core/service/patient-doctor-referral-service.dart index ad108c3b..a15ed05a 100644 --- a/lib/core/service/patient-doctor-referral-service.dart +++ b/lib/core/service/patient-doctor-referral-service.dart @@ -162,6 +162,31 @@ class PatientReferralService extends LookupService { ); } + Future responseReferral(PendingReferral pendingReferral, bool isAccepted) async { + hasError = false; + DoctorProfileModel doctorProfile = await getDoctorProfile(); + + Map body = Map(); + body['IsAccepted'] = isAccepted; + body['AppointmentNo'] = pendingReferral.sourceAppointmentNo; + body['PatientMRN'] = pendingReferral.patientID; + body['PatientName'] = pendingReferral.patientName; + body['ReferralResponse'] = pendingReferral.remarksFromSource; + body['SetupID'] = pendingReferral.sourceSetupID; + body['DoctorName'] = doctorProfile.doctorName; + + await baseAppClient.post( + RESPONSE_PENDING_REFERRAL_PATIENT, + onSuccess: (dynamic response, int statusCode) { + }, + onFailure: (String error, int statusCode) { + hasError = true; + super.error = error; + }, + body: body, + ); + } + Future makeReferral( PatientArrivalEntity patientArrivalEntity, String isoStringDate, diff --git a/lib/core/viewModel/patient-referral-viewmodel.dart b/lib/core/viewModel/patient-referral-viewmodel.dart index 6fa72f6f..9662a910 100644 --- a/lib/core/viewModel/patient-referral-viewmodel.dart +++ b/lib/core/viewModel/patient-referral-viewmodel.dart @@ -107,6 +107,16 @@ class PatientReferralViewModel extends BaseViewModel { setState(ViewState.Idle); } + Future responseReferral(PendingReferral pendingReferral, bool isAccepted) async { + setState(ViewState.Busy); + await _referralPatientService.responseReferral(pendingReferral, isAccepted); + if (_referralPatientService.hasError) { + error = _referralPatientService.error; + setState(ViewState.Error); + } else + setState(ViewState.Idle); + } + Future getPatientArrivalList(String date) async { setState(ViewState.Busy); await _referralPatientService.getPatientArrivalList(date); diff --git a/lib/screens/patients/profile/referral/my-referral-detail-screen.dart b/lib/screens/patients/profile/referral/my-referral-detail-screen.dart index 5f38f190..4c9d41e0 100644 --- a/lib/screens/patients/profile/referral/my-referral-detail-screen.dart +++ b/lib/screens/patients/profile/referral/my-referral-detail-screen.dart @@ -119,7 +119,9 @@ class MyReferralDetailScreen extends StatelessWidget { fontSize: 16, hPadding: 8, vPadding: 12, - handler: null, + handler: (){ + model.responseReferral(pendingReferral, true); + }, ), ), SizedBox( @@ -133,7 +135,9 @@ class MyReferralDetailScreen extends StatelessWidget { fontSize: 16, hPadding: 8, vPadding: 12, - handler: null, + handler: (){ + model.responseReferral(pendingReferral, false); + }, ), ), ],