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 _typeDictionary = new Hashtable(); private List _typeList = new ArrayList(); private List _firsAiderList = new ArrayList(); private List _anesthesiaList = new ArrayList(); private List _placeList = new ArrayList(); 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 GetTypeList() { return _typeList; } public List GetFirstAiderList() { return _firsAiderList; } public List GetAnesthesiaList() { return _anesthesiaList; } public List GetPlaceList() { return _placeList; } }