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.
PatientApp-KKUMC/lib/core/service/medical/WeightPressureService.dart

131 lines
5.0 KiB
Dart

5 years ago
import 'package:diplomaticquarterapp/config/config.dart';
import 'package:diplomaticquarterapp/core/model/my_trakers/weight/MonthWeightMeasurementResultAverage.dart';
import 'package:diplomaticquarterapp/core/model/my_trakers/weight/WeekWeightMeasurementResultAverage.dart';
import 'package:diplomaticquarterapp/core/model/my_trakers/weight/WeightMeasurementResult.dart';
import 'package:diplomaticquarterapp/core/model/my_trakers/weight/YearWeightMeasurementResultAverage.dart';
import 'package:diplomaticquarterapp/core/service/base_service.dart';
class WeightService extends BaseService {
///Average
5 years ago
List<MonthWeightMeasurementResultAverage> monthWeightMeasurementResultAverage = List();
List<WeekWeightMeasurementResultAverage> weekWeightMeasurementResultAverage = List();
List<YearWeightMeasurementResultAverage> yearWeightMeasurementResultAverage = List();
5 years ago
///Result
List<WeightMeasurementResult> monthWeightMeasurementResult = List();
List<WeightMeasurementResult> weekWeightMeasurementResult = List();
List<WeightMeasurementResult> yearWeightMeasurementResult = List();
Future getWeightAverage() async {
hasError = false;
Map<String, dynamic> body = Map();
body['isDentalAllowedBackend'] = false;
4 years ago
monthWeightMeasurementResultAverage.clear();
weekWeightMeasurementResultAverage.clear();
yearWeightMeasurementResultAverage.clear();
5 years ago
await baseAppClient.post(GET_WEIGHT_PRESSURE_RESULT_AVERAGE, onSuccess: (dynamic response, int statusCode) {
5 years ago
response['List_MonthWeightMeasurementResultAverage'].forEach((item) {
5 years ago
monthWeightMeasurementResultAverage.add(MonthWeightMeasurementResultAverage.fromJson(item));
5 years ago
});
response['List_WeekWeightMeasurementResultAverage'].forEach((item) {
5 years ago
weekWeightMeasurementResultAverage.add(WeekWeightMeasurementResultAverage.fromJson(item));
5 years ago
});
response['List_YearWeightMeasurementResultAverage'].forEach((item) {
5 years ago
yearWeightMeasurementResultAverage.add(YearWeightMeasurementResultAverage.fromJson(item));
5 years ago
});
}, onFailure: (String error, int statusCode) {
hasError = true;
super.error = error;
}, body: body);
}
Future getWeightMeasurementResult() async {
hasError = false;
4 years ago
monthWeightMeasurementResult.clear();
weekWeightMeasurementResult.clear();
yearWeightMeasurementResult.clear();
5 years ago
await baseAppClient.post(GET_WEIGHT_PRESSURE_RESULT, onSuccess: (dynamic response, int statusCode) {
5 years ago
response['List_WeekWeightMeasurementResult'].forEach((item) {
weekWeightMeasurementResult.add(WeightMeasurementResult.fromJson(item));
});
response['List_MonthWeightMeasurementResult'].forEach((item) {
5 years ago
monthWeightMeasurementResult.add(WeightMeasurementResult.fromJson(item));
5 years ago
});
response['List_YearWeightMeasurementResult'].forEach((item) {
yearWeightMeasurementResult.add(WeightMeasurementResult.fromJson(item));
});
}, onFailure: (String error, int statusCode) {
hasError = true;
super.error = error;
}, body: Map());
}
5 years ago
addWeightResult({String weightDate, String weightMeasured, int weightUnit}) async {
5 years ago
hasError = false;
super.error = "";
Map<String, dynamic> body = Map();
body['WeightDate'] = weightDate;
body['WeightMeasured'] = weightMeasured;
body['weightUnit'] = weightUnit;
body['isDentalAllowedBackend'] = false;
5 years ago
await baseAppClient.post(ADD_WEIGHT_PRESSURE_RESULT, onSuccess: (response, statusCode) async {},
onFailure: (String error, int statusCode) {
hasError = true;
super.error = error;
}, body: body);
}
5 years ago
updateWeightResult({int lineItemNo, int weightUnit, String weightMeasured, String weightDate}) async {
hasError = false;
super.error = "";
Map<String, dynamic> body = Map();
body['LineItemNo'] = lineItemNo;
body['weightUnit'] = '$weightUnit';
body['WeightMeasured'] = weightMeasured;
body['WeightDate'] = weightDate;
body['isDentalAllowedBackend'] = false;
5 years ago
await baseAppClient.post(UPDATE_WEIGHT_PRESSURE_RESULT, onSuccess: (response, statusCode) async {},
onFailure: (String error, int statusCode) {
hasError = true;
super.error = error;
}, body: body);
}
5 years ago
Future sendReportByEmail() async {
hasError = false;
super.error = "";
Map<String, dynamic> body = Map();
body['isDentalAllowedBackend'] = false;
body['to'] = user.emailAddress;
5 years ago
await baseAppClient.post(SEND_AVERAGE_BLOOD_WEIGHT_REPORT, onSuccess: (response, statusCode) async {},
onFailure: (String error, int statusCode) {
5 years ago
hasError = true;
super.error = error;
}, body: body);
}
5 years ago
deleteWeightResult({
int lineItemNo,
}) async {
hasError = false;
super.error = "";
Map<String, dynamic> body = Map();
body['LineItemNo'] = lineItemNo;
body['isDentalAllowedBackend'] = false;
5 years ago
5 years ago
await baseAppClient.post(DEACTIVATE_WEIGHT_PRESSURE_RESULT, onSuccess: (response, statusCode) async {},
5 years ago
onFailure: (String error, int statusCode) {
hasError = true;
super.error = error;
}, body: body);
}
}