From 1491a04b3911261a4fa908b43f40f485208f52ad Mon Sep 17 00:00:00 2001 From: Elham Rababah Date: Mon, 28 Dec 2020 12:54:34 +0200 Subject: [PATCH] PostPhysicalExam works --- lib/config/config.dart | 1 + lib/core/service/SOAP_service.dart | 12 ++ lib/core/viewModel/SOAP_view_model.dart | 11 ++ .../patients/profile/SOAP/objective_page.dart | 116 ++++++++++++++---- .../SOAP/subjective/subjective_page.dart | 7 +- 5 files changed, 123 insertions(+), 24 deletions(-) diff --git a/lib/config/config.dart b/lib/config/config.dart index 5355dac4..8d6c0935 100644 --- a/lib/config/config.dart +++ b/lib/config/config.dart @@ -107,6 +107,7 @@ const GET_MASTER_LOOKUP_LIST = 'Services/DoctorApplication.svc/REST/GetMasterLoo 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'; var selectedPatientType = 1; diff --git a/lib/core/service/SOAP_service.dart b/lib/core/service/SOAP_service.dart index 1a8c91a1..44b304fc 100644 --- a/lib/core/service/SOAP_service.dart +++ b/lib/core/service/SOAP_service.dart @@ -4,6 +4,7 @@ import 'package:doctor_app_flutter/models/SOAP/master_key_model.dart'; 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 'base/lookup-service.dart'; @@ -60,4 +61,15 @@ class SOAPService extends LookupService { super.error = error; }, body: postChiefComplaintRequestModel.toJson()); } + + 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()); + } } diff --git a/lib/core/viewModel/SOAP_view_model.dart b/lib/core/viewModel/SOAP_view_model.dart index 3ff33389..f43306f0 100644 --- a/lib/core/viewModel/SOAP_view_model.dart +++ b/lib/core/viewModel/SOAP_view_model.dart @@ -7,6 +7,7 @@ import 'package:doctor_app_flutter/models/SOAP/master_key_model.dart'; 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 '../../locator.dart'; import 'base_view_model.dart'; @@ -83,5 +84,15 @@ class SOAPViewModel extends BaseViewModel { setState(ViewState.Idle); } + Future postPhysicalExam(PostPhysicalExamRequestModel postPhysicalExamRequestModel) async { + setState(ViewState.BusyLocal); + await _SOAPService.postPhysicalExam(postPhysicalExamRequestModel); + if (_SOAPService.hasError) { + error = _SOAPService.error; + setState(ViewState.ErrorLocal); + } else + setState(ViewState.Idle); + } + } diff --git a/lib/widgets/patients/profile/SOAP/objective_page.dart b/lib/widgets/patients/profile/SOAP/objective_page.dart index a1b91864..894f7745 100644 --- a/lib/widgets/patients/profile/SOAP/objective_page.dart +++ b/lib/widgets/patients/profile/SOAP/objective_page.dart @@ -1,9 +1,11 @@ +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/master_lookup_key.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/master_key_model.dart'; import 'package:doctor_app_flutter/models/SOAP/my_selected_examination.dart'; +import 'package:doctor_app_flutter/models/SOAP/post_physical_exam_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'; @@ -49,7 +51,9 @@ class _ObjectivePageState extends State { Widget build(BuildContext context) { final screenSize = MediaQuery.of(context).size; - return AppScaffold( + return BaseView( + // onModelReady: (model) => model.getMasterLookup(MasterKeysService.Allergies), + builder: (_, model, w) => AppScaffold( isShowAppBar: false, body: SingleChildScrollView( physics: ScrollPhysics(), @@ -161,7 +165,12 @@ class _ObjectivePageState extends State { 0.070, decoration: containerBorderDecoration( - Colors.white, + examination + .isNormal + ? Color( + 0xFF515A5D) + : Colors + .white, Colors.grey), child: Center( child: Padding( @@ -173,17 +182,28 @@ class _ObjectivePageState extends State { style: TextStyle( fontSize: 12, color: - Colors.black, + examination + .isNormal + ? Colors.white + : Colors + .black, //Colors.black, fontWeight: - FontWeight - .bold, + FontWeight + .bold, ), ), ), )), ), - onTap: () {}), + onTap: () { + setState(() { + examination.isAbnormal = + !examination.isAbnormal; + examination.isNormal = + !examination.isNormal; + }); + }), SizedBox( width: 12, ), @@ -191,33 +211,49 @@ class _ObjectivePageState extends State { child: Center( child: Container( height: - screenSize.height * - 0.070, + screenSize.height * + 0.070, decoration: - containerBorderDecoration( - Color(0xFF515A5D), - Colors.black), + containerBorderDecoration( + examination + .isAbnormal + ? Color( + 0xFF515A5D) + : Colors + .white, + Colors.black), child: Center( child: Padding( padding: - const EdgeInsets - .all(8.0), + const EdgeInsets + .all(8.0), child: Text( "Abnormal", style: TextStyle( fontSize: 12, color: - Colors.white, + examination + .isAbnormal + ? Colors.white + : Colors + .black, //Colors.black, fontWeight: - FontWeight - .bold, + FontWeight + .bold, ), ), ), )), ), - onTap: () {}), + onTap: () { + setState(() { + examination.isAbnormal = + !examination.isAbnormal; + examination.isNormal = + !examination.isNormal; + }); + }), ], ), InkWell( @@ -267,9 +303,11 @@ class _ObjectivePageState extends State { ), DividerWithSpacesAround(height: 30,), AppButton( - title: TranslationBase.of(context).next, - onPressed: () { - widget.changePageViewIndex(2); + title: TranslationBase + .of(context) + .next, + onPressed: () async { + await submitObjectivePage(model); }, ), SizedBox( @@ -279,7 +317,43 @@ class _ObjectivePageState extends State { ), ), ), - )); + ))); + } + + submitObjectivePage(SOAPViewModel model) async { + PostPhysicalExamRequestModel postPhysicalExamRequestModel = new PostPhysicalExamRequestModel(); + widget.mySelectedExamination.forEach((exam) { + if (postPhysicalExamRequestModel.listHisProgNotePhysicalVM == + null) + postPhysicalExamRequestModel.listHisProgNotePhysicalVM = []; + + postPhysicalExamRequestModel.listHisProgNotePhysicalVM.add( + ListHisProgNotePhysicalVM( + 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, + )); + }); + + await model.postPhysicalExam(postPhysicalExamRequestModel); + + if (model.state == ViewState.ErrorLocal) { + helpers.showErrorToast(model.error); + } else { + } + // TODO move it back to else stat when it work. + widget.changePageViewIndex(2); + } removeExamination(MasterKeyModel masterKey) { diff --git a/lib/widgets/patients/profile/SOAP/subjective/subjective_page.dart b/lib/widgets/patients/profile/SOAP/subjective/subjective_page.dart index ae024b10..9100cb76 100644 --- a/lib/widgets/patients/profile/SOAP/subjective/subjective_page.dart +++ b/lib/widgets/patients/profile/SOAP/subjective/subjective_page.dart @@ -140,7 +140,8 @@ class _SubjectivePageState extends State { SizedBox( height: 20, ), - AddMedication(), + // TODO return it back when we need it. + // AddMedication(), ]), ), isExpand: isChiefExpand, @@ -305,9 +306,9 @@ class _SubjectivePageState extends State { remarks: allergy.remark, createdBy: 1485, // - createdOn: "2020-08-14T20:37:22.780Z", + createdOn: DateTime.now().toIso8601String(),//"2020-08-14T20:37:22.780Z", editedBy: 1485, - editedOn: "2020-08-14T20:37:22.780Z", + editedOn: DateTime.now().toIso8601String(),//"2020-08-14T20:37:22.780Z", isChecked: false, isUpdatedByNurse: false)); });