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.
101 lines
3.5 KiB
Dart
101 lines
3.5 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 {
|
|
setState(ViewState.Busy);
|
|
await _vitalSignService.getPatientArrivalList(date, fromDate: fromDate);
|
|
if (_vitalSignService.hasError) {
|
|
error = _vitalSignService.error;
|
|
setState(ViewState.Error);
|
|
} else {
|
|
await getPatientVitalSign(patient);
|
|
}
|
|
}
|
|
|
|
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) {
|
|
_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,
|
|
);
|
|
}
|
|
setState(ViewState.Idle);
|
|
}
|
|
}
|
|
}
|