You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
diplomatic-quarter/lib/core/service/vaccine_service.dart

76 lines
2.6 KiB
Dart

import 'package:diplomaticquarterapp/config/config.dart';
import 'package:diplomaticquarterapp/core/model/vaccine/vaccination_item.dart';
import 'package:diplomaticquarterapp/core/model/vaccine/vaccination_on_hand.dart';
import 'package:diplomaticquarterapp/core/service/base_service.dart';
import 'package:diplomaticquarterapp/core/model/vaccine/my_vaccine.dart';
class VaccineService extends BaseService {
List<VaccineModel> _vaccineList = List();
List<VaccinationItem> vaccinationItemList = List();
List<VaccinationOnHand> vaccinationOnHandList = List();
List<VaccineModel> get vaccineList => _vaccineList;
Future getMyVaccine() async {
Map<String, dynamic> body = Map();
body['To'] = "0";
body['From'] = "0";
hasError = false;
_vaccineList.clear();
await baseAppClient.post(GET_VACCINES,
onSuccess: (dynamic response, int statusCode) {
response['List_DoneVaccines'].forEach((item) {
_vaccineList.add(VaccineModel.fromJson(item));
});
}, onFailure: (String error, int statusCode) {
hasError = true;
super.error = error;
}, body: body);
}
Future sendEmail() async {
Map<String, dynamic> body = Map();
body['ListVaccines'] = vaccineList.map((v) => v.toJson()).toList();
body['To'] = user.emailAddress;
body['DateofBirth'] = user.dateofBirth;
body['PatientIditificationNum'] = user.patientIdentificationNo;
body['PatientMobileNumber'] = user.mobileNumber;
body['PatientName'] = user.firstName + " " + user.lastName;
hasError = false;
await baseAppClient.post(GET_VACCINES_EMAIL,
onSuccess: (dynamic response, int statusCode) {},
onFailure: (String error, int statusCode) {
hasError = true;
super.error = error;
}, body: body);
}
Future getMyVaccinationItem() async {
await baseAppClient.post(GET_VACCINATIONS_ITEMS,
onSuccess: (dynamic response, int statusCode) {
response['GetVaccinationsList'].forEach((item) {
vaccinationItemList.add(VaccinationItem.fromJson(item));
});
}, onFailure: (String error, int statusCode) {
hasError = true;
super.error = error;
}, body: Map());
}
Future getMyVaccinationOnHand({String pItemCode}) async {
Map<String, dynamic> body = Map();
body['P_ITEM_CODE'] = pItemCode;
await baseAppClient.post(GET_VACCINATION_ONHAND,
onSuccess: (dynamic response, int statusCode) {
response['GetVaccinationOnHandList'].forEach((item) {
vaccinationOnHandList.add(VaccinationOnHand.fromJson(item));
});
}, onFailure: (String error, int statusCode) {
hasError = true;
super.error = error;
}, body: body);
}
}