improve add subjective info

replay_status
Elham Rababh 5 years ago
parent 7ef7c8225c
commit 92c791dd72

@ -85,7 +85,7 @@ class SOAPService extends LookupService {
print("Success"); print("Success");
}, onFailure: (String error, int statusCode) { }, onFailure: (String error, int statusCode) {
hasError = true; hasError = true;
super.error = error; super.error = super.error+ "\n"+error;
}, body: postAllergyRequestModel.toJson()); }, body: postAllergyRequestModel.toJson());
} }
@ -97,13 +97,14 @@ class SOAPService extends LookupService {
print("Success"); print("Success");
}, onFailure: (String error, int statusCode) { }, onFailure: (String error, int statusCode) {
hasError = true; hasError = true;
super.error = error; super.error =super.error + "\n"+error;
}, body: postHistoriesRequestModel.toJson()); }, body: postHistoriesRequestModel.toJson());
} }
Future postChiefComplaint( Future postChiefComplaint(
PostChiefComplaintRequestModel postChiefComplaintRequestModel) async { PostChiefComplaintRequestModel postChiefComplaintRequestModel) async {
hasError = false; hasError = false;
super.error ="";
await baseAppClient.post(POST_CHIEF_COMPLAINT, await baseAppClient.post(POST_CHIEF_COMPLAINT,
onSuccess: (dynamic response, int statusCode) { onSuccess: (dynamic response, int statusCode) {
print("Success"); print("Success");
@ -157,7 +158,7 @@ class SOAPService extends LookupService {
print("Success"); print("Success");
}, onFailure: (String error, int statusCode) { }, onFailure: (String error, int statusCode) {
hasError = true; hasError = true;
super.error = error; super.error = "\n"+error;
}, body: patchAllergyRequestModel.toJson()); }, body: patchAllergyRequestModel.toJson());
} }
@ -169,13 +170,14 @@ class SOAPService extends LookupService {
print("Success"); print("Success");
}, onFailure: (String error, int statusCode) { }, onFailure: (String error, int statusCode) {
hasError = true; hasError = true;
super.error = error; super.error = super.error +"\n"+error;
}, body: patchHistoriesRequestModel.toJson()); }, body: patchHistoriesRequestModel.toJson());
} }
Future patchChiefComplaint( Future patchChiefComplaint(
PostChiefComplaintRequestModel patchChiefComplaintRequestModel) async { PostChiefComplaintRequestModel patchChiefComplaintRequestModel) async {
hasError = false; hasError = false;
super.error ="";
await baseAppClient.post(PATCH_CHIEF_COMPLAINT, await baseAppClient.post(PATCH_CHIEF_COMPLAINT,
onSuccess: (dynamic response, int statusCode) { onSuccess: (dynamic response, int statusCode) {
print("Success"); print("Success");

@ -28,7 +28,9 @@ import 'package:doctor_app_flutter/models/SOAP/post_chief_complaint_request_mode
import 'package:doctor_app_flutter/models/SOAP/post_histories_request_model.dart'; 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_physical_exam_request_model.dart';
import 'package:doctor_app_flutter/models/SOAP/post_progress_note_request_model.dart'; import 'package:doctor_app_flutter/models/SOAP/post_progress_note_request_model.dart';
import 'package:doctor_app_flutter/models/SOAP/selected_items/my_selected_allergy.dart';
import 'package:doctor_app_flutter/models/SOAP/selected_items/my_selected_examination.dart'; import 'package:doctor_app_flutter/models/SOAP/selected_items/my_selected_examination.dart';
import 'package:doctor_app_flutter/models/SOAP/selected_items/my_selected_history.dart';
import 'package:doctor_app_flutter/models/patient/patiant_info_model.dart'; import 'package:doctor_app_flutter/models/patient/patiant_info_model.dart';
import 'package:doctor_app_flutter/screens/patients/profile/soap_update/assessment/assessment_call_back.dart'; import 'package:doctor_app_flutter/screens/patients/profile/soap_update/assessment/assessment_call_back.dart';
import 'package:doctor_app_flutter/screens/patients/profile/soap_update/objective/objective_call_back.dart'; import 'package:doctor_app_flutter/screens/patients/profile/soap_update/objective/objective_call_back.dart';
@ -199,38 +201,6 @@ class SOAPViewModel extends BaseViewModel {
setState(ViewState.Idle); setState(ViewState.Idle);
} }
Future postAllergy(PostAllergyRequestModel postAllergyRequestModel) async {
setState(ViewState.BusyLocal);
await _SOAPService.postAllergy(postAllergyRequestModel);
if (_SOAPService.hasError) {
error = _SOAPService.error;
setState(ViewState.ErrorLocal);
} else
setState(ViewState.Idle);
}
Future postHistories(
PostHistoriesRequestModel postHistoriesRequestModel) async {
setState(ViewState.BusyLocal);
await _SOAPService.postHistories(postHistoriesRequestModel);
if (_SOAPService.hasError) {
error = _SOAPService.error;
setState(ViewState.ErrorLocal);
} else
setState(ViewState.Idle);
}
Future postChiefComplaint(
PostChiefComplaintRequestModel postChiefComplaintRequestModel) async {
setState(ViewState.BusyLocal);
await _SOAPService.postChiefComplaint(postChiefComplaintRequestModel);
if (_SOAPService.hasError) {
error = _SOAPService.error;
setState(ViewState.ErrorLocal);
} else
setState(ViewState.Idle);
}
Future postPhysicalExam( Future postPhysicalExam(
PostPhysicalExamRequestModel postPhysicalExamRequestModel) async { PostPhysicalExamRequestModel postPhysicalExamRequestModel) async {
setState(ViewState.BusyLocal); setState(ViewState.BusyLocal);
@ -264,38 +234,6 @@ class SOAPViewModel extends BaseViewModel {
setState(ViewState.Idle); setState(ViewState.Idle);
} }
Future patchAllergy(PostAllergyRequestModel patchAllergyRequestModel) async {
setState(ViewState.BusyLocal);
await _SOAPService.patchAllergy(patchAllergyRequestModel);
if (_SOAPService.hasError) {
error = _SOAPService.error;
setState(ViewState.ErrorLocal);
} else
setState(ViewState.Idle);
}
Future patchHistories(
PostHistoriesRequestModel patchHistoriesRequestModel) async {
setState(ViewState.BusyLocal);
await _SOAPService.patchHistories(patchHistoriesRequestModel);
if (_SOAPService.hasError) {
error = _SOAPService.error;
setState(ViewState.ErrorLocal);
} else
setState(ViewState.Idle);
}
Future patchChiefComplaint(
PostChiefComplaintRequestModel patchChiefComplaintRequestModel) async {
setState(ViewState.BusyLocal);
await _SOAPService.patchChiefComplaint(patchChiefComplaintRequestModel);
if (_SOAPService.hasError) {
error = _SOAPService.error;
setState(ViewState.ErrorLocal);
} else
setState(ViewState.Idle);
}
Future patchPhysicalExam( Future patchPhysicalExam(
PostPhysicalExamRequestModel patchPhysicalExamRequestModel) async { PostPhysicalExamRequestModel patchPhysicalExamRequestModel) async {
setState(ViewState.BusyLocal); setState(ViewState.BusyLocal);
@ -361,28 +299,6 @@ class SOAPViewModel extends BaseViewModel {
return allergiesString; return allergiesString;
} }
Future getPatientHistories(GetHistoryReqModel getHistoryReqModel,
{bool isFirst = false}) async {
setState(ViewState.Busy);
await _SOAPService.getPatientHistories(getHistoryReqModel,
isFirst: isFirst);
if (_SOAPService.hasError) {
error = _SOAPService.error;
setState(ViewState.Error);
} else
setState(ViewState.Idle);
}
Future getPatientChiefComplaint(
GetChiefComplaintReqModel getChiefComplaintReqModel) async {
setState(ViewState.Busy);
await _SOAPService.getPatientChiefComplaint(getChiefComplaintReqModel);
if (_SOAPService.hasError) {
error = _SOAPService.error;
setState(ViewState.Error);
} else
setState(ViewState.Idle);
}
Future getPatientPhysicalExam( Future getPatientPhysicalExam(
PatiantInformtion patientInfo, PatiantInformtion patientInfo,
@ -742,20 +658,16 @@ class SOAPViewModel extends BaseViewModel {
} }
} }
if (allMedicationList.length == 0) { if (allMedicationList.length == 0) {
await getMedicationList();
if (services == null) { if (services == null) {
services = [ services = [_prescriptionService.getMedicationList()];
_prescriptionService.getMedicationList()
];
} else { } else {
services.add( services.add(_prescriptionService.getMedicationList());
_prescriptionService.getMedicationList());
} }
} }
final results = await Future.wait(services ?? []); final results = await Future.wait(services ?? []);
if (_SOAPService.hasError ||_prescriptionService.hasError ) { if (_SOAPService.hasError || _prescriptionService.hasError) {
error = _SOAPService.error + _prescriptionService.error; error = _SOAPService.error + _prescriptionService.error;
setState(ViewState.ErrorLocal); setState(ViewState.ErrorLocal);
} else } else
@ -763,8 +675,7 @@ class SOAPViewModel extends BaseViewModel {
} }
callAddAssessmentLookupsServices({bool allowSetState = true}) async { callAddAssessmentLookupsServices({bool allowSetState = true}) async {
if(allowSetState) if (allowSetState) setState(ViewState.Busy);
setState(ViewState.Busy);
var services; var services;
if (listOfDiagnosisCondition.length == 0) { if (listOfDiagnosisCondition.length == 0) {
if (services == null) { if (services == null) {
@ -782,59 +693,177 @@ class SOAPViewModel extends BaseViewModel {
_SOAPService.getMasterLookup(MasterKeysService.DiagnosisType) _SOAPService.getMasterLookup(MasterKeysService.DiagnosisType)
]; ];
} else { } else {
services.add(_SOAPService.getMasterLookup( services
MasterKeysService.DiagnosisType)); .add(_SOAPService.getMasterLookup(MasterKeysService.DiagnosisType));
} }
} }
if (listOfICD10.length == 0) { if (listOfICD10.length == 0) {
if (services == null) { if (services == null) {
services = [ services = [_SOAPService.getMasterLookup(MasterKeysService.ICD10)];
_SOAPService.getMasterLookup(MasterKeysService.ICD10)
];
} else { } else {
services.add( services.add(_SOAPService.getMasterLookup(MasterKeysService.ICD10));
_SOAPService.getMasterLookup(MasterKeysService.ICD10));
} }
} }
final results = await Future.wait(services ?? []); final results = await Future.wait(services ?? []);
if(allowSetState) { if (allowSetState) {
if (_SOAPService.hasError) { if (_SOAPService.hasError) {
error = _SOAPService.error; error = _SOAPService.error;
setState(ViewState.ErrorLocal); setState(ViewState.ErrorLocal);
} else } else
setState(ViewState.Idle); setState(ViewState.Idle);
} }
} }
onUpdateAssessmentStepStart(PatiantInformtion patientInfo) async { onUpdateAssessmentStepStart(PatiantInformtion patientInfo) async {
GetAssessmentReqModel getAssessmentReqModel = GetAssessmentReqModel( GetAssessmentReqModel getAssessmentReqModel = GetAssessmentReqModel(
patientMRN: patientInfo.patientMRN, patientMRN: patientInfo.patientMRN,
episodeID: patientInfo.episodeNo.toString(), episodeID: patientInfo.episodeNo.toString(),
editedBy: '', editedBy: '',
doctorID: '', doctorID: '',
appointmentNo: appointmentNo: int.parse(patientInfo.appointmentNo.toString()));
int.parse(patientInfo.appointmentNo.toString()));
var services = [ var services = [_SOAPService.getPatientAssessment(getAssessmentReqModel)];
_SOAPService.getPatientAssessment(getAssessmentReqModel)
];
final results = await Future.wait(services); final results = await Future.wait(services);
if (patientAssessmentList.isNotEmpty) { if (patientAssessmentList.isNotEmpty) {
await callAddAssessmentLookupsServices(allowSetState: false); await callAddAssessmentLookupsServices(allowSetState: false);
} }
if (_SOAPService.hasError) { if (_SOAPService.hasError) {
error = _SOAPService.error; error = _SOAPService.error;
setState(ViewState.ErrorLocal); setState(ViewState.ErrorLocal);
} else
setState(ViewState.Idle);
}
postSubjectServices(
{patientInfo,
String complaintsText,
String medicationText,
String illnessText,
List<MySelectedHistory> myHistoryList,
List<MySelectedAllergy> myAllergiesList}) async {
var services;
PostChiefComplaintRequestModel postChiefComplaintRequestModel =
createPostChiefComplaintRequestModel(
patientInfo: patientInfo,
illnessText: illnessText,
medicationText: medicationText,
complaintsText: complaintsText);
if (patientChiefComplaintList.isEmpty) {
postChiefComplaintRequestModel.editedBy = '';
services = [
_SOAPService.postChiefComplaint(postChiefComplaintRequestModel)
];
} else {
postChiefComplaintRequestModel.editedBy = '';
services = [
_SOAPService.patchChiefComplaint(postChiefComplaintRequestModel)
];
}
if (myHistoryList.length != 0) {
PostHistoriesRequestModel postHistoriesRequestModel =
createPostHistoriesRequestModel(
patientInfo: patientInfo, myHistoryList: myHistoryList);
if (patientHistoryList.isEmpty) {
services.add(_SOAPService.postHistories(postHistoriesRequestModel));
} else {
services.add(_SOAPService.patchHistories(postHistoriesRequestModel));
}
}
if (myAllergiesList.length != 0) {
PostAllergyRequestModel postAllergyRequestModel =createPostAllergyRequestModel (myAllergiesList:myAllergiesList, patientInfo: patientInfo);
if (patientAllergiesList.isEmpty) {
services.add(_SOAPService.postAllergy(postAllergyRequestModel));
} else {
services.add(_SOAPService.patchAllergy(postAllergyRequestModel));
}
}
final results = await Future.wait(services);
if (_SOAPService.hasError) {
error = _SOAPService.error;
setState(ViewState.ErrorLocal);
} else } else
setState(ViewState.Idle); setState(ViewState.Idle);
}
PostChiefComplaintRequestModel createPostChiefComplaintRequestModel(
{patientInfo,
String complaintsText,
String medicationText,
String illnessText}) {
return new PostChiefComplaintRequestModel(
admissionNo: patientInfo.admissionNo != null
? int.parse(patientInfo.admissionNo)
: null,
patientMRN: patientInfo.patientMRN,
episodeID: patientInfo.episodeNo ?? 0,
appointmentNo: patientInfo.appointmentNo ?? 0,
chiefComplaint: complaintsText,
currentMedication: medicationText,
hopi: illnessText,
isLactation: false,
ispregnant: false,
doctorID: '',
numberOfWeeks: 0);
}
PostHistoriesRequestModel createPostHistoriesRequestModel(
{patientInfo, List<MySelectedHistory> myHistoryList}) {
PostHistoriesRequestModel postHistoriesRequestModel =
new PostHistoriesRequestModel(doctorID: '');
myHistoryList.forEach((history) {
if (postHistoriesRequestModel.listMedicalHistoryVM == null)
postHistoriesRequestModel.listMedicalHistoryVM = [];
postHistoriesRequestModel.listMedicalHistoryVM.add(ListMedicalHistoryVM(
patientMRN: patientInfo.patientMRN,
episodeId: patientInfo.episodeNo,
appointmentNo: patientInfo.appointmentNo,
remarks: "",
historyId: history.selectedHistory.id,
historyType: history.selectedHistory.typeId,
isChecked: history.isChecked,
));
});
return postHistoriesRequestModel;
}
PostAllergyRequestModel createPostAllergyRequestModel({myAllergiesList, patientInfo}){
PostAllergyRequestModel postAllergyRequestModel =
new PostAllergyRequestModel();
myAllergiesList.forEach((allergy) {
if (postAllergyRequestModel.listHisProgNotePatientAllergyDiseaseVM ==
null)
postAllergyRequestModel.listHisProgNotePatientAllergyDiseaseVM = [];
postAllergyRequestModel.listHisProgNotePatientAllergyDiseaseVM.add(
ListHisProgNotePatientAllergyDiseaseVM(
allergyDiseaseId: allergy.selectedAllergy.id,
allergyDiseaseType: allergy.selectedAllergy.typeId,
patientMRN: patientInfo.patientMRN,
episodeId: patientInfo.episodeNo,
appointmentNo: patientInfo.appointmentNo,
severity: allergy.selectedAllergySeverity.id,
remarks: allergy.remark,
createdBy: allergy.createdBy ?? doctorProfile.doctorID,
createdOn: DateTime.now().toIso8601String(),
editedBy: doctorProfile.doctorID,
editedOn: DateTime.now().toIso8601String(),
isChecked: allergy.isChecked,
isUpdatedByNurse: false));
});
return postAllergyRequestModel;
} }
} }

@ -1,7 +1,6 @@
import 'package:autocomplete_textfield/autocomplete_textfield.dart'; import 'package:autocomplete_textfield/autocomplete_textfield.dart';
import 'package:doctor_app_flutter/config/shared_pref_kay.dart'; import 'package:doctor_app_flutter/config/shared_pref_kay.dart';
import 'package:doctor_app_flutter/config/size_config.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/enum/viewstate.dart';
import 'package:doctor_app_flutter/core/viewModel/SOAP_view_model.dart'; import 'package:doctor_app_flutter/core/viewModel/SOAP_view_model.dart';
import 'package:doctor_app_flutter/core/viewModel/project_view_model.dart'; import 'package:doctor_app_flutter/core/viewModel/project_view_model.dart';

@ -1,7 +1,6 @@
// ignore: must_be_immutable // ignore: must_be_immutable
import 'package:autocomplete_textfield/autocomplete_textfield.dart'; import 'package:autocomplete_textfield/autocomplete_textfield.dart';
import 'package:doctor_app_flutter/config/size_config.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/enum/viewstate.dart';
import 'package:doctor_app_flutter/core/model/search_drug/get_medication_response_model.dart'; import 'package:doctor_app_flutter/core/model/search_drug/get_medication_response_model.dart';
import 'package:doctor_app_flutter/core/viewModel/SOAP_view_model.dart'; import 'package:doctor_app_flutter/core/viewModel/SOAP_view_model.dart';

@ -1,16 +1,9 @@
import 'package:doctor_app_flutter/config/shared_pref_kay.dart';
import 'package:doctor_app_flutter/config/size_config.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/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/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/master_key_model.dart';
import 'package:doctor_app_flutter/models/SOAP/post_allergy_request_model.dart';
import 'package:doctor_app_flutter/models/SOAP/post_chief_complaint_request_model.dart';
import 'package:doctor_app_flutter/models/SOAP/post_histories_request_model.dart';
import 'package:doctor_app_flutter/models/SOAP/selected_items/my_selected_allergy.dart'; import 'package:doctor_app_flutter/models/SOAP/selected_items/my_selected_allergy.dart';
import 'package:doctor_app_flutter/models/SOAP/selected_items/my_selected_history.dart'; import 'package:doctor_app_flutter/models/SOAP/selected_items/my_selected_history.dart';
import 'package:doctor_app_flutter/models/doctor/doctor_profile_model.dart';
import 'package:doctor_app_flutter/models/patient/patiant_info_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/screens/base/base_view.dart';
import 'package:doctor_app_flutter/screens/patients/profile/soap_update/soap_utils.dart'; import 'package:doctor_app_flutter/screens/patients/profile/soap_update/soap_utils.dart';
@ -33,13 +26,18 @@ class UpdateSubjectivePage extends StatefulWidget {
final int currentIndex; final int currentIndex;
UpdateSubjectivePage( UpdateSubjectivePage(
{Key key, this.changePageViewIndex, this.patientInfo, this.changeLoadingState, this.currentIndex}); {Key key,
this.changePageViewIndex,
this.patientInfo,
this.changeLoadingState,
this.currentIndex});
@override @override
_UpdateSubjectivePageState createState() => _UpdateSubjectivePageState(); _UpdateSubjectivePageState createState() => _UpdateSubjectivePageState();
} }
class _UpdateSubjectivePageState extends State<UpdateSubjectivePage> implements SubjectiveCallBack { class _UpdateSubjectivePageState extends State<UpdateSubjectivePage>
implements SubjectiveCallBack {
bool isChiefExpand = false; bool isChiefExpand = false;
bool isHistoryExpand = false; bool isHistoryExpand = false;
bool isAllergiesExpand = false; bool isAllergiesExpand = false;
@ -55,7 +53,8 @@ class _UpdateSubjectivePageState extends State<UpdateSubjectivePage> implements
widget.changeLoadingState(true); widget.changeLoadingState(true);
if (model.patientHistoryList.isNotEmpty) { if (model.patientHistoryList.isNotEmpty) {
model.patientHistoryList.forEach((element) { model.patientHistoryList.forEach((element) {
if (element.historyType == MasterKeysService.HistoryFamily.getMasterKeyService()) { if (element.historyType ==
MasterKeysService.HistoryFamily.getMasterKeyService()) {
MasterKeyModel history = model.getOneMasterKey( MasterKeyModel history = model.getOneMasterKey(
masterKeys: MasterKeysService.HistoryFamily, masterKeys: MasterKeysService.HistoryFamily,
id: element.historyId, id: element.historyId,
@ -63,11 +62,15 @@ class _UpdateSubjectivePageState extends State<UpdateSubjectivePage> implements
if (history != null) { if (history != null) {
MySelectedHistory mySelectedHistory = MySelectedHistory mySelectedHistory =
SoapUtils.generateMySelectedHistory( SoapUtils.generateMySelectedHistory(
history: history, isChecked: element.isChecked, remark: element.remarks, isLocal: false); history: history,
isChecked: element.isChecked,
remark: element.remarks,
isLocal: false);
myHistoryList.add(mySelectedHistory); myHistoryList.add(mySelectedHistory);
} }
} }
if (element.historyType == MasterKeysService.HistoryMedical.getMasterKeyService()) { if (element.historyType ==
MasterKeysService.HistoryMedical.getMasterKeyService()) {
MasterKeyModel history = model.getOneMasterKey( MasterKeyModel history = model.getOneMasterKey(
masterKeys: MasterKeysService.HistoryMedical, masterKeys: MasterKeysService.HistoryMedical,
id: element.historyId, id: element.historyId,
@ -75,11 +78,15 @@ class _UpdateSubjectivePageState extends State<UpdateSubjectivePage> implements
if (history != null) { if (history != null) {
MySelectedHistory mySelectedHistory = MySelectedHistory mySelectedHistory =
SoapUtils.generateMySelectedHistory( SoapUtils.generateMySelectedHistory(
history: history, isChecked: element.isChecked, remark: element.remarks, isLocal: false); history: history,
isChecked: element.isChecked,
remark: element.remarks,
isLocal: false);
myHistoryList.add(mySelectedHistory); myHistoryList.add(mySelectedHistory);
} }
} }
if (element.historyType == MasterKeysService.HistorySports.getMasterKeyService()) { if (element.historyType ==
MasterKeysService.HistorySports.getMasterKeyService()) {
MasterKeyModel history = model.getOneMasterKey( MasterKeyModel history = model.getOneMasterKey(
masterKeys: MasterKeysService.HistorySports, masterKeys: MasterKeysService.HistorySports,
id: element.historyId, id: element.historyId,
@ -87,11 +94,15 @@ class _UpdateSubjectivePageState extends State<UpdateSubjectivePage> implements
if (history != null) { if (history != null) {
MySelectedHistory mySelectedHistory = MySelectedHistory mySelectedHistory =
SoapUtils.generateMySelectedHistory( SoapUtils.generateMySelectedHistory(
history: history, isChecked: element.isChecked, remark: element.remarks, isLocal: false); history: history,
isChecked: element.isChecked,
remark: element.remarks,
isLocal: false);
myHistoryList.add(mySelectedHistory); myHistoryList.add(mySelectedHistory);
} }
} }
if (element.historyType == MasterKeysService.HistorySurgical.getMasterKeyService()) { if (element.historyType ==
MasterKeysService.HistorySurgical.getMasterKeyService()) {
MasterKeyModel history = model.getOneMasterKey( MasterKeyModel history = model.getOneMasterKey(
masterKeys: MasterKeysService.HistorySurgical, masterKeys: MasterKeysService.HistorySurgical,
id: element.historyId, id: element.historyId,
@ -99,7 +110,10 @@ class _UpdateSubjectivePageState extends State<UpdateSubjectivePage> implements
if (history != null) { if (history != null) {
MySelectedHistory mySelectedHistory = MySelectedHistory mySelectedHistory =
SoapUtils.generateMySelectedHistory( SoapUtils.generateMySelectedHistory(
history: history, isChecked: element.isChecked, remark: element.remarks, isLocal: false); history: history,
isChecked: element.isChecked,
remark: element.remarks,
isLocal: false);
myHistoryList.add(mySelectedHistory); myHistoryList.add(mySelectedHistory);
} }
} }
@ -108,15 +122,19 @@ class _UpdateSubjectivePageState extends State<UpdateSubjectivePage> implements
} }
getAllergies(SOAPViewModel model) async { getAllergies(SOAPViewModel model) async {
if (model.patientAllergiesList.isNotEmpty) { if (model.patientAllergiesList.isNotEmpty) {
model.patientAllergiesList.forEach((element) { model.patientAllergiesList.forEach((element) {
MasterKeyModel selectedAllergy = model.getOneMasterKey( MasterKeyModel selectedAllergy = model.getOneMasterKey(
masterKeys: MasterKeysService.Allergies, id: element.allergyDiseaseId, typeId: element.allergyDiseaseType); masterKeys: MasterKeysService.Allergies,
id: element.allergyDiseaseId,
typeId: element.allergyDiseaseType);
MasterKeyModel selectedAllergySeverity; MasterKeyModel selectedAllergySeverity;
if (element.severity == 0) { if (element.severity == 0) {
selectedAllergySeverity = MasterKeyModel( selectedAllergySeverity = MasterKeyModel(
id: 0, typeId: MasterKeysService.AllergySeverity.getMasterKeyService(), nameAr: '', nameEn: ''); id: 0,
typeId: MasterKeysService.AllergySeverity.getMasterKeyService(),
nameAr: '',
nameEn: '');
} else { } else {
selectedAllergySeverity = model.getOneMasterKey( selectedAllergySeverity = model.getOneMasterKey(
masterKeys: MasterKeysService.AllergySeverity, masterKeys: MasterKeysService.AllergySeverity,
@ -124,15 +142,17 @@ class _UpdateSubjectivePageState extends State<UpdateSubjectivePage> implements
); );
} }
MySelectedAllergy mySelectedAllergy = SoapUtils.generateMySelectedAllergy( MySelectedAllergy mySelectedAllergy =
allergy: selectedAllergy, SoapUtils.generateMySelectedAllergy(
isChecked: element.isChecked, allergy: selectedAllergy,
createdBy: element.createdBy, isChecked: element.isChecked,
remark: element.remarks, createdBy: element.createdBy,
isLocal: false, remark: element.remarks,
allergySeverity: selectedAllergySeverity); isLocal: false,
allergySeverity: selectedAllergySeverity);
if (selectedAllergy != null && selectedAllergySeverity != null) myAllergiesList.add(mySelectedAllergy); if (selectedAllergy != null && selectedAllergySeverity != null)
myAllergiesList.add(mySelectedAllergy);
}); });
} }
} }
@ -148,11 +168,14 @@ class _UpdateSubjectivePageState extends State<UpdateSubjectivePage> implements
if (model.patientChiefComplaintList.isNotEmpty) { if (model.patientChiefComplaintList.isNotEmpty) {
isChiefExpand = true; isChiefExpand = true;
complaintsController.text = Helpers.parseHtmlString(model.patientChiefComplaintList[0].chiefComplaint); complaintsController.text = Helpers.parseHtmlString(
model.patientChiefComplaintList[0].chiefComplaint);
illnessController.text = model.patientChiefComplaintList[0].hopi; illnessController.text = model.patientChiefComplaintList[0].hopi;
medicationController.text = !(model.patientChiefComplaintList[0].currentMedication).isNotEmpty medicationController.text =
? model.patientChiefComplaintList[0].currentMedication + '\n \n' !(model.patientChiefComplaintList[0].currentMedication).isNotEmpty
: model.patientChiefComplaintList[0].currentMedication; ? model.patientChiefComplaintList[0].currentMedication +
'\n \n'
: model.patientChiefComplaintList[0].currentMedication;
} }
if (widget.patientInfo.admissionNo == null) { if (widget.patientInfo.admissionNo == null) {
await getHistory(model); await getHistory(model);
@ -200,7 +223,8 @@ class _UpdateSubjectivePageState extends State<UpdateSubjectivePage> implements
isExpanded: isChiefExpand, isExpanded: isChiefExpand,
), ),
SizedBox( SizedBox(
height: SizeConfig.heightMultiplier * (SizeConfig.isHeightVeryShort ? 4 : 2), height: SizeConfig.heightMultiplier *
(SizeConfig.isHeightVeryShort ? 4 : 2),
), ),
if (widget.patientInfo.admissionNo == null) if (widget.patientInfo.admissionNo == null)
ExpandableSOAPWidget( ExpandableSOAPWidget(
@ -212,12 +236,15 @@ class _UpdateSubjectivePageState extends State<UpdateSubjectivePage> implements
}); });
}, },
child: Column( child: Column(
children: [UpdateHistoryWidget(myHistoryList: myHistoryList)], children: [
UpdateHistoryWidget(myHistoryList: myHistoryList)
],
), ),
isExpanded: isHistoryExpand, isExpanded: isHistoryExpand,
), ),
SizedBox( SizedBox(
height: SizeConfig.heightMultiplier * (SizeConfig.isHeightVeryShort ? 4 : 2), height: SizeConfig.heightMultiplier *
(SizeConfig.isHeightVeryShort ? 4 : 2),
), ),
if (widget.patientInfo.admissionNo == null) if (widget.patientInfo.admissionNo == null)
ExpandableSOAPWidget( ExpandableSOAPWidget(
@ -241,7 +268,8 @@ class _UpdateSubjectivePageState extends State<UpdateSubjectivePage> implements
isExpanded: isAllergiesExpand, isExpanded: isAllergiesExpand,
), ),
SizedBox( SizedBox(
height: SizeConfig.heightMultiplier * (SizeConfig.isHeightVeryShort ? 20 : 10), height: SizeConfig.heightMultiplier *
(SizeConfig.isHeightVeryShort ? 20 : 10),
), ),
], ],
), ),
@ -253,7 +281,9 @@ class _UpdateSubjectivePageState extends State<UpdateSubjectivePage> implements
} }
addSubjectiveInfo( addSubjectiveInfo(
{SOAPViewModel model, List<MySelectedAllergy> myAllergiesList, List<MySelectedHistory> myHistoryList}) async { {SOAPViewModel model,
List<MySelectedAllergy> myAllergiesList,
List<MySelectedHistory> myHistoryList}) async {
if (FocusScope.of(context).hasFocus) FocusScope.of(context).unfocus(); if (FocusScope.of(context).hasFocus) FocusScope.of(context).unfocus();
widget.changeLoadingState(true); widget.changeLoadingState(true);
formKey.currentState.save(); formKey.currentState.save();
@ -265,22 +295,15 @@ class _UpdateSubjectivePageState extends State<UpdateSubjectivePage> implements
if (complaintsController.text.isNotEmpty && if (complaintsController.text.isNotEmpty &&
illnessController.text.isNotEmpty && illnessController.text.isNotEmpty &&
complaintsController.text.length > 25) { complaintsController.text.length > 25) {
await postChiefComplaint(model: model); await model.postSubjectServices(
if (model.state == ViewState.ErrorLocal) { patientInfo: widget.patientInfo,
Helpers.showErrorToast(model.error); complaintsText: complaintsController.text,
} medicationText: medicationController.text,
if (myHistoryList.length != 0) { illnessText: illnessController.text,
await postHistories(model: model, myHistoryList: myHistoryList); myHistoryList: myHistoryList,
if (model.state == ViewState.ErrorLocal) { myAllergiesList: myAllergiesList,
Helpers.showErrorToast(model.error); );
}
}
if (myAllergiesList.length != 0) {
await postAllergy(myAllergiesList: myAllergiesList, model: model);
if (model.state == ViewState.ErrorLocal) {
Helpers.showErrorToast(model.error);
}
}
widget.changeLoadingState(true); widget.changeLoadingState(true);
widget.changePageViewIndex(1); widget.changePageViewIndex(1);
@ -311,112 +334,11 @@ class _UpdateSubjectivePageState extends State<UpdateSubjectivePage> implements
} }
} }
postAllergy(
{List<MySelectedAllergy> myAllergiesList, SOAPViewModel model}) async {
PostAllergyRequestModel postAllergyRequestModel =
new PostAllergyRequestModel();
Map profile = await sharedPref.getObj(DOCTOR_PROFILE);
DoctorProfileModel doctorProfile = DoctorProfileModel.fromJson(profile);
myAllergiesList.forEach((allergy) {
if (postAllergyRequestModel.listHisProgNotePatientAllergyDiseaseVM ==
null)
postAllergyRequestModel.listHisProgNotePatientAllergyDiseaseVM = [];
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: allergy.createdBy ?? doctorProfile.doctorID,
createdOn: DateTime.now().toIso8601String(),
editedBy: doctorProfile.doctorID,
editedOn: DateTime.now().toIso8601String(),
isChecked: allergy.isChecked,
isUpdatedByNurse: false));
});
if (model.patientAllergiesList.isEmpty) {
await model.postAllergy(postAllergyRequestModel);
} else {
await model.patchAllergy(postAllergyRequestModel);
}
if (model.state == ViewState.ErrorLocal) {
Helpers.showErrorToast(model.error);
}
GeneralGetReqForSOAP generalGetReqForSOAP = GeneralGetReqForSOAP(
patientMRN: widget.patientInfo.patientMRN,
episodeId: widget.patientInfo.episodeNo,
appointmentNo: widget.patientInfo.appointmentNo,
doctorID: '',
editedBy: '');
await model.getPatientAllergy(generalGetReqForSOAP, isLocalBusy: true);
if (model.state == ViewState.ErrorLocal) {
Helpers.showErrorToast(model.error);
}
}
postHistories(
{List<MySelectedHistory> myHistoryList, SOAPViewModel model}) async {
PostHistoriesRequestModel postHistoriesRequestModel =
new PostHistoriesRequestModel(doctorID: '');
myHistoryList.forEach((history) {
if (postHistoriesRequestModel.listMedicalHistoryVM == null)
postHistoriesRequestModel.listMedicalHistoryVM = [];
postHistoriesRequestModel.listMedicalHistoryVM.add(ListMedicalHistoryVM(
patientMRN: widget.patientInfo.patientMRN,
episodeId: widget.patientInfo.episodeNo,
appointmentNo: widget.patientInfo.appointmentNo,
remarks: "",
historyId: history.selectedHistory.id,
historyType: history.selectedHistory.typeId,
isChecked: history.isChecked,
));
});
if (model.patientHistoryList.isEmpty) {
await model.postHistories(postHistoriesRequestModel);
} else {
await model.patchHistories(postHistoriesRequestModel);
}
if (model.state == ViewState.ErrorLocal) {
Helpers.showErrorToast(model.error);
}
}
postChiefComplaint({SOAPViewModel model}) async {
formKey.currentState.save();
if (formKey.currentState.validate()) {
PostChiefComplaintRequestModel postChiefComplaintRequestModel = new PostChiefComplaintRequestModel(
admissionNo: widget.patientInfo.admissionNo != null ? int.parse(widget.patientInfo.admissionNo) : null,
patientMRN: widget.patientInfo.patientMRN,
episodeID: widget.patientInfo.episodeNo ?? 0,
appointmentNo: widget.patientInfo.appointmentNo ?? 0,
chiefComplaint: complaintsController.text,
currentMedication: medicationController.text,
hopi: illnessController.text,
isLactation: false,
ispregnant: false,
doctorID: '',
numberOfWeeks: 0);
if (model.patientChiefComplaintList.isEmpty) {
postChiefComplaintRequestModel.editedBy = '';
await model.postChiefComplaint(postChiefComplaintRequestModel);
} else {
postChiefComplaintRequestModel.editedBy = '';
await model.patchChiefComplaint(postChiefComplaintRequestModel);
}
}
}
@override @override
Function nextFunction(model) { Function nextFunction(model) {
addSubjectiveInfo(model: model, myAllergiesList: myAllergiesList, myHistoryList: myHistoryList); addSubjectiveInfo(
model: model,
myAllergiesList: myAllergiesList,
myHistoryList: myHistoryList);
} }
} }

Loading…
Cancel
Save