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.
135 lines
4.2 KiB
Dart
135 lines
4.2 KiB
Dart
import 'package:doctor_app_flutter/core/enum/viewstate.dart';
|
|
import 'package:doctor_app_flutter/core/service/patient-vital-signs-service.dart';
|
|
import 'package:doctor_app_flutter/core/viewModel/base_view_model.dart';
|
|
import 'package:doctor_app_flutter/models/patient/PatientArrivalEntity.dart';
|
|
import 'package:doctor_app_flutter/models/patient/patiant_info_model.dart';
|
|
import 'package:doctor_app_flutter/models/patient/vital_sign/patient-vital-sign-data.dart';
|
|
import 'package:doctor_app_flutter/models/patient/vital_sign/vital_sign_res_model.dart';
|
|
|
|
import '../../locator.dart';
|
|
|
|
class VitalSignsViewModel extends BaseViewModel {
|
|
VitalSignsService _vitalSignService = locator<VitalSignsService>();
|
|
|
|
List<PatientArrivalEntity> get patientArrivalList =>
|
|
_vitalSignService.patientArrivalList;
|
|
|
|
VitalSignData get patientVitalSigns => _vitalSignService.patientVitalSigns;
|
|
|
|
Future getPatientArrivalList(String date, PatiantInformtion patient,
|
|
{String fromDate}) async {
|
|
// TODO when arrival list work un comment below lines
|
|
/* setState(ViewState.Busy);
|
|
await _vitalSignService.getPatientArrivalList(date, fromDate: fromDate);
|
|
if (_vitalSignService.hasError) {
|
|
error = _vitalSignService.error;
|
|
setState(ViewState.Error);
|
|
} else {
|
|
await getPatientVitalSign(patient);
|
|
}*/
|
|
makeVitalSignDemoData();
|
|
}
|
|
|
|
PatientArrivalEntity getPatientAppointmentEntity(PatiantInformtion patient) {
|
|
String ffName = "${patient.firstName} ${patient.lastName}";
|
|
String fmfName =
|
|
"${patient.firstName} ${patient.middleName} ${patient.lastName}";
|
|
|
|
for (var element in patientArrivalList) {
|
|
int index = patientArrivalList.indexOf(element);
|
|
if (element.patientName == ffName || element.patientName == fmfName) {
|
|
return element;
|
|
}
|
|
// print("patient index: $index");
|
|
}
|
|
return null;
|
|
}
|
|
|
|
Future getPatientVitalSign(PatiantInformtion patient) async {
|
|
setState(ViewState.Busy);
|
|
PatientArrivalEntity patientArrivalEntity =
|
|
getPatientAppointmentEntity(patient);
|
|
if (patientArrivalEntity == null) {
|
|
_vitalSignService.hasError = true;
|
|
error = "There is no appointments for this patient";
|
|
setState(ViewState.Error);
|
|
return;
|
|
}
|
|
await _vitalSignService.getPatientVitalSign(patientArrivalEntity);
|
|
// TODO remove (not) from below condition
|
|
if (!_vitalSignService.hasError) {
|
|
error = _vitalSignService.error;
|
|
setState(ViewState.Error);
|
|
} else {
|
|
if (patientVitalSigns == null) {
|
|
makeVitalSignDemoData();
|
|
}
|
|
setState(ViewState.Idle);
|
|
}
|
|
}
|
|
|
|
makeVitalSignDemoData(){
|
|
_vitalSignService.patientVitalSigns = VitalSignData(
|
|
appointmentNo: 2016053265,
|
|
bloodPressureCuffLocation: 0,
|
|
bloodPressureCuffSize: 0,
|
|
bloodPressureHigher: 38,
|
|
bloodPressureLower: 32,
|
|
bloodPressurePatientPosition: 1,
|
|
bodyMassIndex: 31.11,
|
|
fio2: 0,
|
|
headCircumCm: 0,
|
|
heightCm: 150,
|
|
idealBodyWeightLbs: -2,
|
|
isPainManagementDone: false,
|
|
isVitalsRequired: true,
|
|
leanBodyWeightLbs: 0,
|
|
painCharacter: null,
|
|
painDuration: null,
|
|
painFrequency: null,
|
|
painLocation: null,
|
|
painScore: 0,
|
|
patientMRN: 3333274,
|
|
patientType: 1,
|
|
pulseBeatPerMinute: 0,
|
|
pulseRhythm: 0,
|
|
respirationBeatPerMinute: 0,
|
|
respirationPattern: 0,
|
|
sao2: 0,
|
|
status: 47,
|
|
temperatureCelcius: 40,
|
|
temperatureCelciusMethod: 1,
|
|
waistSizeInch: 39,
|
|
weightKg: 70,
|
|
);
|
|
}
|
|
|
|
String getBMI(double bodyMassIndex) {
|
|
if (bodyMassIndex <= 18.5) {
|
|
return "Underweight";
|
|
} else if (bodyMassIndex <= 25.0) {
|
|
return "Normal";
|
|
} else if (bodyMassIndex <= 30) {
|
|
return "Overweight";
|
|
} else { // > 30.0
|
|
return "Obese";
|
|
}
|
|
}
|
|
|
|
String getTempratureMethod(int temperatureCelciusMethod){
|
|
// temperatureCelciusMethod ( vital sign response field )- master 2005
|
|
if(temperatureCelciusMethod == 1){
|
|
return "Oral";
|
|
} else if(temperatureCelciusMethod == 2){
|
|
return "Axilla";
|
|
} else if(temperatureCelciusMethod == 3){
|
|
return "Rectal";
|
|
} else if(temperatureCelciusMethod == 4){
|
|
return "Tympanic";
|
|
} else if(temperatureCelciusMethod == 5){
|
|
return "Temporal";
|
|
}
|
|
}
|
|
|
|
}
|