001package org.hl7.fhir.convertors.conv40_50.resources40_50;
002
003import org.hl7.fhir.convertors.context.ConversionContext40_50;
004import org.hl7.fhir.convertors.conv40_50.datatypes40_50.general40_50.Annotation40_50;
005import org.hl7.fhir.convertors.conv40_50.datatypes40_50.general40_50.CodeableConcept40_50;
006import org.hl7.fhir.convertors.conv40_50.datatypes40_50.general40_50.Identifier40_50;
007import org.hl7.fhir.convertors.conv40_50.datatypes40_50.primitive40_50.DateTime40_50;
008import org.hl7.fhir.convertors.conv40_50.datatypes40_50.special40_50.Reference40_50;
009import org.hl7.fhir.exceptions.FHIRException;
010
011/*
012  Copyright (c) 2011+, HL7, Inc.
013  All rights reserved.
014  
015  Redistribution and use in source and binary forms, with or without modification, 
016  are permitted provided that the following conditions are met:
017  
018   * Redistributions of source code must retain the above copyright notice, this 
019     list of conditions and the following disclaimer.
020   * Redistributions in binary form must reproduce the above copyright notice, 
021     this list of conditions and the following disclaimer in the documentation 
022     and/or other materials provided with the distribution.
023   * Neither the name of HL7 nor the names of its contributors may be used to 
024     endorse or promote products derived from this software without specific 
025     prior written permission.
026  
027  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 
028  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
029  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
030  IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 
031  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
032  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 
033  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
034  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
035  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
036  POSSIBILITY OF SUCH DAMAGE.
037  
038*/
039// Generated on Sun, Feb 24, 2019 11:37+1100 for FHIR v4.0.0
040public class Condition40_50 {
041
042  public static org.hl7.fhir.r5.model.Condition convertCondition(org.hl7.fhir.r4.model.Condition src) throws FHIRException {
043    if (src == null)
044      return null;
045    org.hl7.fhir.r5.model.Condition tgt = new org.hl7.fhir.r5.model.Condition();
046    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyDomainResource(src, tgt);
047    for (org.hl7.fhir.r4.model.Identifier t : src.getIdentifier())
048      tgt.addIdentifier(Identifier40_50.convertIdentifier(t));
049    if (src.hasClinicalStatus())
050      tgt.setClinicalStatus(CodeableConcept40_50.convertCodeableConcept(src.getClinicalStatus()));
051    if (src.hasVerificationStatus())
052      tgt.setVerificationStatus(CodeableConcept40_50.convertCodeableConcept(src.getVerificationStatus()));
053    for (org.hl7.fhir.r4.model.CodeableConcept t : src.getCategory())
054      tgt.addCategory(CodeableConcept40_50.convertCodeableConcept(t));
055    if (src.hasSeverity())
056      tgt.setSeverity(CodeableConcept40_50.convertCodeableConcept(src.getSeverity()));
057    if (src.hasCode())
058      tgt.setCode(CodeableConcept40_50.convertCodeableConcept(src.getCode()));
059    for (org.hl7.fhir.r4.model.CodeableConcept t : src.getBodySite())
060      tgt.addBodySite(CodeableConcept40_50.convertCodeableConcept(t));
061    if (src.hasSubject())
062      tgt.setSubject(Reference40_50.convertReference(src.getSubject()));
063    if (src.hasEncounter())
064      tgt.setEncounter(Reference40_50.convertReference(src.getEncounter()));
065    if (src.hasOnset())
066      tgt.setOnset(ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().convertType(src.getOnset()));
067    if (src.hasAbatement())
068      tgt.setAbatement(ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().convertType(src.getAbatement()));
069    if (src.hasRecordedDate())
070      tgt.setRecordedDateElement(DateTime40_50.convertDateTime(src.getRecordedDateElement()));
071    if (src.hasRecorder())
072      tgt.setRecorder(Reference40_50.convertReference(src.getRecorder()));
073    if (src.hasAsserter())
074      tgt.setAsserter(Reference40_50.convertReference(src.getAsserter()));
075    for (org.hl7.fhir.r4.model.Condition.ConditionStageComponent t : src.getStage())
076      tgt.addStage(convertConditionStageComponent(t));
077    for (org.hl7.fhir.r4.model.Condition.ConditionEvidenceComponent t : src.getEvidence())
078      tgt.addEvidence(convertConditionEvidenceComponent(t));
079    for (org.hl7.fhir.r4.model.Annotation t : src.getNote()) tgt.addNote(Annotation40_50.convertAnnotation(t));
080    return tgt;
081  }
082
083  public static org.hl7.fhir.r4.model.Condition convertCondition(org.hl7.fhir.r5.model.Condition src) throws FHIRException {
084    if (src == null)
085      return null;
086    org.hl7.fhir.r4.model.Condition tgt = new org.hl7.fhir.r4.model.Condition();
087    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyDomainResource(src, tgt);
088    for (org.hl7.fhir.r5.model.Identifier t : src.getIdentifier())
089      tgt.addIdentifier(Identifier40_50.convertIdentifier(t));
090    if (src.hasClinicalStatus())
091      tgt.setClinicalStatus(CodeableConcept40_50.convertCodeableConcept(src.getClinicalStatus()));
092    if (src.hasVerificationStatus())
093      tgt.setVerificationStatus(CodeableConcept40_50.convertCodeableConcept(src.getVerificationStatus()));
094    for (org.hl7.fhir.r5.model.CodeableConcept t : src.getCategory())
095      tgt.addCategory(CodeableConcept40_50.convertCodeableConcept(t));
096    if (src.hasSeverity())
097      tgt.setSeverity(CodeableConcept40_50.convertCodeableConcept(src.getSeverity()));
098    if (src.hasCode())
099      tgt.setCode(CodeableConcept40_50.convertCodeableConcept(src.getCode()));
100    for (org.hl7.fhir.r5.model.CodeableConcept t : src.getBodySite())
101      tgt.addBodySite(CodeableConcept40_50.convertCodeableConcept(t));
102    if (src.hasSubject())
103      tgt.setSubject(Reference40_50.convertReference(src.getSubject()));
104    if (src.hasEncounter())
105      tgt.setEncounter(Reference40_50.convertReference(src.getEncounter()));
106    if (src.hasOnset())
107      tgt.setOnset(ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().convertType(src.getOnset()));
108    if (src.hasAbatement())
109      tgt.setAbatement(ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().convertType(src.getAbatement()));
110    if (src.hasRecordedDate())
111      tgt.setRecordedDateElement(DateTime40_50.convertDateTime(src.getRecordedDateElement()));
112    if (src.hasRecorder())
113      tgt.setRecorder(Reference40_50.convertReference(src.getRecorder()));
114    if (src.hasAsserter())
115      tgt.setAsserter(Reference40_50.convertReference(src.getAsserter()));
116    for (org.hl7.fhir.r5.model.Condition.ConditionStageComponent t : src.getStage())
117      tgt.addStage(convertConditionStageComponent(t));
118    for (org.hl7.fhir.r5.model.Condition.ConditionEvidenceComponent t : src.getEvidence())
119      tgt.addEvidence(convertConditionEvidenceComponent(t));
120    for (org.hl7.fhir.r5.model.Annotation t : src.getNote()) tgt.addNote(Annotation40_50.convertAnnotation(t));
121    return tgt;
122  }
123
124  public static org.hl7.fhir.r5.model.Condition.ConditionStageComponent convertConditionStageComponent(org.hl7.fhir.r4.model.Condition.ConditionStageComponent src) throws FHIRException {
125    if (src == null)
126      return null;
127    org.hl7.fhir.r5.model.Condition.ConditionStageComponent tgt = new org.hl7.fhir.r5.model.Condition.ConditionStageComponent();
128    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt);
129    if (src.hasSummary())
130      tgt.setSummary(CodeableConcept40_50.convertCodeableConcept(src.getSummary()));
131    for (org.hl7.fhir.r4.model.Reference t : src.getAssessment()) tgt.addAssessment(Reference40_50.convertReference(t));
132    if (src.hasType())
133      tgt.setType(CodeableConcept40_50.convertCodeableConcept(src.getType()));
134    return tgt;
135  }
136
137  public static org.hl7.fhir.r4.model.Condition.ConditionStageComponent convertConditionStageComponent(org.hl7.fhir.r5.model.Condition.ConditionStageComponent src) throws FHIRException {
138    if (src == null)
139      return null;
140    org.hl7.fhir.r4.model.Condition.ConditionStageComponent tgt = new org.hl7.fhir.r4.model.Condition.ConditionStageComponent();
141    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt);
142    if (src.hasSummary())
143      tgt.setSummary(CodeableConcept40_50.convertCodeableConcept(src.getSummary()));
144    for (org.hl7.fhir.r5.model.Reference t : src.getAssessment()) tgt.addAssessment(Reference40_50.convertReference(t));
145    if (src.hasType())
146      tgt.setType(CodeableConcept40_50.convertCodeableConcept(src.getType()));
147    return tgt;
148  }
149
150  public static org.hl7.fhir.r5.model.Condition.ConditionEvidenceComponent convertConditionEvidenceComponent(org.hl7.fhir.r4.model.Condition.ConditionEvidenceComponent src) throws FHIRException {
151    if (src == null)
152      return null;
153    org.hl7.fhir.r5.model.Condition.ConditionEvidenceComponent tgt = new org.hl7.fhir.r5.model.Condition.ConditionEvidenceComponent();
154    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt);
155    for (org.hl7.fhir.r4.model.CodeableConcept t : src.getCode())
156      tgt.addCode(CodeableConcept40_50.convertCodeableConcept(t));
157    for (org.hl7.fhir.r4.model.Reference t : src.getDetail()) tgt.addDetail(Reference40_50.convertReference(t));
158    return tgt;
159  }
160
161  public static org.hl7.fhir.r4.model.Condition.ConditionEvidenceComponent convertConditionEvidenceComponent(org.hl7.fhir.r5.model.Condition.ConditionEvidenceComponent src) throws FHIRException {
162    if (src == null)
163      return null;
164    org.hl7.fhir.r4.model.Condition.ConditionEvidenceComponent tgt = new org.hl7.fhir.r4.model.Condition.ConditionEvidenceComponent();
165    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt);
166    for (org.hl7.fhir.r5.model.CodeableConcept t : src.getCode())
167      tgt.addCode(CodeableConcept40_50.convertCodeableConcept(t));
168    for (org.hl7.fhir.r5.model.Reference t : src.getDetail()) tgt.addDetail(Reference40_50.convertReference(t));
169    return tgt;
170  }
171}