diff --git a/lib/core/service/SOAP_service.dart b/lib/core/service/SOAP_service.dart index 65b6d0cc..09530d50 100644 --- a/lib/core/service/SOAP_service.dart +++ b/lib/core/service/SOAP_service.dart @@ -3,6 +3,8 @@ import 'package:doctor_app_flutter/models/SOAP/ChiefComplaint/GetChiefComplaintR import 'package:doctor_app_flutter/models/SOAP/ChiefComplaint/GetChiefComplaintResModel.dart'; import 'package:doctor_app_flutter/models/SOAP/GeneralGetReqForSOAP.dart'; import 'package:doctor_app_flutter/models/SOAP/GetAllergiesResModel.dart'; +import 'package:doctor_app_flutter/models/SOAP/GetGetProgressNoteReqModel.dart'; +import 'package:doctor_app_flutter/models/SOAP/GetGetProgressNoteResModel.dart'; import 'package:doctor_app_flutter/models/SOAP/GetHistoryReqModel.dart'; import 'package:doctor_app_flutter/models/SOAP/GetHistoryResModel.dart'; import 'package:doctor_app_flutter/models/SOAP/GetPhysicalExamListResModel.dart'; @@ -24,6 +26,7 @@ class SOAPService extends LookupService { List patientAllergiesList = []; List patientHistoryList = []; List patientPhysicalExamList = []; + List patientProgressNoteList = []; Future getAllergies(GetAllergiesRequestModel getAllergiesRequestModel) async { await baseAppClient.post( @@ -246,6 +249,7 @@ class SOAPService extends LookupService { response['PhysicalExamList']['entityList'].forEach((v) { patientPhysicalExamList.add(GetPhysicalExamResModel.fromJson(v)); }); + }, onFailure: (String error, int statusCode) { hasError = true; super.error = error; @@ -253,15 +257,19 @@ class SOAPService extends LookupService { } Future getPatientProgressNote( - PostProgressNoteRequestModel getPatientProgressNoteRequestModel) async { + GetGetProgressNoteReqModel getGetProgressNoteReqModel) async { hasError = false; await baseAppClient.post (GET_PROGRESS_NOTE, onSuccess: (dynamic response, int statusCode) { print("Success"); + patientProgressNoteList.clear(); + response['ProgressNoteList']['entityList'].forEach((v) { + patientProgressNoteList.add(GetGetProgressNoteResModel.fromJson(v)); + }); }, onFailure: (String error, int statusCode) { hasError = true; super.error = error; - }, body: getPatientProgressNoteRequestModel.toJson()); + }, body: getGetProgressNoteReqModel.toJson()); } Future getPatientAssessment( diff --git a/lib/core/viewModel/SOAP_view_model.dart b/lib/core/viewModel/SOAP_view_model.dart index 4226643a..8d03a04e 100644 --- a/lib/core/viewModel/SOAP_view_model.dart +++ b/lib/core/viewModel/SOAP_view_model.dart @@ -5,6 +5,8 @@ import 'package:doctor_app_flutter/models/SOAP/ChiefComplaint/GetChiefComplaintR import 'package:doctor_app_flutter/models/SOAP/ChiefComplaint/GetChiefComplaintResModel.dart'; import 'package:doctor_app_flutter/models/SOAP/GeneralGetReqForSOAP.dart'; import 'package:doctor_app_flutter/models/SOAP/GetAllergiesResModel.dart'; +import 'package:doctor_app_flutter/models/SOAP/GetGetProgressNoteReqModel.dart'; +import 'package:doctor_app_flutter/models/SOAP/GetGetProgressNoteResModel.dart'; import 'package:doctor_app_flutter/models/SOAP/GetHistoryReqModel.dart'; import 'package:doctor_app_flutter/models/SOAP/GetHistoryResModel.dart'; import 'package:doctor_app_flutter/models/SOAP/GetPhysicalExamListResModel.dart'; @@ -67,6 +69,9 @@ class SOAPViewModel extends BaseViewModel { List get patientPhysicalExamList => _SOAPService.patientPhysicalExamList; + List get patientProgressNoteList => + _SOAPService.patientProgressNoteList; + Future getAllergies(GetAllergiesRequestModel getAllergiesRequestModel) async { setState(ViewState.Busy); await _SOAPService.getAllergies(getAllergiesRequestModel); @@ -245,17 +250,17 @@ class SOAPViewModel extends BaseViewModel { await _SOAPService.getPatientPhysicalExam(getPhysicalExamReqModel); if (_SOAPService.hasError) { error = _SOAPService.error; - setState(ViewState.Busy); + setState(ViewState.Error); } else setState(ViewState.Idle); } - Future getPatientProgressNote(PostProgressNoteRequestModel getPatientProgressNoteRequestModel) async { + Future getPatientProgressNote(GetGetProgressNoteReqModel getGetProgressNoteReqModel) async { setState(ViewState.Busy); - await _SOAPService.getPatientProgressNote(getPatientProgressNoteRequestModel); + await _SOAPService.getPatientProgressNote(getGetProgressNoteReqModel); if (_SOAPService.hasError) { error = _SOAPService.error; - setState(ViewState.Busy); + setState(ViewState.Error); } else setState(ViewState.Idle); } diff --git a/lib/models/SOAP/GetGetProgressNoteReqModel.dart b/lib/models/SOAP/GetGetProgressNoteReqModel.dart new file mode 100644 index 00000000..936c6f65 --- /dev/null +++ b/lib/models/SOAP/GetGetProgressNoteReqModel.dart @@ -0,0 +1,40 @@ +class GetGetProgressNoteReqModel { + int patientMRN; + int appointmentNo; + String episodeID; + String from; + String to; + int clinicID; + int doctorID; + + GetGetProgressNoteReqModel( + {this.patientMRN, + this.appointmentNo, + this.episodeID, + this.from, + this.to, + this.clinicID, + this.doctorID}); + + GetGetProgressNoteReqModel.fromJson(Map json) { + patientMRN = json['PatientMRN']; + appointmentNo = json['AppointmentNo']; + episodeID = json['EpisodeID']; + from = json['From']; + to = json['To']; + clinicID = json['ClinicID']; + doctorID = json['DoctorID']; + } + + Map toJson() { + final Map data = new Map(); + data['PatientMRN'] = this.patientMRN; + data['AppointmentNo'] = this.appointmentNo; + data['EpisodeID'] = this.episodeID; + data['From'] = this.from; + data['To'] = this.to; + data['ClinicID'] = this.clinicID; + data['DoctorID'] = this.doctorID; + return data; + } +} diff --git a/lib/models/SOAP/GetGetProgressNoteResModel.dart b/lib/models/SOAP/GetGetProgressNoteResModel.dart new file mode 100644 index 00000000..bbc184f1 --- /dev/null +++ b/lib/models/SOAP/GetGetProgressNoteResModel.dart @@ -0,0 +1,25 @@ +class GetGetProgressNoteResModel { + int appointmentNo; + int episodeId; + int patientMRN; + String planNote; + + GetGetProgressNoteResModel( + {this.appointmentNo, this.episodeId, this.patientMRN, this.planNote}); + + GetGetProgressNoteResModel.fromJson(Map json) { + 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; + return data; + } +} diff --git a/lib/widgets/patients/profile/soap_update/update_objective_page.dart b/lib/widgets/patients/profile/soap_update/update_objective_page.dart index d7123678..4884422c 100644 --- a/lib/widgets/patients/profile/soap_update/update_objective_page.dart +++ b/lib/widgets/patients/profile/soap_update/update_objective_page.dart @@ -83,6 +83,8 @@ class _UpdateObjectivePageState extends State { }, builder: (_, model, w) => AppScaffold( isShowAppBar: false, + //TODO: retrun it back + // baseViewModel: model, body: SingleChildScrollView( physics: ScrollPhysics(), child: Center( diff --git a/lib/widgets/patients/profile/soap_update/update_plan_page.dart b/lib/widgets/patients/profile/soap_update/update_plan_page.dart index a6ce8fad..506ff103 100644 --- a/lib/widgets/patients/profile/soap_update/update_plan_page.dart +++ b/lib/widgets/patients/profile/soap_update/update_plan_page.dart @@ -2,6 +2,7 @@ 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/GetGetProgressNoteReqModel.dart'; import 'package:doctor_app_flutter/models/SOAP/post_progress_note_request_model.dart'; import 'package:doctor_app_flutter/models/patient/patiant_info_model.dart'; import 'package:doctor_app_flutter/screens/base/base_view.dart'; @@ -53,8 +54,21 @@ class _UpdatePlanPageState extends State { final screenSize = MediaQuery.of(context).size; return BaseView( - // onModelReady: (model) => model.getMasterLookup(MasterKeysService.Allergies), + onModelReady: (model) async { + GetGetProgressNoteReqModel getGetProgressNoteReqModel = + GetGetProgressNoteReqModel( + appointmentNo: widget.patientInfo.appointmentNo, + patientMRN: widget.patientInfo.patientMRN, + episodeID: widget.patientInfo.episodeNo.toString()); + await model.getPatientProgressNote(getGetProgressNoteReqModel); + + if (model.patientProgressNoteList.isNotEmpty) { + progressNoteController.text = + model.patientProgressNoteList[0].planNote; + } + }, builder: (_, model, w) => AppScaffold( + baseViewModel: model, isShowAppBar: false, body: SingleChildScrollView( physics: ScrollPhysics(), @@ -74,8 +88,7 @@ class _UpdatePlanPageState extends State { Row( children: [ Texts('Progress Note', - variant: - isProgressNoteExpand ? "bodyText" : '', + variant: isProgressNoteExpand ? "bodyText" : '', bold: isProgressNoteExpand ? true : false, color: Colors.black), Icon( @@ -88,8 +101,7 @@ class _UpdatePlanPageState extends State { InkWell( onTap: () { setState(() { - isProgressNoteExpand = - !isProgressNoteExpand; + isProgressNoteExpand = !isProgressNoteExpand; }); }, child: Icon(isProgressNoteExpand @@ -105,7 +117,7 @@ class _UpdatePlanPageState extends State { children: [ Container( margin: - EdgeInsets.only(left: 10, right: 10, top: 15), + EdgeInsets.only(left: 10, right: 10, top: 15), child: TextFields( hintText: "Add Progress Note", fontSize: 13.5, @@ -120,8 +132,7 @@ class _UpdatePlanPageState extends State { // controller: messageController, validator: (value) { if (value == null) - return TranslationBase - .of(context) + return TranslationBase.of(context) .emptyMessage; else return null; @@ -133,10 +144,10 @@ class _UpdatePlanPageState extends State { if (progressNoteController.text.isNotEmpty) Container( margin: - EdgeInsets.only(left: 5, right: 5, top: 15), + EdgeInsets.only(left: 5, right: 5, top: 15), child: Row( mainAxisAlignment: - MainAxisAlignment.spaceBetween, + MainAxisAlignment.spaceBetween, crossAxisAlignment: CrossAxisAlignment.start, children: [ Column( @@ -144,9 +155,9 @@ class _UpdatePlanPageState extends State { children: [ Column( mainAxisAlignment: - MainAxisAlignment.start, + MainAxisAlignment.start, crossAxisAlignment: - CrossAxisAlignment.start, + CrossAxisAlignment.start, children: [ AppText( "12".toUpperCase(), @@ -163,13 +174,12 @@ class _UpdatePlanPageState extends State { ], ), Column( - crossAxisAlignment: CrossAxisAlignment - .start, + crossAxisAlignment: + CrossAxisAlignment.start, children: [ - Row( mainAxisAlignment: - MainAxisAlignment.start, + MainAxisAlignment.start, children: [ SizedBox( height: 6, @@ -177,25 +187,25 @@ class _UpdatePlanPageState extends State { Padding( padding: const EdgeInsets.all(0.0), child: Container( - width: MediaQuery - .of(context) - .size - .width * 0.6, + width: MediaQuery.of(context) + .size + .width * + 0.6, child: AppText( progressNoteController.text, fontSize: 10, - color: Colors.grey, ), ), ), ], - ), SizedBox( + ), + SizedBox( height: 8, ), Row( mainAxisAlignment: - MainAxisAlignment.start, + MainAxisAlignment.start, children: [ AppText( "Created By : ", @@ -211,7 +221,7 @@ class _UpdatePlanPageState extends State { ), Row( mainAxisAlignment: - MainAxisAlignment.start, + MainAxisAlignment.start, children: [ AppText( "Edited By : ", @@ -225,7 +235,6 @@ class _UpdatePlanPageState extends State { ), ], ), - ], ), Column( @@ -246,14 +255,13 @@ class _UpdatePlanPageState extends State { ]), isExpand: isProgressNoteExpand, ), - DividerWithSpacesAround(height: 30,), + DividerWithSpacesAround( + height: 30, + ), AppButton( - title: TranslationBase - .of(context) - .next, + title: TranslationBase.of(context).next, loading: model.state == ViewState.BusyLocal, onPressed: () { - submitPlan(model); // widget.changePageViewIndex(2); }, @@ -265,7 +273,9 @@ class _UpdatePlanPageState extends State { ), ), ), - ),),); + ), + ), + ); } submitPlan(SOAPViewModel model) async { @@ -276,8 +286,13 @@ class _UpdatePlanPageState extends State { appointmentNo: widget.patientInfo.appointmentNo, planNote: progressNoteController.text); + if(model.patientProgressNoteList.isEmpty){ + await model.postProgressNote(postProgressNoteRequestModel); + + }else { + await model.patchProgressNote(postProgressNoteRequestModel); - await model.patchProgressNote(postProgressNoteRequestModel); + } if (model.state == ViewState.ErrorLocal) { helpers.showErrorToast(model.error);