diff options
| author | dam <dam@gudinoff> | 2021-11-30 01:06:44 +0000 |
|---|---|---|
| committer | dam <dam@gudinoff> | 2021-11-30 01:06:44 +0000 |
| commit | 697e1ba3c4cb0a96c4584f1553de368d46287ab7 (patch) | |
| tree | 75ef68904ee92233f97eb00f1ded734b7c0709a3 /src/com/example/surgerylog/MedLogRoot.java | |
| parent | da1195d4446963a2a3d95bdced6571bd26b8abfa (diff) | |
| download | surgery-log-697e1ba3c4cb0a96c4584f1553de368d46287ab7.tar.zst surgery-log-697e1ba3c4cb0a96c4584f1553de368d46287ab7.zip | |
Initial commit.
Diffstat (limited to 'src/com/example/surgerylog/MedLogRoot.java')
| -rwxr-xr-x | src/com/example/surgerylog/MedLogRoot.java | 142 |
1 files changed, 142 insertions, 0 deletions
diff --git a/src/com/example/surgerylog/MedLogRoot.java b/src/com/example/surgerylog/MedLogRoot.java new file mode 100755 index 0000000..073701b --- /dev/null +++ b/src/com/example/surgerylog/MedLogRoot.java @@ -0,0 +1,142 @@ +package com.example.surgerylog;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Dictionary;
+import java.util.Hashtable;
+import java.util.List;
+
+public class MedLogRoot implements Serializable {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 7337501254153966693L;
+ private Dictionary<String, MedLogType> _typeDictionary = new Hashtable<String, MedLogType>();
+ private List<String> _typeList = new ArrayList<String>();
+
+ private List<String> _firsAiderList = new ArrayList<String>();
+ private List<String> _anesthesiaList = new ArrayList<String>();
+ private List<String> _placeList = new ArrayList<String>();
+
+ public MedLogRoot() {
+ }
+
+ public void GrowTreeWithInfo(MedLogInfo info) {
+ // try to add new first aider
+ if (HasFirstAider(info.FirstAider) == false) {
+ AddFirstAider(info.FirstAider);
+ }
+
+ // try to add new anesthesia
+ if (HasAnesthesia(info.Anesthesia) == false) {
+ AddAnesthesia(info.Anesthesia);
+ }
+
+ // try to add new place
+ if (HasPlace(info.Place) == false) {
+ AddPlace(info.Place);
+ }
+
+ // try to add new Type
+ if (HasType(info.Type) == false) {
+ AddType(info.Type);
+ }
+
+ // Only add branches if has root...
+ if (HasType(info.Type) == true) {
+
+ // get Type
+ MedLogType type = _typeDictionary.get(info.Type);
+
+ // add Type related information
+ if (type.HasSubType(info.SubType) == false) {
+ type.AddSubType(info.SubType);
+ }
+
+ // Only add branches if has root...
+ if (type.HasSubType(info.SubType) == true) {
+
+ // get SubType
+ MedLogSubType subType = type.GetMedLogSubType(info.SubType);
+
+ // add SubTyppe related information
+ if (subType.HasSubSubType(info.SubSubType) == false) {
+ subType.AddSubSubType(info.SubSubType);
+ }
+ if (subType.HasPathology(info.Pathology) == false) {
+ subType.AddPathology(info.Pathology);
+ }
+ if (subType.HasIntervention(info.Intervention) == false) {
+ subType.AddIntervention(info.Intervention);
+ }
+ }
+ }
+ }
+
+ private Boolean IsValid(String verify) {
+ return verify.trim().isEmpty() == false;
+ }
+
+ public Boolean HasFirstAider(String firstAider) {
+ return _firsAiderList.contains(firstAider.trim());
+ }
+
+ public void AddFirstAider(String firstAider) {
+ if (IsValid(firstAider))
+ _firsAiderList.add(firstAider.trim());
+ }
+
+ public Boolean HasAnesthesia(String anesthesia) {
+ return _anesthesiaList.contains(anesthesia.trim());
+ }
+
+ public void AddAnesthesia(String anesthesia) {
+ if (IsValid(anesthesia))
+ _anesthesiaList.add(anesthesia.trim());
+ }
+
+ public Boolean HasPlace(String place) {
+ return _placeList.contains(place.trim());
+ }
+
+ public void AddPlace(String place) {
+ if (IsValid(place))
+ _placeList.add(place.trim());
+ }
+
+ public Boolean HasType(String type) {
+ return _typeList.contains(type.trim());
+ }
+
+ public void AddType(String type) {
+ if (IsValid(type)) {
+ String typeTrim = type.trim();
+
+ _typeList.add(typeTrim);
+
+ MedLogType surgeryType = new MedLogType();
+ _typeDictionary.put(typeTrim, surgeryType);
+ }
+ }
+
+ public MedLogType GetMedLogType(String type) {
+ return _typeDictionary.get(type.trim());
+ }
+
+ public List<String> GetTypeList() {
+ return _typeList;
+ }
+
+ public List<String> GetFirstAiderList() {
+ return _firsAiderList;
+ }
+
+ public List<String> GetAnesthesiaList() {
+ return _anesthesiaList;
+ }
+
+ public List<String> GetPlaceList() {
+ return _placeList;
+ }
+}
|
