From 82285ccf39e0705a76a6b76f83b53a8c648887d7 Mon Sep 17 00:00:00 2001 From: Elham Rababah Date: Thu, 22 Apr 2021 14:42:05 +0300 Subject: [PATCH] show progress_note part --- lib/config/config.dart | 6 +- lib/core/model/note/CreateNoteModel.dart | 88 +++++++++++++++++++ lib/core/service/patient_service.dart | 19 +++- lib/core/viewModel/patient_view_model.dart | 13 ++- .../profile/note/progress_note_screen.dart | 2 + .../patients/profile/note/update_note.dart | 77 ++++++++++------ ...rofile_medical_info_widget_in_patient.dart | 2 +- .../shared/buttons/app_buttons_widget.dart | 2 +- 8 files changed, 177 insertions(+), 32 deletions(-) create mode 100644 lib/core/model/note/CreateNoteModel.dart diff --git a/lib/config/config.dart b/lib/config/config.dart index 1ce6750d..c10f8838 100644 --- a/lib/config/config.dart +++ b/lib/config/config.dart @@ -4,8 +4,8 @@ const MAX_SMALL_SCREEN = 660; const ONLY_NUMBERS = "[0-9]"; const ONLY_LETTERS = "[a-zA-Z &'\"]"; const ONLY_DATE = "[0-9/]"; -// const BASE_URL = 'https://hmgwebservices.com/'; -const BASE_URL = 'https://uat.hmgwebservices.com/'; +const BASE_URL = 'https://hmgwebservices.com/'; +// const BASE_URL = 'https://uat.hmgwebservices.com/'; const PHARMACY_ITEMS_URL = "Services/Lists.svc/REST/GetPharmcyItems_Region_enh"; const PHARMACY_LIST_URL = "Services/Patients.svc/REST/GetPharmcyList"; const PATIENT_PROGRESS_NOTE_URL = @@ -252,7 +252,7 @@ const GET_PRESCRIPTION_REPORT_ENH = 'Services/Patients.svc/REST/GetPrescriptionReport_enh'; const GET_PHARMACY_LIST = "Services/Patients.svc/REST/GetPharmcyList"; const UPDATE_PROGRESS_NOTE_FOR_INPATIENT = "Services/DoctorApplication.svc/REST/UpdateProgressNoteForInPatient"; - +const CREATE_PROGRESS_NOTE_FOR_INPATIENT = "Services/DoctorApplication.svc/REST/CreateProgressNoteForInPatient"; var selectedPatientType = 1; //*********change value to decode json from Dropdown ************ diff --git a/lib/core/model/note/CreateNoteModel.dart b/lib/core/model/note/CreateNoteModel.dart new file mode 100644 index 00000000..ce076705 --- /dev/null +++ b/lib/core/model/note/CreateNoteModel.dart @@ -0,0 +1,88 @@ +class CreateNoteModel { + int visitType; + int admissionNo; + int projectID; + int patientTypeID; + int patientID; + int clinicID; + String notes; + int createdBy; + int editedBy; + String nursingRemarks; + int languageID; + String stamp; + String iPAdress; + double versionID; + int channel; + String tokenID; + String sessionID; + bool isLoginForDoctorApp; + bool patientOutSA; + + CreateNoteModel( + {this.visitType, + this.admissionNo, + this.projectID, + this.patientTypeID, + this.patientID, + this.clinicID, + this.notes, + this.createdBy, + this.editedBy, + this.nursingRemarks, + this.languageID, + this.stamp, + this.iPAdress, + this.versionID, + this.channel, + this.tokenID, + this.sessionID, + this.isLoginForDoctorApp, + this.patientOutSA}); + + CreateNoteModel.fromJson(Map json) { + visitType = json['VisitType']; + admissionNo = json['AdmissionNo']; + projectID = json['ProjectID']; + patientTypeID = json['PatientTypeID']; + patientID = json['PatientID']; + clinicID = json['ClinicID']; + notes = json['Notes']; + createdBy = json['CreatedBy']; + editedBy = json['EditedBy']; + nursingRemarks = json['NursingRemarks']; + languageID = json['LanguageID']; + stamp = json['stamp']; + iPAdress = json['IPAdress']; + versionID = json['VersionID']; + channel = json['Channel']; + tokenID = json['TokenID']; + sessionID = json['SessionID']; + isLoginForDoctorApp = json['IsLoginForDoctorApp']; + patientOutSA = json['PatientOutSA']; + } + + Map toJson() { + final Map data = new Map(); + data['VisitType'] = this.visitType; + data['AdmissionNo'] = this.admissionNo; + data['ProjectID'] = this.projectID; + data['PatientTypeID'] = this.patientTypeID; + data['PatientID'] = this.patientID; + data['ClinicID'] = this.clinicID; + data['Notes'] = this.notes; + data['CreatedBy'] = this.createdBy; + data['EditedBy'] = this.editedBy; + data['NursingRemarks'] = this.nursingRemarks; + data['LanguageID'] = this.languageID; + data['stamp'] = this.stamp; + data['IPAdress'] = this.iPAdress; + data['VersionID'] = this.versionID; + data['Channel'] = this.channel; + data['TokenID'] = this.tokenID; + data['SessionID'] = this.sessionID; + data['IsLoginForDoctorApp'] = this.isLoginForDoctorApp; + data['PatientOutSA'] = this.patientOutSA; + return data; + } +} diff --git a/lib/core/service/patient_service.dart b/lib/core/service/patient_service.dart index 29a1d445..6caaf0fc 100644 --- a/lib/core/service/patient_service.dart +++ b/lib/core/service/patient_service.dart @@ -1,6 +1,7 @@ import 'package:doctor_app_flutter/client/base_app_client.dart'; import 'package:doctor_app_flutter/config/config.dart'; import 'package:doctor_app_flutter/config/shared_pref_kay.dart'; +import 'package:doctor_app_flutter/core/model/note/CreateNoteModel.dart'; import 'package:doctor_app_flutter/core/model/note/note_model.dart'; import 'package:doctor_app_flutter/core/model/note/update_note_model.dart'; import 'package:doctor_app_flutter/core/service/base/base_service.dart'; @@ -297,7 +298,23 @@ class PatientService extends BaseService { hasError = false; await baseAppClient.post( - PATIENT_PROGRESS_NOTE_URL, + UPDATE_PROGRESS_NOTE_FOR_INPATIENT, + onSuccess: (dynamic response, int statusCode) { + print("ok"); + }, + onFailure: (String error, int statusCode) { + hasError = true; + super.error = error; + }, + body: req.toJson(), + ); + } + + Future createPatientProgressNote(CreateNoteModel req) async { + hasError = false; + + await baseAppClient.post( + CREATE_PROGRESS_NOTE_FOR_INPATIENT, onSuccess: (dynamic response, int statusCode) { print("ok"); }, diff --git a/lib/core/viewModel/patient_view_model.dart b/lib/core/viewModel/patient_view_model.dart index 785a978c..aaa7364f 100644 --- a/lib/core/viewModel/patient_view_model.dart +++ b/lib/core/viewModel/patient_view_model.dart @@ -1,4 +1,5 @@ import 'package:doctor_app_flutter/core/enum/viewstate.dart'; +import 'package:doctor_app_flutter/core/model/note/CreateNoteModel.dart'; import 'package:doctor_app_flutter/core/model/note/note_model.dart'; import 'package:doctor_app_flutter/core/model/note/update_note_model.dart'; import 'package:doctor_app_flutter/core/service/patient_service.dart'; @@ -150,7 +151,17 @@ class PatientViewModel extends BaseViewModel { Future updatePatientProgressNote(UpdateNoteReqModel req) async { setState(ViewState.BusyLocal); - await _patientService.getPatientProgressNote(req); + await _patientService.updatePatientProgressNote(req); + if (_patientService.hasError) { + error = _patientService.error; + setState(ViewState.ErrorLocal); + } else + setState(ViewState.Idle); + } + + Future createPatientProgressNote(CreateNoteModel req) async { + setState(ViewState.BusyLocal); + await _patientService.createPatientProgressNote(req); if (_patientService.hasError) { error = _patientService.error; setState(ViewState.ErrorLocal); diff --git a/lib/screens/patients/profile/note/progress_note_screen.dart b/lib/screens/patients/profile/note/progress_note_screen.dart index 129d2ca6..3682a6a0 100644 --- a/lib/screens/patients/profile/note/progress_note_screen.dart +++ b/lib/screens/patients/profile/note/progress_note_screen.dart @@ -85,6 +85,7 @@ class _ProgressNoteState extends State { patientModel: model, patient: patient, visitType: widget.visitType, + isUpdate: false, )), ); },label: 'Add a New Order',), @@ -191,6 +192,7 @@ class _ProgressNoteState extends State { patientModel: model, patient: patient, visitType: widget.visitType, + isUpdate: true, )), ); diff --git a/lib/screens/patients/profile/note/update_note.dart b/lib/screens/patients/profile/note/update_note.dart index 1e242c7b..c3806b1a 100644 --- a/lib/screens/patients/profile/note/update_note.dart +++ b/lib/screens/patients/profile/note/update_note.dart @@ -1,23 +1,20 @@ +import 'package:doctor_app_flutter/config/shared_pref_kay.dart'; import 'package:doctor_app_flutter/config/size_config.dart'; import 'package:doctor_app_flutter/core/enum/viewstate.dart'; -import 'package:doctor_app_flutter/core/model/medical_file_model.dart'; +import 'package:doctor_app_flutter/core/model/note/CreateNoteModel.dart'; import 'package:doctor_app_flutter/core/model/note/note_model.dart'; import 'package:doctor_app_flutter/core/model/note/update_note_model.dart'; import 'package:doctor_app_flutter/core/viewModel/patient_view_model.dart'; -import 'package:doctor_app_flutter/core/viewModel/procedure_View_model.dart'; +import 'package:doctor_app_flutter/models/doctor/doctor_profile_model.dart'; import 'package:doctor_app_flutter/models/patient/patiant_info_model.dart'; import 'package:doctor_app_flutter/models/patient/progress_note_request.dart'; import 'package:doctor_app_flutter/screens/base/base_view.dart'; import 'package:doctor_app_flutter/screens/patients/profile/soap_update/shared_soap_widgets/bottom_sheet_title.dart'; -import 'package:doctor_app_flutter/screens/procedures/entity_list_checkbox_search_widget.dart'; -import 'package:doctor_app_flutter/util/dr_app_toast_msg.dart'; import 'package:doctor_app_flutter/util/helpers.dart'; import 'package:doctor_app_flutter/util/translations_delegate_base.dart'; import 'package:doctor_app_flutter/widgets/shared/app_scaffold_widget.dart'; -import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart'; import 'package:doctor_app_flutter/widgets/shared/buttons/app_buttons_widget.dart'; import 'package:doctor_app_flutter/widgets/shared/loader/gif_loader_dialog_utils.dart'; -import 'package:doctor_app_flutter/widgets/shared/network_base_view.dart'; import 'package:doctor_app_flutter/widgets/shared/text_fields/app-textfield-custom.dart'; import 'package:flutter/material.dart'; @@ -26,9 +23,10 @@ class UpdateNoteOrder extends StatefulWidget { final PatientViewModel patientModel; final PatiantInformtion patient; final int visitType; + final bool isUpdate; const UpdateNoteOrder( - {Key key, this.note, this.patientModel, this.patient, this.visitType}) + {Key key, this.note, this.patientModel, this.patient, this.visitType, this.isUpdate}) : super(key: key); @override @@ -107,23 +105,52 @@ class _UpdateNoteOrderState extends State { children: [ AppButton( title: 'Add Progress Note', - color: Color(0xff359846), - disabled: progressNoteController.text.isEmpty, - fontWeight: FontWeight.w700, - onPressed: () async { - UpdateNoteReqModel reqModel = UpdateNoteReqModel( - admissionNo: int.parse(widget.patient.admissionNo), - cancelledNote: false, - lineItemNo: 30, - notes - :progressNoteController.text, verifiedNote: false); - - GifLoaderDialogUtils.showMyDialog(context); - await model.updatePatientProgressNote(reqModel); - if (model.state == ViewState.ErrorLocal) { - Helpers.showErrorToast("Error"); - } else { - ProgressNoteRequest progressNoteRequest = ProgressNoteRequest( + color: Color(0xff359846), + // disabled: progressNoteController.text.isEmpty, + fontWeight: FontWeight.w700, + onPressed: () async { + GifLoaderDialogUtils.showMyDialog(context); + Map profile = await sharedPref.getObj(DOCTOR_PROFILE); + + DoctorProfileModel doctorProfile = DoctorProfileModel.fromJson(profile); + + + if (widget.isUpdate) { + UpdateNoteReqModel reqModel = UpdateNoteReqModel( + admissionNo: int.parse(widget.patient.admissionNo), + cancelledNote: false, + lineItemNo: 30, + createdBy: widget.note.createdBy, + notes: progressNoteController.text + + , + verifiedNote: false, + + patientTypeID: widget.patient.patientType, + patientOutSA: false, + ); + await model.updatePatientProgressNote(reqModel); + } else { + CreateNoteModel reqModel = CreateNoteModel( + admissionNo: int.parse(widget.patient.admissionNo), + createdBy: doctorProfile.doctorID, + visitType: widget.visitType, + patientID: widget.patient.patientId, + nursingRemarks: ' ', + patientTypeID: widget.patient.patientType, + patientOutSA: false, + + notes: progressNoteController.text + ); + + await model.createPatientProgressNote(reqModel); + } + + if (model.state == ViewState.ErrorLocal) { + Helpers.showErrorToast("Error"); + } else { + ProgressNoteRequest progressNoteRequest = + ProgressNoteRequest( visitType: widget.visitType, // if equal 5 then this will return progress note admissionNo: int.parse(widget.patient.admissionNo), @@ -131,7 +158,7 @@ class _UpdateNoteOrderState extends State { patientTypeID: widget.patient.patientType, languageID: 2); await widget.patientModel.getPatientProgressNote( - progressNoteRequest); + progressNoteRequest.toJson()); } GifLoaderDialogUtils.hideDialog(context); diff --git a/lib/widgets/patients/profile/profile_medical_info_widget_in_patient.dart b/lib/widgets/patients/profile/profile_medical_info_widget_in_patient.dart index f00c7ce0..230cce06 100644 --- a/lib/widgets/patients/profile/profile_medical_info_widget_in_patient.dart +++ b/lib/widgets/patients/profile/profile_medical_info_widget_in_patient.dart @@ -95,7 +95,7 @@ class ProfileMedicalInfoWidgetInPatient extends StatelessWidget { patient: patient, patientType: patientType, arrivalType: arrivalType, - route: null, + route: ORDER_NOTE, nameLine1: "Text", nameLine2: TranslationBase.of(context).orders, icon: 'patient/Progress_notes.png'), diff --git a/lib/widgets/shared/buttons/app_buttons_widget.dart b/lib/widgets/shared/buttons/app_buttons_widget.dart index 36f9d983..521d1025 100644 --- a/lib/widgets/shared/buttons/app_buttons_widget.dart +++ b/lib/widgets/shared/buttons/app_buttons_widget.dart @@ -49,7 +49,7 @@ class _AppButtonState extends State { @override Widget build(BuildContext context) { return IgnorePointer( - ignoring: widget.loading, + ignoring: widget.loading ||widget.disabled, child: RawMaterialButton( fillColor: widget.color != null ? widget.color : HexColor("#B8382C"), splashColor: widget.color,