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 'base_service.dart'; class LookupService extends BaseService { 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 getMasterLookup(MasterKeysService masterKeys) async { Map body = { "MasterInput": masterKeys.getMasterKeyService() }; await baseAppClient.post(GET_MASTER_LOOKUP_LIST, onSuccess: (dynamic response, int statusCode) { setMasterLookupInCorrectArray( response['MasterLookUpList']['entityList'], masterKeys); }, onFailure: (String error, int statusCode) { hasError = true; super.error = error; }, body: body); } setMasterLookupInCorrectArray(entryList, MasterKeysService masterKeys) { switch (masterKeys) { case MasterKeysService.Allergies: listOfAllergies.clear(); entryList.forEach((v) { listOfAllergies .add(MasterKeyModel.fromJson(v)); }); break; case MasterKeysService.HistoryFamily: _historyFamilyList.clear(); entryList.forEach((v) { _historyFamilyList .add(MasterKeyModel.fromJson(v)); }); break; case MasterKeysService.HistoryMedical: _historyMedicalList.clear(); entryList.forEach((v) { _historyMedicalList .add(MasterKeyModel.fromJson(v)); }); break; case MasterKeysService.HistorySocial: historySocialList.clear(); entryList.forEach((v) { historySocialList .add(MasterKeyModel.fromJson(v)); }); break; case MasterKeysService.HistorySports: _historySportList.clear(); entryList.forEach((v) { _historySportList .add(MasterKeyModel.fromJson(v)); }); break; case MasterKeysService.HistorySurgical: _historySurgicalList.clear(); entryList.forEach((v) { _historySurgicalList .add(MasterKeyModel.fromJson(v)); }); break; case MasterKeysService.PhysicalExamination: return 59; break; case MasterKeysService.AllergySeverity: _allergySeverityList.clear(); entryList.forEach((v) { _allergySeverityList .add(MasterKeyModel.fromJson(v)); }); break; } } }