get update_subjective_page.dart

pull/209/head
Elham Rababah 5 years ago
parent f0fd5d30e1
commit 39970fe1a8

@ -1,6 +1,7 @@
import 'package:doctor_app_flutter/config/config.dart';
import 'package:doctor_app_flutter/models/SOAP/ChiefComplaint/GetChiefComplaintResModel.dart';
import 'package:doctor_app_flutter/models/SOAP/GeneralGetReqForSOAP.dart';
import 'package:doctor_app_flutter/models/SOAP/GetAllergiesResModel.dart';
import 'package:doctor_app_flutter/models/SOAP/get_Allergies_request_model.dart';
import 'package:doctor_app_flutter/models/SOAP/master_key_model.dart';
import 'package:doctor_app_flutter/models/SOAP/post_allergy_request_model.dart';
@ -14,7 +15,8 @@ import 'package:doctor_app_flutter/widgets/patients/profile/soap_update/update_a
import 'base/lookup-service.dart';
class SOAPService extends LookupService {
List<GetChiefComplaintResModel> chiefComplaintList = [];
List<GetChiefComplaintResModel> patientChiefComplaintList = [];
List<GetAllergiesResModel> patientAllergiesList = [];
Future getAllergies(GetAllergiesRequestModel getAllergiesRequestModel) async {
await baseAppClient.post(
@ -181,16 +183,19 @@ class SOAPService extends LookupService {
Future getPatientAllergy(PostAllergyRequestModel getPatientAllergyRequestModel) async {
Future getPatientAllergy(GeneralGetReqForSOAP generalGetReqForSOAP) async {
hasError = false;
await baseAppClient.post (GET_ALLERGY,
onSuccess: (dynamic response, int statusCode) {
print("Success");
patientAllergiesList.clear();
response['List_Allergies']['entityList'].forEach((v) {
patientAllergiesList.add(GetAllergiesResModel.fromJson(v));
});
}, onFailure: (String error, int statusCode) {
hasError = true;
super.error = error;
}, body: getPatientAllergyRequestModel.toJson());
}, body: generalGetReqForSOAP.toJson());
}
Future getPatientHistories(
@ -206,19 +211,19 @@ class SOAPService extends LookupService {
}
Future getPatientChiefComplaint(
GeneralGetReqForSOAP getPatientChiefComplaintRequestModel) async {
GeneralGetReqForSOAP generalGetReqForSOAP) async {
hasError = false;
await baseAppClient.post (GET_CHIEF_COMPLAINT,
onSuccess: (dynamic response, int statusCode) {
print("Success");
chiefComplaintList.clear();
patientChiefComplaintList.clear();
response['List_ChiefComplaint']['entityList'].forEach((v) {
chiefComplaintList.add(GetChiefComplaintResModel.fromJson(v));
patientChiefComplaintList.add(GetChiefComplaintResModel.fromJson(v));
});
}, onFailure: (String error, int statusCode) {
hasError = true;
super.error = error;
}, body: getPatientChiefComplaintRequestModel.toJson());
}, body: generalGetReqForSOAP.toJson());
}
Future getPatientPhysicalExam(

@ -1,6 +1,7 @@
import 'package:doctor_app_flutter/config/config.dart';
import 'package:doctor_app_flutter/core/enum/master_lookup_key.dart';
import 'package:doctor_app_flutter/models/SOAP/master_key_model.dart';
import 'package:flutter/cupertino.dart';
import 'base_service.dart';
@ -130,4 +131,5 @@ class LookupService extends BaseService {
break;
}
}
}

@ -1,8 +1,9 @@
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/service/SOAP_service.dart';
import 'package:doctor_app_flutter/models/SOAP/Allergy_model.dart';
import 'package:doctor_app_flutter/models/SOAP/ChiefComplaint/GetChiefComplaintResModel.dart';
import 'package:doctor_app_flutter/models/SOAP/GeneralGetReqForSOAP.dart';
import 'package:doctor_app_flutter/models/SOAP/GetAllergiesResModel.dart';
import 'package:doctor_app_flutter/models/SOAP/get_Allergies_request_model.dart';
import 'package:doctor_app_flutter/models/SOAP/master_key_model.dart';
import 'package:doctor_app_flutter/models/SOAP/post_allergy_request_model.dart';
@ -12,6 +13,7 @@ import 'package:doctor_app_flutter/models/SOAP/post_histories_request_model.dart
import 'package:doctor_app_flutter/models/SOAP/post_physical_exam_request_model.dart';
import 'package:doctor_app_flutter/models/SOAP/post_progress_note_request_model.dart';
import 'package:doctor_app_flutter/widgets/patients/profile/soap_update/update_assessment_page.dart';
import 'package:flutter/material.dart';
import '../../locator.dart';
import 'base_view_model.dart';
@ -32,14 +34,29 @@ class SOAPViewModel extends BaseViewModel {
List<MasterKeyModel> get historySportList => _SOAPService.historySportList;
List<MasterKeyModel> get historySocialList => _SOAPService.historySocialList;
List<MasterKeyModel> get historySurgicalList => _SOAPService.historySurgicalList;
List<MasterKeyModel> get mergeHistorySurgicalWithHistorySportList => [...historySurgicalList,...historySportList];
List<MasterKeyModel> get physicalExaminationList => _SOAPService.physicalExaminationList;
List<MasterKeyModel> get listOfDiagnosisType => _SOAPService.listOfDiagnosisType;
List<MasterKeyModel> get listOfDiagnosisCondition => _SOAPService.listOfDiagnosisCondition;
List<MasterKeyModel> get listOfICD10 => _SOAPService.listOfICD10;
List<MasterKeyModel> get historySurgicalList =>
_SOAPService.historySurgicalList;
List<MasterKeyModel> get mergeHistorySurgicalWithHistorySportList =>
[...historySurgicalList, ...historySportList];
List<MasterKeyModel> get physicalExaminationList =>
_SOAPService.physicalExaminationList;
List<MasterKeyModel> get listOfDiagnosisType =>
_SOAPService.listOfDiagnosisType;
List<MasterKeyModel> get listOfDiagnosisCondition =>
_SOAPService.listOfDiagnosisCondition;
List<MasterKeyModel> get listOfICD10 => _SOAPService.listOfICD10;
List<GetChiefComplaintResModel> get chiefComplaintList =>
_SOAPService.patientChiefComplaintList;
List<GetAllergiesResModel> get patientAllergiesList =>
_SOAPService.patientAllergiesList;
Future getAllergies(GetAllergiesRequestModel getAllergiesRequestModel) async {
setState(ViewState.Busy);
@ -183,11 +200,9 @@ class SOAPViewModel extends BaseViewModel {
}
Future getPatientAllergy(PostAllergyRequestModel getPatientAllergyRequestModel) async {
Future getPatientAllergy(GeneralGetReqForSOAP generalGetReqForSOAP) async {
setState(ViewState.Busy);
await _SOAPService.getPatientAllergy(getPatientAllergyRequestModel);
await _SOAPService.getPatientAllergy(generalGetReqForSOAP);
if (_SOAPService.hasError) {
error = _SOAPService.error;
setState(ViewState.Busy);
@ -205,9 +220,10 @@ class SOAPViewModel extends BaseViewModel {
setState(ViewState.Idle);
}
Future getPatientChiefComplaint(GeneralGetReqForSOAP getPatientChiefComplaintRequestModel) async {
Future getPatientChiefComplaint(
GeneralGetReqForSOAP generalGetReqForSOAP) async {
setState(ViewState.Busy);
await _SOAPService.getPatientChiefComplaint(getPatientChiefComplaintRequestModel);
await _SOAPService.getPatientChiefComplaint(generalGetReqForSOAP);
if (_SOAPService.hasError) {
error = _SOAPService.error;
setState(ViewState.Busy);
@ -235,7 +251,8 @@ class SOAPViewModel extends BaseViewModel {
setState(ViewState.Idle);
}
Future getPatientAssessment(PostAssessmentRequestModel getPatientAssessmentRequestModel) async {
Future getPatientAssessment(
PostAssessmentRequestModel getPatientAssessmentRequestModel) async {
setState(ViewState.Busy);
await _SOAPService.getPatientAssessment(getPatientAssessmentRequestModel);
if (_SOAPService.hasError) {
@ -245,4 +262,133 @@ class SOAPViewModel extends BaseViewModel {
setState(ViewState.Idle);
}
// ignore: missing_return
MasterKeyModel getOneMasterKey(
{@required MasterKeysService masterKeys, int id, int typeId}) {
switch (masterKeys) {
case MasterKeysService.Allergies:
List<MasterKeyModel> result = allergiesList.where((element) {
print(element.id == id);
return element.id == id &&
element.typeId == masterKeys.getMasterKeyService();
}).toList();
if (result.isNotEmpty) {
return result.first;
}
break;
case MasterKeysService.HistoryFamily:
List<MasterKeyModel> result = historyFamilyList.where((element) {
print(element.id == id);
return element.id == id &&
element.typeId == masterKeys.getMasterKeyService();
}).toList();
if (result.isNotEmpty) {
return result.first;
}
break;
case MasterKeysService.HistoryMedical:
List<MasterKeyModel> result = historyMedicalList.where((element) {
print(element.id == id);
return element.id == id &&
element.typeId == masterKeys.getMasterKeyService();
}).toList();
if (result.isNotEmpty) {
return result.first;
}
break;
case MasterKeysService.HistorySocial:
List<MasterKeyModel> result = historySocialList.where((element) {
print(element.id == id);
return element.id == id &&
element.typeId == masterKeys.getMasterKeyService();
}).toList();
if (result.isNotEmpty) {
return result.first;
}
break;
case MasterKeysService.HistorySports:
List<MasterKeyModel> result = historySocialList.where((element) {
print(element.id == id);
return element.id == id &&
element.typeId == masterKeys.getMasterKeyService();
}).toList();
if (result.isNotEmpty) {
return result.first;
}
break;
case MasterKeysService.HistorySurgical:
List<MasterKeyModel> result = historySurgicalList.where((element) {
print(element.id == id);
return element.id == id &&
element.typeId == masterKeys.getMasterKeyService();
}).toList();
if (result.isNotEmpty) {
return result.first;
}
break;
case MasterKeysService.PhysicalExamination:
List<MasterKeyModel> result = physicalExaminationList.where((element) {
print(element.id == id);
return element.id == id &&
element.typeId == masterKeys.getMasterKeyService();
}).toList();
if (result.isNotEmpty) {
return result.first;
}
break;
case MasterKeysService.AllergySeverity:
List<MasterKeyModel> result = allergySeverityList.where((element) {
print(element.id == id);
return element.id == id &&
element.typeId == masterKeys.getMasterKeyService();
}).toList();
if (result.isNotEmpty) {
return result.first;
}
break;
// case MasterKeysService.physiotherapyGoals:
// listOfPhysiotherapyGoals.clear();
// entryList.forEach((v) {
// listOfPhysiotherapyGoals.add(MasterKeyModel.fromJson(v));
// });
// break;
case MasterKeysService.DiagnosisType:
List<MasterKeyModel> result = listOfDiagnosisType.where((element) {
print(element.id == id);
return element.id == id &&
element.typeId == masterKeys.getMasterKeyService();
}).toList();
if (result.isNotEmpty) {
return result.first;
}
break;
case MasterKeysService.DiagnosisCondition:
List<MasterKeyModel> result = listOfDiagnosisCondition.where((element) {
print(element.id == id);
return element.id == id &&
element.typeId == masterKeys.getMasterKeyService();
}).toList();
if (result.isNotEmpty) {
return result.first;
}
break;
case MasterKeysService.ICD10:
listOfICD10.clear();
List<MasterKeyModel> result = listOfICD10.where((element) {
print(element.id == id);
return element.id == id &&
element.typeId == masterKeys.getMasterKeyService();
}).toList();
if (result.isNotEmpty) {
return result.first;
}
break;
break;
}
}
}

@ -0,0 +1,60 @@
class GetAllergiesResModel {
int allergyDiseaseId;
String allergyDiseaseName;
int allergyDiseaseType;
int appointmentNo;
int createdBy;
String createdByName;
String createdOn;
int episodeID;
bool isChecked;
bool isUpdatedByNurse;
int severity;
String severityName;
GetAllergiesResModel(
{this.allergyDiseaseId,
this.allergyDiseaseName,
this.allergyDiseaseType,
this.appointmentNo,
this.createdBy,
this.createdByName,
this.createdOn,
this.episodeID,
this.isChecked,
this.isUpdatedByNurse,
this.severity,
this.severityName});
GetAllergiesResModel.fromJson(Map<String, dynamic> json) {
allergyDiseaseId = json['allergyDiseaseId'];
allergyDiseaseName = json['allergyDiseaseName'];
allergyDiseaseType = json['allergyDiseaseType'];
appointmentNo = json['appointmentNo'];
createdBy = json['createdBy'];
createdByName = json['createdByName'];
createdOn = json['createdOn'];
episodeID = json['episodeID'];
isChecked = json['isChecked'];
isUpdatedByNurse = json['isUpdatedByNurse'];
severity = json['severity'];
severityName = json['severityName'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['allergyDiseaseId'] = this.allergyDiseaseId;
data['allergyDiseaseName'] = this.allergyDiseaseName;
data['allergyDiseaseType'] = this.allergyDiseaseType;
data['appointmentNo'] = this.appointmentNo;
data['createdBy'] = this.createdBy;
data['createdByName'] = this.createdByName;
data['createdOn'] = this.createdOn;
data['episodeID'] = this.episodeID;
data['isChecked'] = this.isChecked;
data['isUpdatedByNurse'] = this.isUpdatedByNurse;
data['severity'] = this.severity;
data['severityName'] = this.severityName;
return data;
}
}

@ -1,7 +1,9 @@
import 'package:doctor_app_flutter/client/base_app_client.dart';
import 'package:doctor_app_flutter/config/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/viewModel/SOAP_view_model.dart';
import 'package:doctor_app_flutter/models/SOAP/GeneralGetReqForSOAP.dart';
import 'package:doctor_app_flutter/models/SOAP/master_key_model.dart';
import 'package:doctor_app_flutter/models/SOAP/my_selected_allergy.dart';
import 'package:doctor_app_flutter/models/SOAP/post_allergy_request_model.dart';
@ -10,8 +12,6 @@ import 'package:doctor_app_flutter/models/SOAP/post_histories_request_model.dart
import 'package:doctor_app_flutter/models/patient/patiant_info_model.dart';
import 'package:doctor_app_flutter/screens/base/base_view.dart';
import 'package:doctor_app_flutter/util/translations_delegate_base.dart';
import 'package:doctor_app_flutter/widgets/patients/profile/SOAP/subjective/add_allergies_widget.dart';
import 'package:doctor_app_flutter/widgets/patients/profile/SOAP/subjective/add_history_widget.dart';
import 'package:doctor_app_flutter/widgets/patients/profile/soap_update/subjective/update_allergies_widget.dart';
import 'package:doctor_app_flutter/widgets/patients/profile/soap_update/subjective/update_history_widget.dart';
import 'package:doctor_app_flutter/widgets/shared/Text.dart';
@ -51,7 +51,41 @@ class _UpdateSubjectivePageState extends State<UpdateSubjectivePage> {
@override
Widget build(BuildContext context) {
return BaseView<SOAPViewModel>(
// onModelReady: (model) => model.getMasterLookup(MasterKeysService.Allergies),
onModelReady: (model) async {
GeneralGetReqForSOAP generalGetReqForSOAP = GeneralGetReqForSOAP(
patientMRN: widget.patientInfo.patientMRN,
episodeId: widget.patientInfo.episodeNo,
appointmentNo: widget.patientInfo.appointmentNo);
if (model.allergiesList.isEmpty)
await model.getMasterLookup(MasterKeysService.Allergies);
if (model.allergySeverityList.isEmpty)
await model.getMasterLookup(MasterKeysService.AllergySeverity);
await model.getPatientChiefComplaint(generalGetReqForSOAP);
if (model.chiefComplaintList.isNotEmpty) {
complaintsController.text =
model.chiefComplaintList[0].chiefComplaint;
illnessController.text = model.chiefComplaintList[0].hopi;
}
await model.getPatientAllergy(generalGetReqForSOAP);
if (model.patientAllergiesList.isNotEmpty) {
model.patientAllergiesList.forEach((element) {
MasterKeyModel selectedAllergy = model.getOneMasterKey(
masterKeys: MasterKeysService.Allergies,
id: element.allergyDiseaseId,
typeId: element.allergyDiseaseType);
MasterKeyModel selectedAllergySeverity = model.getOneMasterKey(
masterKeys: MasterKeysService.AllergySeverity,
id: element.severity,
);
MySelectedAllergy mySelectedAllergy = MySelectedAllergy(
selectedAllergy: selectedAllergy,
selectedAllergySeverity: selectedAllergySeverity);
widget.myAllergiesList.add(mySelectedAllergy);
});
}
},
builder: (_, model, w) => AppScaffold(
isShowAppBar: false,
baseViewModel: model,
@ -279,45 +313,45 @@ class _UpdateSubjectivePageState extends State<UpdateSubjectivePage> {
formKey.currentState.validate();
// if(complaintsController.text.isNotEmpty && illnessController.text.isNotEmpty && complaintsController.text.length>25) {
// await postChiefComplaint(model: model);
// if (model.state == ViewState.ErrorLocal) {
// helpers.showErrorToast(model.error);
// } else {
// if (myHistoryList.length != 0) {
// await postHistories(model: model, myHistoryList: myHistoryList);
// if (model.state == ViewState.ErrorLocal) {
// helpers.showErrorToast(model.error);
// } else {
// if (myAllergiesList.length != 0) {
// await postAllergy(myAllergiesList: myAllergiesList, model: model);
// if (model.state == ViewState.ErrorLocal) {
// helpers.showErrorToast(model.error);
// } else {
// widget.changePageViewIndex(1);
// }
// } else {
// widget.changePageViewIndex(1);
//
// }
//
// }
// } else {
// if (myAllergiesList.length != 0) {
// await postAllergy(myAllergiesList: myAllergiesList, model: model);
// if (model.state == ViewState.ErrorLocal) {
// helpers.showErrorToast(model.error);
// } else {
// widget.changePageViewIndex(1);
// }
// } else {
// widget.changePageViewIndex(1);
// }
// }
// }
// } else {
// helpers.showErrorToast('Please add required field correctly');
// }
if (complaintsController.text.isNotEmpty &&
illnessController.text.isNotEmpty &&
complaintsController.text.length > 25) {
await postChiefComplaint(model: model);
if (model.state == ViewState.ErrorLocal) {
helpers.showErrorToast(model.error);
} else {
if (myHistoryList.length != 0) {
await postHistories(model: model, myHistoryList: myHistoryList);
if (model.state == ViewState.ErrorLocal) {
helpers.showErrorToast(model.error);
} else {
if (myAllergiesList.length != 0) {
await postAllergy(myAllergiesList: myAllergiesList, model: model);
if (model.state == ViewState.ErrorLocal) {
helpers.showErrorToast(model.error);
} else {
widget.changePageViewIndex(1);
}
} else {
widget.changePageViewIndex(1);
}
}
} else {
if (myAllergiesList.length != 0) {
await postAllergy(myAllergiesList: myAllergiesList, model: model);
if (model.state == ViewState.ErrorLocal) {
helpers.showErrorToast(model.error);
} else {
widget.changePageViewIndex(1);
}
} else {
widget.changePageViewIndex(1);
}
}
}
} else {
helpers.showErrorToast('Please add required field correctly');
}
widget.changePageViewIndex(1);
@ -334,22 +368,28 @@ class _UpdateSubjectivePageState extends State<UpdateSubjectivePage> {
//TODO: make static value dynamic
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: 1485,
//
createdOn: DateTime.now().toIso8601String(),//"2020-08-14T20:37:22.780Z",
editedBy: 1485,
editedOn: DateTime.now().toIso8601String(),//"2020-08-14T20:37:22.780Z",
isChecked: false,
isUpdatedByNurse: false));
allergyDiseaseId: allergy.selectedAllergy.id,
allergyDiseaseType: allergy.selectedAllergy.id,
patientMRN: widget.patientInfo.patientMRN,
episodeId: widget.patientInfo.episodeNo,
appointmentNo: widget.patientInfo.appointmentNo,
severity: allergy.selectedAllergySeverity.id,
remarks: allergy.remark,
createdBy: 4709,
//
createdOn: DateTime.now().toIso8601String(),
//"2020-08-14T20:37:22.780Z",
editedBy: 4709,
editedOn: DateTime.now().toIso8601String(),
//"2020-08-14T20:37:22.780Z",
isChecked: false,
isUpdatedByNurse: false));
});
await model.patchAllergy(postAllergyRequestModel);
if (model.patientAllergiesList.isEmpty) {
await model.postAllergy(postAllergyRequestModel);
} else {
await model.patchAllergy(postAllergyRequestModel);
}
if (model.state == ViewState.ErrorLocal) {
helpers.showErrorToast(model.error);
@ -374,6 +414,14 @@ class _UpdateSubjectivePageState extends State<UpdateSubjectivePage> {
isChecked: false,
));
});
if (model.patientAllergiesList.isEmpty) {
await model.postHistories(postHistoriesRequestModel);
} else {
await model.patchHistories(postHistoriesRequestModel);
}
await model.patchHistories(postHistoriesRequestModel);
if (model.state == ViewState.ErrorLocal) {

@ -6,7 +6,11 @@ import 'package:doctor_app_flutter/models/SOAP/my_selected_examination.dart';
import 'package:doctor_app_flutter/models/patient/patiant_info_model.dart';
import 'package:doctor_app_flutter/screens/base/base_view.dart';
import 'package:doctor_app_flutter/util/translations_delegate_base.dart';
import 'package:doctor_app_flutter/widgets/patients/profile/SOAP/assessment_page.dart';
import 'package:doctor_app_flutter/widgets/patients/profile/SOAP/objective_page.dart';
import 'package:doctor_app_flutter/widgets/patients/profile/SOAP/plan_page.dart';
import 'package:doctor_app_flutter/widgets/patients/profile/SOAP/steps_widget.dart';
import 'package:doctor_app_flutter/widgets/patients/profile/SOAP/subjective/subjective_page.dart';
import 'package:doctor_app_flutter/widgets/patients/profile/patient-page-header-widget.dart';
import 'package:doctor_app_flutter/widgets/patients/profile/soap_update/subjective/update_subjective_page.dart';
import 'package:doctor_app_flutter/widgets/patients/profile/soap_update/update_assessment_page.dart';

Loading…
Cancel
Save