diff --git a/lib/core/service/SOAP_service.dart b/lib/core/service/SOAP_service.dart index de729be3..1f28e714 100644 --- a/lib/core/service/SOAP_service.dart +++ b/lib/core/service/SOAP_service.dart @@ -4,12 +4,30 @@ 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'; -class SOAPService extends BaseService { +class SOAPService extends BaseService { List get listOfAllergies => _listOfAllergies; - List get allergySeverityList => _allergySeverityList; List _listOfAllergies = []; + + List get allergySeverityList => _allergySeverityList; List _allergySeverityList = []; + List get historyFamilyList => _historyFamilyList; + List _historyFamilyList = []; + + List get historyMedicalList => _historyMedicalList; + List _historyMedicalList = []; + + List get historySportList => _historySportList; + List _historySportList = []; + + List get historySocialList => _historySocialList; + List _historySocialList = []; + + List get historySurgicalList => _historySurgicalList; + List _historySurgicalList = []; + + + Future getAllergies(GetAllergiesRequestModel getAllergiesRequestModel) async { await baseAppClient.post( GET_ALLERGIES, @@ -51,19 +69,38 @@ class SOAPService extends BaseService { }); break; case MasterKeysService.HistoryFamily: - return 36; + _historyFamilyList.clear(); + entryList.forEach((v) { + _historyFamilyList + .add(MasterKeyModel.fromJson(v)); + }); break; case MasterKeysService.HistoryMedical: - return 37; + _historyMedicalList.clear(); + entryList.forEach((v) { + _historyMedicalList + .add(MasterKeyModel.fromJson(v)); + }); break; case MasterKeysService.HistorySocial: - return 38; + historySocialList.clear(); + entryList.forEach((v) { + historySocialList + .add(MasterKeyModel.fromJson(v)); + }); break; case MasterKeysService.HistorySports: - return 39; - break; + _historySportList.clear(); + entryList.forEach((v) { + _historySportList + .add(MasterKeyModel.fromJson(v)); + }); break; case MasterKeysService.HistorySurgical: - return 66; + _historySurgicalList.clear(); + entryList.forEach((v) { + _historySurgicalList + .add(MasterKeyModel.fromJson(v)); + }); break; case MasterKeysService.PhysicalExamination: return 59; diff --git a/lib/core/viewModel/SOAP_view_model.dart b/lib/core/viewModel/SOAP_view_model.dart index b48bfcba..1fd239b9 100644 --- a/lib/core/viewModel/SOAP_view_model.dart +++ b/lib/core/viewModel/SOAP_view_model.dart @@ -12,7 +12,22 @@ class SOAPViewModel extends BaseViewModel { SOAPService _SOAPService = locator(); List get listOfAllergies => _SOAPService.listOfAllergies; - List get allergySeverityList => _SOAPService.allergySeverityList; + + List get allergySeverityList => + _SOAPService.allergySeverityList; + + + List get historyFamilyList => _SOAPService.historyFamilyList; + + List get historyMedicalList => _SOAPService.historyMedicalList; + + List get historySportList => _SOAPService.historySportList; + + List get historySocialList => _SOAPService.historySocialList; + List get historySurgicalList => _SOAPService.historySurgicalList; + List get mergeHistorySurgicalWithHistorySportList => [...historySurgicalList,...historySportList]; + + Future getAllergies(GetAllergiesRequestModel getAllergiesRequestModel) async { setState(ViewState.Busy); 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 9dda8c00..d3260776 100644 --- a/lib/widgets/patients/profile/SOAP/subjective/add_allergies_widget.dart +++ b/lib/widgets/patients/profile/SOAP/subjective/add_allergies_widget.dart @@ -168,10 +168,10 @@ class _AddAllergiesState extends State { heightFactor: 0.7, child: BaseView( onModelReady: (model) async { - if (model.listOfAllergies == null) { + if (model.listOfAllergies.length == 0) { await model.getMasterLookup(MasterKeysService.Allergies); } - if (model.allergySeverityList == null) { + if (model.allergySeverityList.length == 0) { await model.getMasterLookup(MasterKeysService.AllergySeverity); } }, diff --git a/lib/widgets/patients/profile/SOAP/subjective/add_history_widget.dart b/lib/widgets/patients/profile/SOAP/subjective/add_history_widget.dart index b83f5f16..085fa68d 100644 --- a/lib/widgets/patients/profile/SOAP/subjective/add_history_widget.dart +++ b/lib/widgets/patients/profile/SOAP/subjective/add_history_widget.dart @@ -116,7 +116,7 @@ class _AddHistoryWidgetState extends State isScrollControlled: true, context: context, builder: (context) { - return AddHistoryDialog(); + return AddHistoryDialog(changePageViewIndex:changePageViewIndex, controller: _controller,); }); } } @@ -218,11 +218,8 @@ class _AddHistoryDialogState extends State { heightFactor: 0.7, child: BaseView( onModelReady: (model) async { - // if (model.listOfAllergies == null) { - await model.getMasterLookup(MasterKeysService.Allergies); - // } - if (model.allergySeverityList == null) { - await model.getMasterLookup(MasterKeysService.AllergySeverity); + if (model.historyFamilyList.length == 0) { + await model.getMasterLookup(MasterKeysService.HistoryFamily); } }, builder: (_, model, w) => AppScaffold( @@ -237,8 +234,19 @@ class _AddHistoryDialogState extends State { SizedBox( height: 10, ), - PriorityBar(onTap: (activePriority) { + PriorityBar(onTap: (activePriority) async { widget.changePageViewIndex(activePriority); + if(activePriority ==1) { + if (model.historySurgicalList.length == 0) { + await model.getMasterLookup(MasterKeysService.HistorySurgical); + await model.getMasterLookup(MasterKeysService.HistorySports); + } + } + if(activePriority ==2) { + if (model.historyMedicalList.length == 0) { + await model.getMasterLookup(MasterKeysService.HistoryMedical); + } + } }), SizedBox( height: 20, @@ -254,240 +262,211 @@ class _AddHistoryDialogState extends State { }, scrollDirection: Axis.horizontal, children: [ - Column( - children: [ - NetworkBaseView( - baseViewModel: model, - child: Container( - height: - MediaQuery.of(context).size.height * 0.5, - child: Center( - child: Container( - margin: EdgeInsets.only(top: 15), - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(12), - color: Colors.white), - child: ListView( - children: [ - Column( - children: [ - Row( - children: [ - Checkbox( - value: true, - activeColor: - Colors.red[800], - onChanged: (bool newValue) { - setState(() {}); - }), - Expanded( - child: Padding( - padding: const EdgeInsets - .symmetric( - horizontal: 10, - vertical: 0), - child: Texts('History', - variant: "bodyText", - bold: true, - color: Colors.black), - ), - ), - ], - ), - DividerWithSpacesAround(), - Row( - children: [ - Checkbox( - value: true, - activeColor: - Colors.red[800], - onChanged: (bool newValue) { - setState(() {}); - }), - Expanded( - child: Padding( - padding: const EdgeInsets - .symmetric( - horizontal: 10, - vertical: 0), - child: Texts('History', - variant: "bodyText", - bold: true, - color: Colors.black), - ), - ), - ], - ), - DividerWithSpacesAround(), - Row( - children: [ - Checkbox( - value: true, - activeColor: - Colors.red[800], - onChanged: (bool newValue) { - setState(() {}); - }), - Expanded( - child: Padding( - padding: const EdgeInsets - .symmetric( - horizontal: 10, - vertical: 0), - child: Texts('History', - variant: "bodyText", - bold: true, - color: Colors.black), - ), - ), - ], - ), - DividerWithSpacesAround(), - Row( - children: [ - Checkbox( - value: true, - activeColor: - Colors.red[800], - onChanged: (bool newValue) { - setState(() {}); - }), - Expanded( - child: Padding( - padding: const EdgeInsets - .symmetric( - horizontal: 10, - vertical: 0), - child: Texts('History', - variant: "bodyText", - bold: true, - color: Colors.black), - ), - ), - ], - ), - DividerWithSpacesAround(), - Row( - children: [ - Checkbox( - value: true, - activeColor: - Colors.red[800], - onChanged: (bool newValue) { - setState(() {}); - }), - Expanded( - child: Padding( - padding: const EdgeInsets - .symmetric( - horizontal: 10, - vertical: 0), - child: Texts('History', - variant: "bodyText", - bold: true, - color: Colors.black), - ), - ), - ], - ), - DividerWithSpacesAround(), - Row( - children: [ - Checkbox( - value: true, - activeColor: - Colors.red[800], - onChanged: (bool newValue) { - setState(() {}); - }), - Expanded( - child: Padding( - padding: const EdgeInsets - .symmetric( - horizontal: 10, - vertical: 0), - child: Texts('History', - variant: "bodyText", - bold: true, - color: Colors.black), - ), - ), - ], - ), - DividerWithSpacesAround(), - Row( - children: [ - Checkbox( - value: true, - activeColor: - Colors.red[800], - onChanged: (bool newValue) { - setState(() {}); - }), - Expanded( - child: Padding( - padding: const EdgeInsets - .symmetric( - horizontal: 10, - vertical: 0), - child: Texts('History', - variant: "bodyText", - bold: true, - color: Colors.black), - ), - ), - ], - ), - DividerWithSpacesAround(), - Row( - children: [ - Checkbox( - value: true, - activeColor: - Colors.red[800], - onChanged: (bool newValue) { - setState(() {}); - }), - Expanded( - child: Padding( - padding: const EdgeInsets - .symmetric( - horizontal: 10, - vertical: 0), - child: Texts('History', - variant: "bodyText", - bold: true, - color: Colors.black), + Container( + child: Column( + children: [ + NetworkBaseView( + baseViewModel: model, + child: Container( + height: + MediaQuery.of(context).size.height * 0.5, + child: Center( + child: Container( + margin: EdgeInsets.only(top: 15), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(12), + color: Colors.white), + child: ListView( + children: [ + Column( + children: model.historyFamilyList + .map((historyInfo) { + return Column( + children: [ + Row( + children: [ + Checkbox( + value: true, + activeColor: + Colors.red[800], + onChanged: + (bool newValue) { + setState(() {}); + }), + Expanded( + child: Padding( + padding: + const EdgeInsets + .symmetric( + horizontal: 10, + vertical: 0), + child: Texts( + historyInfo.nameEn, + variant: "bodyText", + bold: true, + color: + Colors.black), + ), + ), + ], ), - ), - ], - ), - DividerWithSpacesAround(), - ], - ), - ], - ), - )), + DividerWithSpacesAround(), + ], + ); + }).toList(), + ), + ], + ), + )), + ), ), - ), - SizedBox( - height: 10, - ), - if (model.state == ViewState.Idle) - AppButton( - title: "Add SELECTED HISTORIES".toUpperCase(), - onPressed: () {}, + SizedBox( + height: 10, ), - ], + if (model.state == ViewState.Idle) + AppButton( + title: "Add SELECTED HISTORIES".toUpperCase(), + onPressed: () {}, + ), + ], + ), ), Container( - child: Center( - child: Texts("eee"), + child: Column( + children: [ + NetworkBaseView( + baseViewModel: model, + child: Container( + height: + MediaQuery.of(context).size.height * 0.5, + child: Center( + child: Container( + margin: EdgeInsets.only(top: 15), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(12), + color: Colors.white), + child: ListView( + children: [ + Column( + children: model.mergeHistorySurgicalWithHistorySportList + .map((historyInfo) { + return Column( + children: [ + Row( + children: [ + Checkbox( + value: true, + activeColor: + Colors.red[800], + onChanged: + (bool newValue) { + setState(() {}); + }), + Expanded( + child: Padding( + padding: + const EdgeInsets + .symmetric( + horizontal: 10, + vertical: 0), + child: Texts( + historyInfo.nameEn, + variant: "bodyText", + bold: true, + color: + Colors.black), + ), + ), + ], + ), + DividerWithSpacesAround(), + ], + ); + }).toList(), + ), + ], + ), + )), + ), + ), + SizedBox( + height: 10, + ), + if (model.state == ViewState.Idle) + AppButton( + title: "Add SELECTED HISTORIES".toUpperCase(), + onPressed: () {}, + ), + ], ), ), Container( - child: Center( - child: Texts("cccc"), + child: Column( + children: [ + NetworkBaseView( + baseViewModel: model, + child: Container( + height: + MediaQuery.of(context).size.height * 0.5, + child: Center( + child: Container( + margin: EdgeInsets.only(top: 15), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(12), + color: Colors.white), + child: ListView( + children: [ + Column( + children: model.historyMedicalList + .map((historyInfo) { + return Column( + children: [ + Row( + children: [ + Checkbox( + value: true, + activeColor: + Colors.red[800], + onChanged: + (bool newValue) { + setState(() {}); + }), + Expanded( + child: Padding( + padding: + const EdgeInsets + .symmetric( + horizontal: 10, + vertical: 0), + child: Texts( + historyInfo.nameEn, + variant: "bodyText", + bold: true, + color: + Colors.black), + ), + ), + ], + ), + DividerWithSpacesAround(), + ], + ); + }).toList(), + ), + ], + ), + )), + ), + ), + SizedBox( + height: 10, + ), + if (model.state == ViewState.Idle) + AppButton( + title: "Add SELECTED HISTORIES".toUpperCase(), + onPressed: () {}, + ), + ], ), ), ],