import 'dart:convert'; import 'package:doctor_app_flutter/config/config.dart'; import 'package:doctor_app_flutter/models/patient/patient_model.dart'; import 'package:doctor_app_flutter/screens/patients/patiant_info_model.dart'; import 'package:doctor_app_flutter/util/helpers.dart'; import 'package:flutter/cupertino.dart'; import 'package:http/http.dart'; import 'package:http_interceptor/http_client_with_interceptor.dart'; import '../interceptor/http_interceptor.dart'; const GET_PATIENT_VITAL_SIGN = BASE_URL + 'Doctors.svc/REST/Doctor_GetPatientVitalSign'; class PatientsProvider with ChangeNotifier { bool isLoading = true; bool isError = false; String error = ''; List patientVitalSignList = []; Client client = HttpClientWithInterceptor.build(interceptors: [HttpInterceptor()]); PatiantInformtion _selectedPatient; Future getPatientList(PatientModel patient, patientType) async { /* const url = BASE_URL+'DoctorApplication.svc/REST/GetMyInPatient';*/ // var srvicePatiant = ["GetMyOutPatient", "GetMyInPatient", "GtMyDischargePatient","GtMyReferredPatient","GtMyDischargeReferralPatient","GtMyTomorrowPatient","GtMyReferralPatient"]; // print("a=SERVICES_PATIANT[patientType]========='=======a"); int val = int.parse(patientType); final url = BASE_URL + 'DoctorApplication.svc/REST/' + SERVICES_PATIANT[val]; // print("a===========$url=======a"); try { final response = await client.post(url, body: json.encode({ "ProjectID": patient.ProjectID, "ClinicID": patient.ClinicID, "DoctorID": patient.DoctorID, "FirstName": patient.FirstName, "MiddleName": patient.MiddleName, "LastName": patient.LastName, "PatientMobileNumber": patient.PatientMobileNumber, "PatientIdentificationID": patient.PatientIdentificationID, "PatientID": patient.PatientID, "From": patient.From, "To": patient.To, "LanguageID": patient.LanguageID, "stamp": patient.stamp, "IPAdress": patient.IPAdress, "VersionID": patient.VersionID, "Channel": patient.Channel, "TokenID": patient.TokenID, "SessionID": patient.SessionID, "IsLoginForDoctorApp": patient.IsLoginForDoctorApp, "PatientOutSA": patient.PatientOutSA })); //********************** //*********************** return Future.value(json.decode(response.body)); } catch (error) { throw error; } } /* *@author: Elham Rababah *@Date:27/4/2020 *@param: *@return:Future *@desc: getPatientVitalSign */ getPatientVitalSign(patient) async { try { if (await Helpers.checkConnection()) { final response = await client.post(GET_PATIENT_VITAL_SIGN, body: json.encode(patient)); final int statusCode = response.statusCode; isLoading = false; if (statusCode < 200 || statusCode >= 400 || json == null) { isError = true; error = 'Error While Fetching data'; } else { var res = json.decode(response.body); print('$res'); if (res['MessageStatus'] == 1) { patientVitalSignList = res['List_DoctorPatientVitalSign']; } else { isError = true; error = res['ErrorMessage'] ?? res['ErrorEndUserMessage']; } } } else { isLoading = false; isError = true; error = 'Please Check The Internet Connection'; } notifyListeners(); } catch (error) { throw error; } } PatiantInformtion getSelectedPatient() { return _selectedPatient; } setSelectedPatient(PatiantInformtion patient) { // return _selectedPatient; _selectedPatient = patient; } }