diff --git a/lib/config/config.dart b/lib/config/config.dart index 817925f5..783cf811 100644 --- a/lib/config/config.dart +++ b/lib/config/config.dart @@ -85,6 +85,7 @@ const END_CALL_WITH_CHARGE = 'LiveCareApi/DoctorApp/CompleteCallWithCharge'; const GET_ALLERGIES = 'Services/DoctorApplication.svc/REST/GetAllergies'; const GET_MASTER_LOOKUP_LIST = 'Services/DoctorApplication.svc/REST/GetMasterLookUpList'; +const POST_ALLERGY = 'Services/DoctorApplication.svc/REST/PostAllergies'; var selectedPatientType = 1; diff --git a/lib/core/service/SOAP_service.dart b/lib/core/service/SOAP_service.dart index 1f28e714..88d44e5a 100644 --- a/lib/core/service/SOAP_service.dart +++ b/lib/core/service/SOAP_service.dart @@ -3,6 +3,7 @@ import 'package:doctor_app_flutter/core/enum/master_lookup_key.dart'; import 'package:doctor_app_flutter/core/service/base/base_service.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'; class SOAPService extends BaseService { List get listOfAllergies => _listOfAllergies; @@ -59,6 +60,17 @@ class SOAPService extends BaseService { }, body: body); } + Future postAllergy(PostAllergyRequestModel postAllergyRequestModel) async { + + await baseAppClient.post(POST_ALLERGY, + onSuccess: (dynamic response, int statusCode) { + print("Success"); + }, onFailure: (String error, int statusCode) { + hasError = true; + super.error = error; + }, body: postAllergyRequestModel.toJson()); + } + setMasterLookupInCorrectArray(entryList, MasterKeysService masterKeys) { switch (masterKeys) { case MasterKeysService.Allergies: diff --git a/lib/core/viewModel/SOAP_view_model.dart b/lib/core/viewModel/SOAP_view_model.dart index 1fd239b9..608b2e3d 100644 --- a/lib/core/viewModel/SOAP_view_model.dart +++ b/lib/core/viewModel/SOAP_view_model.dart @@ -4,6 +4,7 @@ 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/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'; import '../../locator.dart'; import 'base_view_model.dart'; @@ -48,4 +49,16 @@ class SOAPViewModel extends BaseViewModel { } else 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); + } + + } diff --git a/lib/models/SOAP/post_allergy_request_model.dart b/lib/models/SOAP/post_allergy_request_model.dart new file mode 100644 index 00000000..6783d885 --- /dev/null +++ b/lib/models/SOAP/post_allergy_request_model.dart @@ -0,0 +1,93 @@ +class PostAllergyRequestModel { + List + listHisProgNotePatientAllergyDiseaseVM; + + PostAllergyRequestModel({this.listHisProgNotePatientAllergyDiseaseVM}); + + PostAllergyRequestModel.fromJson(Map json) { + if (json['listHisProgNotePatientAllergyDiseaseVM'] != null) { + listHisProgNotePatientAllergyDiseaseVM = + new List(); + json['listHisProgNotePatientAllergyDiseaseVM'].forEach((v) { + listHisProgNotePatientAllergyDiseaseVM + .add(new ListHisProgNotePatientAllergyDiseaseVM.fromJson(v)); + }); + } + } + + Map toJson() { + final Map data = new Map(); + if (this.listHisProgNotePatientAllergyDiseaseVM != null) { + data['listHisProgNotePatientAllergyDiseaseVM'] = this + .listHisProgNotePatientAllergyDiseaseVM + .map((v) => v.toJson()) + .toList(); + } + return data; + } +} + +class ListHisProgNotePatientAllergyDiseaseVM { + int patientMRN; + int allergyDiseaseType; + int allergyDiseaseId; + int episodeId; + int appointmentNo; + int severity; + bool isChecked; + bool isUpdatedByNurse; + String remarks; + int createdBy; + String createdOn; + int editedBy; + String editedOn; + + ListHisProgNotePatientAllergyDiseaseVM( + {this.patientMRN, + this.allergyDiseaseType, + this.allergyDiseaseId, + this.episodeId, + this.appointmentNo, + this.severity, + this.isChecked, + this.isUpdatedByNurse, + this.remarks, + this.createdBy, + this.createdOn, + this.editedBy, + this.editedOn}); + + ListHisProgNotePatientAllergyDiseaseVM.fromJson(Map json) { + patientMRN = json['patientMRN']; + allergyDiseaseType = json['allergyDiseaseType']; + allergyDiseaseId = json['allergyDiseaseId']; + episodeId = json['episodeId']; + appointmentNo = json['appointmentNo']; + severity = json['severity']; + isChecked = json['isChecked']; + isUpdatedByNurse = json['isUpdatedByNurse']; + remarks = json['remarks']; + createdBy = json['createdBy']; + createdOn = json['createdOn']; + editedBy = json['editedBy']; + editedOn = json['editedOn']; + } + + Map toJson() { + final Map data = new Map(); + data['patientMRN'] = this.patientMRN; + data['allergyDiseaseType'] = this.allergyDiseaseType; + data['allergyDiseaseId'] = this.allergyDiseaseId; + data['episodeId'] = this.episodeId; + data['appointmentNo'] = this.appointmentNo; + data['severity'] = this.severity; + data['isChecked'] = this.isChecked; + data['isUpdatedByNurse'] = this.isUpdatedByNurse; + data['remarks'] = this.remarks; + data['createdBy'] = this.createdBy; + data['createdOn'] = this.createdOn; + data['editedBy'] = this.editedBy; + data['editedOn'] = this.editedOn; + return data; + } +} diff --git a/lib/widgets/patients/profile/SOAP/add_SOAP_index.dart b/lib/widgets/patients/profile/SOAP/add_SOAP_index.dart index 2018a582..9d75b22c 100644 --- a/lib/widgets/patients/profile/SOAP/add_SOAP_index.dart +++ b/lib/widgets/patients/profile/SOAP/add_SOAP_index.dart @@ -1,5 +1,7 @@ import 'package:doctor_app_flutter/core/viewModel/doctor_replay_view_model.dart'; import 'package:doctor_app_flutter/icons_app/doctor_app_icons.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/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'; @@ -26,7 +28,8 @@ class _AddSOAPIndexState extends State with TickerProviderStateMixin { PageController _controller; int _currentIndex = 0; - + List myAllergiesList= List(); + List myHistoryList = List(); changePageViewIndex(pageIndex) { _controller.jumpToPage(pageIndex); } @@ -60,7 +63,7 @@ class _AddSOAPIndexState extends State padding: const EdgeInsets.all(8.0), child: Row( crossAxisAlignment: CrossAxisAlignment.start, - children: [ + children: [ AvatarWidget( Icon( patient.genderDescription == "Male" @@ -149,7 +152,7 @@ class _AddSOAPIndexState extends State }, scrollDirection: Axis.horizontal, children: [ - SubjectivePage(changePageViewIndex: changePageViewIndex,), + SubjectivePage(changePageViewIndex: changePageViewIndex,myAllergiesList: myAllergiesList,myHistoryList: myHistoryList,), ObjectivePage(changePageViewIndex: changePageViewIndex,), AssessmentPage(changePageViewIndex: changePageViewIndex,), PlanPage(changePageViewIndex: changePageViewIndex,) diff --git a/lib/widgets/patients/profile/SOAP/subjective/add_allergies_widget.dart b/lib/widgets/patients/profile/SOAP/subjective/add_allergies_widget.dart index eaa3889d..7f764a0d 100644 --- a/lib/widgets/patients/profile/SOAP/subjective/add_allergies_widget.dart +++ b/lib/widgets/patients/profile/SOAP/subjective/add_allergies_widget.dart @@ -119,8 +119,10 @@ class _AddAllergiesWidgetState extends State { builder: (context) { return AddAllergies( addAllergiesFun: (MySelectedAllergy mySelectedAllergy) { - widget.myAllergiesList.add(mySelectedAllergy); - Navigator.of(context).pop(); + setState(() { + widget.myAllergiesList.add(mySelectedAllergy); + Navigator.of(context).pop(); + }); },); }); } diff --git a/lib/widgets/patients/profile/SOAP/subjective/subjective_page.dart b/lib/widgets/patients/profile/SOAP/subjective/subjective_page.dart index bfea6d35..86a17e89 100644 --- a/lib/widgets/patients/profile/SOAP/subjective/subjective_page.dart +++ b/lib/widgets/patients/profile/SOAP/subjective/subjective_page.dart @@ -1,8 +1,8 @@ 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/viewModel/SOAP_view_model.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'; 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'; @@ -19,8 +19,10 @@ import 'package:font_awesome_flutter/font_awesome_flutter.dart'; class SubjectivePage extends StatefulWidget { final Function changePageViewIndex; + final List myAllergiesList; + final List myHistoryList ; - SubjectivePage({Key key, this.changePageViewIndex}); + SubjectivePage({Key key, this.changePageViewIndex, this.myAllergiesList, this.myHistoryList}); @override _SubjectivePageState createState() => _SubjectivePageState(); @@ -30,9 +32,9 @@ class _SubjectivePageState extends State { bool isChiefExpand = false; bool isHistoryExpand = false; bool isAllergiesExpand = false; - List myAllergiesList = List(); List myHistoryList = List(); - TextEditingController messageController = TextEditingController(); + TextEditingController illnessController = TextEditingController(); + TextEditingController complaintsController = TextEditingController(); @override Widget build(BuildContext context) { @@ -92,10 +94,12 @@ class _SubjectivePageState extends State { fontWeight: FontWeight.w600, maxLines: 25, minLines: 13, - controller: messageController, + controller: complaintsController, validator: (value) { if (value == null) - return TranslationBase.of(context).emptyMessage; + return TranslationBase + .of(context) + .emptyMessage; else return null; }), @@ -112,10 +116,12 @@ class _SubjectivePageState extends State { fontWeight: FontWeight.w600, maxLines: 25, minLines: 13, - controller: messageController, + controller: illnessController, validator: (value) { if (value == null) - return TranslationBase.of(context).emptyMessage; + return TranslationBase + .of(context) + .emptyMessage; else return null; }), @@ -215,7 +221,7 @@ class _SubjectivePageState extends State { ), bodyWidget:Column( children: [ - AddAllergiesWidget(myAllergiesList: myAllergiesList,), + AddAllergiesWidget(myAllergiesList: widget.myAllergiesList,), SizedBox( height: 30, ), @@ -239,16 +245,52 @@ class _SubjectivePageState extends State { title: TranslationBase .of(context) .next, - onPressed: () { - print( myHistoryList.toString()); - widget.changePageViewIndex(1); + + onPressed: () async { + addSubjectiveInfo(model: model, + myAllergiesList: widget.myAllergiesList, + myHistoryList: myHistoryList); + }, ), - ], - ), - ), + ], ), + ), + ), ),),); } + addSubjectiveInfo( + {SOAPViewModel model, List myAllergiesList, List< + MasterKeyModel> myHistoryList }) async { + PostAllergyRequestModel postAllergyRequestModel = new PostAllergyRequestModel(); + widget.myAllergiesList.forEach((allergy) { + if(postAllergyRequestModel.listHisProgNotePatientAllergyDiseaseVM ==null) + postAllergyRequestModel.listHisProgNotePatientAllergyDiseaseVM = []; + postAllergyRequestModel.listHisProgNotePatientAllergyDiseaseVM.add( + ListHisProgNotePatientAllergyDiseaseVM( + allergyDiseaseId: allergy.selectedAllergy.id, + allergyDiseaseType: allergy.selectedAllergy.typeId, + patientMRN: 2500477, + episodeId: 200011502, + appointmentNo: 2016053271, + severity: allergy.selectedAllergySeverity.id, + remarks: allergy.remark, + createdBy: 1485, + createdOn: "2020-08-14T20:37:22.780Z", + editedBy: 1485, + editedOn: "2020-08-14T20:37:22.780Z", + isChecked: false, + isUpdatedByNurse: false + )); + }); + await model.postAllergy(postAllergyRequestModel); + + + widget.changePageViewIndex(1); + + print(postAllergyRequestModel); + + } + }