diff --git a/lib/config/config.dart b/lib/config/config.dart index 8616a2f7..d192c31b 100644 --- a/lib/config/config.dart +++ b/lib/config/config.dart @@ -5,8 +5,8 @@ const ONLY_NUMBERS = "[0-9]"; const ONLY_LETTERS = "[a-zA-Z &'\"]"; const ONLY_DATE = "[0-9/]"; const BASE_URL_LIVE_CARE = 'https://livecare.hmg.com/'; -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 = "Services/DoctorApplication.svc/REST/GetProgressNoteForInPatient"; @@ -133,6 +133,7 @@ const GET_ALLERGIES = 'Services/DoctorApplication.svc/REST/GetAllergies'; const GET_MASTER_LOOKUP_LIST = 'Services/DoctorApplication.svc/REST/GetMasterLookUpList'; const POST_EPISODE = 'Services/DoctorApplication.svc/REST/PostEpisode'; +const POST_EPISODE_FOR_IN_PATIENT = 'Services/DoctorApplication.svc/REST/PostEpisode'; const POST_ALLERGY = 'Services/DoctorApplication.svc/REST/PostAllergies'; const POST_HISTORY = 'Services/DoctorApplication.svc/REST/PostHistory'; diff --git a/lib/core/service/patient_medical_file/soap/SOAP_service.dart b/lib/core/service/patient_medical_file/soap/SOAP_service.dart index b2e0d603..3422f750 100644 --- a/lib/core/service/patient_medical_file/soap/SOAP_service.dart +++ b/lib/core/service/patient_medical_file/soap/SOAP_service.dart @@ -14,6 +14,7 @@ import 'package:doctor_app_flutter/models/SOAP/GetPhysicalExamReqModel.dart'; import 'package:doctor_app_flutter/models/SOAP/PatchAssessmentReqModel.dart'; import 'package:doctor_app_flutter/models/SOAP/PostEpisodeReqModel.dart'; import 'package:doctor_app_flutter/models/SOAP/get_Allergies_request_model.dart'; +import 'package:doctor_app_flutter/models/SOAP/in_patient/PostEpisodeForInpatientRequestModel.dart'; 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_assessment_request_model.dart'; @@ -63,6 +64,18 @@ class SOAPService extends LookupService { }, body: postEpisodeReqModel.toJson()); } + Future postEpisodeForInPatient(PostEpisodeForInpatientRequestModel postEpisodeForInpatientRequestModel) async { + hasError = false; + + await baseAppClient.post(POST_EPISODE_FOR_IN_PATIENT, + onSuccess: (dynamic response, int statusCode) { + episodeID = response['EpisodeID']; + }, onFailure: (String error, int statusCode) { + hasError = true; + super.error = error; + }, body: postEpisodeForInpatientRequestModel.toJson()); + } + Future postAllergy(PostAllergyRequestModel postAllergyRequestModel) async { hasError = false; diff --git a/lib/core/viewModel/SOAP_view_model.dart b/lib/core/viewModel/SOAP_view_model.dart index d42098a2..7fa9182e 100644 --- a/lib/core/viewModel/SOAP_view_model.dart +++ b/lib/core/viewModel/SOAP_view_model.dart @@ -19,6 +19,7 @@ import 'package:doctor_app_flutter/models/SOAP/GetPhysicalExamReqModel.dart'; import 'package:doctor_app_flutter/models/SOAP/PatchAssessmentReqModel.dart'; import 'package:doctor_app_flutter/models/SOAP/PostEpisodeReqModel.dart'; import 'package:doctor_app_flutter/models/SOAP/get_Allergies_request_model.dart'; +import 'package:doctor_app_flutter/models/SOAP/in_patient/PostEpisodeForInpatientRequestModel.dart'; 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_assessment_request_model.dart'; @@ -176,6 +177,16 @@ class SOAPViewModel extends BaseViewModel { setState(ViewState.Idle); } + Future postEpisodeForInPatient(PostEpisodeForInpatientRequestModel postEpisodeForInpatientRequestModel) async { + setState(ViewState.BusyLocal); + await _SOAPService.postEpisodeForInPatient(postEpisodeForInpatientRequestModel); + if (_SOAPService.hasError) { + error = _SOAPService.error; + setState(ViewState.ErrorLocal); + } else + setState(ViewState.Idle); + } + Future postAllergy(PostAllergyRequestModel postAllergyRequestModel) async { setState(ViewState.BusyLocal); await _SOAPService.postAllergy(postAllergyRequestModel); diff --git a/lib/models/SOAP/in_patient/PostEpisodeForInpatientRequestModel.dart b/lib/models/SOAP/in_patient/PostEpisodeForInpatientRequestModel.dart new file mode 100644 index 00000000..2dff7a60 --- /dev/null +++ b/lib/models/SOAP/in_patient/PostEpisodeForInpatientRequestModel.dart @@ -0,0 +1,22 @@ +class PostEpisodeForInpatientRequestModel { + int admissionNo; + int patientID; + int patientTypeID; + + PostEpisodeForInpatientRequestModel( + {this.admissionNo, this.patientID, this.patientTypeID = 1}); + + PostEpisodeForInpatientRequestModel.fromJson(Map json) { + admissionNo = json['AdmissionNo']; + patientID = json['PatientID']; + patientTypeID = json['PatientTypeID']; + } + + Map toJson() { + final Map data = new Map(); + data['AdmissionNo'] = this.admissionNo; + data['PatientID'] = this.patientID; + data['PatientTypeID'] = this.patientTypeID; + return data; + } +} diff --git a/lib/screens/patients/profile/profile_screen/patient_profile_screen.dart b/lib/screens/patients/profile/profile_screen/patient_profile_screen.dart index eec42b86..dec07ec2 100644 --- a/lib/screens/patients/profile/profile_screen/patient_profile_screen.dart +++ b/lib/screens/patients/profile/profile_screen/patient_profile_screen.dart @@ -6,6 +6,7 @@ import 'package:doctor_app_flutter/core/service/VideoCallService.dart'; import 'package:doctor_app_flutter/core/viewModel/LiveCarePatientViewModel.dart'; import 'package:doctor_app_flutter/core/viewModel/SOAP_view_model.dart'; import 'package:doctor_app_flutter/models/SOAP/PostEpisodeReqModel.dart'; +import 'package:doctor_app_flutter/models/SOAP/in_patient/PostEpisodeForInpatientRequestModel.dart'; import 'package:doctor_app_flutter/models/patient/patiant_info_model.dart'; import 'package:doctor_app_flutter/screens/base/base_view.dart'; import 'package:doctor_app_flutter/screens/live_care/end_call_screen.dart'; @@ -218,7 +219,7 @@ class _PatientProfileScreenState extends State with Single child: Row( children: [ Expanded(child: Container()), - if (patient.episodeNo == 0) + if (patient.episodeNo == 0 || isInpatient) AppButton( title: "${TranslationBase.of(context).createNew}\n${TranslationBase.of(context).episode}", @@ -241,19 +242,7 @@ class _PatientProfileScreenState extends State with Single onPressed: () async { if ((isFromLiveCare && patient.appointmentNo != null) || patient.patientStatusType == 43) { - await locator().logEvent( - eventCategory: "Patient Profile", - eventAction: "Create Episode", - ); - PostEpisodeReqModel postEpisodeReqModel = PostEpisodeReqModel( - appointmentNo: int.parse(patient.appointmentNo.toString()), - patientMRN: patient.patientMRN); - GifLoaderDialogUtils.showMyDialog(context); - await model.postEpisode(postEpisodeReqModel); - GifLoaderDialogUtils.hideDialog(context); - patient.episodeNo = model.episodeID; - Navigator.of(context) - .pushNamed(CREATE_EPISODE, arguments: {'patient': patient}); + createEpisode(patient:patient, model:model); } }, ), @@ -387,6 +376,39 @@ class _PatientProfileScreenState extends State with Single ), ); } + + createEpisode({PatiantInformtion patient, SOAPViewModel model}) async{ + await locator().logEvent( + eventCategory: "Patient Profile", + eventAction: "Create Episode", + ); + GifLoaderDialogUtils.showMyDialog(context); + if (patient.admissionNo == null ||patient.admissionNo.isNotEmpty ) { + PostEpisodeForInpatientRequestModel postEpisodeReqModel = PostEpisodeForInpatientRequestModel( + admissionNo: int.parse(patient.admissionNo), + patientID: patient.patientId + + + ); + await model.postEpisodeForInPatient(postEpisodeReqModel); + }else{ + PostEpisodeReqModel postEpisodeReqModel = PostEpisodeReqModel( + appointmentNo: int.parse(patient.appointmentNo.toString()), + patientMRN: patient.patientMRN); + + await model.postEpisode(postEpisodeReqModel); + } + + GifLoaderDialogUtils.hideDialog(context); + if(model.state == ViewState.ErrorLocal) { + Helpers.showErrorToast(model.error); + }else{ + patient.episodeNo = model.episodeID; + Navigator.of(context) + .pushNamed(CREATE_EPISODE, arguments: {'patient': patient}); + } + + } } class AvatarWidget extends StatelessWidget {