Skip to content
Snippets Groups Projects
Commit 7e44f822 authored by Thi Huyen Trang Nguyen's avatar Thi Huyen Trang Nguyen
Browse files

newBranchTEST: Added startTriage.dart and invalid_triage_state_exception.dart

parent a7614f57
No related branches found
No related tags found
No related merge requests found
class InvalidTriageStateException implements Exception { }
\ No newline at end of file
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;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment