001package org.hl7.fhir.convertors.conv43_50.resources43_50;
002
003import org.hl7.fhir.convertors.context.ConversionContext43_50;
004import org.hl7.fhir.convertors.conv43_50.datatypes43_50.general43_50.CodeableConcept43_50;
005import org.hl7.fhir.convertors.conv43_50.datatypes43_50.general43_50.Identifier43_50;
006import org.hl7.fhir.convertors.conv43_50.datatypes43_50.primitive43_50.DateTime43_50;
007import org.hl7.fhir.convertors.conv43_50.datatypes43_50.primitive43_50.String43_50;
008import org.hl7.fhir.convertors.conv43_50.datatypes43_50.primitive43_50.Uri43_50;
009import org.hl7.fhir.convertors.conv43_50.datatypes43_50.special43_50.Reference43_50;
010import org.hl7.fhir.exceptions.FHIRException;
011import org.hl7.fhir.r4b.model.Enumerations;
012import org.hl7.fhir.r5.model.DetectedIssue;
013import org.hl7.fhir.r5.model.Enumeration;
014
015/*
016  Copyright (c) 2011+, HL7, Inc.
017  All rights reserved.
018  
019  Redistribution and use in source and binary forms, with or without modification, 
020  are permitted provided that the following conditions are met:
021  
022   * Redistributions of source code must retain the above copyright notice, this 
023     list of conditions and the following disclaimer.
024   * Redistributions in binary form must reproduce the above copyright notice, 
025     this list of conditions and the following disclaimer in the documentation 
026     and/or other materials provided with the distribution.
027   * Neither the name of HL7 nor the names of its contributors may be used to 
028     endorse or promote products derived from this software without specific 
029     prior written permission.
030  
031  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 
032  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
033  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
034  IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 
035  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
036  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 
037  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
038  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
039  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
040  POSSIBILITY OF SUCH DAMAGE.
041  
042*/
043// Generated on Sun, Feb 24, 2019 11:37+1100 for FHIR v4.0.0
044public class DetectedIssue43_50 {
045
046  public static org.hl7.fhir.r5.model.DetectedIssue convertDetectedIssue(org.hl7.fhir.r4b.model.DetectedIssue src) throws FHIRException {
047    if (src == null)
048      return null;
049    org.hl7.fhir.r5.model.DetectedIssue tgt = new org.hl7.fhir.r5.model.DetectedIssue();
050    ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyDomainResource(src, tgt);
051    for (org.hl7.fhir.r4b.model.Identifier t : src.getIdentifier())
052      tgt.addIdentifier(Identifier43_50.convertIdentifier(t));
053    if (src.hasStatus())
054      tgt.setStatusElement(convertDetectedIssueStatus(src.getStatusElement()));
055    if (src.hasCode())
056      tgt.setCode(CodeableConcept43_50.convertCodeableConcept(src.getCode()));
057    if (src.hasSeverity())
058      tgt.setSeverityElement(convertDetectedIssueSeverity(src.getSeverityElement()));
059    if (src.hasPatient())
060      tgt.setSubject(Reference43_50.convertReference(src.getPatient()));
061    if (src.hasIdentified())
062      tgt.setIdentified(ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().convertType(src.getIdentified()));
063    if (src.hasAuthor())
064      tgt.setAuthor(Reference43_50.convertReference(src.getAuthor()));
065    for (org.hl7.fhir.r4b.model.Reference t : src.getImplicated()) tgt.addImplicated(Reference43_50.convertReference(t));
066    for (org.hl7.fhir.r4b.model.DetectedIssue.DetectedIssueEvidenceComponent t : src.getEvidence())
067      tgt.addEvidence(convertDetectedIssueEvidenceComponent(t));
068    if (src.hasDetail())
069      tgt.setDetailElement(String43_50.convertStringToMarkdown(src.getDetailElement()));
070    if (src.hasReference())
071      tgt.setReferenceElement(Uri43_50.convertUri(src.getReferenceElement()));
072    for (org.hl7.fhir.r4b.model.DetectedIssue.DetectedIssueMitigationComponent t : src.getMitigation())
073      tgt.addMitigation(convertDetectedIssueMitigationComponent(t));
074    return tgt;
075  }
076
077  public static org.hl7.fhir.r4b.model.DetectedIssue convertDetectedIssue(org.hl7.fhir.r5.model.DetectedIssue src) throws FHIRException {
078    if (src == null)
079      return null;
080    org.hl7.fhir.r4b.model.DetectedIssue tgt = new org.hl7.fhir.r4b.model.DetectedIssue();
081    ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyDomainResource(src, tgt);
082    for (org.hl7.fhir.r5.model.Identifier t : src.getIdentifier())
083      tgt.addIdentifier(Identifier43_50.convertIdentifier(t));
084    if (src.hasStatus())
085      tgt.setStatusElement(convertDetectedIssueStatus(src.getStatusElement()));
086    if (src.hasCode())
087      tgt.setCode(CodeableConcept43_50.convertCodeableConcept(src.getCode()));
088    if (src.hasSeverity())
089      tgt.setSeverityElement(convertDetectedIssueSeverity(src.getSeverityElement()));
090    if (src.hasSubject())
091      tgt.setPatient(Reference43_50.convertReference(src.getSubject()));
092    if (src.hasIdentified())
093      tgt.setIdentified(ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().convertType(src.getIdentified()));
094    if (src.hasAuthor())
095      tgt.setAuthor(Reference43_50.convertReference(src.getAuthor()));
096    for (org.hl7.fhir.r5.model.Reference t : src.getImplicated()) tgt.addImplicated(Reference43_50.convertReference(t));
097    for (org.hl7.fhir.r5.model.DetectedIssue.DetectedIssueEvidenceComponent t : src.getEvidence())
098      tgt.addEvidence(convertDetectedIssueEvidenceComponent(t));
099    if (src.hasDetail())
100      tgt.setDetailElement(String43_50.convertString(src.getDetailElement()));
101    if (src.hasReference())
102      tgt.setReferenceElement(Uri43_50.convertUri(src.getReferenceElement()));
103    for (org.hl7.fhir.r5.model.DetectedIssue.DetectedIssueMitigationComponent t : src.getMitigation())
104      tgt.addMitigation(convertDetectedIssueMitigationComponent(t));
105    return tgt;
106  }
107
108  static public org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.DetectedIssue.DetectedIssueStatus> convertDetectedIssueStatus(org.hl7.fhir.r4b.model.Enumeration<org.hl7.fhir.r4b.model.Enumerations.ObservationStatus> src) throws FHIRException {
109      if (src == null || src.isEmpty())
110          return null;
111      Enumeration<DetectedIssue.DetectedIssueStatus> tgt = new Enumeration<>(new DetectedIssue.DetectedIssueStatusEnumFactory());
112      ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyElement(src, tgt);
113      if (src.getValue() == null) {
114          tgt.setValue(null);
115      } else {
116          switch (src.getValue()) {
117              case REGISTERED:
118                  tgt.setValue(DetectedIssue.DetectedIssueStatus.PRELIMINARY);
119                  break;
120              case PRELIMINARY:
121                  tgt.setValue(DetectedIssue.DetectedIssueStatus.PRELIMINARY);
122                  break;
123              case FINAL:
124                  tgt.setValue(DetectedIssue.DetectedIssueStatus.FINAL);
125                  break;
126              case AMENDED:
127                  tgt.setValue(DetectedIssue.DetectedIssueStatus.FINAL);
128                  break;
129              case CORRECTED:
130                  tgt.setValue(DetectedIssue.DetectedIssueStatus.MITIGATED);
131                  break;
132              case CANCELLED:
133                  tgt.setValue(DetectedIssue.DetectedIssueStatus.MITIGATED);
134                  break;
135              case ENTEREDINERROR:
136                  tgt.setValue(DetectedIssue.DetectedIssueStatus.ENTEREDINERROR);
137                  break;
138              case UNKNOWN:
139                  tgt.setValue(DetectedIssue.DetectedIssueStatus.NULL);
140                  break;
141              default:
142                  tgt.setValue(DetectedIssue.DetectedIssueStatus.NULL);
143                  break;
144          }
145      }
146      return tgt;
147  }
148
149  static public org.hl7.fhir.r4b.model.Enumeration<org.hl7.fhir.r4b.model.Enumerations.ObservationStatus> convertDetectedIssueStatus(org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.DetectedIssue.DetectedIssueStatus> src) throws FHIRException {
150      if (src == null || src.isEmpty())
151          return null;
152      org.hl7.fhir.r4b.model.Enumeration<Enumerations.ObservationStatus> tgt = new org.hl7.fhir.r4b.model.Enumeration<>(new Enumerations.ObservationStatusEnumFactory());
153      ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyElement(src, tgt);
154      if (src.getValue() == null) {
155          tgt.setValue(null);
156      } else {
157          switch (src.getValue()) {
158              case PRELIMINARY:
159                  tgt.setValue(Enumerations.ObservationStatus.PRELIMINARY);
160                  break;
161              case FINAL:
162                  tgt.setValue(Enumerations.ObservationStatus.FINAL);
163                  break;
164              case MITIGATED:
165                  tgt.setValue(Enumerations.ObservationStatus.CORRECTED);
166                  break;
167              case ENTEREDINERROR:
168                  tgt.setValue(Enumerations.ObservationStatus.ENTEREDINERROR);
169                  break;
170              default:
171                  tgt.setValue(Enumerations.ObservationStatus.NULL);
172                  break;
173          }
174      }
175      return tgt;
176  }
177
178  static public org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.DetectedIssue.DetectedIssueSeverity> convertDetectedIssueSeverity(org.hl7.fhir.r4b.model.Enumeration<org.hl7.fhir.r4b.model.DetectedIssue.DetectedIssueSeverity> src) throws FHIRException {
179      if (src == null || src.isEmpty())
180          return null;
181      Enumeration<DetectedIssue.DetectedIssueSeverity> tgt = new Enumeration<>(new DetectedIssue.DetectedIssueSeverityEnumFactory());
182      ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyElement(src, tgt);
183      if (src.getValue() == null) {
184          tgt.setValue(null);
185      } else {
186          switch (src.getValue()) {
187              case HIGH:
188                  tgt.setValue(DetectedIssue.DetectedIssueSeverity.HIGH);
189                  break;
190              case MODERATE:
191                  tgt.setValue(DetectedIssue.DetectedIssueSeverity.MODERATE);
192                  break;
193              case LOW:
194                  tgt.setValue(DetectedIssue.DetectedIssueSeverity.LOW);
195                  break;
196              default:
197                  tgt.setValue(DetectedIssue.DetectedIssueSeverity.NULL);
198                  break;
199          }
200      }
201      return tgt;
202  }
203
204  static public org.hl7.fhir.r4b.model.Enumeration<org.hl7.fhir.r4b.model.DetectedIssue.DetectedIssueSeverity> convertDetectedIssueSeverity(org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.DetectedIssue.DetectedIssueSeverity> src) throws FHIRException {
205      if (src == null || src.isEmpty())
206          return null;
207      org.hl7.fhir.r4b.model.Enumeration<org.hl7.fhir.r4b.model.DetectedIssue.DetectedIssueSeverity> tgt = new org.hl7.fhir.r4b.model.Enumeration<>(new org.hl7.fhir.r4b.model.DetectedIssue.DetectedIssueSeverityEnumFactory());
208      ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyElement(src, tgt);
209      if (src.getValue() == null) {
210          tgt.setValue(null);
211      } else {
212          switch (src.getValue()) {
213              case HIGH:
214                  tgt.setValue(org.hl7.fhir.r4b.model.DetectedIssue.DetectedIssueSeverity.HIGH);
215                  break;
216              case MODERATE:
217                  tgt.setValue(org.hl7.fhir.r4b.model.DetectedIssue.DetectedIssueSeverity.MODERATE);
218                  break;
219              case LOW:
220                  tgt.setValue(org.hl7.fhir.r4b.model.DetectedIssue.DetectedIssueSeverity.LOW);
221                  break;
222              default:
223                  tgt.setValue(org.hl7.fhir.r4b.model.DetectedIssue.DetectedIssueSeverity.NULL);
224                  break;
225          }
226      }
227      return tgt;
228  }
229
230  public static org.hl7.fhir.r5.model.DetectedIssue.DetectedIssueEvidenceComponent convertDetectedIssueEvidenceComponent(org.hl7.fhir.r4b.model.DetectedIssue.DetectedIssueEvidenceComponent src) throws FHIRException {
231    if (src == null)
232      return null;
233    org.hl7.fhir.r5.model.DetectedIssue.DetectedIssueEvidenceComponent tgt = new org.hl7.fhir.r5.model.DetectedIssue.DetectedIssueEvidenceComponent();
234    ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyBackboneElement(src, tgt);
235    for (org.hl7.fhir.r4b.model.CodeableConcept t : src.getCode())
236      tgt.addCode(CodeableConcept43_50.convertCodeableConcept(t));
237    for (org.hl7.fhir.r4b.model.Reference t : src.getDetail()) tgt.addDetail(Reference43_50.convertReference(t));
238    return tgt;
239  }
240
241  public static org.hl7.fhir.r4b.model.DetectedIssue.DetectedIssueEvidenceComponent convertDetectedIssueEvidenceComponent(org.hl7.fhir.r5.model.DetectedIssue.DetectedIssueEvidenceComponent src) throws FHIRException {
242    if (src == null)
243      return null;
244    org.hl7.fhir.r4b.model.DetectedIssue.DetectedIssueEvidenceComponent tgt = new org.hl7.fhir.r4b.model.DetectedIssue.DetectedIssueEvidenceComponent();
245    ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyBackboneElement(src, tgt);
246    for (org.hl7.fhir.r5.model.CodeableConcept t : src.getCode())
247      tgt.addCode(CodeableConcept43_50.convertCodeableConcept(t));
248    for (org.hl7.fhir.r5.model.Reference t : src.getDetail()) tgt.addDetail(Reference43_50.convertReference(t));
249    return tgt;
250  }
251
252  public static org.hl7.fhir.r5.model.DetectedIssue.DetectedIssueMitigationComponent convertDetectedIssueMitigationComponent(org.hl7.fhir.r4b.model.DetectedIssue.DetectedIssueMitigationComponent src) throws FHIRException {
253    if (src == null)
254      return null;
255    org.hl7.fhir.r5.model.DetectedIssue.DetectedIssueMitigationComponent tgt = new org.hl7.fhir.r5.model.DetectedIssue.DetectedIssueMitigationComponent();
256    ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyBackboneElement(src, tgt);
257    if (src.hasAction())
258      tgt.setAction(CodeableConcept43_50.convertCodeableConcept(src.getAction()));
259    if (src.hasDate())
260      tgt.setDateElement(DateTime43_50.convertDateTime(src.getDateElement()));
261    if (src.hasAuthor())
262      tgt.setAuthor(Reference43_50.convertReference(src.getAuthor()));
263    return tgt;
264  }
265
266  public static org.hl7.fhir.r4b.model.DetectedIssue.DetectedIssueMitigationComponent convertDetectedIssueMitigationComponent(org.hl7.fhir.r5.model.DetectedIssue.DetectedIssueMitigationComponent src) throws FHIRException {
267    if (src == null)
268      return null;
269    org.hl7.fhir.r4b.model.DetectedIssue.DetectedIssueMitigationComponent tgt = new org.hl7.fhir.r4b.model.DetectedIssue.DetectedIssueMitigationComponent();
270    ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyBackboneElement(src, tgt);
271    if (src.hasAction())
272      tgt.setAction(CodeableConcept43_50.convertCodeableConcept(src.getAction()));
273    if (src.hasDate())
274      tgt.setDateElement(DateTime43_50.convertDateTime(src.getDateElement()));
275    if (src.hasAuthor())
276      tgt.setAuthor(Reference43_50.convertReference(src.getAuthor()));
277    return tgt;
278  }
279}