001/** 002 * Copyright (C) 2014 Universidade de Aveiro, DETI/IEETA, Bioinformatics Group - http://bioinformatics.ua.pt/ 003 * 004 * This file is part of Dicoogle/dicoogle. 005 * 006 * Dicoogle/dicoogle is free software: you can redistribute it and/or modify 007 * it under the terms of the GNU General Public License as published by 008 * the Free Software Foundation, either version 3 of the License, or 009 * (at your option) any later version. 010 * 011 * Dicoogle/dicoogle is distributed in the hope that it will be useful, 012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 014 * GNU General Public License for more details. 015 * 016 * You should have received a copy of the GNU General Public License 017 * along with Dicoogle. If not, see <http://www.gnu.org/licenses/>. 018 */ 019package pt.ua.dicoogle.core.dim; 020 021import java.util.ArrayList; 022import java.util.HashMap; 023import java.util.Hashtable; 024import java.util.Map; 025 026/** 027 * 028 * @author Luís A. Bastião Silva <bastiao@ua.pt> 029 */ 030public class Patient 031{ 032 private String PatientID; 033 private String PatientName; 034 private String PatientSex; 035 private String PatientBirthDate; 036 037 private ArrayList<Study> studies = new ArrayList<>() ; 038 private Map<String, Study> studiesHash = new HashMap<>(); 039 private int nStudyOverride = -1; 040 041 public Patient(String PatientID, String PatientName) 042 { 043 this.PatientName = PatientName; 044 this.PatientID = PatientID; 045 } 046 047 public Patient(String PatientID) 048 { 049 this.PatientID = PatientID; 050 } 051 052 /** 053 * Add new Study to Patient 054 * @param s 055 */ 056 public void addStudy(Study s) 057 { 058 059 if (this.studiesHash.containsKey(s.getStudyInstanceUID())) 060 { 061 /** 062 * The study exists, so it will take the series and add the series 063 */ 064 065 Study es = this.studiesHash.get(s.getStudyInstanceUID()) ; 066 es.setStudyDescription(s.getStudyDescription()); 067 for (Serie e: s.getSeries()) 068 { 069 es.addSerie(e); 070 } 071 072 } 073 else 074 { 075 this.getStudies().add(s); 076 this.studiesHash.put(s.getStudyInstanceUID(), s); 077 } 078 079 } 080 081 /** 082 * Get the Study with StudyInstanceUID. If it exists 083 * will be returned. Otherwise a null is returned 084 * @return s Stydy Result 085 */ 086 public Study getStudy(String studyInstanceUID) 087 { 088 return this.studiesHash.get(studyInstanceUID); 089 } 090 091 092 public String toString() 093 { 094 String result = ""; 095 result += "PatientID: " + this.getPatientID() ; 096 if (this.getPatientName()!=null) 097 result = "PatientName: " + this.getPatientName() + "\n"; 098 if (this.getPatientSex() != null) 099 result = "PatientSax: " + this.getPatientSex() + "\n"; 100 101 // XXX Study + Series 102 103 return result ; 104 } 105 106 /** 107 * @return the PatientID 108 */ 109 public String getPatientID() { 110 return PatientID; 111 } 112 113 /** 114 * @param PatientID the PatientID to set 115 */ 116 public void setPatientID(String PatientID) { 117 this.PatientID = PatientID; 118 } 119 120 /** 121 * @return the PatientName 122 */ 123 public String getPatientName() { 124 return PatientName; 125 } 126 127 /** 128 * @param PatientName the PatientName to set 129 */ 130 public void setPatientName(String PatientName) { 131 this.PatientName = PatientName; 132 } 133 134 /** 135 * @return the PatientSex 136 */ 137 public String getPatientSex() { 138 return PatientSex; 139 } 140 141 /** 142 * @param PatientSex the PatientSex to set 143 */ 144 public void setPatientSex(String PatientSex) { 145 this.PatientSex = PatientSex; 146 } 147 148 /** 149 * @return the studies 150 */ 151 public ArrayList<Study> getStudies() { 152 return studies; 153 } 154 155 /** 156 * @return the PatientBirthDate 157 */ 158 public String getPatientBirthDate() { 159 return PatientBirthDate; 160 } 161 162 /** 163 * @param PatientBirthDate the PatientBirthDate to set 164 */ 165 public void setPatientBirthDate(String PatientBirthDate) { 166 this.PatientBirthDate = PatientBirthDate; 167 } 168 169}