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.Annotation43_50;
005import org.hl7.fhir.convertors.conv43_50.datatypes43_50.general43_50.CodeableConcept43_50;
006import org.hl7.fhir.convertors.conv43_50.datatypes43_50.general43_50.Identifier43_50;
007import org.hl7.fhir.convertors.conv43_50.datatypes43_50.primitive43_50.DateTime43_50;
008import org.hl7.fhir.convertors.conv43_50.datatypes43_50.primitive43_50.String43_50;
009import org.hl7.fhir.convertors.conv43_50.datatypes43_50.primitive43_50.Uri43_50;
010import org.hl7.fhir.convertors.conv43_50.datatypes43_50.special43_50.Reference43_50;
011import org.hl7.fhir.exceptions.FHIRException;
012
013/*
014  Copyright (c) 2011+, HL7, Inc.
015  All rights reserved.
016  
017  Redistribution and use in source and binary forms, with or without modification, 
018  are permitted provided that the following conditions are met:
019  
020   * Redistributions of source code must retain the above copyright notice, this 
021     list of conditions and the following disclaimer.
022   * Redistributions in binary form must reproduce the above copyright notice, 
023     this list of conditions and the following disclaimer in the documentation 
024     and/or other materials provided with the distribution.
025   * Neither the name of HL7 nor the names of its contributors may be used to 
026     endorse or promote products derived from this software without specific 
027     prior written permission.
028  
029  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 
030  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
031  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
032  IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 
033  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
034  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 
035  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
036  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
037  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
038  POSSIBILITY OF SUCH DAMAGE.
039  
040*/
041// Generated on Sun, Feb 24, 2019 11:37+1100 for FHIR v4.0.0
042public class ClinicalImpression43_50 {
043
044  public static org.hl7.fhir.r5.model.ClinicalImpression convertClinicalImpression(org.hl7.fhir.r4b.model.ClinicalImpression src) throws FHIRException {
045    if (src == null)
046      return null;
047    org.hl7.fhir.r5.model.ClinicalImpression tgt = new org.hl7.fhir.r5.model.ClinicalImpression();
048    ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyDomainResource(src, tgt);
049    for (org.hl7.fhir.r4b.model.Identifier t : src.getIdentifier())
050      tgt.addIdentifier(Identifier43_50.convertIdentifier(t));
051    if (src.hasStatus())
052      tgt.setStatusElement(convertClinicalImpressionStatus(src.getStatusElement()));
053    if (src.hasStatusReason())
054      tgt.setStatusReason(CodeableConcept43_50.convertCodeableConcept(src.getStatusReason()));
055    // if (src.hasCode())
056    // tgt.setCode(convertCodeableConcept(src.getCode()));
057    if (src.hasDescription())
058      tgt.setDescriptionElement(String43_50.convertString(src.getDescriptionElement()));
059    if (src.hasSubject())
060      tgt.setSubject(Reference43_50.convertReference(src.getSubject()));
061    if (src.hasEncounter())
062      tgt.setEncounter(Reference43_50.convertReference(src.getEncounter()));
063    if (src.hasEffective())
064      tgt.setEffective(ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().convertType(src.getEffective()));
065    if (src.hasDate())
066      tgt.setDateElement(DateTime43_50.convertDateTime(src.getDateElement()));
067    if (src.hasAssessor())
068      tgt.setPerformer(Reference43_50.convertReference(src.getAssessor()));
069    if (src.hasPrevious())
070      tgt.setPrevious(Reference43_50.convertReference(src.getPrevious()));
071    for (org.hl7.fhir.r4b.model.Reference t : src.getProblem()) tgt.addProblem(Reference43_50.convertReference(t));
072    for (org.hl7.fhir.r4b.model.UriType t : src.getProtocol()) tgt.getProtocol().add(Uri43_50.convertUri(t));
073    if (src.hasSummary())
074      tgt.setSummaryElement(String43_50.convertString(src.getSummaryElement()));
075    for (org.hl7.fhir.r4b.model.ClinicalImpression.ClinicalImpressionFindingComponent t : src.getFinding())
076      tgt.addFinding(convertClinicalImpressionFindingComponent(t));
077    for (org.hl7.fhir.r4b.model.CodeableConcept t : src.getPrognosisCodeableConcept())
078      tgt.addPrognosisCodeableConcept(CodeableConcept43_50.convertCodeableConcept(t));
079    for (org.hl7.fhir.r4b.model.Reference t : src.getPrognosisReference())
080      tgt.addPrognosisReference(Reference43_50.convertReference(t));
081    for (org.hl7.fhir.r4b.model.Reference t : src.getSupportingInfo())
082      tgt.addSupportingInfo(Reference43_50.convertReference(t));
083    for (org.hl7.fhir.r4b.model.Annotation t : src.getNote()) tgt.addNote(Annotation43_50.convertAnnotation(t));
084    return tgt;
085  }
086
087  public static org.hl7.fhir.r4b.model.ClinicalImpression convertClinicalImpression(org.hl7.fhir.r5.model.ClinicalImpression src) throws FHIRException {
088    if (src == null)
089      return null;
090    org.hl7.fhir.r4b.model.ClinicalImpression tgt = new org.hl7.fhir.r4b.model.ClinicalImpression();
091    ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyDomainResource(src, tgt);
092    for (org.hl7.fhir.r5.model.Identifier t : src.getIdentifier())
093      tgt.addIdentifier(Identifier43_50.convertIdentifier(t));
094    if (src.hasStatus())
095      tgt.setStatusElement(convertClinicalImpressionStatus(src.getStatusElement()));
096    if (src.hasStatusReason())
097      tgt.setStatusReason(CodeableConcept43_50.convertCodeableConcept(src.getStatusReason()));
098    // if (src.hasCode())
099    // tgt.setCode(convertCodeableConcept(src.getCode()));
100    if (src.hasDescription())
101      tgt.setDescriptionElement(String43_50.convertString(src.getDescriptionElement()));
102    if (src.hasSubject())
103      tgt.setSubject(Reference43_50.convertReference(src.getSubject()));
104    if (src.hasEncounter())
105      tgt.setEncounter(Reference43_50.convertReference(src.getEncounter()));
106    if (src.hasEffective())
107      tgt.setEffective(ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().convertType(src.getEffective()));
108    if (src.hasDate())
109      tgt.setDateElement(DateTime43_50.convertDateTime(src.getDateElement()));
110    if (src.hasPerformer())
111      tgt.setAssessor(Reference43_50.convertReference(src.getPerformer()));
112    if (src.hasPrevious())
113      tgt.setPrevious(Reference43_50.convertReference(src.getPrevious()));
114    for (org.hl7.fhir.r5.model.Reference t : src.getProblem()) tgt.addProblem(Reference43_50.convertReference(t));
115    for (org.hl7.fhir.r5.model.UriType t : src.getProtocol()) tgt.getProtocol().add(Uri43_50.convertUri(t));
116    if (src.hasSummary())
117      tgt.setSummaryElement(String43_50.convertString(src.getSummaryElement()));
118    for (org.hl7.fhir.r5.model.ClinicalImpression.ClinicalImpressionFindingComponent t : src.getFinding())
119      tgt.addFinding(convertClinicalImpressionFindingComponent(t));
120    for (org.hl7.fhir.r5.model.CodeableConcept t : src.getPrognosisCodeableConcept())
121      tgt.addPrognosisCodeableConcept(CodeableConcept43_50.convertCodeableConcept(t));
122    for (org.hl7.fhir.r5.model.Reference t : src.getPrognosisReference())
123      tgt.addPrognosisReference(Reference43_50.convertReference(t));
124    for (org.hl7.fhir.r5.model.Reference t : src.getSupportingInfo())
125      tgt.addSupportingInfo(Reference43_50.convertReference(t));
126    for (org.hl7.fhir.r5.model.Annotation t : src.getNote()) tgt.addNote(Annotation43_50.convertAnnotation(t));
127    return tgt;
128  }
129
130  static public org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Enumerations.EventStatus> convertClinicalImpressionStatus(org.hl7.fhir.r4b.model.Enumeration<org.hl7.fhir.r4b.model.ClinicalImpression.ClinicalImpressionStatus> src) throws FHIRException {
131    if (src == null || src.isEmpty())
132      return null;
133    org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Enumerations.EventStatus> tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.Enumerations.EventStatusEnumFactory());
134    ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyElement(src, tgt);
135    switch (src.getValue()) {
136      case INPROGRESS:
137        tgt.setValue(org.hl7.fhir.r5.model.Enumerations.EventStatus.INPROGRESS);
138        break;
139      case COMPLETED:
140        tgt.setValue(org.hl7.fhir.r5.model.Enumerations.EventStatus.COMPLETED);
141        break;
142      case ENTEREDINERROR:
143        tgt.setValue(org.hl7.fhir.r5.model.Enumerations.EventStatus.ENTEREDINERROR);
144        break;
145      default:
146        tgt.setValue(org.hl7.fhir.r5.model.Enumerations.EventStatus.NULL);
147        break;
148    }
149    return tgt;
150  }
151
152  static public org.hl7.fhir.r4b.model.Enumeration<org.hl7.fhir.r4b.model.ClinicalImpression.ClinicalImpressionStatus> convertClinicalImpressionStatus(org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Enumerations.EventStatus> src) throws FHIRException {
153    if (src == null || src.isEmpty())
154      return null;
155    org.hl7.fhir.r4b.model.Enumeration<org.hl7.fhir.r4b.model.ClinicalImpression.ClinicalImpressionStatus> tgt = new org.hl7.fhir.r4b.model.Enumeration<>(new org.hl7.fhir.r4b.model.ClinicalImpression.ClinicalImpressionStatusEnumFactory());
156    ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyElement(src, tgt);
157    switch (src.getValue()) {
158      case INPROGRESS:
159        tgt.setValue(org.hl7.fhir.r4b.model.ClinicalImpression.ClinicalImpressionStatus.INPROGRESS);
160        break;
161      case COMPLETED:
162        tgt.setValue(org.hl7.fhir.r4b.model.ClinicalImpression.ClinicalImpressionStatus.COMPLETED);
163        break;
164      case ENTEREDINERROR:
165        tgt.setValue(org.hl7.fhir.r4b.model.ClinicalImpression.ClinicalImpressionStatus.ENTEREDINERROR);
166        break;
167      default:
168        tgt.setValue(org.hl7.fhir.r4b.model.ClinicalImpression.ClinicalImpressionStatus.NULL);
169        break;
170    }
171    return tgt;
172  }
173
174  public static org.hl7.fhir.r5.model.ClinicalImpression.ClinicalImpressionFindingComponent convertClinicalImpressionFindingComponent(org.hl7.fhir.r4b.model.ClinicalImpression.ClinicalImpressionFindingComponent src) throws FHIRException {
175    if (src == null)
176      return null;
177    org.hl7.fhir.r5.model.ClinicalImpression.ClinicalImpressionFindingComponent tgt = new org.hl7.fhir.r5.model.ClinicalImpression.ClinicalImpressionFindingComponent();
178    ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyBackboneElement(src, tgt);
179    if (src.hasItemCodeableConcept())
180      tgt.setItem(CodeableConcept43_50.convertCodeableConceptToCodeableReference(src.getItemCodeableConcept()));
181    if (src.hasItemReference())
182      tgt.setItem(Reference43_50.convertReferenceToCodeableReference(src.getItemReference()));
183    if (src.hasBasis())
184      tgt.setBasisElement(String43_50.convertString(src.getBasisElement()));
185    return tgt;
186  }
187
188  public static org.hl7.fhir.r4b.model.ClinicalImpression.ClinicalImpressionFindingComponent convertClinicalImpressionFindingComponent(org.hl7.fhir.r5.model.ClinicalImpression.ClinicalImpressionFindingComponent src) throws FHIRException {
189    if (src == null)
190      return null;
191    org.hl7.fhir.r4b.model.ClinicalImpression.ClinicalImpressionFindingComponent tgt = new org.hl7.fhir.r4b.model.ClinicalImpression.ClinicalImpressionFindingComponent();
192    ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyBackboneElement(src, tgt);
193    if (src.hasItem() && src.getItem().hasConcept())
194      tgt.setItemCodeableConcept(CodeableConcept43_50.convertCodeableConcept(src.getItem().getConcept()));
195    if (src.hasItem() && src.getItem().hasReference())
196      tgt.setItemReference(Reference43_50.convertReference(src.getItem().getReference()));
197    if (src.hasBasis())
198      tgt.setBasisElement(String43_50.convertString(src.getBasisElement()));
199    return tgt;
200  }
201}