From 562fd1b515f652d85b3e0ece5d678a48b589cef5 Mon Sep 17 00:00:00 2001 From: hussam al-habibeh Date: Wed, 11 Aug 2021 08:46:23 +0300 Subject: [PATCH] chef complint for in patient --- lib/config/config.dart | 4 +- .../GetChiefComplaintReqModel.dart | 16 +- .../post_chief_complaint_request_model.dart | 15 +- lib/models/patient/patiant_info_model.dart | 217 +++++------ .../subjective/update_subjective_page.dart | 355 ++++++++---------- 5 files changed, 280 insertions(+), 327 deletions(-) diff --git a/lib/config/config.dart b/lib/config/config.dart index 26c0445b..4e96c39c 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"; diff --git a/lib/models/SOAP/ChiefComplaint/GetChiefComplaintReqModel.dart b/lib/models/SOAP/ChiefComplaint/GetChiefComplaintReqModel.dart index 8e253151..45e0dae6 100644 --- a/lib/models/SOAP/ChiefComplaint/GetChiefComplaintReqModel.dart +++ b/lib/models/SOAP/ChiefComplaint/GetChiefComplaintReqModel.dart @@ -21,10 +21,18 @@ class GetChiefComplaintReqModel { Map toJson() { final Map data = new Map(); data['PatientMRN'] = this.patientMRN; - data['AppointmentNo'] = this.appointmentNo; - data['EpisodeId'] = this.episodeId; - data['EpisodeID'] = this.episodeID; - data['DoctorID'] = this.doctorID; + if (this.appointmentNo != null) { + data['AppointmentNo'] = this.appointmentNo; + } + if (this.episodeId != null) { + data['EpisodeId'] = this.episodeId; + } + if (episodeID != null) { + data['EpisodeID'] = this.episodeID; + } + if (doctorID != null) { + data['DoctorID'] = this.doctorID; + } if (this.admissionNo != null) { data['AdmissionNo'] = this.admissionNo; } diff --git a/lib/models/SOAP/post_chief_complaint_request_model.dart b/lib/models/SOAP/post_chief_complaint_request_model.dart index 5f5fe721..682342df 100644 --- a/lib/models/SOAP/post_chief_complaint_request_model.dart +++ b/lib/models/SOAP/post_chief_complaint_request_model.dart @@ -43,8 +43,13 @@ class PostChiefComplaintRequestModel { Map toJson() { final Map data = new Map(); - data['AppointmentNo'] = this.appointmentNo; - data['EpisodeID'] = this.episodeID; + if (appointmentNo != null) { + data['AppointmentNo'] = this.appointmentNo; + } + + if (episodeID != null) { + data['EpisodeID'] = this.episodeID; + } data['PatientMRN'] = this.patientMRN; data['chiefComplaint'] = this.chiefComplaint; data['Hopi'] = this.hopi; @@ -53,8 +58,10 @@ class PostChiefComplaintRequestModel { data['isLactation'] = this.isLactation; data['numberOfWeeks'] = this.numberOfWeeks; data['DoctorID'] = this.doctorID; - data['EditedBy'] = this.editedBy; - if (this.admissionNo != null) { + if (editedBy != null) { + data['EditedBy'] = this.editedBy; + } + if (admissionNo != null) { data['AdmissionNo'] = this.admissionNo; } diff --git a/lib/models/patient/patiant_info_model.dart b/lib/models/patient/patiant_info_model.dart index 83a70b01..df966f03 100644 --- a/lib/models/patient/patiant_info_model.dart +++ b/lib/models/patient/patiant_info_model.dart @@ -79,95 +79,93 @@ class PatiantInformtion { int vcId; String voipToken; - PatiantInformtion({this.patientDetails, - this.projectId, - this.clinicId, - this.doctorId, - this.patientId, - this.doctorName, - this.doctorNameN, - this.firstName, - this.middleName, - this.lastName, - this.firstNameN, - this.middleNameN, - this.lastNameN, - this.gender, - this.dateofBirth, - this.nationalityId, - this.mobileNumber, - this.emailAddress, - this.patientIdentificationNo, - this.patientType, - this.admissionNo, - this.admissionDate, - this.createdOn, - this.roomId, - this.bedId, - this.nursingStationId, - this.description, - this.clinicDescription, - this.clinicDescriptionN, - this.nationalityName, - this.nationalityNameN, - this.age, - this.genderDescription, - this.nursingStationName, - this.appointmentDate, - this.startTime, - this.appointmentNo, - this.arrivalTime, - this.arrivalTimeD, - this.callStatus, - this.callStatusDisc, - this.callTypeID, - this.clientRequestID, - this.clinicName, - this.consoltationEnd, - this.consultationNotes, - this.appointmentType, - this.appointmentTypeId, - this.arrivedOn, - this.clinicGroupId, - this.companyName, - this.dischargeStatus, - this.doctorDetails, - this.endTime, - this.episodeNo, - this.fallRiskScore, - this.genderInt, - this.isSigned, - this.medicationOrders, - this.nationality, - this.patientMRN, - this.visitType, - this.fullName, - this.fullNameN, - this.nationalityFlagURL, - this.patientStatusType, - this.patientStatus, - this.visitTypeId, - this.startTimes, - this.dischargeDate, - this.status, - this.vcId, - this.voipToken, - this.admissionDateWithDateTimeForm, + PatiantInformtion( + {this.patientDetails, + this.projectId, + this.clinicId, + this.doctorId, + this.patientId, + this.doctorName, + this.doctorNameN, + this.firstName, + this.middleName, + this.lastName, + this.firstNameN, + this.middleNameN, + this.lastNameN, + this.gender, + this.dateofBirth, + this.nationalityId, + this.mobileNumber, + this.emailAddress, + this.patientIdentificationNo, + this.patientType, + this.admissionNo, + this.admissionDate, + this.createdOn, + this.roomId, + this.bedId, + this.nursingStationId, + this.description, + this.clinicDescription, + this.clinicDescriptionN, + this.nationalityName, + this.nationalityNameN, + this.age, + this.genderDescription, + this.nursingStationName, + this.appointmentDate, + this.startTime, + this.appointmentNo, + this.arrivalTime, + this.arrivalTimeD, + this.callStatus, + this.callStatusDisc, + this.callTypeID, + this.clientRequestID, + this.clinicName, + this.consoltationEnd, + this.consultationNotes, + this.appointmentType, + this.appointmentTypeId, + this.arrivedOn, + this.clinicGroupId, + this.companyName, + this.dischargeStatus, + this.doctorDetails, + this.endTime, + this.episodeNo, + this.fallRiskScore, + this.genderInt, + this.isSigned, + this.medicationOrders, + this.nationality, + this.patientMRN, + this.visitType, + this.fullName, + this.fullNameN, + this.nationalityFlagURL, + this.patientStatusType, + this.patientStatus, + this.visitTypeId, + this.startTimes, + this.dischargeDate, + this.status, + this.vcId, + this.voipToken, + this.admissionDateWithDateTimeForm, this.appointmentDateWithDateTimeForm}); - PatiantInformtion.fromJson(Map json) { { - patientDetails = json['patientDetails'] != null - ? new PatiantInformtion.fromJson(json['patientDetails']) - : null; + patientDetails = json['patientDetails'] != null ? new PatiantInformtion.fromJson(json['patientDetails']) : null; projectId = json["ProjectID"] ?? json["projectID"]; clinicId = json["ClinicID"] ?? json["clinicID"]; doctorId = json["DoctorID"] ?? json["doctorID"]; patientId = json["PatientID"] != null ? json["PatientID"] is String - ? int.parse(json["PatientID"]) - : json["PatientID"] + ? int.parse(json["PatientID"]) + : json["PatientID"] : json["patientID"] ?? json['patientMRN'] ?? json['PatientMRN']; doctorName = json["DoctorName"] ?? json["doctorName"]; doctorNameN = json["DoctorNameN"] ?? json["doctorNameN"]; @@ -179,18 +177,16 @@ class PatiantInformtion { lastNameN = json["LastNameN"] ?? json["lastNameN"]; gender = json["Gender"] != null ? json["Gender"] is String - ? int.parse(json["Gender"]) - : json["Gender"] + ? int.parse(json["Gender"]) + : json["Gender"] : json["gender"]; fullName = json["fullName"] ?? json["fullName"] ?? json["PatientName"]; - fullNameN = - json["fullNameN"] ?? json["fullNameN"] ?? json["PatientName"]; + fullNameN = json["fullNameN"] ?? json["fullNameN"] ?? json["PatientName"]; dateofBirth = json["DateofBirth"] ?? json["dob"] ?? json['DateOfBirth']; nationalityId = json["NationalityID"] ?? json["nationalityID"]; mobileNumber = json["MobileNumber"] ?? json["mobileNumber"]; emailAddress = json["EmailAddress"] ?? json["emailAddress"]; - patientIdentificationNo = - json["PatientIdentificationNo"] ?? json["patientIdentificationNo"]; + patientIdentificationNo = json["PatientIdentificationNo"] ?? json["patientIdentificationNo"]; //TODO make 7 dynamic when the backend retrun it in patient arrival patientType = json["PatientType"] ?? json["patientType"] ?? 1; admissionNo = json["AdmissionNo"] ?? json["admissionNo"]; @@ -200,16 +196,10 @@ class PatiantInformtion { bedId = json["BedID"] ?? json["bedID"]; nursingStationId = json["NursingStationID"] ?? json["nursingStationID"]; description = json["Description"] ?? json["description"]; - clinicDescription = - json["ClinicDescription"] ?? json["clinicDescription"]; - clinicDescriptionN = - json["ClinicDescriptionN"] ?? json["clinicDescriptionN"]; - nationalityName = json["NationalityName"] ?? - json["nationalityName"] ?? - json['NationalityName']; - nationalityNameN = json["NationalityNameN"] ?? - json["nationalityNameN"] ?? - json['NationalityNameN']; + clinicDescription = json["ClinicDescription"] ?? json["clinicDescription"]; + clinicDescriptionN = json["ClinicDescriptionN"] ?? json["clinicDescriptionN"]; + nationalityName = json["NationalityName"] ?? json["nationalityName"] ?? json['NationalityName']; + nationalityNameN = json["NationalityNameN"] ?? json["nationalityNameN"] ?? json['NationalityNameN']; age = json["Age"] ?? json["age"]; genderDescription = json["GenderDescription"]; nursingStationName = json["NursingStationName"]; @@ -217,8 +207,7 @@ class PatiantInformtion { startTime = json["startTime"] ?? json['StartTime']; appointmentNo = json['appointmentNo'] ?? json['AppointmentNo']; appointmentType = json['appointmentType']; - appointmentTypeId = - json['appointmentTypeId'] ?? json['appointmentTypeid']; + appointmentTypeId = json['appointmentTypeId'] ?? json['appointmentTypeid']; arrivedOn = json['ArrivedOn'] ?? json['arrivedOn'] ?? json['ArrivedOn']; clinicGroupId = json['clinicGroupId']; companyName = json['companyName']; @@ -234,16 +223,15 @@ class PatiantInformtion { json['PatientMRN'] ?? (json["PatientID"] != null ? int?.parse(json["PatientID"].toString()) - : json["patientID"] != null ? int?.parse( - json["patientID"].toString()) : json["patientId"] != null ? int - ?.parse(json["patientId"].toString()) : ''); + : json["patientID"] != null + ? int?.parse(json["patientID"].toString()) + : json["patientId"] != null + ? int?.parse(json["patientId"].toString()) + : ''); visitType = json['visitType'] ?? json['visitType'] ?? json['visitType']; - nationalityFlagURL = - json['NationalityFlagURL'] ?? json['NationalityFlagURL']; - patientStatusType = - json['patientStatusType'] ?? json['PatientStatusType']; - visitTypeId = - json['visitTypeId'] ?? json['visitTypeId'] ?? json['visitTypeid']; + nationalityFlagURL = json['NationalityFlagURL'] ?? json['NationalityFlagURL']; + patientStatusType = json['patientStatusType'] ?? json['PatientStatusType']; + visitTypeId = json['visitTypeId'] ?? json['visitTypeId'] ?? json['visitTypeid']; startTimes = json['StartTime'] ?? json['StartTime']; dischargeDate = json['DischargeDate']; status = json['Status']; @@ -262,16 +250,15 @@ class PatiantInformtion { voipToken = json['VoipToken']; admissionDateWithDateTimeForm = json["AdmissionDate"] != null ? AppDateUtils.convertStringToDate(json["AdmissionDate"]) - : json["admissionDate"] != null ? AppDateUtils.convertStringToDate( - json["admissionDate"]) : null; + : json["admissionDate"] != null + ? AppDateUtils.convertStringToDate(json["admissionDate"]) + : null; appointmentDateWithDateTimeForm = - json["AppointmentDate"] != null ? AppDateUtils.convertStringToDate( - json["AppointmentDate"]) : null; + json["AppointmentDate"] != null ? AppDateUtils.convertStringToDate(json["AppointmentDate"]) : null; } } - Map toJson() { final Map data = new Map(); @@ -315,9 +302,9 @@ class PatiantInformtion { data["Gender"] = this.gender; data["gender"] = this.gender; - data['Age'] = this.age; - data['AppointmentDate'] = this.appointmentDate.isNotEmpty?this.appointmentDate:null; + data['AppointmentDate'] = this.appointmentDate.isNotEmpty ? this.appointmentDate : null; + data['AppointmentNo'] = this.appointmentNo; data['ArrivalTime'] = this.arrivalTime; data['ArrivalTimeD'] = this.arrivalTimeD; @@ -343,4 +330,4 @@ class PatiantInformtion { data['DateOfBirth'] = this.dateofBirth; return data; } -} \ No newline at end of file +} diff --git a/lib/screens/patients/profile/soap_update/subjective/update_subjective_page.dart b/lib/screens/patients/profile/soap_update/subjective/update_subjective_page.dart index 269f20a5..1a1dd2f8 100644 --- a/lib/screens/patients/profile/soap_update/subjective/update_subjective_page.dart +++ b/lib/screens/patients/profile/soap_update/subjective/update_subjective_page.dart @@ -37,18 +37,13 @@ class UpdateSubjectivePage extends StatefulWidget { final int currentIndex; UpdateSubjectivePage( - {Key key, - this.changePageViewIndex, - this.patientInfo, - this.changeLoadingState, - this.currentIndex}); + {Key key, this.changePageViewIndex, this.patientInfo, this.changeLoadingState, this.currentIndex}); @override _UpdateSubjectivePageState createState() => _UpdateSubjectivePageState(); } -class _UpdateSubjectivePageState extends State - implements SubjectiveCallBack { +class _UpdateSubjectivePageState extends State implements SubjectiveCallBack { bool isChiefExpand = false; bool isHistoryExpand = false; bool isAllergiesExpand = false; @@ -88,63 +83,47 @@ class _UpdateSubjectivePageState extends State } model.patientHistoryList.forEach((element) { - if (element.historyType == - MasterKeysService.HistoryFamily.getMasterKeyService()) { + if (element.historyType == MasterKeysService.HistoryFamily.getMasterKeyService()) { MasterKeyModel history = model.getOneMasterKey( masterKeys: MasterKeysService.HistoryFamily, id: element.historyId, ); if (history != null) { MySelectedHistory mySelectedHistory = SoapUtils.generateMySelectedHistory( - history: history, - isChecked: element.isChecked, - remark: element.remarks, - isLocal: false); + history: history, isChecked: element.isChecked, remark: element.remarks, isLocal: false); myHistoryList.add(mySelectedHistory); } } - if (element.historyType == - MasterKeysService.HistoryMedical.getMasterKeyService()) { + if (element.historyType == MasterKeysService.HistoryMedical.getMasterKeyService()) { MasterKeyModel history = model.getOneMasterKey( masterKeys: MasterKeysService.HistoryMedical, id: element.historyId, ); if (history != null) { MySelectedHistory mySelectedHistory = SoapUtils.generateMySelectedHistory( - history: history, - isChecked: element.isChecked, - remark: element.remarks, - isLocal: false); + history: history, isChecked: element.isChecked, remark: element.remarks, isLocal: false); myHistoryList.add(mySelectedHistory); } } - if (element.historyType == - MasterKeysService.HistorySports.getMasterKeyService()) { + if (element.historyType == MasterKeysService.HistorySports.getMasterKeyService()) { MasterKeyModel history = model.getOneMasterKey( masterKeys: MasterKeysService.HistorySports, id: element.historyId, ); if (history != null) { MySelectedHistory mySelectedHistory = SoapUtils.generateMySelectedHistory( - history: history, - isChecked: element.isChecked, - remark: element.remarks, - isLocal: false); + history: history, isChecked: element.isChecked, remark: element.remarks, isLocal: false); myHistoryList.add(mySelectedHistory); } } - if (element.historyType == - MasterKeysService.HistorySurgical.getMasterKeyService()) { + if (element.historyType == MasterKeysService.HistorySurgical.getMasterKeyService()) { MasterKeyModel history = model.getOneMasterKey( masterKeys: MasterKeysService.HistorySurgical, id: element.historyId, ); if (history != null) { MySelectedHistory mySelectedHistory = SoapUtils.generateMySelectedHistory( - history: history, - isChecked: element.isChecked, - remark: element.remarks, - isLocal: false); + history: history, isChecked: element.isChecked, remark: element.remarks, isLocal: false); myHistoryList.add(mySelectedHistory); } } @@ -161,23 +140,16 @@ class _UpdateSubjectivePageState extends State editedBy: ''); await model.getPatientAllergy(generalGetReqForSOAP); if (model.patientAllergiesList.isNotEmpty) { - if (model.allergiesList.isEmpty) - await model.getMasterLookup(MasterKeysService.Allergies); - if (model.allergySeverityList.isEmpty) - await model.getMasterLookup(MasterKeysService.AllergySeverity); + if (model.allergiesList.isEmpty) await model.getMasterLookup(MasterKeysService.Allergies); + if (model.allergySeverityList.isEmpty) await model.getMasterLookup(MasterKeysService.AllergySeverity); model.patientAllergiesList.forEach((element) { MasterKeyModel selectedAllergy = model.getOneMasterKey( - masterKeys: MasterKeysService.Allergies, - id: element.allergyDiseaseId, - typeId: element.allergyDiseaseType); + masterKeys: MasterKeysService.Allergies, id: element.allergyDiseaseId, typeId: element.allergyDiseaseType); MasterKeyModel selectedAllergySeverity; if (element.severity == 0) { selectedAllergySeverity = MasterKeyModel( - id: 0, - typeId: MasterKeysService.AllergySeverity.getMasterKeyService(), - nameAr: '', - nameEn: ''); + id: 0, typeId: MasterKeysService.AllergySeverity.getMasterKeyService(), nameAr: '', nameEn: ''); } else { selectedAllergySeverity = model.getOneMasterKey( masterKeys: MasterKeysService.AllergySeverity, @@ -185,17 +157,15 @@ class _UpdateSubjectivePageState extends State ); } - MySelectedAllergy mySelectedAllergy = - SoapUtils.generateMySelectedAllergy( - allergy: selectedAllergy, - isChecked: element.isChecked, - createdBy: element.createdBy, - remark: element.remarks, - isLocal: false, - allergySeverity: selectedAllergySeverity); - - if (selectedAllergy != null && selectedAllergySeverity != null) - myAllergiesList.add(mySelectedAllergy); + MySelectedAllergy mySelectedAllergy = SoapUtils.generateMySelectedAllergy( + allergy: selectedAllergy, + isChecked: element.isChecked, + createdBy: element.createdBy, + remark: element.remarks, + isLocal: false, + allergySeverity: selectedAllergySeverity); + + if (selectedAllergy != null && selectedAllergySeverity != null) myAllergiesList.add(mySelectedAllergy); }); } } @@ -207,29 +177,29 @@ class _UpdateSubjectivePageState extends State myAllergiesList.clear(); myHistoryList.clear(); model.setSubjectiveCallBack(this); - GetChiefComplaintReqModel getChiefComplaintReqModel = - GetChiefComplaintReqModel( - admissionNo: int.parse(widget.patientInfo.admissionNo),patientMRN: widget.patientInfo.patientMRN, - appointmentNo: - int.parse(widget.patientInfo.appointmentNo.toString()), - episodeId: widget.patientInfo.episodeNo, - episodeID: widget.patientInfo.episodeNo, - doctorID: ''); + GetChiefComplaintReqModel getChiefComplaintReqModel = GetChiefComplaintReqModel( + admissionNo: widget.patientInfo.admissionNo != null ? int.parse(widget.patientInfo.admissionNo) : null, + patientMRN: widget.patientInfo.patientMRN, + appointmentNo: widget.patientInfo.appointmentNo != null + ? int.parse(widget.patientInfo.appointmentNo.toString()) + : null, + episodeId: widget.patientInfo.episodeNo, + episodeID: widget.patientInfo.episodeNo, + doctorID: ''); await model.getPatientChiefComplaint(getChiefComplaintReqModel); if (model.patientChiefComplaintList.isNotEmpty) { isChiefExpand = true; - complaintsController.text = Helpers.parseHtmlString( - model.patientChiefComplaintList[0].chiefComplaint); + complaintsController.text = Helpers.parseHtmlString(model.patientChiefComplaintList[0].chiefComplaint); illnessController.text = model.patientChiefComplaintList[0].hopi; - medicationController.text = - !(model.patientChiefComplaintList[0].currentMedication).isNotEmpty - ? model.patientChiefComplaintList[0].currentMedication + - '\n \n' - : model.patientChiefComplaintList[0].currentMedication; + medicationController.text = !(model.patientChiefComplaintList[0].currentMedication).isNotEmpty + ? model.patientChiefComplaintList[0].currentMedication + '\n \n' + : model.patientChiefComplaintList[0].currentMedication; } + if (widget.patientInfo.admissionNo == null) { + await getHistory(model); - await getHistory(model); - await getAllergies(model); + await getAllergies(model); + } widget.changeLoadingState(false); }, @@ -245,9 +215,7 @@ class _UpdateSubjectivePageState extends State mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start, children: [ - SOAPStepHeader( - currentIndex: widget.currentIndex, - changePageViewIndex: widget.changePageViewIndex), + SOAPStepHeader(currentIndex: widget.currentIndex, changePageViewIndex: widget.changePageViewIndex), ExpandableSOAPWidget( headerTitle: TranslationBase.of(context).chiefComplaints, onTap: () { @@ -267,51 +235,48 @@ class _UpdateSubjectivePageState extends State isExpanded: isChiefExpand, ), SizedBox( - height: SizeConfig.heightMultiplier * - (SizeConfig.isHeightVeryShort ? 4 : 2), + height: SizeConfig.heightMultiplier * (SizeConfig.isHeightVeryShort ? 4 : 2), ), - ExpandableSOAPWidget( - headerTitle: TranslationBase.of(context).histories, - isRequired: false, - onTap: () { - setState(() { - isHistoryExpand = !isHistoryExpand; - }); - }, - child: Column( - children: [ - UpdateHistoryWidget(myHistoryList: myHistoryList) - ], + if (widget.patientInfo.admissionNo == null) + ExpandableSOAPWidget( + headerTitle: TranslationBase.of(context).histories, + isRequired: false, + onTap: () { + setState(() { + isHistoryExpand = !isHistoryExpand; + }); + }, + child: Column( + children: [UpdateHistoryWidget(myHistoryList: myHistoryList)], + ), + isExpanded: isHistoryExpand, ), - isExpanded: isHistoryExpand, - ), SizedBox( - height: SizeConfig.heightMultiplier * - (SizeConfig.isHeightVeryShort ? 4 : 2), + height: SizeConfig.heightMultiplier * (SizeConfig.isHeightVeryShort ? 4 : 2), ), - ExpandableSOAPWidget( - headerTitle: TranslationBase.of(context).allergiesSoap, - isRequired: false, - onTap: () { - setState(() { - isAllergiesExpand = !isAllergiesExpand; - }); - }, - child: Column( - children: [ - UpdateAllergiesWidget( - myAllergiesList: myAllergiesList, - ), - SizedBox( - height: 30, - ), - ], + if (widget.patientInfo.admissionNo == null) + ExpandableSOAPWidget( + headerTitle: TranslationBase.of(context).allergiesSoap, + isRequired: false, + onTap: () { + setState(() { + isAllergiesExpand = !isAllergiesExpand; + }); + }, + child: Column( + children: [ + UpdateAllergiesWidget( + myAllergiesList: myAllergiesList, + ), + SizedBox( + height: 30, + ), + ], + ), + isExpanded: isAllergiesExpand, ), - isExpanded: isAllergiesExpand, - ), SizedBox( - height: SizeConfig.heightMultiplier * - (SizeConfig.isHeightVeryShort ? 20 : 10), + height: SizeConfig.heightMultiplier * (SizeConfig.isHeightVeryShort ? 20 : 10), ), ], ), @@ -323,9 +288,7 @@ class _UpdateSubjectivePageState extends State } addSubjectiveInfo( - {SOAPViewModel model, - List myAllergiesList, - List myHistoryList}) async { + {SOAPViewModel model, List myAllergiesList, List myHistoryList}) async { if (FocusScope.of(context).hasFocus) FocusScope.of(context).unfocus(); widget.changeLoadingState(true); formKey.currentState.save(); @@ -338,79 +301,73 @@ class _UpdateSubjectivePageState extends State ///TODO Elham* /// widget.changePageViewIndex(1); - // if (complaintsController.text.isNotEmpty && - // illnessController.text.isNotEmpty && - // complaintsController.text.length > 25) { - // await postChiefComplaint(model: model); - // if (model.state == ViewState.ErrorLocal) { - // Helpers.showErrorToast(model.error); - // } - // if (myHistoryList.length != 0) { - // await postHistories(model: model, myHistoryList: myHistoryList); - // if (model.state == ViewState.ErrorLocal) { - // Helpers.showErrorToast(model.error); - // } - // } - // if (myAllergiesList.length != 0) { - // await postAllergy(myAllergiesList: myAllergiesList, model: model); - // if (model.state == ViewState.ErrorLocal) { - // Helpers.showErrorToast(model.error); - // } - // } - // widget.changeLoadingState(true); - // - // widget.changePageViewIndex(1); - // } else { - // setState(() { - // if (complaintsController.text.isEmpty) { - // complaintsControllerError = TranslationBase.of(context).emptyMessage; - // } else if (complaintsController.text.length < 25) { - // complaintsControllerError = - // TranslationBase.of(context).chiefComplaintLength; - // } - // - // if (illnessController.text.isEmpty) { - // illnessControllerError = TranslationBase.of(context).emptyMessage; - // } - // - // if (medicationController.text.isEmpty) { - // medicationControllerError = TranslationBase.of(context).emptyMessage; - // } - // }); - // - // widget.changeLoadingState(false); - // Helpers.showErrorToast( - // TranslationBase.of(context).chiefComplaintErrorMsg); - // } + if (complaintsController.text.isNotEmpty && + illnessController.text.isNotEmpty && + complaintsController.text.length > 25) { + await postChiefComplaint(model: model); + if (model.state == ViewState.ErrorLocal) { + Helpers.showErrorToast(model.error); + } + if (myHistoryList.length != 0 && widget.patientInfo.admissionNo == null) { + await postHistories(model: model, myHistoryList: myHistoryList); + if (model.state == ViewState.ErrorLocal) { + Helpers.showErrorToast(model.error); + } + } + if (myAllergiesList.length != 0 && widget.patientInfo.admissionNo == null) { + await postAllergy(myAllergiesList: myAllergiesList, model: model); + if (model.state == ViewState.ErrorLocal) { + Helpers.showErrorToast(model.error); + } + } + widget.changeLoadingState(true); + + widget.changePageViewIndex(1); + } else { + setState(() { + if (complaintsController.text.isEmpty) { + complaintsControllerError = TranslationBase.of(context).emptyMessage; + } else if (complaintsController.text.length < 25) { + complaintsControllerError = TranslationBase.of(context).chiefComplaintLength; + } + + if (illnessController.text.isEmpty) { + illnessControllerError = TranslationBase.of(context).emptyMessage; + } + + if (medicationController.text.isEmpty) { + medicationControllerError = TranslationBase.of(context).emptyMessage; + } + }); + + widget.changeLoadingState(false); + Helpers.showErrorToast(TranslationBase.of(context).chiefComplaintErrorMsg); + } } - postAllergy( - {List myAllergiesList, SOAPViewModel model}) async { - PostAllergyRequestModel postAllergyRequestModel = - new PostAllergyRequestModel(); + postAllergy({List myAllergiesList, SOAPViewModel model}) async { + PostAllergyRequestModel postAllergyRequestModel = new PostAllergyRequestModel(); Map profile = await sharedPref.getObj(DOCTOR_PROFILE); DoctorProfileModel doctorProfile = DoctorProfileModel.fromJson(profile); myAllergiesList.forEach((allergy) { - if (postAllergyRequestModel.listHisProgNotePatientAllergyDiseaseVM == - null) + if (postAllergyRequestModel.listHisProgNotePatientAllergyDiseaseVM == null) postAllergyRequestModel.listHisProgNotePatientAllergyDiseaseVM = []; - postAllergyRequestModel.listHisProgNotePatientAllergyDiseaseVM.add( - ListHisProgNotePatientAllergyDiseaseVM( - allergyDiseaseId: allergy.selectedAllergy.id, - allergyDiseaseType: allergy.selectedAllergy.typeId, - patientMRN: widget.patientInfo.patientMRN, - episodeId: widget.patientInfo.episodeNo, - appointmentNo: widget.patientInfo.appointmentNo, - severity: allergy.selectedAllergySeverity.id, - remarks: allergy.remark, - createdBy: allergy.createdBy ?? doctorProfile.doctorID, - createdOn: DateTime.now().toIso8601String(), - editedBy: doctorProfile.doctorID, - editedOn: DateTime.now().toIso8601String(), - isChecked: allergy.isChecked, - isUpdatedByNurse: false)); + postAllergyRequestModel.listHisProgNotePatientAllergyDiseaseVM.add(ListHisProgNotePatientAllergyDiseaseVM( + allergyDiseaseId: allergy.selectedAllergy.id, + allergyDiseaseType: allergy.selectedAllergy.typeId, + patientMRN: widget.patientInfo.patientMRN, + episodeId: widget.patientInfo.episodeNo, + appointmentNo: widget.patientInfo.appointmentNo, + severity: allergy.selectedAllergySeverity.id, + remarks: allergy.remark, + createdBy: allergy.createdBy ?? doctorProfile.doctorID, + createdOn: DateTime.now().toIso8601String(), + editedBy: doctorProfile.doctorID, + editedOn: DateTime.now().toIso8601String(), + isChecked: allergy.isChecked, + isUpdatedByNurse: false)); }); if (model.patientAllergiesList.isEmpty) { await model.postAllergy(postAllergyRequestModel); @@ -434,13 +391,10 @@ class _UpdateSubjectivePageState extends State } } - postHistories( - {List myHistoryList, SOAPViewModel model}) async { - PostHistoriesRequestModel postHistoriesRequestModel = - new PostHistoriesRequestModel(doctorID: ''); + postHistories({List myHistoryList, SOAPViewModel model}) async { + PostHistoriesRequestModel postHistoriesRequestModel = new PostHistoriesRequestModel(doctorID: ''); myHistoryList.forEach((history) { - if (postHistoriesRequestModel.listMedicalHistoryVM == null) - postHistoriesRequestModel.listMedicalHistoryVM = []; + if (postHistoriesRequestModel.listMedicalHistoryVM == null) postHistoriesRequestModel.listMedicalHistoryVM = []; postHistoriesRequestModel.listMedicalHistoryVM.add(ListMedicalHistoryVM( patientMRN: widget.patientInfo.patientMRN, episodeId: widget.patientInfo.episodeNo, @@ -466,18 +420,18 @@ class _UpdateSubjectivePageState extends State postChiefComplaint({SOAPViewModel model}) async { formKey.currentState.save(); if (formKey.currentState.validate()) { - PostChiefComplaintRequestModel postChiefComplaintRequestModel = - new PostChiefComplaintRequestModel( - admissionNo: int.parse(widget.patientInfo.admissionNo),patientMRN: widget.patientInfo.patientMRN, - episodeID: widget.patientInfo.episodeNo, - appointmentNo: widget.patientInfo.appointmentNo, - chiefComplaint: complaintsController.text, - currentMedication: medicationController.text, - hopi: illnessController.text, - isLactation: false, - ispregnant: false, - doctorID: '', - numberOfWeeks: 0); + PostChiefComplaintRequestModel postChiefComplaintRequestModel = new PostChiefComplaintRequestModel( + admissionNo: widget.patientInfo.admissionNo != null ? int.parse(widget.patientInfo.admissionNo) : null, + patientMRN: widget.patientInfo.patientMRN, + episodeID: widget.patientInfo.episodeNo, + appointmentNo: widget.patientInfo.appointmentNo, + chiefComplaint: complaintsController.text, + currentMedication: medicationController.text, + hopi: illnessController.text, + isLactation: false, + ispregnant: false, + doctorID: '', + numberOfWeeks: 0); if (model.patientChiefComplaintList.isEmpty) { postChiefComplaintRequestModel.editedBy = ''; await model.postChiefComplaint(postChiefComplaintRequestModel); @@ -489,9 +443,6 @@ class _UpdateSubjectivePageState extends State @override Function nextFunction(model) { - addSubjectiveInfo( - model: model, - myAllergiesList: myAllergiesList, - myHistoryList: myHistoryList); + addSubjectiveInfo(model: model, myAllergiesList: myAllergiesList, myHistoryList: myHistoryList); } }