add medical report new service

merge-requests/757/head
hussam al-habibeh 5 years ago
parent 07835aaa1b
commit c652f40a89

@ -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";
@ -228,6 +228,10 @@ const ADD_REFERRED_REMARKS_NEW = "Services/DoctorApplication.svc/REST/AddReferre
const GET_SPECIAL_CLINICAL_CARE_LIST = "Services/DoctorApplication.svc/REST/GetSpecialClinicalCareList";
const GET_SPECIAL_CLINICAL_CARE_MAPPING_LIST = "Services/DoctorApplication.svc/REST/GetSpecialClinicalCareMappingList";
const INSERT_MEDICAL_REPORT = "Services/Patients.svc/REST/DAPP_InsertMedicalReport_New";
const UPDATE_MEDICAL_REPORT = "Services/Patients.svc/REST/DAPP_UpdateMedicalReport";
var selectedPatientType = 1;
//*********change value to decode json from Dropdown ************

@ -16,9 +16,7 @@ class PatientMedicalReportService extends BaseService {
body['SetupID'] = doctorProfile.setupID;
body['ProjectID'] = doctorProfile.projectID;
await baseAppClient.postPatient(PATIENT_MEDICAL_REPORT_GET_LIST,
onSuccess: (dynamic response, int statusCode) {
await baseAppClient.postPatient(PATIENT_MEDICAL_REPORT_GET_LIST, onSuccess: (dynamic response, int statusCode) {
medicalReportList.clear();
if (response['DAPP_ListMedicalReportList'] != null) {
response['DAPP_ListMedicalReportList'].forEach((v) {
@ -38,19 +36,17 @@ class PatientMedicalReportService extends BaseService {
body['SetupID'] = "91877";
body['TemplateID'] = 43;
await baseAppClient.post(PATIENT_MEDICAL_REPORT_GET_TEMPLATE,
onSuccess: (dynamic response, int statusCode) {
medicalReportTemplate.clear();
if (response['DAPP_GetTemplateByIDList'] != null) {
response['DAPP_GetTemplateByIDList'].forEach((v) {
medicalReportTemplate.add(MedicalReportTemplate.fromJson(v));
});
}
}, onFailure: (String error, int statusCode) {
hasError = true;
super.error = error.toString();
}, body: body);
await baseAppClient.post(PATIENT_MEDICAL_REPORT_GET_TEMPLATE, onSuccess: (dynamic response, int statusCode) {
medicalReportTemplate.clear();
if (response['DAPP_GetTemplateByIDList'] != null) {
response['DAPP_GetTemplateByIDList'].forEach((v) {
medicalReportTemplate.add(MedicalReportTemplate.fromJson(v));
});
}
}, onFailure: (String error, int statusCode) {
hasError = true;
super.error = error.toString();
}, body: body);
}
Future insertMedicalReport(PatiantInformtion patient, String htmlText) async {
@ -61,13 +57,11 @@ class PatientMedicalReportService extends BaseService {
body['AdmissionNo'] = patient.admissionNo;
body['MedicalReportHTML'] = htmlText;
await baseAppClient.postPatient(PATIENT_MEDICAL_REPORT_INSERT,
onSuccess: (dynamic response, int statusCode) {
}, onFailure: (String error, int statusCode) {
hasError = true;
super.error = error.toString();
}, body: body, patient: patient);
await baseAppClient.postPatient(PATIENT_MEDICAL_REPORT_INSERT, onSuccess: (dynamic response, int statusCode) {},
onFailure: (String error, int statusCode) {
hasError = true;
super.error = error.toString();
}, body: body, patient: patient);
}
Future verifyMedicalReport(PatiantInformtion patient, MedicalReportModel medicalReport) async {
@ -79,12 +73,48 @@ class PatientMedicalReportService extends BaseService {
body['InvoiceNo'] = medicalReport.invoiceNo;
body['LineItemNo'] = medicalReport.lineItemNo;
await baseAppClient.postPatient(PATIENT_MEDICAL_REPORT_VERIFIED,
onSuccess: (dynamic response, int statusCode) {
await baseAppClient.postPatient(PATIENT_MEDICAL_REPORT_VERIFIED, onSuccess: (dynamic response, int statusCode) {},
onFailure: (String error, int statusCode) {
hasError = true;
super.error = error.toString();
}, body: body, patient: patient);
}
}, onFailure: (String error, int statusCode) {
hasError = true;
super.error = error.toString();
}, body: body, patient: patient);
Future addMedicalReport(PatiantInformtion patient, String htmlText) async {
hasError = false;
Map<String, dynamic> body = Map();
// body['TokenID'] = "@dm!n";
body['SetupID'] = "91877";
body['AdmissionNo'] = int.parse(patient.admissionNo);
body['MedicalReportHTML'] = htmlText;
if (body['ProjectID'] == null) {
body['ProjectID'] = doctorProfile?.projectID;
}
if (body['DoctorID'] == null) body['DoctorID'] = doctorProfile?.doctorID;
await baseAppClient.postPatient(INSERT_MEDICAL_REPORT, onSuccess: (dynamic response, int statusCode) {},
onFailure: (String error, int statusCode) {
hasError = true;
super.error = error.toString();
}, body: body, patient: patient);
}
Future updateMedicalReport(PatiantInformtion patient, String htmlText) async {
hasError = false;
Map<String, dynamic> body = Map();
// body['TokenID'] = "@dm!n";
body['SetupID'] = "91877";
body['AdmissionNo'] = int.parse(patient.admissionNo);
body['MedicalReportHTML'] = htmlText;
if (body['ProjectID'] == null) {
body['ProjectID'] = doctorProfile?.projectID;
}
if (body['DoctorID'] == null) body['DoctorID'] = doctorProfile?.doctorID;
await baseAppClient.postPatient(INSERT_MEDICAL_REPORT, onSuccess: (dynamic response, int statusCode) {},
onFailure: (String error, int statusCode) {
hasError = true;
super.error = error.toString();
}, body: body, patient: patient);
}
}

@ -12,8 +12,7 @@ class PatientMedicalReportViewModel extends BaseViewModel {
List<MedicalReportModel> get medicalReportList => _service.medicalReportList;
List<MedicalReportTemplate> get medicalReportTemplate =>
_service.medicalReportTemplate;
List<MedicalReportTemplate> get medicalReportTemplate => _service.medicalReportTemplate;
Future getMedicalReportList(PatiantInformtion patient) async {
setState(ViewState.Busy);
@ -25,16 +24,15 @@ class PatientMedicalReportViewModel extends BaseViewModel {
setState(ViewState.Idle);
}
bool hasOnHold(){
bool hasOnHold() {
bool hasHold = false;
medicalReportList.forEach((element) {
if(element.status == 1){
if (element.status == 1) {
hasHold = true;
}
});
return hasHold;
}
Future getMedicalReportTemplate() async {
@ -57,8 +55,7 @@ class PatientMedicalReportViewModel extends BaseViewModel {
setState(ViewState.Idle);
}
Future verifyMedicalReport(
PatiantInformtion patient, MedicalReportModel medicalReport) async {
Future verifyMedicalReport(PatiantInformtion patient, MedicalReportModel medicalReport) async {
setState(ViewState.Busy);
await _service.verifyMedicalReport(patient, medicalReport);
if (_service.hasError) {
@ -67,4 +64,14 @@ class PatientMedicalReportViewModel extends BaseViewModel {
} else
setState(ViewState.Idle);
}
Future addMedicalReport(PatiantInformtion patient, String htmlText) async {
setState(ViewState.Busy);
await _service.addMedicalReport(patient, htmlText);
if (_service.hasError) {
error = _service.error;
setState(ViewState.ErrorLocal);
} else
setState(ViewState.Idle);
}
}

@ -28,9 +28,7 @@ class _AddVerifyMedicalReportState extends State<AddVerifyMedicalReport> {
final routeArgs = ModalRoute.of(context).settings.arguments as Map;
PatiantInformtion patient = routeArgs['patient'];
MedicalReportStatus status = routeArgs['status'];
MedicalReportModel medicalReport = routeArgs.containsKey("medicalReport")
? routeArgs['medicalReport']
: null;
MedicalReportModel medicalReport = routeArgs.containsKey("medicalReport") ? routeArgs['medicalReport'] : null;
return BaseView<PatientMedicalReportViewModel>(
onModelReady: (model) => model.getMedicalReportTemplate(),
@ -55,88 +53,82 @@ class _AddVerifyMedicalReportState extends State<AddVerifyMedicalReport> {
child: Container(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
// if (model.medicalReportTemplate.length > 0)
HtmlRichEditor(
initialText: (medicalReport != null
? medicalReport.reportDataHtml
: model.medicalReportTemplate
.length > 0 ? model
.medicalReportTemplate[0] : ""),
hint: "Write the medical report ",
height:
MediaQuery
.of(context)
.size
.height *
0.75,
children: [
// if (model.medicalReportTemplate.length > 0)
HtmlRichEditor(
initialText: (medicalReport != null
? medicalReport.reportDataHtml
: model.medicalReportTemplate[0].templateText.length > 0
? model.medicalReportTemplate[0].templateText
: ""),
hint: "Write the medical report ",
height: MediaQuery.of(context).size.height * 0.75,
),
],
),
],
),
),
),
),
],
),
),
],
),
),
),
Container(
padding: EdgeInsets.all(16.0),
color: Colors.white,
child: Row(
children: [
Expanded(
child: AppButton(
title: status == MedicalReportStatus.ADD
? TranslationBase.of(context).save
: TranslationBase.of(context).save,
color: Color(0xffEAEAEA),
fontColor: Colors.black,
// disabled: progressNoteController.text.isEmpty,
fontWeight: FontWeight.w700,
onPressed: () async {
String txtOfMedicalReport =
await HtmlEditor.getText();
),
Container(
padding: EdgeInsets.all(16.0),
color: Colors.white,
child: Row(
children: [
Expanded(
child: AppButton(
title: status == MedicalReportStatus.ADD
? TranslationBase.of(context).save
: TranslationBase.of(context).save,
color: Color(0xffEAEAEA),
fontColor: Colors.black,
// disabled: progressNoteController.text.isEmpty,
fontWeight: FontWeight.w700,
onPressed: () async {
String txtOfMedicalReport = await HtmlEditor.getText();
if (txtOfMedicalReport.isNotEmpty) {
GifLoaderDialogUtils.showMyDialog(context);
model.insertMedicalReport(
patient, txtOfMedicalReport);
GifLoaderDialogUtils.hideDialog(context);
if (model.state == ViewState.ErrorLocal) {
DrAppToastMsg.showErrorToast(model.error);
}
}
},
if (txtOfMedicalReport.isNotEmpty) {
GifLoaderDialogUtils.showMyDialog(context);
status == MedicalReportStatus.ADD
? model.addMedicalReport(patient, txtOfMedicalReport)
: model.addMedicalReport(patient, txtOfMedicalReport);
GifLoaderDialogUtils.hideDialog(context);
if (model.state == ViewState.ErrorLocal) {
DrAppToastMsg.showErrorToast(model.error);
}
}
},
),
),
SizedBox(
width: 8,
),
if (medicalReport != null)
Expanded(
child: AppButton(
title: status == MedicalReportStatus.ADD
? TranslationBase.of(context).add
: TranslationBase.of(context).verify,
color: Color(0xff359846),
fontWeight: FontWeight.w700,
onPressed: () async {
GifLoaderDialogUtils.showMyDialog(context);
await model.verifyMedicalReport(patient, medicalReport);
GifLoaderDialogUtils.hideDialog(context);
if (model.state == ViewState.ErrorLocal) {
DrAppToastMsg.showErrorToast(model.error);
}
},
),
),
],
),
),
SizedBox(
width: 8,
),
if (medicalReport != null)
Expanded(
child: AppButton(
title: status == MedicalReportStatus.ADD
? TranslationBase.of(context).add
: TranslationBase.of(context).verify,
color: Color(0xff359846),
fontWeight: FontWeight.w700,
onPressed: () async {
GifLoaderDialogUtils.showMyDialog(context);
await model.verifyMedicalReport(
patient, medicalReport);
GifLoaderDialogUtils.hideDialog(context);
if (model.state == ViewState.ErrorLocal) {
DrAppToastMsg.showErrorToast(model.error);
}
},
),
),
],
),
),
],
),
));
}

Loading…
Cancel
Save