From 7e44f822dc005f56e13a7da40203f744012268a7 Mon Sep 17 00:00:00 2001 From: Trang Nguyen <thi_huyen_trang.nguyen@student.reutlingen-university.de> Date: Wed, 20 Jan 2021 17:54:24 +0100 Subject: [PATCH] newBranchTEST: Added startTriage.dart and invalid_triage_state_exception.dart --- .../invalid_triage_state_exception.dart | 1 + .../lib/start_triage_system/startTriage.dart | 209 ++++++++++++++++++ 2 files changed, 210 insertions(+) create mode 100644 rescueapp/lib/start_triage_system/invalid_triage_state_exception.dart create mode 100644 rescueapp/lib/start_triage_system/startTriage.dart diff --git a/rescueapp/lib/start_triage_system/invalid_triage_state_exception.dart b/rescueapp/lib/start_triage_system/invalid_triage_state_exception.dart new file mode 100644 index 0000000..fccd2fc --- /dev/null +++ b/rescueapp/lib/start_triage_system/invalid_triage_state_exception.dart @@ -0,0 +1 @@ +class InvalidTriageStateException implements Exception { } \ No newline at end of file diff --git a/rescueapp/lib/start_triage_system/startTriage.dart b/rescueapp/lib/start_triage_system/startTriage.dart new file mode 100644 index 0000000..1989059 --- /dev/null +++ b/rescueapp/lib/start_triage_system/startTriage.dart @@ -0,0 +1,209 @@ +import 'package:flutter/material.dart'; +import 'package:rescueapp/start_triage_system/after_opening_airways.dart'; + +import 'package:rescueapp/start_triage_system/ambulatory.dart'; +import 'package:rescueapp/start_triage_system/camera_access.dart'; +import 'package:rescueapp/start_triage_system/lock_screen.dart'; +import 'package:rescueapp/start_triage_system/spontaneous_breathing_present.dart'; + +import 'breathing_frequency_per_minute.dart'; +import 'circulation.dart'; +import 'invalid_triage_state_exception.dart'; +import 'neurology.dart'; + +class StartTriage { + + bool _isAmbulatory; + bool _isSpontaneousBreathingPresent; + bool _isAfterOpeningAirways; + bool _isBreathingFrequencyPerMinute; + bool _isCirculation; + bool _isNeurology; + + Object _state; + + TriageCategory _triageCategory = new TriageCategory(); + + bool getIsAmbulatory() { + return _isAmbulatory; + } + + bool getIsSpontaneousBreathingPresent() { + return _isSpontaneousBreathingPresent; + } + + bool getIsAfterOpeningAirways() { + return _isAfterOpeningAirways; + } + + bool getIsBreathingFrequencyPerMinute() { + return _isBreathingFrequencyPerMinute; + } + + bool getIsCirculation() { + return _isCirculation; + } + + bool getIsNeurology() { + return _isNeurology; + } + + void setIsAmbulatory(bool isAmbulatory) { + if (_state is Ambulatory || + _state is SpontaneousBreathingPresent || + _state is AfterOpeningAirways || + _state is BreathingFrequencyPerMinute || + _state is CapillaryFillingTime || + _state is Neurology) { + if (_state is Ambulatory) { + this._isAmbulatory = isAmbulatory; + } else { + throw new InvalidTriageStateException(); + } + } + } + + void setIsSpontaneousBreathingPresent(bool isSpontaneousBreathingPresent) { + if (_state is Ambulatory || + _state is SpontaneousBreathingPresent || + _state is AfterOpeningAirways || + _state is BreathingFrequencyPerMinute || + _state is CapillaryFillingTime || + _state is Neurology) { + this._isSpontaneousBreathingPresent = isSpontaneousBreathingPresent; + } else { + throw new InvalidTriageStateException(); + } + } + + void setIsAfterOpeningAirways(bool isAfterOpeningAirways) { + if (_state is Ambulatory || + _state is AfterOpeningAirways || + _state is SpontaneousBreathingPresent) { + this._isAfterOpeningAirways = isAfterOpeningAirways; + } else { + throw new InvalidTriageStateException(); + } + } + + void setBreathingFrequencyPerMinute(bool isBreathingFrequencyPerMinute) { + if (_state is Ambulatory || + _state is BreathingFrequencyPerMinute || + _state is SpontaneousBreathingPresent || + _state is CapillaryFillingTime || + _state is Neurology) { + this._isBreathingFrequencyPerMinute = isBreathingFrequencyPerMinute; + } else { + throw new InvalidTriageStateException(); + } + } + + void setIsNeurology(bool isNeurology) { + if (_state is Ambulatory || + _state is BreathingFrequencyPerMinute || + _state is SpontaneousBreathingPresent || + _state is CapillaryFillingTime || + _state is Neurology) { + this._isNeurology = isNeurology; + } else { + throw new InvalidTriageStateException(); + } + } + + void setIsCirculation(bool isCirculation) { + if (_state is Ambulatory || + _state is BreathingFrequencyPerMinute || + _state is SpontaneousBreathingPresent || + _state is CapillaryFillingTime || + _state is Neurology) { + this._isCirculation = isCirculation; + } else { + throw new InvalidTriageStateException(); + } + } + + void setState(Object state) { + _state = state; + String categoryName; + print(_isAmbulatory); + Color color; + if (_state is Ambulatory || + _state is AfterOpeningAirways || + _state is BreathingFrequencyPerMinute || + _state is SpontaneousBreathingPresent || + _state is CapillaryFillingTime || + _state is Neurology) { + categoryName = ""; + } else if (_state is LockScreen || _state is CameraAccess) { + if ((this._isAmbulatory == true)) { + categoryName = 'Kategorie T3'; + color = Colors.green; + } else if (this._isAmbulatory == false && + this._isSpontaneousBreathingPresent == false && + this._isAfterOpeningAirways == false) { + categoryName = "Kategorie T4"; + color = Colors.black; + } else if (this._isAmbulatory == false && + this._isSpontaneousBreathingPresent == false && + this._isAfterOpeningAirways == true) { + categoryName = "Kategorie T1A"; + color = Colors.red; + } else if (this._isAmbulatory == false && + this._isSpontaneousBreathingPresent == true && + this._isBreathingFrequencyPerMinute == true) { + categoryName = "Kategorie T1B"; + color = Colors.red; + } else if (this._isAmbulatory == false && + this._isSpontaneousBreathingPresent == true && + this._isBreathingFrequencyPerMinute == false && + this._isCirculation == true) { + categoryName = "Kategorie T1C"; + color = Colors.red; + } else if (this._isAmbulatory == false && + this._isSpontaneousBreathingPresent == true && + this._isBreathingFrequencyPerMinute == false && + this._isCirculation == false && + this._isNeurology == false) { + categoryName = "Kategorie T1D"; + color = Colors.red; + } else if (this._isAmbulatory == false && + this._isSpontaneousBreathingPresent == true && + this._isBreathingFrequencyPerMinute == false && + this._isCirculation == false && + this._isNeurology == true) { + categoryName = "Kategorie T2"; + color = Colors.yellow; + } + } + if (categoryName != null) { + _triageCategory.setCategory(categoryName); + _triageCategory.setColor(color); + } else { + throw new InvalidTriageStateException(); + } + } + TriageCategory getTriageCategory() { + return _triageCategory; + } +} + +class TriageCategory { + String _category; + Color _color; + + String getCategory() { + return _category; + } + + void setCategory(String category) { + this._category = category; + } + + Color getColor() { + return _color; + } + + void setColor(Color color) { + this._color = color; + } +} -- GitLab