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.CodeableConcept40_50;
005import org.hl7.fhir.convertors.conv40_50.datatypes40_50.general40_50.Identifier40_50;
006import org.hl7.fhir.convertors.conv40_50.datatypes40_50.primitive40_50.DateTime40_50;
007import org.hl7.fhir.convertors.conv40_50.datatypes40_50.primitive40_50.String40_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 ImmunizationEvaluation40_50 {
041
042  public static org.hl7.fhir.r5.model.ImmunizationEvaluation convertImmunizationEvaluation(org.hl7.fhir.r4.model.ImmunizationEvaluation src) throws FHIRException {
043    if (src == null)
044      return null;
045    org.hl7.fhir.r5.model.ImmunizationEvaluation tgt = new org.hl7.fhir.r5.model.ImmunizationEvaluation();
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.hasStatus())
050      tgt.setStatusElement(convertImmunizationEvaluationStatus(src.getStatusElement()));
051    if (src.hasPatient())
052      tgt.setPatient(Reference40_50.convertReference(src.getPatient()));
053    if (src.hasDate())
054      tgt.setDateElement(DateTime40_50.convertDateTime(src.getDateElement()));
055    if (src.hasAuthority())
056      tgt.setAuthority(Reference40_50.convertReference(src.getAuthority()));
057    if (src.hasTargetDisease())
058      tgt.setTargetDisease(CodeableConcept40_50.convertCodeableConcept(src.getTargetDisease()));
059    if (src.hasImmunizationEvent())
060      tgt.setImmunizationEvent(Reference40_50.convertReference(src.getImmunizationEvent()));
061    if (src.hasDoseStatus())
062      tgt.setDoseStatus(CodeableConcept40_50.convertCodeableConcept(src.getDoseStatus()));
063    for (org.hl7.fhir.r4.model.CodeableConcept t : src.getDoseStatusReason())
064      tgt.addDoseStatusReason(CodeableConcept40_50.convertCodeableConcept(t));
065    if (src.hasDescription())
066      tgt.setDescriptionElement(String40_50.convertStringToMarkdown(src.getDescriptionElement()));
067    if (src.hasSeries())
068      tgt.setSeriesElement(String40_50.convertString(src.getSeriesElement()));
069    if (src.hasDoseNumber())
070      tgt.setDoseNumber(src.getDoseNumber().primitiveValue());
071    if (src.hasSeriesDoses())
072      tgt.setSeriesDoses(src.getSeriesDoses().primitiveValue());
073    return tgt;
074  }
075
076  public static org.hl7.fhir.r4.model.ImmunizationEvaluation convertImmunizationEvaluation(org.hl7.fhir.r5.model.ImmunizationEvaluation src) throws FHIRException {
077    if (src == null)
078      return null;
079    org.hl7.fhir.r4.model.ImmunizationEvaluation tgt = new org.hl7.fhir.r4.model.ImmunizationEvaluation();
080    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyDomainResource(src, tgt);
081    for (org.hl7.fhir.r5.model.Identifier t : src.getIdentifier())
082      tgt.addIdentifier(Identifier40_50.convertIdentifier(t));
083    if (src.hasStatus())
084      tgt.setStatusElement(convertImmunizationEvaluationStatus(src.getStatusElement()));
085    if (src.hasPatient())
086      tgt.setPatient(Reference40_50.convertReference(src.getPatient()));
087    if (src.hasDate())
088      tgt.setDateElement(DateTime40_50.convertDateTime(src.getDateElement()));
089    if (src.hasAuthority())
090      tgt.setAuthority(Reference40_50.convertReference(src.getAuthority()));
091    if (src.hasTargetDisease())
092      tgt.setTargetDisease(CodeableConcept40_50.convertCodeableConcept(src.getTargetDisease()));
093    if (src.hasImmunizationEvent())
094      tgt.setImmunizationEvent(Reference40_50.convertReference(src.getImmunizationEvent()));
095    if (src.hasDoseStatus())
096      tgt.setDoseStatus(CodeableConcept40_50.convertCodeableConcept(src.getDoseStatus()));
097    for (org.hl7.fhir.r5.model.CodeableConcept t : src.getDoseStatusReason())
098      tgt.addDoseStatusReason(CodeableConcept40_50.convertCodeableConcept(t));
099    if (src.hasDescription())
100      tgt.setDescriptionElement(String40_50.convertString(src.getDescriptionElement()));
101    if (src.hasSeries())
102      tgt.setSeriesElement(String40_50.convertString(src.getSeriesElement()));
103    if (src.hasDoseNumber())
104      tgt.setDoseNumber(ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().convertType(src.getDoseNumberElement()));
105    if (src.hasSeriesDoses())
106      tgt.setSeriesDoses(ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().convertType(src.getSeriesDosesElement()));
107    return tgt;
108  }
109
110  static public org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.ImmunizationEvaluation.ImmunizationEvaluationStatusCodes> convertImmunizationEvaluationStatus(org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.ImmunizationEvaluation.ImmunizationEvaluationStatus> src) throws FHIRException {
111    if (src == null || src.isEmpty())
112      return null;
113    org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.ImmunizationEvaluation.ImmunizationEvaluationStatusCodes> tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.ImmunizationEvaluation.ImmunizationEvaluationStatusCodesEnumFactory());
114    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt);
115    switch (src.getValue()) {
116      case COMPLETED:
117        tgt.setValue(org.hl7.fhir.r5.model.ImmunizationEvaluation.ImmunizationEvaluationStatusCodes.COMPLETED);
118        break;
119      case ENTEREDINERROR:
120        tgt.setValue(org.hl7.fhir.r5.model.ImmunizationEvaluation.ImmunizationEvaluationStatusCodes.ENTEREDINERROR);
121        break;
122      default:
123        tgt.setValue(org.hl7.fhir.r5.model.ImmunizationEvaluation.ImmunizationEvaluationStatusCodes.NULL);
124        break;
125    }
126    return tgt;
127  }
128
129  static public org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.ImmunizationEvaluation.ImmunizationEvaluationStatus> convertImmunizationEvaluationStatus(org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.ImmunizationEvaluation.ImmunizationEvaluationStatusCodes> src) throws FHIRException {
130    if (src == null || src.isEmpty())
131      return null;
132    org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.ImmunizationEvaluation.ImmunizationEvaluationStatus> tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.ImmunizationEvaluation.ImmunizationEvaluationStatusEnumFactory());
133    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt);
134    switch (src.getValue()) {
135      case COMPLETED:
136        tgt.setValue(org.hl7.fhir.r4.model.ImmunizationEvaluation.ImmunizationEvaluationStatus.COMPLETED);
137        break;
138      case ENTEREDINERROR:
139        tgt.setValue(org.hl7.fhir.r4.model.ImmunizationEvaluation.ImmunizationEvaluationStatus.ENTEREDINERROR);
140        break;
141      default:
142        tgt.setValue(org.hl7.fhir.r4.model.ImmunizationEvaluation.ImmunizationEvaluationStatus.NULL);
143        break;
144    }
145    return tgt;
146  }
147}