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.
257 lines
8.8 KiB
Dart
257 lines
8.8 KiB
Dart
import 'package:doctor_app_flutter/config/config.dart';
|
|
import 'package:doctor_app_flutter/core/service/base/base_service.dart';
|
|
import 'package:doctor_app_flutter/models/doctor/request_schedule.dart';
|
|
import 'package:doctor_app_flutter/models/patient/get_clinic_by_project_id_request.dart';
|
|
import 'package:doctor_app_flutter/models/patient/get_doctor_by_clinic_id_request.dart';
|
|
import 'package:doctor_app_flutter/models/patient/get_list_stp_referral_frequency_request.dart';
|
|
import 'package:doctor_app_flutter/models/patient/lab_orders/lab_orders_res_model.dart';
|
|
import 'package:doctor_app_flutter/models/patient/lab_result/lab_result.dart';
|
|
import 'package:doctor_app_flutter/models/patient/lab_result/lab_result_req_model.dart';
|
|
import 'package:doctor_app_flutter/models/patient/prescription/prescription_report.dart';
|
|
import 'package:doctor_app_flutter/models/patient/prescription/prescription_report_for_in_patient.dart';
|
|
import 'package:doctor_app_flutter/models/patient/prescription/prescription_res_model.dart';
|
|
import 'package:doctor_app_flutter/models/patient/radiology/radiology_res_model.dart';
|
|
import 'package:doctor_app_flutter/models/patient/refer_to_doctor_request.dart';
|
|
import 'package:doctor_app_flutter/models/patient/vital_sign/vital_sign_res_model.dart';
|
|
|
|
class PatientService extends BaseService {
|
|
List<VitalSignResModel> _patientVitalSignList = [];
|
|
List<VitalSignResModel> patientVitalSignOrderdSubList = [];
|
|
|
|
List<VitalSignResModel> get patientVitalSignList => _patientVitalSignList;
|
|
|
|
List<LabOrdersResModel> _patientLabResultOrdersList = [];
|
|
|
|
List<LabOrdersResModel> get patientLabResultOrdersList =>
|
|
_patientLabResultOrdersList;
|
|
|
|
List<PrescriptionResModel> get patientPrescriptionsList =>
|
|
_patientPrescriptionsList;
|
|
List<PrescriptionResModel> _patientPrescriptionsList = [];
|
|
|
|
List<PrescriptionReportForInPatient> get prescriptionReportForInPatientList =>
|
|
_prescriptionReportForInPatientList;
|
|
List<PrescriptionReportForInPatient> _prescriptionReportForInPatientList = [];
|
|
|
|
List<RadiologyResModel> _patientRadiologyList = [];
|
|
|
|
List<RadiologyResModel> get patientRadiologyList => _patientRadiologyList;
|
|
|
|
List<PrescriptionReport> _prescriptionReport = [];
|
|
|
|
List<PrescriptionReport> get prescriptionReport => _prescriptionReport;
|
|
|
|
List<LabResult> _labResultList = [];
|
|
List<LabResult> get labResultList => _labResultList;
|
|
|
|
// TODO: replace var with model
|
|
var _patientProgressNoteList = [];
|
|
get patientProgressNoteList => _patientProgressNoteList;
|
|
|
|
// TODO: replace var with model
|
|
var _insuranceApporvalsList = [];
|
|
get insuranceApporvalsList => _insuranceApporvalsList;
|
|
|
|
// TODO: replace var with model
|
|
var doctorsList = [];
|
|
// TODO: replace var with model
|
|
var clinicsList = [];
|
|
// TODO: replace var with model
|
|
var referalFrequancyList = [];
|
|
|
|
DoctorsByClinicIdRequest _doctorsByClinicIdRequest =
|
|
DoctorsByClinicIdRequest();
|
|
STPReferralFrequencyRequest _referralFrequencyRequest =
|
|
STPReferralFrequencyRequest();
|
|
ClinicByProjectIdRequest _clinicByProjectIdRequest =
|
|
ClinicByProjectIdRequest();
|
|
ReferToDoctorRequest _referToDoctorRequest;
|
|
|
|
RequestSchedule _requestSchedule = RequestSchedule();
|
|
|
|
Future getPatientVitalSign(patient) async {
|
|
hasError = false;
|
|
await baseAppClient.post(
|
|
GET_PATIENT_VITAL_SIGN,
|
|
onSuccess: (dynamic response, int statusCode) {
|
|
_patientVitalSignList = [];
|
|
response['List_DoctorPatientVitalSign'].forEach((v) {
|
|
_patientVitalSignList.add(new VitalSignResModel.fromJson(v));
|
|
});
|
|
|
|
if (_patientVitalSignList.length > 0) {
|
|
List<VitalSignResModel> patientVitalSignOrderdSubListTemp = [];
|
|
patientVitalSignOrderdSubListTemp = _patientVitalSignList;
|
|
patientVitalSignOrderdSubListTemp
|
|
.sort((VitalSignResModel a, VitalSignResModel b) {
|
|
return b.vitalSignDate.microsecondsSinceEpoch -
|
|
a.vitalSignDate.microsecondsSinceEpoch;
|
|
});
|
|
patientVitalSignOrderdSubList.clear();
|
|
int length = patientVitalSignOrderdSubListTemp.length >= 20
|
|
? 20
|
|
: patientVitalSignOrderdSubListTemp.length;
|
|
for (int x = 0; x < length; x++) {
|
|
patientVitalSignOrderdSubList
|
|
.add(patientVitalSignOrderdSubListTemp[x]);
|
|
}
|
|
}
|
|
},
|
|
onFailure: (String error, int statusCode) {
|
|
hasError = true;
|
|
super.error = error;
|
|
},
|
|
body: patient,
|
|
);
|
|
}
|
|
|
|
Future getLabResultOrders(patient) async {
|
|
hasError = false;
|
|
await baseAppClient.post(
|
|
GET_PATIENT_LAB_OREDERS,
|
|
onSuccess: (dynamic response, int statusCode) {
|
|
_patientLabResultOrdersList = [];
|
|
response['List_GetLabOreders'].forEach((v) {
|
|
_patientLabResultOrdersList.add(new LabOrdersResModel.fromJson(v));
|
|
});
|
|
},
|
|
onFailure: (String error, int statusCode) {
|
|
hasError = true;
|
|
super.error = error;
|
|
},
|
|
body: patient,
|
|
);
|
|
}
|
|
|
|
Future getOutPatientPrescriptions(patient) async {
|
|
hasError = false;
|
|
await baseAppClient.post(
|
|
GET_PRESCRIPTION,
|
|
onSuccess: (dynamic response, int statusCode) {
|
|
_patientPrescriptionsList = [];
|
|
response['PatientPrescriptionList'].forEach((v) {
|
|
_patientPrescriptionsList.add(new PrescriptionResModel.fromJson(v));
|
|
});
|
|
},
|
|
onFailure: (String error, int statusCode) {
|
|
hasError = true;
|
|
super.error = error;
|
|
},
|
|
body: patient,
|
|
);
|
|
}
|
|
|
|
Future getInPatientPrescriptions(patient) async {
|
|
hasError = false;
|
|
await baseAppClient.post(
|
|
GET_PRESCRIPTION_REPORT_FOR_IN_PATIENT,
|
|
onSuccess: (dynamic response, int statusCode) {
|
|
_prescriptionReportForInPatientList = [];
|
|
response['List_PrescriptionReportForInPatient'].forEach((v) {
|
|
prescriptionReportForInPatientList
|
|
.add(PrescriptionReportForInPatient.fromJson(v));
|
|
});
|
|
},
|
|
onFailure: (String error, int statusCode) {
|
|
hasError = true;
|
|
super.error = error;
|
|
},
|
|
body: patient,
|
|
);
|
|
}
|
|
|
|
Future getPrescriptionReport(prescriptionReqModel) async {
|
|
hasError = false;
|
|
await baseAppClient.post(
|
|
GET_PRESCRIPTION_REPORT,
|
|
onSuccess: (dynamic response, int statusCode) {
|
|
_prescriptionReport = [];
|
|
response['ListPRM'].forEach((v) {
|
|
_prescriptionReport.add(PrescriptionReport.fromJson(v));
|
|
});
|
|
},
|
|
onFailure: (String error, int statusCode) {
|
|
hasError = true;
|
|
super.error = error;
|
|
},
|
|
body: prescriptionReqModel,
|
|
);
|
|
}
|
|
|
|
Future getPatientRadiology(patient) async {
|
|
hasError = false;
|
|
await baseAppClient.post(
|
|
GET_RADIOLOGY,
|
|
onSuccess: (dynamic response, int statusCode) {
|
|
_patientRadiologyList = [];
|
|
response['List_GetRadOreders'].forEach((v) {
|
|
_patientRadiologyList.add(new RadiologyResModel.fromJson(v));
|
|
});
|
|
},
|
|
onFailure: (String error, int statusCode) {
|
|
hasError = true;
|
|
super.error = error;
|
|
},
|
|
body: patient,
|
|
);
|
|
}
|
|
|
|
Future getLabResult(LabOrdersResModel labOrdersResModel) async {
|
|
hasError = false;
|
|
|
|
RequestLabResult requestLabResult = RequestLabResult();
|
|
requestLabResult.sessionID = labOrdersResModel.setupID;
|
|
requestLabResult.orderNo = labOrdersResModel.orderNo;
|
|
requestLabResult.invoiceNo = labOrdersResModel.invoiceNo;
|
|
requestLabResult.patientTypeID = labOrdersResModel.patientType;
|
|
await baseAppClient.post(
|
|
GET_PATIENT_LAB_RESULTS,
|
|
onSuccess: (dynamic response, int statusCode) {
|
|
_labResultList = [];
|
|
response['List_GetLabNormal'].forEach((v) {
|
|
_labResultList.add(new LabResult.fromJson(v));
|
|
});
|
|
},
|
|
onFailure: (String error, int statusCode) {
|
|
hasError = true;
|
|
super.error = error;
|
|
},
|
|
body: requestLabResult.toJson(),
|
|
);
|
|
}
|
|
Future getPatientInsuranceApprovals(patient) async {
|
|
hasError = false;
|
|
|
|
await baseAppClient.post(
|
|
PATIENT_INSURANCE_APPROVALS_URL,
|
|
onSuccess: (dynamic response, int statusCode) {
|
|
_insuranceApporvalsList = [];
|
|
_insuranceApporvalsList = response['List_ApprovalMain_InPatient'];
|
|
|
|
},
|
|
onFailure: (String error, int statusCode) {
|
|
hasError = true;
|
|
super.error = error;
|
|
},
|
|
body: patient,
|
|
);
|
|
}
|
|
Future getPatientProgressNote(patient) async {
|
|
hasError = false;
|
|
|
|
await baseAppClient.post(
|
|
PATIENT_PROGRESS_NOTE_URL,
|
|
onSuccess: (dynamic response, int statusCode) {
|
|
_patientProgressNoteList = [];
|
|
_patientProgressNoteList = response['List_GetPregressNoteForInPatient'];
|
|
|
|
},
|
|
onFailure: (String error, int statusCode) {
|
|
hasError = true;
|
|
super.error = error;
|
|
},
|
|
body: patient,
|
|
);
|
|
}
|
|
}
|