From 531e7f497b3427377576372d7df03a378961d0be Mon Sep 17 00:00:00 2001 From: Sultan Khan Date: Thu, 4 Mar 2021 16:24:18 +0300 Subject: [PATCH 1/2] drug to drug intraction --- lib/client/base_app_client.dart | 2 +- .../model/get_medication_response_model.dart | 15 +- lib/core/model/prescription_model.dart | 5 +- lib/core/service/prescription_service.dart | 144 +++++++++++------- .../viewModel/prescription_view_model.dart | 9 +- .../prescription/add_prescription_form.dart | 82 ++++++++-- lib/screens/prescription/drugtodrug.dart | 53 +++++-- 7 files changed, 209 insertions(+), 101 deletions(-) diff --git a/lib/client/base_app_client.dart b/lib/client/base_app_client.dart index 92c0735b..11021ff4 100644 --- a/lib/client/base_app_client.dart +++ b/lib/client/base_app_client.dart @@ -83,7 +83,7 @@ class BaseAppClient { print("URL : $url"); print("Body : ${json.encode(body)}"); - var ee ={json.encode(body)}; + var ee = {json.encode(body)}; if (await Helpers.checkConnection()) { final response = await http.post(url, diff --git a/lib/core/model/get_medication_response_model.dart b/lib/core/model/get_medication_response_model.dart index f9df77a3..f9b687f6 100644 --- a/lib/core/model/get_medication_response_model.dart +++ b/lib/core/model/get_medication_response_model.dart @@ -5,14 +5,15 @@ class GetMedicationResponseModel { String keywords; dynamic price; dynamic quantity; - + dynamic mediSpanGPICode; GetMedicationResponseModel( {this.description, - this.genericName, - this.itemId, - this.keywords, - this.price, - this.quantity}); + this.genericName, + this.itemId, + this.keywords, + this.price, + this.quantity, + this.mediSpanGPICode}); GetMedicationResponseModel.fromJson(Map json) { description = json['Description']; @@ -21,6 +22,7 @@ class GetMedicationResponseModel { keywords = json['Keywords']; price = json['Price']; quantity = json['Quantity']; + mediSpanGPICode = json['mediSpanGPICode']; } Map toJson() { @@ -31,6 +33,7 @@ class GetMedicationResponseModel { data['Keywords'] = this.keywords; data['Price'] = this.price; data['Quantity'] = this.quantity; + data['mediSpanGPICode'] = this.mediSpanGPICode; return data; } } diff --git a/lib/core/model/prescription_model.dart b/lib/core/model/prescription_model.dart index 49001673..4bdc4105 100644 --- a/lib/core/model/prescription_model.dart +++ b/lib/core/model/prescription_model.dart @@ -59,7 +59,7 @@ class EntityList { dynamic uom; dynamic pharmacistRemarks; dynamic refill; - + dynamic mediSpanGPICode; EntityList( {this.appointmentNo, this.clinicName, @@ -91,6 +91,7 @@ class EntityList { this.stopDate, this.uom, this.pharmacistRemarks, + this.mediSpanGPICode, this.refill}); EntityList.fromJson(Map json) { @@ -124,6 +125,7 @@ class EntityList { stopDate = json['stopDate']; uom = json['uom']; pharmacistRemarks = json['pharmacistRemarks']; + mediSpanGPICode = json['mediSpanGPICode']; refill = json['refill']; } @@ -159,6 +161,7 @@ class EntityList { data['stopDate'] = this.stopDate; data['uom'] = this.uom; data['pharmacistRemarks'] = this.pharmacistRemarks; + data['mediSpanGPICode'] = this.mediSpanGPICode; data['refill'] = this.refill; return data; } diff --git a/lib/core/service/prescription_service.dart b/lib/core/service/prescription_service.dart index 54640fcc..cc366d96 100644 --- a/lib/core/service/prescription_service.dart +++ b/lib/core/service/prescription_service.dart @@ -2,6 +2,7 @@ import 'package:doctor_app_flutter/config/config.dart'; import 'package:doctor_app_flutter/core/model/Prescription_model.dart'; import 'package:doctor_app_flutter/core/model/get_medication_response_model.dart'; import 'package:doctor_app_flutter/core/model/item_by_medicine_request_model.dart'; +import 'package:doctor_app_flutter/core/model/medical_file_model.dart'; import 'package:doctor_app_flutter/core/model/prescription_req_model.dart'; import 'package:doctor_app_flutter/core/model/post_prescrition_req_model.dart'; import 'package:doctor_app_flutter/core/model/search_drug_model.dart'; @@ -14,6 +15,7 @@ import 'package:doctor_app_flutter/models/SOAP/GetAssessmentResModel.dart'; import 'package:doctor_app_flutter/models/SOAP/master_key_model.dart'; import 'package:doctor_app_flutter/models/patient/patiant_info_model.dart'; import 'package:doctor_app_flutter/models/patient/vital_sign/patient-vital-sign-data.dart'; +import 'package:doctor_app_flutter/util/date-utils.dart'; class PrescriptionService extends LookupService { List _prescriptionList = List(); @@ -24,6 +26,7 @@ class PrescriptionService extends LookupService { List allMedicationList = []; List specialityList = []; List drugToDrug = []; + List get drugToDrugList => drugToDrug; List itemMedicineList = []; List itemMedicineListRoute = []; List itemMedicineListUnit = []; @@ -153,70 +156,71 @@ class PrescriptionService extends LookupService { Future getDrugToDrug( VitalSignData vital, - List diagnosis, + List lstAssessments, List allergy, PatiantInformtion patient, - List prescription) async { + List prescription) async { + // Map request = { + // "Prescription": { + // "objPatientInfo": {"Gender": "Male", "Age": "21/06/1967"}, + // "objVitalSign": {"Height": "180", "Weight": "37"}, + // "objPrescriptionItems": [ + // { + // "DrugId": "83-20-00-30-20-03-03", + // "DrugName": "WARFARIN 1 MG TAB 28'S (N)", + // "Dose": "1", + // "DoseType": "04", + // "Unit": "actuation(s)", + // "FrequencyType": "1/3/Day", + // "Duration": "3/Day", + // "IsScreen": "true" + // }, + // { + // "DrugId": "64-20-00-10-00-03-15", + // "DrugName": "PANADOL 500 MG TAB 24'S(DIS)", + // "Dose": "1", + // "DoseType": "04", + // "Unit": "MG", + // "FrequencyType": "3/1/Day", + // "Duration": "4/Day", + // "RouteID": "24", + // "IsScreen": "true" + // } + // ], + // "objAllergies": { + // "Allergy": { + // "objProperties": {"Id": "26", "Name": "phenoxymethylpenicillin"} + // } + // }, + // "objDiagnosis": { + // "Diagnosis": { + // "objProperties": {"Id": "A01.1", "Name": "Paratyphoid fever A"} + // } + // }, + // "IsDoctor": "false", + // "IsPharmacist": "false" + // }, + // "IPAdress": "10.10.10.10", + // "Channel": 9, + // "LanguageID": 2, + // "VersionID": 5.3, + // "SessionID": "BlUSkYymTt", + // "IsLoginForDoctorApp": true, + // "PatientOutSA": 0, + // "TokenID": "@dm!n", + // "OutSA": true + // }; Map request = { - "Prescription": { - "objPatientInfo": {"Gender": "Male", "Age": "21/06/1967"}, - "objVitalSign": {"Height": "180", "Weight": "37"}, - "objPrescriptionItems": [ - { - "DrugId": "83-20-00-30-20-03-03", - "DrugName": "WARFARIN 1 MG TAB 28'S (N)", - "Dose": "1", - "DoseType": "04", - "Unit": "actuation(s)", - "FrequencyType": "1/3/Day", - "Duration": "3/Day", - "IsScreen": "true" - }, - { - "DrugId": "64-20-00-10-00-03-15", - "DrugName": "PANADOL 500 MG TAB 24'S(DIS)", - "Dose": "1", - "DoseType": "04", - "Unit": "MG", - "FrequencyType": "3/1/Day", - "Duration": "4/Day", - "RouteID": "24", - "IsScreen": "true" - } - ], - "objAllergies": { - "Allergy": { - "objProperties": {"Id": "26", "Name": "phenoxymethylpenicillin"} - } - }, - "objDiagnosis": { - "Diagnosis": { - "objProperties": {"Id": "A01.1", "Name": "Paratyphoid fever A"} - } - }, - "IsDoctor": "false", - "IsPharmacist": "false" - }, - "IPAdress": "10.10.10.10", - "Channel": 9, - "LanguageID": 2, - "VersionID": 5.3, - "SessionID": "BlUSkYymTt", - "IsLoginForDoctorApp": true, - "PatientOutSA": 0, - "TokenID": "@dm!n", - "OutSA": true - }; - Map requestN = { "Prescription": { "objPatientInfo": { "Gender": patient.gender == 1 ? 'Male' : 'Female', - "Age": patient.age + "Age": DateUtils.convertDateFromServerFormat( + patient.dateofBirth, 'dd/MM/yyyy') }, - "objVitalSign": {"Height": vital.heightCm, "Weight": vital.weightKg}, - "objPrescriptionItems": prescription[0].entityList, - "objAllergies": allergy, - "objDiagnosis": diagnosis, + "objVitalSign": {"Height": vital?.heightCm, "Weight": vital?.weightKg}, + "objPrescriptionItems": prescription, + "objAllergies": getAllergiesObj(allergy), + "objDiagnosis": getDiagnosisObj(lstAssessments), "IsDoctor": "false", "IsPharmacist": "false" } @@ -226,10 +230,34 @@ class PrescriptionService extends LookupService { await baseAppClient.post(DRUG_TO_DRUG, onSuccess: (dynamic response, int statusCode) { drugToDrug = []; - //drugToDrug = //response['MedicationList']['entityList']; + drugToDrug = + response['DrugToDrugResponse']['objPrescriptionCheckerResult']; }, onFailure: (String error, int statusCode) { hasError = true; super.error = error; }, body: request); } + + getAllergiesObj(List allergies) { + var allergiesObj = []; + allergies.forEach((element) { + allergiesObj.add({ + "objProperties": { + 'Id': element.allergyDiseaseId, + 'Name': element.allergyDiseaseName + } + }); + }); + return allergiesObj; + } + + getDiagnosisObj(List lstAssessments) { + var lstAssessmentsObj = []; + lstAssessments.forEach((element) { + lstAssessmentsObj.add({ + "objProperties": {'Id': element.icdCode10ID, 'Name': element.asciiDesc} + }); + }); + return lstAssessmentsObj; + } } diff --git a/lib/core/viewModel/prescription_view_model.dart b/lib/core/viewModel/prescription_view_model.dart index 63dc19c5..a07ae715 100644 --- a/lib/core/viewModel/prescription_view_model.dart +++ b/lib/core/viewModel/prescription_view_model.dart @@ -1,12 +1,14 @@ import 'package:doctor_app_flutter/core/enum/viewstate.dart'; import 'package:doctor_app_flutter/core/model/Prescription_model.dart'; import 'package:doctor_app_flutter/core/model/get_medication_response_model.dart'; +import 'package:doctor_app_flutter/core/model/medical_file_model.dart'; import 'package:doctor_app_flutter/core/model/post_prescrition_req_model.dart'; import 'package:doctor_app_flutter/core/model/search_drug_model.dart'; import 'package:doctor_app_flutter/core/service/prescription_service.dart'; import 'package:doctor_app_flutter/core/viewModel/base_view_model.dart'; import 'package:doctor_app_flutter/locator.dart'; import 'package:doctor_app_flutter/models/SOAP/GetAllergiesResModel.dart'; +import 'package:doctor_app_flutter/models/SOAP/GetAssessmentResModel.dart'; import 'package:doctor_app_flutter/models/SOAP/master_key_model.dart'; import 'package:doctor_app_flutter/models/patient/patiant_info_model.dart'; import 'package:doctor_app_flutter/models/patient/vital_sign/patient-vital-sign-data.dart'; @@ -21,6 +23,7 @@ class PrescriptionViewModel extends BaseViewModel { _prescriptionService.prescriptionList; List get drugsList => _prescriptionService.doctorsList; //List get allMedicationList => _prescriptionService.allMedicationList; + List get drugToDrug => _prescriptionService.drugToDrugList; List get itemMedicineList => _prescriptionService.itemMedicineList; @@ -102,14 +105,14 @@ class PrescriptionViewModel extends BaseViewModel { Future getDrugToDrug( VitalSignData vital, - List listOfDiagnosisType, + List lstAssessments, List allergy, PatiantInformtion patient, - List prescription) async { + List prescription) async { hasError = false; setState(ViewState.Busy); await _prescriptionService.getDrugToDrug( - vital, listOfDiagnosisType, allergy, patient, prescription); + vital, lstAssessments, allergy, patient, prescription); if (_prescriptionService.hasError) { error = _prescriptionService.error; setState(ViewState.ErrorLocal); diff --git a/lib/screens/prescription/add_prescription_form.dart b/lib/screens/prescription/add_prescription_form.dart index 5ec6e240..5fa14285 100644 --- a/lib/screens/prescription/add_prescription_form.dart +++ b/lib/screens/prescription/add_prescription_form.dart @@ -785,13 +785,15 @@ class _PrescriptionFormWidgetState extends State { if (formKey.currentState .validate()) { Navigator.pop(context); + openDrugToDrug(model); { - // var x = model + /*// var x = model // .patientAssessmentList // .map((value) => // value.icdCode10ID) // .toList() // .join(','); + postProcedure( icdCode: model .patientAssessmentList[ @@ -838,8 +840,10 @@ class _PrescriptionFormWidgetState extends State { .text, doseTime: selectedDate, ); + */ } } + { // Navigator.push( // context, @@ -918,7 +922,7 @@ class _PrescriptionFormWidgetState extends State { ); } - openDrugToDrug() { + openDrugToDrug(model) { showModalBottomSheet( context: context, builder: (context) { @@ -929,26 +933,43 @@ class _PrescriptionFormWidgetState extends State { child: Column( // mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - DrugToDrug(widget.patient, widget.prescriptionList), + DrugToDrug( + widget.patient, + getPriscriptionforDrug(widget.prescriptionList), + model.patientAssessmentList), Container( margin: EdgeInsets.all(SizeConfig.widthMultiplier * 3), child: AppButton( title: TranslationBase.of(context).addMedication, onPressed: () { + Navigator.pop(context); postProcedure( - dose: strengthController.text, - doseUnit: units['id'].toString(), - patient: widget.patient, - doseTimeIn: doseTime['id'].toString(), - model: widget.model, - duration: duration['id'].toString(), - frequency: frequency['id'].toString(), - route: route['id'].toString(), - drugId: selectedDrug['ItemId'].toString(), - strength: strengthController.text, - indication: indicationController.text, - instruction: instructionController.text, - doseTime: selectedDate); + icdCode: + model.patientAssessmentList[0].icdCode10ID.isEmpty + ? "test" + : model.patientAssessmentList[0].icdCode10ID + .toString(), + // icdCode: model + // .patientAssessmentList + // .map((value) => value + // .icdCode10ID + // .trim()) + // .toList() + // .join(' '), + dose: strengthController.text, + doseUnit: units['parameterCode'].toString(), + patient: widget.patient, + doseTimeIn: doseTime['id'].toString(), + model: widget.model, + duration: duration['id'].toString(), + frequency: frequency['parameterCode'].toString(), + route: route['parameterCode'].toString(), + drugId: _selectedMedication.itemId.toString(), + strength: strengthController.text, + indication: indicationController.text, + instruction: instructionController.text, + doseTime: selectedDate, + ); }, )) ], @@ -959,4 +980,33 @@ class _PrescriptionFormWidgetState extends State { ); }); } + + getPriscriptionforDrug(List prescriptionList) { + var prescriptionDetails = []; + prescriptionList[0].entityList.forEach((element) { + prescriptionDetails.add({ + 'DrugId': element.mediSpanGPICode, + 'DrugName': element.medicationName, + 'Dose': element.doseDailyQuantity, + 'DoseType': element.doseDailyUnitID, + 'Unit': element.uom, + 'FrequencyType': element.frequencyID, + 'Duration': element.doseDurationDays, + 'RouteID': element.routeID, + 'IsScreen': element.isSIG + }); + }); + prescriptionDetails.add({ + 'DrugId': _selectedMedication.mediSpanGPICode, + 'DrugName': _selectedMedication.description, + 'Dose': strengthController.text, + 'DoseType': units['parameterCode'].toString(), + 'Unit': units['description'], + 'FrequencyType': frequency['parameterCode'].toString(), + 'Duration': duration['id'].toString(), + 'RouteID': route['parameterCode'].toString(), + 'IsScreen': true + }); + return prescriptionDetails; + } } diff --git a/lib/screens/prescription/drugtodrug.dart b/lib/screens/prescription/drugtodrug.dart index b97dbb2d..ec2bda43 100644 --- a/lib/screens/prescription/drugtodrug.dart +++ b/lib/screens/prescription/drugtodrug.dart @@ -2,25 +2,29 @@ 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/master_lookup_key.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/prescription_model.dart'; import 'package:doctor_app_flutter/core/viewModel/SOAP_view_model.dart'; import 'package:doctor_app_flutter/core/viewModel/patient-vital-sign-viewmodel.dart'; import 'package:doctor_app_flutter/core/viewModel/patient_view_model.dart'; import 'package:doctor_app_flutter/core/viewModel/prescription_view_model.dart'; import 'package:doctor_app_flutter/models/SOAP/GeneralGetReqForSOAP.dart'; +import 'package:doctor_app_flutter/models/SOAP/GetAssessmentResModel.dart'; import 'package:doctor_app_flutter/models/patient/patiant_info_model.dart'; import 'package:doctor_app_flutter/models/patient/vital_sign/vital_sign_req_model.dart'; import 'package:doctor_app_flutter/screens/base/base_view.dart'; import 'package:doctor_app_flutter/screens/medicine/medicine_search_screen.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/network_base_view.dart'; import 'package:flutter/material.dart'; class DrugToDrug extends StatefulWidget { final PatiantInformtion patient; final prescription; - DrugToDrug(this.patient, this.prescription); + final List listAssessment; + DrugToDrug(this.patient, this.prescription, this.listAssessment); @override _DrugToDrug createState() => _DrugToDrug(); } @@ -29,11 +33,11 @@ class _DrugToDrug extends State { int typeID = 1; bool isLoaded = false; List> expandableList = [ - {'name': 'CRITICAL'}, - {'name': 'HIGH'}, - {'name': 'MODERATE'}, - {'name': 'LOW'}, - {'name': 'INFO'}, + {'name': 'CRITICAL', 'level': 'LEVEL_4'}, + {'name': 'HIGH', 'level': 'LEVEL_3'}, + {'name': 'MODERATE', 'level': 'LEVEL_2'}, + {'name': 'LOW', 'level': 'LEVEL_1'}, + {'name': 'INFO', 'level': 'INFO'}, ]; GeneralGetReqForSOAP generalGetReqForSOAP = GeneralGetReqForSOAP( patientMRN: 2954208, //widget.patient.patientMRN, @@ -58,7 +62,7 @@ class _DrugToDrug extends State { ? BaseView( onModelReady: (model3) => model3.getDrugToDrug( model.patientVitalSigns, - model2.listOfDiagnosisType, + widget.listAssessment, model2.patientAllergiesList, widget.patient, widget.prescription), @@ -72,15 +76,28 @@ class _DrugToDrug extends State { itemCount: expandableList.length, itemBuilder: (context, i) { return new ExpansionTile( - title: new Text( - expandableList[i]['name'], - style: new TextStyle( - fontSize: 20.0, - fontWeight: FontWeight.bold, - fontStyle: FontStyle.italic), - ), - children: [Text('Hi')], - ); + title: new AppText( + expandableList[i]['name'] + + ' ' + + '(' + + getDrugInfo(expandableList[i]['level'], + model3) + .length + .toString() + + ')', + fontSize: 20, + fontWeight: FontWeight.bold, + ), + children: getDrugInfo( + expandableList[i]['level'], model3) + .map((item) { + return Container( + padding: EdgeInsets.all(10), + child: AppText( + item['comment'], + color: Colors.red[900], + )); + }).toList()); })))) : Container( height: SizeConfig.realScreenHeight * .45, @@ -107,4 +124,8 @@ class _DrugToDrug extends State { }); } } + + List getDrugInfo(level, model3) { + return model3.drugToDrug.where((i) => i['Severity'] == level).toList(); + } } From 817718f897a5071655fa7d42478c1cbf3a3938c1 Mon Sep 17 00:00:00 2001 From: Sultan Khan Date: Thu, 4 Mar 2021 17:03:01 +0300 Subject: [PATCH 2/2] drug to drug intraction --- .../prescription/add_prescription_form.dart | 46 ++++++++++--------- 1 file changed, 25 insertions(+), 21 deletions(-) diff --git a/lib/screens/prescription/add_prescription_form.dart b/lib/screens/prescription/add_prescription_form.dart index 8cf3b414..e22a28e0 100644 --- a/lib/screens/prescription/add_prescription_form.dart +++ b/lib/screens/prescription/add_prescription_form.dart @@ -1001,29 +1001,33 @@ class _PrescriptionFormWidgetState extends State { getPriscriptionforDrug(List prescriptionList) { var prescriptionDetails = []; prescriptionList[0].entityList.forEach((element) { + if (element.mediSpanGPICode != null) { + prescriptionDetails.add({ + 'DrugId': element.mediSpanGPICode, + 'DrugName': element.medicationName, + 'Dose': element.doseDailyQuantity, + 'DoseType': element.doseDailyUnitID, + 'Unit': element.uom, + 'FrequencyType': element.frequencyID, + 'Duration': element.doseDurationDays, + 'RouteID': element.routeID, + 'IsScreen': element.isSIG + }); + } + }); + if (_selectedMedication.mediSpanGPICode != null) { prescriptionDetails.add({ - 'DrugId': element.mediSpanGPICode, - 'DrugName': element.medicationName, - 'Dose': element.doseDailyQuantity, - 'DoseType': element.doseDailyUnitID, - 'Unit': element.uom, - 'FrequencyType': element.frequencyID, - 'Duration': element.doseDurationDays, - 'RouteID': element.routeID, - 'IsScreen': element.isSIG + 'DrugId': _selectedMedication.mediSpanGPICode, + 'DrugName': _selectedMedication.description, + 'Dose': strengthController.text, + 'DoseType': units['parameterCode'].toString(), + 'Unit': units['description'], + 'FrequencyType': frequency['parameterCode'].toString(), + 'Duration': duration['id'].toString(), + 'RouteID': route['parameterCode'].toString(), + 'IsScreen': true }); - }); - prescriptionDetails.add({ - 'DrugId': _selectedMedication.mediSpanGPICode, - 'DrugName': _selectedMedication.description, - 'Dose': strengthController.text, - 'DoseType': units['parameterCode'].toString(), - 'Unit': units['description'], - 'FrequencyType': frequency['parameterCode'].toString(), - 'Duration': duration['id'].toString(), - 'RouteID': route['parameterCode'].toString(), - 'IsScreen': true - }); + } return prescriptionDetails; } }