You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
211 lines
7.2 KiB
Dart
211 lines
7.2 KiB
Dart
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/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';
|
|
import 'package:doctor_app_flutter/core/model/search_drug_request_model.dart';
|
|
import 'package:doctor_app_flutter/core/service/base/base_service.dart';
|
|
import 'package:doctor_app_flutter/core/service/base/lookup-service.dart';
|
|
import 'package:doctor_app_flutter/models/SOAP/GetAllergiesResModel.dart';
|
|
import 'package:doctor_app_flutter/models/SOAP/GetAssessmentReqModel.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';
|
|
|
|
class PrescriptionService extends LookupService {
|
|
List<PrescriptionModel> _prescriptionList = List();
|
|
List<PrescriptionModel> get prescriptionList => _prescriptionList;
|
|
List<SearchDrugModel> _drugsList = List();
|
|
List<SearchDrugModel> get drugsList => _drugsList;
|
|
List<dynamic> doctorsList = [];
|
|
List<GetMedicationResponseModel> allMedicationList = [];
|
|
List<dynamic> specialityList = [];
|
|
List<dynamic> drugToDrug = [];
|
|
|
|
PrescriptionReqModel _prescriptionReqModel = PrescriptionReqModel();
|
|
SearchDrugRequestModel _drugRequestModel = SearchDrugRequestModel(
|
|
//search: ["Acetaminophen"],
|
|
search: ["Amoxicillin"],
|
|
);
|
|
|
|
PostPrescriptionReqModel _postPrescriptionReqModel =
|
|
PostPrescriptionReqModel();
|
|
Future getPatientAssessment(
|
|
GetAssessmentReqModel getAssessmentReqModel) async {
|
|
hasError = false;
|
|
await baseAppClient.post(GET_ASSESSMENT,
|
|
onSuccess: (dynamic response, int statusCode) {
|
|
print("Success");
|
|
patientAssessmentList.clear();
|
|
response['AssessmentList']['entityList'].forEach((v) {
|
|
patientAssessmentList.add(GetAssessmentResModel.fromJson(v));
|
|
});
|
|
}, onFailure: (String error, int statusCode) {
|
|
hasError = true;
|
|
super.error = error;
|
|
}, body: getAssessmentReqModel.toJson());
|
|
}
|
|
|
|
Future getPrescription({int mrn}) async {
|
|
_prescriptionReqModel = PrescriptionReqModel(patientMRN: mrn);
|
|
hasError = false;
|
|
_prescriptionList.clear();
|
|
await baseAppClient.post(GET_PRESCRIPTION_LIST,
|
|
onSuccess: (dynamic response, int statusCode) {
|
|
_prescriptionList
|
|
.add(PrescriptionModel.fromJson(response['PrescriptionList']));
|
|
}, onFailure: (String error, int statusCode) {
|
|
hasError = true;
|
|
super.error = error;
|
|
}, body: _prescriptionReqModel.toJson());
|
|
}
|
|
|
|
Future getDrugs({String drugName}) async {
|
|
_drugRequestModel = SearchDrugRequestModel(search: [drugName]);
|
|
|
|
hasError = false;
|
|
|
|
await baseAppClient.post(SEARCH_DRUG,
|
|
onSuccess: (dynamic response, int statusCode) {
|
|
doctorsList = [];
|
|
doctorsList = response['MedicationList']['entityList'];
|
|
}, onFailure: (String error, int statusCode) {
|
|
hasError = true;
|
|
super.error = error;
|
|
}, body: _drugRequestModel.toJson());
|
|
}
|
|
|
|
Future getMedicationList() async {
|
|
hasError = false;
|
|
_drugRequestModel.search = [""];
|
|
await baseAppClient.post(SEARCH_DRUG,
|
|
onSuccess: (dynamic response, int statusCode) {
|
|
allMedicationList = [];
|
|
response['MedicationList']['entityList'].forEach((v) {
|
|
allMedicationList.add(GetMedicationResponseModel.fromJson(v));
|
|
});
|
|
}, onFailure: (String error, int statusCode) {
|
|
hasError = true;
|
|
super.error = error;
|
|
}, body: _drugRequestModel.toJson());
|
|
}
|
|
|
|
Future postPrescription(
|
|
PostPrescriptionReqModel postProcedureReqModel) async {
|
|
hasError = false;
|
|
//_prescriptionList.clear();
|
|
await baseAppClient.post(
|
|
POST_PRESCRIPTION_LIST,
|
|
onSuccess: (dynamic response, int statusCode) {
|
|
print("Success");
|
|
},
|
|
onFailure: (String error, int statusCode) {
|
|
hasError = true;
|
|
super.error = error;
|
|
},
|
|
body: postProcedureReqModel.toJson(),
|
|
);
|
|
}
|
|
|
|
Future updatePrescription(
|
|
PostPrescriptionReqModel updatePrescriptionReqModel) async {
|
|
hasError = false;
|
|
//_prescriptionList.clear();
|
|
await baseAppClient.post(
|
|
UPDATE_PRESCRIPTION,
|
|
onSuccess: (dynamic response, int statusCode) {
|
|
print("Accepted");
|
|
},
|
|
onFailure: (String error, int statusCode) {
|
|
hasError = true;
|
|
super.error = error;
|
|
},
|
|
body: updatePrescriptionReqModel.toJson(),
|
|
);
|
|
}
|
|
|
|
Future getDrugToDrug(
|
|
VitalSignData vital,
|
|
List<MasterKeyModel> diagnosis,
|
|
List<GetAllergiesResModel> allergy,
|
|
PatiantInformtion patient,
|
|
List<PrescriptionModel> prescription) async {
|
|
Map<String, dynamic> 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<String, dynamic> requestN = {
|
|
"Prescription": {
|
|
"objPatientInfo": {
|
|
"Gender": patient.gender == 1 ? 'Male' : 'Female',
|
|
"Age": patient.age
|
|
},
|
|
"objVitalSign": {"Height": vital.heightCm, "Weight": vital.weightKg},
|
|
"objPrescriptionItems": prescription[0].entityList,
|
|
"objAllergies": allergy,
|
|
"objDiagnosis": diagnosis,
|
|
"IsDoctor": "false",
|
|
"IsPharmacist": "false"
|
|
}
|
|
};
|
|
|
|
hasError = false;
|
|
await baseAppClient.post(DRUG_TO_DRUG,
|
|
onSuccess: (dynamic response, int statusCode) {
|
|
drugToDrug = [];
|
|
//drugToDrug = //response['MedicationList']['entityList'];
|
|
}, onFailure: (String error, int statusCode) {
|
|
hasError = true;
|
|
super.error = error;
|
|
}, body: request);
|
|
}
|
|
}
|