@ -1,7 +1,11 @@
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/ChiefComplaint/GetChiefComplaintReqModel.dart ' ;
import ' package:doctor_app_flutter/models/SOAP/GeneralGetReqForSOAP.dart ' ;
import ' package:doctor_app_flutter/models/SOAP/GetHistoryReqModel.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 +14,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 ' ;
@ -47,11 +49,114 @@ class _UpdateSubjectivePageState extends State<UpdateSubjectivePage> {
TextEditingController illnessController = TextEditingController ( ) ;
TextEditingController complaintsController = TextEditingController ( ) ;
final formKey = GlobalKey < FormState > ( ) ;
getHistory ( SOAPViewModel model ) async {
GetHistoryReqModel getHistoryMedicalReqModel = GetHistoryReqModel (
patientMRN: widget . patientInfo . patientMRN ,
historyType:
MasterKeysService . HistoryMedical . getMasterKeyService ( ) ) ;
GetHistoryReqModel getHistorySportsReqModel = GetHistoryReqModel (
patientMRN: widget . patientInfo . patientMRN ,
historyType:
MasterKeysService . HistorySports . getMasterKeyService ( ) ) ;
GetHistoryReqModel getHistorySurgicalReqModel = GetHistoryReqModel (
patientMRN: widget . patientInfo . patientMRN ,
historyType:
MasterKeysService . HistorySurgical . getMasterKeyService ( ) ) ;
GetHistoryReqModel getHistoryFamilyReqModel = GetHistoryReqModel (
patientMRN: widget . patientInfo . patientMRN ,
historyType:
MasterKeysService . HistoryFamily . getMasterKeyService ( ) ) ;
await model . getPatientHistories ( getHistoryMedicalReqModel ) ;
await model . getPatientHistories ( getHistorySportsReqModel ) ;
await model . getPatientHistories ( getHistorySurgicalReqModel ) ;
await model . getPatientHistories ( getHistoryFamilyReqModel ) ;
if ( model . patientHistoryList . isNotEmpty ) {
if ( model . historyFamilyList . isEmpty ) {
await model . getMasterLookup ( MasterKeysService . HistoryFamily ) ;
}
if ( model . historyMedicalList . isEmpty ) {
await model . getMasterLookup ( MasterKeysService . HistoryMedical ) ;
}
if ( model . historySurgicalList . length = = 0 ) {
await model . getMasterLookup ( MasterKeysService . HistorySurgical ) ;
await model . getMasterLookup ( MasterKeysService . HistorySports ) ;
}
model . patientHistoryList . forEach ( ( element ) {
if ( element . historyType = = MasterKeysService . HistoryFamily . getMasterKeyService ( ) ) {
widget . myHistoryList . add ( model . getOneMasterKey (
masterKeys: MasterKeysService . HistoryFamily ,
id: element . historyId ,
) ) ;
} if ( element . historyType = = MasterKeysService . HistoryMedical . getMasterKeyService ( ) ) {
widget . myHistoryList . add ( model . getOneMasterKey (
masterKeys: MasterKeysService . HistoryMedical ,
id: element . historyId ,
) ) ;
} if ( element . historyType = = MasterKeysService . HistorySports . getMasterKeyService ( ) ) {
widget . myHistoryList . add ( model . getOneMasterKey (
masterKeys: MasterKeysService . HistorySports ,
id: element . historyId ,
) ) ;
}
if ( element . historyType = =
MasterKeysService . HistorySurgical . getMasterKeyService ( ) ) {
widget . myHistoryList . add ( model . getOneMasterKey (
masterKeys: MasterKeysService . HistorySurgical ,
id: element . historyId ,
) ) ;
}
} ) ;
}
}
@ 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 ) ;
GetChiefComplaintReqModel getChiefComplaintReqModel =
GetChiefComplaintReqModel (
patientMRN: widget . patientInfo . patientMRN ,
appointmentNo: widget . patientInfo . appointmentNo ,
episodeId: widget . patientInfo . episodeNo ,
episodeID: widget . patientInfo . episodeNo ) ;
await model . getPatientChiefComplaint ( getChiefComplaintReqModel ) ;
if ( model . patientChiefComplaintList . isNotEmpty ) {
complaintsController . text =
model . patientChiefComplaintList [ 0 ] . chiefComplaint ;
illnessController . text = model . patientChiefComplaintList [ 0 ] . hopi ;
}
await model . getPatientAllergy ( generalGetReqForSOAP ) ;
if ( model . patientAllergiesList . isNotEmpty ) {
if ( model . allergiesList . isEmpty )
await model . getMasterLookup ( MasterKeysService . Allergies ) ;
if ( model . allergySeverityList . isEmpty )
await model . getMasterLookup ( MasterKeysService . AllergySeverity ) ;
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 ) ;
} ) ;
}
await getHistory ( model ) ;
} ,
builder: ( _ , model , w ) = > AppScaffold (
isShowAppBar: false ,
baseViewModel: model ,
@ -279,45 +384,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 +439,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 +485,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 ) {
@ -386,19 +505,22 @@ class _UpdateSubjectivePageState extends State<UpdateSubjectivePage> {
if ( formKey . currentState . validate ( ) ) {
PostChiefComplaintRequestModel postChiefComplaintRequestModel =
/ / TODO: make static value dynamic
new PostChiefComplaintRequestModel (
patientMRN: widget . patientInfo . patientMRN ,
episodeID: widget . patientInfo . episodeNo ,
appointmentNo: widget . patientInfo . appointmentNo ,
chiefComplaint: complaintsController . text ,
currentMedication: " currentMedication " ,
hopi: illnessController . text ,
isLactation: false ,
ispregnant: false ,
numberOfWeeks: 22 ) ;
await model . patchChiefComplaint ( postChiefComplaintRequestModel ) ;
new PostChiefComplaintRequestModel (
patientMRN: widget . patientInfo . patientMRN ,
episodeID: widget . patientInfo . episodeNo ,
appointmentNo: widget . patientInfo . appointmentNo ,
chiefComplaint: complaintsController . text ,
currentMedication: " currentMedication " ,
hopi: illnessController . text ,
isLactation: false ,
ispregnant: true ,
numberOfWeeks: 22 ) ;
if ( model . patientChiefComplaintList . isEmpty ) {
/ / TODO: make it postChiefComplaint after it start to work
await model . postChiefComplaint ( postChiefComplaintRequestModel ) ;
} else {
await model . patchChiefComplaint ( postChiefComplaintRequestModel ) ;
}
}
}