View Javadoc
1   /*
2    * Copyright 2015 the original author or authors.
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *       http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  
17  package org.openehealth.ipf.commons.ihe.fhir.iti78;
18  
19  import ca.uhn.fhir.model.api.annotation.*;
20  import ca.uhn.fhir.model.api.annotation.Extension;
21  import ca.uhn.fhir.rest.gclient.DateClientParam;
22  import ca.uhn.fhir.rest.gclient.StringClientParam;
23  import ca.uhn.fhir.rest.gclient.TokenClientParam;
24  import ca.uhn.fhir.util.ElementUtil;
25  import org.hl7.fhir.dstu3.model.*;
26  import org.hl7.fhir.instance.model.api.IAnyResource;
27  
28  import java.util.ArrayList;
29  import java.util.List;
30  
31  /**
32   * Patient as defined by the PDQm specification plus some of the most common extensions
33   * This extends the default patient resource with the following attributes:
34   * <ul>
35   * <li>birthplace</li>
36   * <li>mothersMaidenName</li>
37   * <li>citizenship</li>
38   * <li>religion</li>
39   * <li>race</li>
40   * <li>ethnicity</li>
41   * </ul>
42   *
43   * @author Christian Ohr
44   * @since 3.4
45   */
46  @ResourceDef(name = "Patient", id = "pdqm")
47  public class PdqPatient extends Patient {
48  
49      // Search Parameters
50  
51      public static final TokenClientParam IDENTIFIER = new TokenClientParam(Patient.SP_IDENTIFIER);
52      public static final TokenClientParam ACTIVE = new TokenClientParam(Patient.SP_ACTIVE);
53      public static final StringClientParam FAMILY = new StringClientParam(Patient.SP_FAMILY);
54      public static final StringClientParam GIVEN = new StringClientParam(Patient.SP_GIVEN);
55      public static final DateClientParam BIRTHDATE = new DateClientParam(Patient.SP_BIRTHDATE);
56      public static final StringClientParam ADDRESS = new StringClientParam(Patient.SP_ADDRESS);
57      public static final TokenClientParam GENDER = new TokenClientParam(Patient.SP_GENDER);
58      public static final TokenClientParam RESOURCE_IDENTIFIER = new TokenClientParam(IAnyResource.SP_RES_ID);
59      public static final StringClientParam TELECOM = new StringClientParam(Patient.SP_TELECOM);
60  
61      @Child(name = "birthPlace")
62      @Extension(url = "http://hl7.org/fhir/StructureDefinition/birthPlace", isModifier = false, definedLocally = false)
63      @Description(shortDefinition = "The registered place of birth of the patient. A system may use the address.text if they don't store the birthPlace address in discrete elements")
64      private Address birthPlace;
65  
66      @Child(name = "mothersMaidenName")
67      @Extension(url = "http://hl7.org/fhir/StructureDefinition/patient-mothersMaidenName", isModifier = false, definedLocally = false)
68      @Description(shortDefinition = "Mother's maiden name of a patient")
69      private HumanName mothersMaidenName;
70  
71      @Child(name = "citizenship", max = Child.MAX_UNLIMITED)
72      @Extension(url = "http://hl7.org/fhir/StructureDefinition/patient-citizenship", isModifier = false, definedLocally = false)
73      @Description(shortDefinition = "The citizenship of the patient")
74      private List<Citizenship> citizenship;
75  
76      @Child(name = "religion", max = Child.MAX_UNLIMITED)
77      @Extension(url = "http://hl7.org/fhir/StructureDefinition/patient-religion", isModifier = false, definedLocally = false)
78      @Description(shortDefinition = "The patient's professed religious affiliations")
79      private List<CodeableConcept> religion;
80  
81      @Child(name = "race")
82      @Extension(url = "http://hl7.org/fhir/us/core/StructureDefinition/us-core-race", isModifier = false, definedLocally = false)
83      @Description(shortDefinition = "Concepts classifying  the person into a named category of humans sharing common history, traits, geographical origin or nationality")
84      private Race race;
85  
86      @Child(name = "ethnicity")
87      @Extension(url = "http://hl7.org/fhir/us/core/StructureDefinition/us-core-ethnicity", isModifier = false, definedLocally = false)
88      @Description(shortDefinition = "Concepts classifying the person into a named category of humans sharing common history, traits, geographical origin or nationality.")
89      private Ethnicity ethnicity;
90  
91      @Override
92      public boolean isEmpty() {
93          return super.isEmpty() && ElementUtil.isEmpty(birthPlace, mothersMaidenName, citizenship, religion, race, ethnicity);
94      }
95  
96      public Address getBirthPlace() {
97          if (birthPlace == null) {
98              birthPlace = new Address();
99          }
100         return birthPlace;
101     }
102 
103     public void setBirthPlace(Address birthPlace) {
104         this.birthPlace = birthPlace;
105     }
106 
107     public boolean hasBirthPlace() {
108         return this.birthPlace != null && !this.birthPlace.isEmpty();
109     }
110 
111     public HumanName getMothersMaidenName() {
112         if (mothersMaidenName == null) {
113             mothersMaidenName = new HumanName();
114         }
115         return mothersMaidenName;
116     }
117 
118     public void setMothersMaidenName(HumanName mothersMaidenName) {
119         this.mothersMaidenName = mothersMaidenName;
120     }
121 
122     public boolean hasMothersMaidenName() {
123         return this.mothersMaidenName != null && !this.mothersMaidenName.isEmpty();
124     }
125 
126     public List<Citizenship> getCitizenship() {
127         if (citizenship == null) {
128             citizenship = new ArrayList<>();
129         }
130         return citizenship;
131     }
132 
133     public void setCitizenship(List<Citizenship> citizenship) {
134         this.citizenship = citizenship;
135     }
136 
137     public Citizenship addCitizenship() {
138         Citizenship t = new Citizenship();
139         if (this.citizenship == null)
140             this.citizenship = new ArrayList<>();
141         this.citizenship.add(t);
142         return t;
143     }
144 
145     public Patient addCitizenship(Citizenship t) {
146         if (t == null)
147             return this;
148         if (this.citizenship == null)
149             this.citizenship = new ArrayList<>();
150         this.citizenship.add(t);
151         return this;
152     }
153 
154     public boolean hasCitizenship() {
155         if (this.citizenship == null)
156             return false;
157         for (Citizenship item : this.citizenship)
158             if (!item.isEmpty())
159                 return true;
160         return false;
161     }
162 
163     public List<CodeableConcept> getReligion() {
164         if (religion == null) {
165             religion = new ArrayList<>();
166         }
167         return religion;
168     }
169 
170     public void setReligion(List<CodeableConcept> religion) {
171         this.religion = religion;
172     }
173 
174     public boolean hasReligion() {
175         if (this.religion == null)
176             return false;
177         for (CodeableConcept item : this.religion)
178             if (!item.isEmpty())
179                 return true;
180         return false;
181     }
182 
183     public CodeableConcept addReligion() {
184         CodeableConcept t = new CodeableConcept();
185         if (this.religion == null)
186             this.religion = new ArrayList<>();
187         this.religion.add(t);
188         return t;
189     }
190 
191     public Patient addReligion(CodeableConcept t) {
192         if (t == null)
193             return this;
194         if (this.religion == null)
195             this.religion = new ArrayList<>();
196         this.religion.add(t);
197         return this;
198     }
199 
200     public Race getRace() {
201         if (race == null) {
202             race = new Race();
203         }
204         return race;
205     }
206 
207     public void setRace(Race race) {
208         this.race = race;
209     }
210 
211     public boolean hasRace() {
212         return this.race != null && !this.race.isEmpty();
213     }
214 
215     public Ethnicity getEthnicity() {
216         if (ethnicity == null) {
217             ethnicity = new Ethnicity();
218         }
219         return ethnicity;
220     }
221 
222     public void setEthnicity(Ethnicity ethnicity) {
223         this.ethnicity = ethnicity;
224     }
225 
226     public boolean hasEthnicity() {
227         return this.ethnicity != null && !this.ethnicity.isEmpty();
228     }
229 
230     @Block
231     public static class Citizenship extends BackboneElement {
232 
233         @Child(name = "code")
234         @Extension(url = "http://hl7.org/fhir/StructureDefinition/patient-citizenship/code", definedLocally = false, isModifier = false)
235         private CodeableConcept code;
236 
237         @Child(name = "period")
238         @Extension(url = "http://hl7.org/fhir/StructureDefinition/patient-citizenship/period", definedLocally = false, isModifier = false)
239         private Period period;
240 
241         @Override
242         public Citizenship copy() {
243             Citizenship copy = new Citizenship();
244             copy.code = code;
245             copy.period = period;
246             return copy;
247         }
248 
249         @Override
250         public boolean isEmpty() {
251             return super.isEmpty() && ElementUtil.isEmpty(code, period);
252         }
253 
254         public CodeableConcept getCode() {
255             return code;
256         }
257 
258         public Period getPeriod() {
259             return period;
260         }
261 
262         public void setCode(CodeableConcept code) {
263             this.code = code;
264         }
265 
266         public boolean hasCode() {
267             return code != null && !code.isEmpty();
268         }
269 
270         public void setPeriod(Period period) {
271             this.period = period;
272         }
273 
274         public boolean hasPeriod() {
275             return period != null && !period.isEmpty();
276         }
277     }
278 
279     @Block
280     public static class Race extends BackboneElement {
281 
282         @Child(name = "ombCategory")
283         @Extension(url = "http://hl7.org/fhir/us/core/StructureDefinition/us-core-race/ombCategory", definedLocally = false, isModifier = false)
284         private Coding ombCategory;
285 
286         @Child(name = "detailed")
287         @Extension(url = "http://hl7.org/fhir/us/core/StructureDefinition/us-core-race/detailed", definedLocally = false, isModifier = false)
288         private Coding detailed;
289 
290         @Child(name = "text")
291         @Extension(url = "http://hl7.org/fhir/us/core/StructureDefinition/us-core-race/text", definedLocally = false, isModifier = false)
292         private StringType text;
293 
294         @Override
295         public Race copy() {
296             Race copy = new Race();
297             copy.ombCategory = ombCategory;
298             copy.detailed = detailed;
299             copy.text = text;
300             return copy;
301         }
302 
303         @Override
304         public boolean isEmpty() {
305             return super.isEmpty() && ElementUtil.isEmpty(ombCategory, detailed, text);
306         }
307 
308         public Coding getOmbCategory() {
309             return ombCategory;
310         }
311 
312         public Coding getDetailed() {
313             return detailed;
314         }
315 
316         public StringType getText() {
317             return text;
318         }
319 
320         public void setOmbCategory(Coding ombCategory) {
321             this.ombCategory = ombCategory;
322         }
323 
324         public void setDetailed(Coding detailed) {
325             this.detailed = detailed;
326         }
327 
328         public void setText(StringType text) {
329             this.text = text;
330         }
331 
332         public boolean hasOmbCategory() {
333             return ombCategory != null && !ombCategory.isEmpty();
334         }
335 
336         public boolean hasDetailed() {
337             return detailed != null && !detailed.isEmpty();
338         }
339         public boolean hasText() {
340             return text != null && !text.isEmpty();
341         }
342     }
343 
344     @Block
345     public static class Ethnicity extends BackboneElement {
346 
347         @Child(name = "ombCategory")
348         @Extension(url = "http://hl7.org/fhir/us/core/StructureDefinition/us-core-ethnicity/ombCategory", definedLocally = false, isModifier = false)
349         private Coding ombCategory;
350 
351         @Child(name = "detailed")
352         @Extension(url = "http://hl7.org/fhir/us/core/StructureDefinition/us-core-ethnicity/detailed", definedLocally = false, isModifier = false)
353         private Coding detailed;
354 
355         @Child(name = "text")
356         @Extension(url = "http://hl7.org/fhir/us/core/StructureDefinition/us-core-ethnicity/text", definedLocally = false, isModifier = false)
357         private StringType text;
358 
359         @Override
360         public Ethnicity copy() {
361             Ethnicity copy = new Ethnicity();
362             copy.ombCategory = ombCategory;
363             copy.detailed = detailed;
364             copy.text = text;
365             return copy;
366         }
367 
368         @Override
369         public boolean isEmpty() {
370             return super.isEmpty() && ElementUtil.isEmpty(ombCategory, detailed, text);
371         }
372 
373         public Coding getOmbCategory() {
374             return ombCategory;
375         }
376 
377         public Coding getDetailed() {
378             return detailed;
379         }
380 
381         public StringType getText() {
382             return text;
383         }
384 
385         public void setOmbCategory(Coding ombCategory) {
386             this.ombCategory = ombCategory;
387         }
388 
389         public void setDetailed(Coding detailed) {
390             this.detailed = detailed;
391         }
392 
393         public void setText(StringType text) {
394             this.text = text;
395         }
396 
397         public boolean hasOmbCategory() {
398             return ombCategory != null && !ombCategory.isEmpty();
399         }
400 
401         public boolean hasDetailed() {
402             return detailed != null && !detailed.isEmpty();
403         }
404         public boolean hasText() {
405             return text != null && !text.isEmpty();
406         }
407     }
408 }