import 'dart:convert'; import 'package:hmg_nurses/classes/consts.dart'; import 'package:hmg_nurses/main.dart'; import 'package:hmg_nurses/model/base/generic_response_model.dart'; import 'package:hmg_nurses/services/api_client.dart'; import 'package:injector/injector.dart'; abstract class IPatientApiRepo { Future getPatientInfo(int patientID); Future getVitalSigns({int? patientID, int? patientTypeID, int? inOutPatientType, bool isDentalAllowedBackend, int? doctorID, int setupID, int? patientType}); } class PatientApiRepo implements IPatientApiRepo { @override Future getPatientInfo(int patientID) async { String url = "${ApiConsts.baseUrlServices}Patients.svc/REST/GetPatientInformation_PRM"; Map postParams = {}; postParams.addAll(appState.postParamsJson); postParams["FirstName"] = "0"; postParams["MiddleName"] = "0"; postParams["LastName"] = "0"; postParams["PatientMobileNumber"] = "0"; postParams["PatientIdentificationID"] = "0"; postParams["PatientID"] = patientID; postParams["From"] = "0"; postParams["To"] = "0"; postParams["SearchType"] = 1; postParams["MobileNo"] = ""; postParams["IdentificationNo"] = "0"; postParams["NursingStationID"] = "0"; GenericResponseModel response; print(jsonEncode(postParams)); // return GenericResponseModel(); try { response = await Injector.appInstance.get().postJsonForObject((json) => GenericResponseModel.fromJson(json), url, postParams); } catch (e) { rethrow; } return response; } @override Future getVitalSigns({int? patientID, int? patientTypeID, int? inOutPatientType, bool? isDentalAllowedBackend, int? doctorID, int? setupID, int? patientType}) async { String url = "${ApiConsts.baseUrlServices}Doctors.svc/REST/Doctor_GetPatientVitalSign"; Map postParams = {}; // { // "PatientID": 12, // "PatientTypeID": 1, // "InOutPatientType": 0, // "isDentalAllowedBackend": false, // "DoctorID": 2477, // "SetupID": "91877", // "PatientType": 1, // } postParams.addAll(appState.postParamsJson); postParams["PatientID"] = patientID; postParams["PatientTypeID"] = patientTypeID; postParams["InOutPatientType"] = inOutPatientType; postParams["isDentalAllowedBackend"] = isDentalAllowedBackend; postParams["DoctorID"] = doctorID; postParams["SetupID"] = setupID; postParams["PatientType"] = patientType; postParams.remove("ProjectID"); postParams.remove("ClinicID"); GenericResponseModel response; // return GenericResponseModel(); try { response = await Injector.appInstance.get().postJsonForObject((json) => GenericResponseModel.fromJson(json), url, postParams); } catch (e) { rethrow; } return response; } }