getPatientData method
Implementation
Future<Patient?> getPatientData() async {
if (_sessionId == null) {
return null;
}
String data = jsonEncode(await _libraryData.getValue("patient"));
var obj = jsonDecode(jsonDecode(data).toString());
if(obj == null){
return null;
}
var patient = PatientBuilder();
patient.sessionId = _sessionId;
if (obj[PatientData().age] != null) {
patient.age = obj[PatientData().age] as String;
}
if (obj[PatientData().gender] != null) {
patient.gender = obj[PatientData().gender] as String;
}
if (obj[PatientData().insurance] != null) {
patient.insurance = obj[PatientData().insurance] as String;
}
if (obj[PatientData().insuranceType] != null) {
patient.insuranceType = obj[PatientData().insuranceType] as List<dynamic>;
}
if (obj[PatientData().insuranceName] != null) {
patient.insuranceName = obj[PatientData().insuranceName] as List<dynamic>;
}
if (obj[PatientData().temperature] != null) {
patient.temperature = obj[PatientData().temperature] as Map<String, dynamic>;
}
if (obj[PatientData().bp] != null) {
patient.bp = obj[PatientData().bp] as String;
}
if (obj[PatientData().pulse] != null) {
patient.pulse = obj[PatientData().pulse] as String;
}
if (obj[PatientData().respiration] != null) {
patient.respiration = obj[PatientData().respiration] as String?;
}
if (obj[PatientData().labTest] != null) {
patient.labTest = obj[PatientData().labTest] as List<dynamic>;
}
if (obj[PatientData().diagnosis] != null) {
patient.diagnosis = obj[PatientData().diagnosis] as List<dynamic>;
}
if (obj[PatientData().prescription] != null) {
patient.prescription = obj[PatientData().prescription] as List;
}
if (obj[PatientData().pharmacy] != null) {
patient.pharmacy = obj[PatientData().pharmacy] as List<dynamic>;
}
if (obj[PatientData().labTestHistory] != null) {
patient.labTestHistory = obj[PatientData().labTestHistory] as HistoryType;
}
if (obj[PatientData().diagnosisHistory] != null) {
patient.diagnosisHistory = obj[PatientData().diagnosisHistory] as HistoryType;
}
if (obj[PatientData().prescriptionHistory] != null) {
patient.prescriptionHistory = obj[PatientData().prescriptionHistory] as HistoryType;
}
if (obj[PatientData().pharmacyHistory] != null) {
patient.pharmacyHistory = obj[PatientData().pharmacyHistory] as HistoryType;
}
return patient.build()!;
}