Merge branch 'lockupService' into 'development'

Lockup service

See merge request Cloud_Solution/doctor_app_flutter!191
merge-requests/193/merge
mousa zaid 5 years ago
commit 1e5255f4f7

@ -5,37 +5,17 @@ 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<MasterKeyModel> get listOfAllergies => _listOfAllergies;
List<MasterKeyModel> _listOfAllergies = [];
List<MasterKeyModel> get allergySeverityList => _allergySeverityList;
List<MasterKeyModel> _allergySeverityList = [];
List<MasterKeyModel> get historyFamilyList => _historyFamilyList;
List<MasterKeyModel> _historyFamilyList = [];
List<MasterKeyModel> get historyMedicalList => _historyMedicalList;
List<MasterKeyModel> _historyMedicalList = [];
List<MasterKeyModel> get historySportList => _historySportList;
List<MasterKeyModel> _historySportList = [];
List<MasterKeyModel> get historySocialList => _historySocialList;
List<MasterKeyModel> _historySocialList = [];
List<MasterKeyModel> get historySurgicalList => _historySurgicalList;
List<MasterKeyModel> _historySurgicalList = [];
import 'base/lockup-service.dart';
class SOAPService extends LookupService {
Future getAllergies(GetAllergiesRequestModel getAllergiesRequestModel) async {
await baseAppClient.post(
GET_ALLERGIES,
onSuccess: (dynamic response, int statusCode) {
_listOfAllergies.clear();
listOfAllergies.clear();
response['List_Allergies']['entityList'].forEach((v) {
_listOfAllergies.add(MasterKeyModel.fromJson(v));
listOfAllergies.add(MasterKeyModel.fromJson(v));
});
},
onFailure: (String error, int statusCode) {
@ -46,20 +26,6 @@ class SOAPService extends BaseService {
);
}
Future getMasterLookup(MasterKeysService masterKeys) async {
Map<String, dynamic> 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);
}
Future postAllergy(PostAllergyRequestModel postAllergyRequestModel) async {
await baseAppClient.post(POST_ALLERGY,
@ -70,60 +36,4 @@ class SOAPService extends BaseService {
super.error = error;
}, body: postAllergyRequestModel.toJson());
}
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;
}
}
}

@ -0,0 +1,98 @@
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<MasterKeyModel> listOfAllergies = [];
List<MasterKeyModel> get allergySeverityList => _allergySeverityList;
List<MasterKeyModel> _allergySeverityList = [];
List<MasterKeyModel> get historyFamilyList => _historyFamilyList;
List<MasterKeyModel> _historyFamilyList = [];
List<MasterKeyModel> get historyMedicalList => _historyMedicalList;
List<MasterKeyModel> _historyMedicalList = [];
List<MasterKeyModel> get historySportList => _historySportList;
List<MasterKeyModel> _historySportList = [];
List<MasterKeyModel> get historySocialList => _historySocialList;
List<MasterKeyModel> _historySocialList = [];
List<MasterKeyModel> get historySurgicalList => _historySurgicalList;
List<MasterKeyModel> _historySurgicalList = [];
Future getMasterLookup(MasterKeysService masterKeys) async {
Map<String, dynamic> 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;
}
}
}
Loading…
Cancel
Save