From dc4250a4def72b8846f7c4146eb5e03761fe3457 Mon Sep 17 00:00:00 2001 From: Elham Rababah Date: Mon, 28 Dec 2020 18:45:15 +0200 Subject: [PATCH] Post progress Note --- lib/config/config.dart | 1 + lib/core/service/SOAP_service.dart | 34 ++- lib/core/viewModel/SOAP_view_model.dart | 11 + .../post_progress_note_request_model.dart | 16 +- lib/util/helpers.dart | 5 +- .../patients/profile/SOAP/add_SOAP_index.dart | 11 +- .../patients/profile/SOAP/objective_page.dart | 57 ++-- .../patients/profile/SOAP/plan_page.dart | 282 +++++++++--------- 8 files changed, 230 insertions(+), 187 deletions(-) diff --git a/lib/config/config.dart b/lib/config/config.dart index 8d6c0935..bc2fd0db 100644 --- a/lib/config/config.dart +++ b/lib/config/config.dart @@ -108,6 +108,7 @@ const POST_ALLERGY = 'Services/DoctorApplication.svc/REST/PostAllergies'; const POST_HISTORY = 'Services/DoctorApplication.svc/REST/PostHistory'; const POST_CHIEF_COMPLAINT = 'Services/DoctorApplication.svc/REST/PostChiefcomplaint'; const POST_PHYSICAL_EXAM = 'Services/DoctorApplication.svc/REST/PostPhysicalExam'; +const POST_PROGRESS_NOTE = '/Services/DoctorApplication.svc/REST/PostProgressNote'; var selectedPatientType = 1; diff --git a/lib/core/service/SOAP_service.dart b/lib/core/service/SOAP_service.dart index 44b304fc..e5d2023c 100644 --- a/lib/core/service/SOAP_service.dart +++ b/lib/core/service/SOAP_service.dart @@ -5,6 +5,7 @@ import 'package:doctor_app_flutter/models/SOAP/post_allergy_request_model.dart'; import 'package:doctor_app_flutter/models/SOAP/post_chief_complaint_request_model.dart'; import 'package:doctor_app_flutter/models/SOAP/post_histories_request_model.dart'; import 'package:doctor_app_flutter/models/SOAP/post_physical_exam_request_model.dart'; +import 'package:doctor_app_flutter/models/SOAP/post_progress_note_request_model.dart'; import 'base/lookup-service.dart'; @@ -56,20 +57,33 @@ class SOAPService extends LookupService { await baseAppClient.post(POST_CHIEF_COMPLAINT, onSuccess: (dynamic response, int statusCode) { print("Success"); - }, onFailure: (String error, int statusCode) { - hasError = true; - super.error = error; - }, body: postChiefComplaintRequestModel.toJson()); + }, onFailure: (String error, int statusCode) { + hasError = true; + super.error = error; + }, body: postChiefComplaintRequestModel.toJson()); } - Future postPhysicalExam(PostPhysicalExamRequestModel postPhysicalExamRequestModel) async { + Future postPhysicalExam( + PostPhysicalExamRequestModel postPhysicalExamRequestModel) async { hasError = false; await baseAppClient.post(POST_PHYSICAL_EXAM, onSuccess: (dynamic response, int statusCode) { - print("Success"); - }, onFailure: (String error, int statusCode) { - hasError = true; - super.error = error; - }, body: postPhysicalExamRequestModel.toJson()); + print("Success"); + }, onFailure: (String error, int statusCode) { + hasError = true; + super.error = error; + }, body: postPhysicalExamRequestModel.toJson()); + } + + Future postProgressNote( + PostProgressNoteRequestModel postProgressNoteRequestModel) async { + hasError = false; + await baseAppClient.post(POST_PROGRESS_NOTE, + onSuccess: (dynamic response, int statusCode) { + print("Success"); + }, onFailure: (String error, int statusCode) { + hasError = true; + super.error = error; + }, body: postProgressNoteRequestModel.toJson()); } } diff --git a/lib/core/viewModel/SOAP_view_model.dart b/lib/core/viewModel/SOAP_view_model.dart index f43306f0..b9a96f6c 100644 --- a/lib/core/viewModel/SOAP_view_model.dart +++ b/lib/core/viewModel/SOAP_view_model.dart @@ -8,6 +8,7 @@ import 'package:doctor_app_flutter/models/SOAP/post_allergy_request_model.dart'; import 'package:doctor_app_flutter/models/SOAP/post_chief_complaint_request_model.dart'; import 'package:doctor_app_flutter/models/SOAP/post_histories_request_model.dart'; import 'package:doctor_app_flutter/models/SOAP/post_physical_exam_request_model.dart'; +import 'package:doctor_app_flutter/models/SOAP/post_progress_note_request_model.dart'; import '../../locator.dart'; import 'base_view_model.dart'; @@ -94,5 +95,15 @@ class SOAPViewModel extends BaseViewModel { setState(ViewState.Idle); } + Future postProgressNote(PostProgressNoteRequestModel postProgressNoteRequestModel) async { + setState(ViewState.BusyLocal); + await _SOAPService.postProgressNote(postProgressNoteRequestModel); + if (_SOAPService.hasError) { + error = _SOAPService.error; + setState(ViewState.ErrorLocal); + } else + setState(ViewState.Idle); + } + } diff --git a/lib/models/SOAP/post_progress_note_request_model.dart b/lib/models/SOAP/post_progress_note_request_model.dart index 7bbea882..2217d4ee 100644 --- a/lib/models/SOAP/post_progress_note_request_model.dart +++ b/lib/models/SOAP/post_progress_note_request_model.dart @@ -8,18 +8,18 @@ class PostProgressNoteRequestModel { {this.appointmentNo, this.episodeId, this.patientMRN, this.planNote}); PostProgressNoteRequestModel.fromJson(Map json) { - appointmentNo = json['appointmentNo']; - episodeId = json['episodeId']; - patientMRN = json['patientMRN']; - planNote = json['planNote']; + appointmentNo = json['AppointmentNo']; + episodeId = json['EpisodeId']; + patientMRN = json['PatientMRN']; + planNote = json['PlanNote']; } Map toJson() { final Map data = new Map(); - data['appointmentNo'] = this.appointmentNo; - data['episodeId'] = this.episodeId; - data['patientMRN'] = this.patientMRN; - data['planNote'] = this.planNote; + data['AppointmentNo'] = this.appointmentNo; + data['EpisodeId'] = this.episodeId; + data['PatientMRN'] = this.patientMRN; + data['PlanNote'] = this.planNote; return data; } } diff --git a/lib/util/helpers.dart b/lib/util/helpers.dart index 0c3f1b5f..c1d70cef 100644 --- a/lib/util/helpers.dart +++ b/lib/util/helpers.dart @@ -348,7 +348,8 @@ 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); + // TODO Fix it + // Navigator.of(AppGlobal.CONTEX).popUntil((ModalRoute.withName(LOGIN))); } } diff --git a/lib/widgets/patients/profile/SOAP/add_SOAP_index.dart b/lib/widgets/patients/profile/SOAP/add_SOAP_index.dart index 705bc85f..f1d81812 100644 --- a/lib/widgets/patients/profile/SOAP/add_SOAP_index.dart +++ b/lib/widgets/patients/profile/SOAP/add_SOAP_index.dart @@ -108,10 +108,13 @@ class _AddSOAPIndexState extends State ), ], ), - AppText( - "ALLERGIC TO: FOOD, ASPIRIN, EGG WHITE", - color: Color(0xFFB9382C), - fontWeight: FontWeight.bold, + Container( + width: MediaQuery.of(context).size.width *0.65, + child: AppText( + "ALLERGIC TO: FOOD, ASPIRIN, EGG WHITE", + color: Color(0xFFB9382C), + fontWeight: FontWeight.bold, + ), ), ], ) diff --git a/lib/widgets/patients/profile/SOAP/objective_page.dart b/lib/widgets/patients/profile/SOAP/objective_page.dart index 5f9d6f2c..add9ca16 100644 --- a/lib/widgets/patients/profile/SOAP/objective_page.dart +++ b/lib/widgets/patients/profile/SOAP/objective_page.dart @@ -320,38 +320,41 @@ class _ObjectivePageState extends State { } submitObjectivePage(SOAPViewModel model) async { - PostPhysicalExamRequestModel postPhysicalExamRequestModel = new PostPhysicalExamRequestModel(); - widget.mySelectedExamination.forEach((exam) { - if (postPhysicalExamRequestModel.listHisProgNotePhysicalExaminationVM == - null) - postPhysicalExamRequestModel.listHisProgNotePhysicalExaminationVM = []; + if(widget.mySelectedExamination.isNotEmpty){ + PostPhysicalExamRequestModel postPhysicalExamRequestModel = new PostPhysicalExamRequestModel(); + widget.mySelectedExamination.forEach((exam) { + if (postPhysicalExamRequestModel.listHisProgNotePhysicalExaminationVM == + null) + postPhysicalExamRequestModel.listHisProgNotePhysicalExaminationVM = []; - postPhysicalExamRequestModel.listHisProgNotePhysicalExaminationVM.add( - ListHisProgNotePhysicalExaminationVM( - patientMRN: 3120690, - episodeId: 200012117, - appointmentNo: 2016054573, - remarks: exam.remark ?? '', - createdBy: 1485, - createdOn: DateTime.now().toIso8601String(), - editedBy: 1485, - editedOn: DateTime.now().toIso8601String(), - examId: exam.selectedExamination.id, - examType: exam.selectedExamination.typeId, - isAbnormal: exam.isAbnormal, - isNormal: exam.isNormal, - masterDescription: exam.selectedExamination, - notExamined: false + postPhysicalExamRequestModel.listHisProgNotePhysicalExaminationVM.add( + ListHisProgNotePhysicalExaminationVM( + patientMRN: 3120690, + episodeId: 200012117, + appointmentNo: 2016054573, + remarks: exam.remark ?? '', + createdBy: 1485, + createdOn: DateTime.now().toIso8601String(), + editedBy: 1485, + editedOn: DateTime.now().toIso8601String(), + examId: exam.selectedExamination.id, + examType: exam.selectedExamination.typeId, + isAbnormal: exam.isAbnormal, + isNormal: exam.isNormal, + masterDescription: exam.selectedExamination, + notExamined: false - )); - }); + )); + }); - await model.postPhysicalExam(postPhysicalExamRequestModel); + await model.postPhysicalExam(postPhysicalExamRequestModel); - if (model.state == ViewState.ErrorLocal) { - helpers.showErrorToast(model.error); - } else { + if (model.state == ViewState.ErrorLocal) { + helpers.showErrorToast(model.error); + } else { + } } + // TODO move it back to else stat when it work. widget.changePageViewIndex(2); diff --git a/lib/widgets/patients/profile/SOAP/plan_page.dart b/lib/widgets/patients/profile/SOAP/plan_page.dart index 9bf907d9..3e5ca10a 100644 --- a/lib/widgets/patients/profile/SOAP/plan_page.dart +++ b/lib/widgets/patients/profile/SOAP/plan_page.dart @@ -1,5 +1,8 @@ +import 'package:doctor_app_flutter/client/base_app_client.dart'; import 'package:doctor_app_flutter/config/config.dart'; +import 'package:doctor_app_flutter/core/enum/viewstate.dart'; import 'package:doctor_app_flutter/core/viewModel/SOAP_view_model.dart'; +import 'package:doctor_app_flutter/models/SOAP/post_progress_note_request_model.dart'; import 'package:doctor_app_flutter/screens/base/base_view.dart'; import 'package:doctor_app_flutter/util/translations_delegate_base.dart'; import 'package:doctor_app_flutter/widgets/shared/Text.dart'; @@ -27,7 +30,9 @@ class _PlanPageState extends State { List progressNoteList; - TextEditingController progressNoteController = TextEditingController(); + TextEditingController progressNoteController = + TextEditingController(text: null); + BoxDecoration containerBorderDecoration( Color containerColor, Color borderColor) { return BoxDecoration( @@ -40,6 +45,7 @@ class _PlanPageState extends State { )), ); } + @override Widget build(BuildContext context) { final screenSize = MediaQuery.of(context).size; @@ -112,7 +118,8 @@ class _PlanPageState extends State { // controller: messageController, validator: (value) { if (value == null) - return TranslationBase.of(context) + return TranslationBase + .of(context) .emptyMessage; else return null; @@ -121,110 +128,117 @@ class _PlanPageState extends State { SizedBox( height: 20, ), - Container( - margin: EdgeInsets.only(left: 5, right: 5, top: 15), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Column( - mainAxisAlignment: MainAxisAlignment.start, - children: [ - Column( - mainAxisAlignment: - MainAxisAlignment.start, - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - AppText( - "12".toUpperCase(), - fontWeight: FontWeight.bold, - fontSize: 16, - ), - AppText( - "DEC".toUpperCase(), - fontSize: 10, - color: Colors.grey, - ), - ], - ) - ], - ), - Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ + if (progressNoteController.text.isNotEmpty) + Container( + margin: + EdgeInsets.only(left: 5, right: 5, top: 15), + child: Row( + mainAxisAlignment: + MainAxisAlignment.spaceBetween, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Column( + mainAxisAlignment: MainAxisAlignment.start, + children: [ + Column( + mainAxisAlignment: + MainAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + AppText( + "12".toUpperCase(), + fontWeight: FontWeight.bold, + fontSize: 16, + ), + AppText( + "DEC".toUpperCase(), + fontSize: 10, + color: Colors.grey, + ), + ], + ) + ], + ), + Column( + crossAxisAlignment: CrossAxisAlignment + .start, + children: [ - Row( - mainAxisAlignment: - MainAxisAlignment.start, - children: [ - SizedBox( - height: 6, - ), - Padding( - padding: const EdgeInsets.all(0.0), - child: Container( - width: MediaQuery.of(context).size.width * 0.6, - child: AppText( - progressNoteController.text, - fontSize: 10, + Row( + mainAxisAlignment: + MainAxisAlignment.start, + children: [ + SizedBox( + height: 6, + ), + Padding( + padding: const EdgeInsets.all(0.0), + child: Container( + width: MediaQuery + .of(context) + .size + .width * 0.6, + child: AppText( + progressNoteController.text, + fontSize: 10, - color: Colors.grey, + color: Colors.grey, + ), ), ), - ), - ], - ),SizedBox( - height: 8, - ), - Row( - mainAxisAlignment: - MainAxisAlignment.start, - children: [ - AppText( - "Created By : ", - fontWeight: FontWeight.bold, - fontSize: 16, - ), - AppText( - "Anas Abdullah on 12 De", - fontSize: 10, - color: Colors.grey, - ), - ], - ), - Row( - mainAxisAlignment: - MainAxisAlignment.start, - children: [ - AppText( - "Edited By : ", - fontWeight: FontWeight.bold, - fontSize: 16, - ), - AppText( - "Rahim on 13 Dec", - fontSize: 10, - color: Colors.grey, - ), - ], - ), + ], + ), SizedBox( + height: 8, + ), + Row( + mainAxisAlignment: + MainAxisAlignment.start, + children: [ + AppText( + "Created By : ", + fontWeight: FontWeight.bold, + fontSize: 16, + ), + AppText( + "Anas Abdullah on 12 De", + fontSize: 10, + color: Colors.grey, + ), + ], + ), + Row( + mainAxisAlignment: + MainAxisAlignment.start, + children: [ + AppText( + "Edited By : ", + fontWeight: FontWeight.bold, + fontSize: 16, + ), + AppText( + "Rahim on 13 Dec", + fontSize: 10, + color: Colors.grey, + ), + ], + ), - ], - ), - Column( - children: [ - InkWell( - onTap: () { - openProgressNote(context); - }, - child: Icon(EvaIcons.edit2Outline), - ) - ], - ), - ], - ), - ) + ], + ), + Column( + children: [ + InkWell( + onTap: () { + openProgressNote(context); + }, + child: Icon(EvaIcons.edit2Outline), + ) + ], + ), + ], + ), + ) ], ) ]), @@ -232,50 +246,46 @@ class _PlanPageState extends State { ), DividerWithSpacesAround(height: 30,), AppButton( - title: TranslationBase.of(context).next, + title: TranslationBase + .of(context) + .next, + loading: model.state == ViewState.BusyLocal, onPressed: () { - widget.changePageViewIndex(2); + + submitPlan(model); + // widget.changePageViewIndex(2); }, ), - SizedBox( - height: 30, - ), - ], + SizedBox( + height: 30, ), - ), + ], ), - ),),); + ), + ), + ),),); } - openProgressNote(BuildContext context) { - final screenSize = MediaQuery - .of(context) - .size; - InputDecoration textFieldSelectorDecoration(String hintText, - String selectedText, bool isDropDown) { - return InputDecoration( - focusedBorder: OutlineInputBorder( - borderSide: BorderSide(color: Color(0xFFCCCCCC), width: 2.0), - borderRadius: BorderRadius.circular(8), - ), - enabledBorder: OutlineInputBorder( - borderSide: BorderSide(color: Color(0xFFCCCCCC), width: 2.0), - borderRadius: BorderRadius.circular(8), - ), - disabledBorder: OutlineInputBorder( - borderSide: BorderSide(color: Color(0xFFCCCCCC), width: 2.0), - borderRadius: BorderRadius.circular(8), - ), - hintText: selectedText != null ? selectedText : hintText, - suffixIcon: isDropDown ? Icon(Icons.arrow_drop_down) : null, - hintStyle: TextStyle( - fontSize: 14, - color: Colors.grey.shade600, - ), - ); + submitPlan(SOAPViewModel model) async { + if (progressNoteController.text.isNotEmpty) { + PostProgressNoteRequestModel postProgressNoteRequestModel = new PostProgressNoteRequestModel( + patientMRN: 3120690, + episodeId: 200012117, + appointmentNo: 2016054573, + planNote: progressNoteController.text); + + + await model.postProgressNote(postProgressNoteRequestModel); + + if (model.state == ViewState.ErrorLocal) { + helpers.showErrorToast(model.error); + } else { + Navigator.of(context).pop(); + } } + } - ; + openProgressNote(BuildContext context) { showModalBottomSheet( backgroundColor: Colors.white, isScrollControlled: true,