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/er/EdOnlineServices.dart

80 lines
3.3 KiB
Dart

import 'package:diplomaticquarterapp/config/config.dart';
import 'package:diplomaticquarterapp/config/shared_pref_kay.dart';
import 'package:diplomaticquarterapp/core/model/er/ErPatientShareModel.dart';
import 'package:diplomaticquarterapp/core/model/er/TriageQuestionsModel.dart';
import 'package:diplomaticquarterapp/core/service/base_service.dart';
import 'package:diplomaticquarterapp/uitl/app_shared_preferences.dart';
import 'package:flutter/cupertino.dart';
class EdOnlineServices extends BaseService {
List<TriageQuestionsModel> triageQuestionsModelList = List();
ErPatientShareModel erPatientShareModel;
Future getQuestions() async {
hasError = false;
triageQuestionsModelList.clear();
Map<String, dynamic> body = Map();
body['ProjectID'] = 15;
await baseAppClient.post(ER_GET_VISUAL_TRIAGE_QUESTIONS, onSuccess: (dynamic response, int statusCode) {
triageQuestionsModelList.clear();
response['ER_TriageQuestionsList'].forEach((questions) {
triageQuestionsModelList.add(TriageQuestionsModel.fromJson(questions));
});
}, onFailure: (String error, int statusCode) {
hasError = true;
super.error = error;
}, body: body);
}
Future getPatientPaymentInformation({var id}) async {
hasError = false;
await baseAppClient.post(ER_GetPatientPaymentInformationForERClinic, onSuccess: (dynamic response, int statusCode) {
erPatientShareModel = ErPatientShareModel.fromJson(response['ER_PatientShare']);
}, onFailure: (String error, int statusCode) {
hasError = true;
super.error = error;
}, body: Map.from({"ProjectID": 15, "ClinicID": 10}));
}
Future saveQuestionsInformation({String notes, String chiefComplaint, int projectId, DateTime selectedTime, List<TriageQuestionsModel> selectedQuestions}) async {
AppSharedPreferences sharedPref = AppSharedPreferences();
hasError = false;
Map<String, dynamic> body = Map();
List<Map> checklist = List();
body['ProjectID'] = 15;
body['ProjectId'] = projectId;
int riskScore = 0;
if (user.age > 14) {
selectedQuestions.forEach((element) {
int score = int.parse((element.adultPoints != "" ? element.adultPoints : "0"));
riskScore += score;
checklist.add(Map.from({"IsSelected": 1, "ParameterCode": element.parameterCode, "ParameterGroup": element.parameterGroup, "ParameterType": element.parameterType, "Score": score}));
});
} else {
selectedQuestions.forEach((element) {
int score = int.parse(element.pediaPoints);
riskScore += score;
checklist.add(Map.from({"IsSelected": 1, "ParameterCode": element.parameterCode, "ParameterGroup": element.parameterGroup, "ParameterType": element.parameterType, "Score": score}));
});
}
body['ERTriageInformation'] = {
"Notes": notes,
"ChiefComplaint": chiefComplaint,
"PatientId": user.patientID,
"ProjectId": projectId,
"RiskScore": riskScore,
"checklist": checklist.map((e) => e).toList()
};
sharedPref.setInt(ER_CHECKIN_RISK_SCORE, riskScore);
await baseAppClient.post(ER_SAVE_TRIAGE_INFORMATION, onSuccess: (dynamic response, int statusCode) {}, onFailure: (String error, int statusCode) {
hasError = true;
super.error = error;
}, body: body);
}
}