From d251ca0e1c3a8a0997cc9c6caeac7cd19b2c23cc Mon Sep 17 00:00:00 2001 From: haroon amjad Date: Mon, 14 Aug 2023 13:33:23 +0300 Subject: [PATCH] Inpatient medical instructions implemented --- lib/config/config.dart | 6 +- ...t_medical_instructions_response_model.dart | 85 +++++++++++++++ .../InPatientServices/inpatient_home.dart | 21 +++- .../medical_instructions.dart | 100 ++++++++++++++++++ lib/pages/login/confirm-login.dart | 23 ++-- lib/pages/login/login.dart | 12 ++- .../clinic_services/get_clinic_service.dart | 14 +++ 7 files changed, 245 insertions(+), 16 deletions(-) create mode 100644 lib/models/InPatientServices/get_medical_instructions_response_model.dart create mode 100644 lib/pages/InPatientServices/medical_instructions.dart diff --git a/lib/config/config.dart b/lib/config/config.dart index 5b08cb1d..59773264 100644 --- a/lib/config/config.dart +++ b/lib/config/config.dart @@ -20,10 +20,10 @@ var PACKAGES_ORDERS = '/api/orders'; var PACKAGES_ORDER_HISTORY = '/api/orders/items'; var PACKAGES_TAMARA_OPT = '/api/orders/paymentoptions/tamara'; // var BASE_URL = 'http://10.50.100.198:2018/'; - // var BASE_URL = 'https://uat.hmgwebservices.com/'; + var BASE_URL = 'https://uat.hmgwebservices.com/'; // var BASE_URL = 'https://hmgwebservices.com/'; // var BASE_URL = 'https://orash.cloudsolutions.com.sa/'; -var BASE_URL = 'https://vidauat.cloudsolutions.com.sa/'; +// var BASE_URL = 'https://vidauat.cloudsolutions.com.sa/'; // Pharmacy UAT URLs // var BASE_PHARMACY_URL = 'https://uat.hmgwebservices.com/epharmacy/api/'; @@ -611,6 +611,8 @@ var CHECK_IF_PATIENT_ADMITTED = 'Services/Inps.svc/REST/chekIsPatientAdmitted'; // Get General Instructions API var GET_GENERAL_INSTRUCTIONS = 'Services/INPs.svc/REST/getGeneralInstructions'; +// Get General Instructions API +var GET_MEDICAL_INSTRUCTIONS = 'Services/INPs.svc/REST/getPatientAdmissionRequest'; var INSERT_INPATIENT_ORDER = 'Services/INPs.svc/REST/Inpcp_insertOrder'; diff --git a/lib/models/InPatientServices/get_medical_instructions_response_model.dart b/lib/models/InPatientServices/get_medical_instructions_response_model.dart new file mode 100644 index 00000000..2bbe1e83 --- /dev/null +++ b/lib/models/InPatientServices/get_medical_instructions_response_model.dart @@ -0,0 +1,85 @@ +class GetMedicalInstructions { + dynamic propertyChanged; + int admissionRequestNoField; + String clinicNameField; + String doctorNameField; + String expectedAdmissionDateField; + List medicaLInstructionsField; + dynamic medicalInstructionsXMLField; + String medicalRemarksField; + int projectIdField; + String projectNameField; + String setupIdField; + + GetMedicalInstructions( + {this.propertyChanged, + this.admissionRequestNoField, + this.clinicNameField, + this.doctorNameField, + this.expectedAdmissionDateField, + this.medicaLInstructionsField, + this.medicalInstructionsXMLField, + this.medicalRemarksField, + this.projectIdField, + this.projectNameField, + this.setupIdField}); + + GetMedicalInstructions.fromJson(Map json) { + propertyChanged = json['PropertyChanged']; + admissionRequestNoField = json['admissionRequestNoField']; + clinicNameField = json['clinicNameField']; + doctorNameField = json['doctorNameField']; + expectedAdmissionDateField = json['expectedAdmissionDateField']; + if (json['medicaLInstructionsField'] != null) { + medicaLInstructionsField = []; + json['medicaLInstructionsField'].forEach((v) { + medicaLInstructionsField.add(new MedicaLInstructionsField.fromJson(v)); + }); + } + medicalInstructionsXMLField = json['medicalInstructionsXMLField']; + medicalRemarksField = json['medicalRemarksField']; + projectIdField = json['projectIdField']; + projectNameField = json['projectNameField']; + setupIdField = json['setupIdField']; + } + + Map toJson() { + final Map data = new Map(); + data['PropertyChanged'] = this.propertyChanged; + data['admissionRequestNoField'] = this.admissionRequestNoField; + data['clinicNameField'] = this.clinicNameField; + data['doctorNameField'] = this.doctorNameField; + data['expectedAdmissionDateField'] = this.expectedAdmissionDateField; + if (this.medicaLInstructionsField != null) { + data['medicaLInstructionsField'] = this.medicaLInstructionsField.map((v) => v.toJson()).toList(); + } + data['medicalInstructionsXMLField'] = this.medicalInstructionsXMLField; + data['medicalRemarksField'] = this.medicalRemarksField; + data['projectIdField'] = this.projectIdField; + data['projectNameField'] = this.projectNameField; + data['setupIdField'] = this.setupIdField; + return data; + } +} + +class MedicaLInstructionsField { + Null propertyChanged; + String descriptionField; + int parameterCodeField; + + MedicaLInstructionsField({this.propertyChanged, this.descriptionField, this.parameterCodeField}); + + MedicaLInstructionsField.fromJson(Map json) { + propertyChanged = json['PropertyChanged']; + descriptionField = json['descriptionField']; + parameterCodeField = json['parameterCodeField']; + } + + Map toJson() { + final Map data = new Map(); + data['PropertyChanged'] = this.propertyChanged; + data['descriptionField'] = this.descriptionField; + data['parameterCodeField'] = this.parameterCodeField; + return data; + } +} diff --git a/lib/pages/InPatientServices/inpatient_home.dart b/lib/pages/InPatientServices/inpatient_home.dart index 19ae5b3d..013bd2d0 100644 --- a/lib/pages/InPatientServices/inpatient_home.dart +++ b/lib/pages/InPatientServices/inpatient_home.dart @@ -5,6 +5,7 @@ import 'package:diplomaticquarterapp/pages/InPatientServices/general_instruction import 'package:diplomaticquarterapp/pages/InPatientServices/help_PRO.dart'; import 'package:diplomaticquarterapp/pages/InPatientServices/inpatient_advance_payment.dart'; import 'package:diplomaticquarterapp/pages/InPatientServices/meal_plan.dart'; +import 'package:diplomaticquarterapp/pages/InPatientServices/medical_instructions.dart'; import 'package:diplomaticquarterapp/services/clinic_services/get_clinic_service.dart'; import 'package:diplomaticquarterapp/uitl/gif_loader_dialog_utils.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; @@ -15,6 +16,8 @@ import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; +import '../../models/InPatientServices/get_medical_instructions_response_model.dart'; + class InPatientServicesHome extends StatelessWidget { ProjectViewModel projectViewModel; @@ -90,7 +93,7 @@ class InPatientServicesHome extends StatelessWidget { serviceList.add( InkWell( onTap: () { - // Navigator.push(context, FadePage(page: AdvancePaymentPage())); + openMedicalInstructions(context); }, child: MedicalProfileItem( title: TranslationBase.of(context).medicalInstructionsTitle, @@ -257,4 +260,20 @@ class InPatientServicesHome extends StatelessWidget { print(err); }); } + + void openMedicalInstructions(BuildContext context) { + ClinicListService service = new ClinicListService(); + GifLoaderDialogUtils.showMyDialog(context); + service.getMedicalInstructions(projectViewModel.inPatientProjectID, context).then((res) { + List getMedicalInstructionsList = []; + res['MedicalInstruction'].forEach((v) { + getMedicalInstructionsList.add(new GetMedicalInstructions.fromJson(v)); + }); + GifLoaderDialogUtils.hideDialog(context); + print(res['MedicalInstruction']); + Navigator.push(context, FadePage(page: MedicalInstructionsPage(getMedicalInstructionsList: getMedicalInstructionsList))); + }).catchError((err) { + print(err); + }); + } } diff --git a/lib/pages/InPatientServices/medical_instructions.dart b/lib/pages/InPatientServices/medical_instructions.dart new file mode 100644 index 00000000..b5062b9b --- /dev/null +++ b/lib/pages/InPatientServices/medical_instructions.dart @@ -0,0 +1,100 @@ +import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; +import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; +import 'package:diplomaticquarterapp/uitl/utils_new.dart'; +import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_svg/flutter_svg.dart'; +import 'package:provider/provider.dart'; + +import '../../models/InPatientServices/get_medical_instructions_response_model.dart'; + +class MedicalInstructionsPage extends StatefulWidget { + List getMedicalInstructionsList; + + MedicalInstructionsPage({@required this.getMedicalInstructionsList}); + + @override + State createState() => _MedicalInstructionsPageState(); +} + +class _MedicalInstructionsPageState extends State { + ProjectViewModel projectViewModel; + + @override + Widget build(BuildContext context) { + projectViewModel = Provider.of(context); + return AppScaffold( + isShowAppBar: true, + isShowDecPage: false, + showNewAppBarTitle: true, + showNewAppBar: true, + appBarTitle: TranslationBase.of(context).InPatientServicesHeader, + body: Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisSize: MainAxisSize.min, + children: [ + Padding( + padding: const EdgeInsets.all(21.0), + child: Text("Medical Instructions", + overflow: TextOverflow.clip, + style: TextStyle( + fontSize: 21.0, + fontWeight: FontWeight.w600, + color: Color(0xff2B353E), + letterSpacing: -0.64, + )), + ), + Expanded( + child: Container( + width: MediaQuery.of(context).size.width, + child: Card( + elevation: 0.0, + margin: EdgeInsets.all(16), + color: Colors.white, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(10), + side: BorderSide(color: Colors.transparent, width: 0.0), + ), + child: Padding( + padding: EdgeInsets.all(16.0), + child: Container( + child: ListView.separated( + itemCount: widget.getMedicalInstructionsList[0].medicaLInstructionsField.length, + itemBuilder: (BuildContext context, int index) { + return Container( + child: Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Container( + child: SvgPicture.asset("assets/images/new-design/ionic-ios-checkmark-circle.svg"), + ), + Container( + width: MediaQuery.of(context).size.width * 0.75, + margin: EdgeInsets.only(left: 5.0, right: 5.0), + child: Text(widget.getMedicalInstructionsList[0].medicaLInstructionsField[index].descriptionField, + overflow: TextOverflow.clip, + style: TextStyle( + fontSize: 14.0, + fontWeight: FontWeight.w600, + color: Color(0xff2B353E), + letterSpacing: -0.64, + )), + ), + ], + )); + }, + separatorBuilder: (BuildContext context, int index) { + return Padding( + padding: const EdgeInsets.only(left: 14, right: 14), + child: mHeight(16.0), + ); + }, + )), + ), + ), + ), + ) + ], + )); + } +} diff --git a/lib/pages/login/confirm-login.dart b/lib/pages/login/confirm-login.dart index baf5a5a5..1e80ec3e 100644 --- a/lib/pages/login/confirm-login.dart +++ b/lib/pages/login/confirm-login.dart @@ -43,8 +43,9 @@ import 'package:provider/provider.dart'; class ConfirmLogin extends StatefulWidget { final Function changePageViewIndex; final fromRegistration; - final bool isDubai; - const ConfirmLogin({Key key, this.changePageViewIndex, this.fromRegistration = false, this.isDubai =false}) : super(key: key); + final bool isDubai; + + const ConfirmLogin({Key key, this.changePageViewIndex, this.fromRegistration = false, this.isDubai = false}) : super(key: key); @override _ConfirmLogin createState() => _ConfirmLogin(); @@ -387,9 +388,9 @@ class _ConfirmLogin extends State { request.sMSSignature = await SMSOTP.getSignature(); GifLoaderDialogUtils.showMyDialog(context); if (healthId != null || widget.isDubai) { - if(!widget.isDubai){ - request.dob = dob; //isHijri == 1 ? dob : dateFormat2.format(dateFormat.parse(dob)); - } + if (!widget.isDubai) { + request.dob = dob; //isHijri == 1 ? dob : dateFormat2.format(dateFormat.parse(dob)); + } request.healthId = healthId; request.isHijri = isHijri; await this.authService.sendActivationCodeRegister(request).then((result) { @@ -569,7 +570,7 @@ class _ConfirmLogin extends State { var request = this.getCommonRequest().toJson(); dynamic res; if (healthId != null || widget.isDubai) { - if(!widget.isDubai) { + if (!widget.isDubai) { request['DOB'] = dob; } request['HealthId'] = healthId; @@ -584,7 +585,7 @@ class _ConfirmLogin extends State { result = CheckActivationCode.fromJson(result), if (this.registerd_data != null && this.registerd_data.isRegister == true) { - // if(widget.isDubai ==false){ + // if(widget.isDubai ==false){ widget.changePageViewIndex(1), Navigator.popUntil(context, (route) => Utils.route(route, equalsTo: RegisterNew)), } @@ -679,11 +680,15 @@ class _ConfirmLogin extends State { if (res['MessageStatus'] == 1) { isAdmitted = res['isAdmitted']; print("IS ADMITTED: $isAdmitted"); - if (res['PatientAdmittedInformation'].length != 0) { + if (res['isAdmitted'] == true) { print("INPATIENT!!!"); getAdmissionInfoResponseModel = GetAdmissionInfoResponseModel.fromJson(res['PatientAdmittedInformation'][0]); projectViewModel.setIsPatientAdmitted(true); - projectViewModel.setInPatientProjectID(res['PatientAdmittedInformation'][0]['ProjectID']); + if (res['PatientAdmittedInformation'].length != 0) { + projectViewModel.setInPatientProjectID(res['PatientAdmittedInformation'][0]['ProjectID']); + } else { + projectViewModel.setInPatientProjectID(15); + } projectViewModel.setInPatientAdmissionInfo(getAdmissionInfoResponseModel); } else { print("OUTPATIENT!!!"); diff --git a/lib/pages/login/login.dart b/lib/pages/login/login.dart index 856a5bc3..ab715836 100644 --- a/lib/pages/login/login.dart +++ b/lib/pages/login/login.dart @@ -401,12 +401,16 @@ class _Login extends State { if (res['MessageStatus'] == 1) { isAdmitted = res['isAdmitted']; print("IS ADMITTED: $isAdmitted"); - if (res['PatientAdmittedInformation'].length != 0) { + if (res['isAdmitted'] == true) { print("INPATIENT!!!"); - getAdmissionInfoResponseModel = GetAdmissionInfoResponseModel.fromJson(res['PatientAdmittedInformation'][0]); projectViewModel.setIsPatientAdmitted(true); - projectViewModel.setInPatientProjectID(res['PatientAdmittedInformation'][0]['ProjectID']); - projectViewModel.setInPatientAdmissionInfo(getAdmissionInfoResponseModel); + if (res['PatientAdmittedInformation'].length != 0) { + getAdmissionInfoResponseModel = GetAdmissionInfoResponseModel.fromJson(res['PatientAdmittedInformation'][0]); + projectViewModel.setInPatientProjectID(res['PatientAdmittedInformation'][0]['ProjectID']); + projectViewModel.setInPatientAdmissionInfo(getAdmissionInfoResponseModel); + } else { + projectViewModel.setInPatientProjectID(15); + } } else { print("OUTPATIENT!!!"); projectViewModel.setIsPatientAdmitted(false); diff --git a/lib/services/clinic_services/get_clinic_service.dart b/lib/services/clinic_services/get_clinic_service.dart index 6bea9aa4..73103aea 100644 --- a/lib/services/clinic_services/get_clinic_service.dart +++ b/lib/services/clinic_services/get_clinic_service.dart @@ -93,6 +93,20 @@ class ClinicListService extends BaseService { return Future.value(localRes); } + Future getMedicalInstructions(int projectID, context) async { + Map request; + request = {"ProjectID": projectID}; + + dynamic localRes; + + await baseAppClient.post(GET_MEDICAL_INSTRUCTIONS, onSuccess: (response, statusCode) async { + localRes = response; + }, onFailure: (String error, int statusCode) { + throw error; + }, body: request, isAllowAny: true); + return Future.value(localRes); + } + Future getProjectsList(context) async { Map request; var languageID = await sharedPref.getStringWithDefaultValue(APP_LANGUAGE, 'ar');