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.general40_50.SimpleQuantity40_50;
008import org.hl7.fhir.convertors.conv40_50.datatypes40_50.primitive40_50.*;
009import org.hl7.fhir.convertors.conv40_50.datatypes40_50.special40_50.Reference40_50;
010import org.hl7.fhir.exceptions.FHIRException;
011import org.hl7.fhir.r5.model.CodeableReference;
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 Immunization40_50 {
043
044  public static org.hl7.fhir.r5.model.Immunization convertImmunization(org.hl7.fhir.r4.model.Immunization src) throws FHIRException {
045    if (src == null)
046      return null;
047    org.hl7.fhir.r5.model.Immunization tgt = new org.hl7.fhir.r5.model.Immunization();
048    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyDomainResource(src, tgt);
049    for (org.hl7.fhir.r4.model.Identifier t : src.getIdentifier())
050      tgt.addIdentifier(Identifier40_50.convertIdentifier(t));
051    if (src.hasStatus())
052      tgt.setStatusElement(convertImmunizationStatus(src.getStatusElement()));
053    if (src.hasStatusReason())
054      tgt.setStatusReason(CodeableConcept40_50.convertCodeableConcept(src.getStatusReason()));
055    if (src.hasVaccineCode())
056      tgt.setVaccineCode(CodeableConcept40_50.convertCodeableConcept(src.getVaccineCode()));
057    if (src.hasPatient())
058      tgt.setPatient(Reference40_50.convertReference(src.getPatient()));
059    if (src.hasEncounter())
060      tgt.setEncounter(Reference40_50.convertReference(src.getEncounter()));
061    if (src.hasOccurrence())
062      tgt.setOccurrence(ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().convertType(src.getOccurrence()));
063    if (src.hasRecorded())
064      tgt.setRecordedElement(DateTime40_50.convertDateTime(src.getRecordedElement()));
065    if (src.hasPrimarySource())
066      tgt.setPrimarySourceElement(Boolean40_50.convertBoolean(src.getPrimarySourceElement()));
067    if (src.hasReportOrigin())
068      tgt.setInformationSource(CodeableConcept40_50.convertCodeableConcept(src.getReportOrigin()));
069    if (src.hasLocation())
070      tgt.setLocation(Reference40_50.convertReference(src.getLocation()));
071    if (src.hasManufacturer())
072      tgt.setManufacturer(Reference40_50.convertReference(src.getManufacturer()));
073    if (src.hasLotNumber())
074      tgt.setLotNumberElement(String40_50.convertString(src.getLotNumberElement()));
075    if (src.hasExpirationDate())
076      tgt.setExpirationDateElement(Date40_50.convertDate(src.getExpirationDateElement()));
077    if (src.hasSite())
078      tgt.setSite(CodeableConcept40_50.convertCodeableConcept(src.getSite()));
079    if (src.hasRoute())
080      tgt.setRoute(CodeableConcept40_50.convertCodeableConcept(src.getRoute()));
081    if (src.hasDoseQuantity())
082      tgt.setDoseQuantity(SimpleQuantity40_50.convertSimpleQuantity(src.getDoseQuantity()));
083    for (org.hl7.fhir.r4.model.Immunization.ImmunizationPerformerComponent t : src.getPerformer())
084      tgt.addPerformer(convertImmunizationPerformerComponent(t));
085    for (org.hl7.fhir.r4.model.Annotation t : src.getNote()) tgt.addNote(Annotation40_50.convertAnnotation(t));
086    for (org.hl7.fhir.r4.model.CodeableConcept t : src.getReasonCode())
087      tgt.addReason(CodeableConcept40_50.convertCodeableConceptToCodeableReference(t));
088    for (org.hl7.fhir.r4.model.Reference t : src.getReasonReference())
089      tgt.addReason(Reference40_50.convertReferenceToCodeableReference(t));
090    if (src.hasIsSubpotent())
091      tgt.setIsSubpotentElement(Boolean40_50.convertBoolean(src.getIsSubpotentElement()));
092    for (org.hl7.fhir.r4.model.CodeableConcept t : src.getSubpotentReason())
093      tgt.addSubpotentReason(CodeableConcept40_50.convertCodeableConcept(t));
094    for (org.hl7.fhir.r4.model.Immunization.ImmunizationEducationComponent t : src.getEducation())
095      tgt.addEducation(convertImmunizationEducationComponent(t));
096    for (org.hl7.fhir.r4.model.CodeableConcept t : src.getProgramEligibility())
097      tgt.addProgramEligibility(CodeableConcept40_50.convertCodeableConcept(t));
098    if (src.hasFundingSource())
099      tgt.setFundingSource(CodeableConcept40_50.convertCodeableConcept(src.getFundingSource()));
100    for (org.hl7.fhir.r4.model.Immunization.ImmunizationReactionComponent t : src.getReaction())
101      tgt.addReaction(convertImmunizationReactionComponent(t));
102    for (org.hl7.fhir.r4.model.Immunization.ImmunizationProtocolAppliedComponent t : src.getProtocolApplied())
103      tgt.addProtocolApplied(convertImmunizationProtocolAppliedComponent(t));
104    return tgt;
105  }
106
107  public static org.hl7.fhir.r4.model.Immunization convertImmunization(org.hl7.fhir.r5.model.Immunization src) throws FHIRException {
108    if (src == null)
109      return null;
110    org.hl7.fhir.r4.model.Immunization tgt = new org.hl7.fhir.r4.model.Immunization();
111    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyDomainResource(src, tgt);
112    for (org.hl7.fhir.r5.model.Identifier t : src.getIdentifier())
113      tgt.addIdentifier(Identifier40_50.convertIdentifier(t));
114    if (src.hasStatus())
115      tgt.setStatusElement(convertImmunizationStatus(src.getStatusElement()));
116    if (src.hasStatusReason())
117      tgt.setStatusReason(CodeableConcept40_50.convertCodeableConcept(src.getStatusReason()));
118    if (src.hasVaccineCode())
119      tgt.setVaccineCode(CodeableConcept40_50.convertCodeableConcept(src.getVaccineCode()));
120    if (src.hasPatient())
121      tgt.setPatient(Reference40_50.convertReference(src.getPatient()));
122    if (src.hasEncounter())
123      tgt.setEncounter(Reference40_50.convertReference(src.getEncounter()));
124    if (src.hasOccurrence())
125      tgt.setOccurrence(ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().convertType(src.getOccurrence()));
126    if (src.hasRecorded())
127      tgt.setRecordedElement(DateTime40_50.convertDateTime(src.getRecordedElement()));
128    if (src.hasPrimarySource())
129      tgt.setPrimarySourceElement(Boolean40_50.convertBoolean(src.getPrimarySourceElement()));
130    if (src.hasInformationSourceCodeableConcept())
131      tgt.setReportOrigin(CodeableConcept40_50.convertCodeableConcept(src.getInformationSourceCodeableConcept()));
132    if (src.hasLocation())
133      tgt.setLocation(Reference40_50.convertReference(src.getLocation()));
134    if (src.hasManufacturer())
135      tgt.setManufacturer(Reference40_50.convertReference(src.getManufacturer()));
136    if (src.hasLotNumber())
137      tgt.setLotNumberElement(String40_50.convertString(src.getLotNumberElement()));
138    if (src.hasExpirationDate())
139      tgt.setExpirationDateElement(Date40_50.convertDate(src.getExpirationDateElement()));
140    if (src.hasSite())
141      tgt.setSite(CodeableConcept40_50.convertCodeableConcept(src.getSite()));
142    if (src.hasRoute())
143      tgt.setRoute(CodeableConcept40_50.convertCodeableConcept(src.getRoute()));
144    if (src.hasDoseQuantity())
145      tgt.setDoseQuantity(SimpleQuantity40_50.convertSimpleQuantity(src.getDoseQuantity()));
146    for (org.hl7.fhir.r5.model.Immunization.ImmunizationPerformerComponent t : src.getPerformer())
147      tgt.addPerformer(convertImmunizationPerformerComponent(t));
148    for (org.hl7.fhir.r5.model.Annotation t : src.getNote()) tgt.addNote(Annotation40_50.convertAnnotation(t));
149    for (CodeableReference t : src.getReason())
150      if (t.hasConcept())
151        tgt.addReasonCode(CodeableConcept40_50.convertCodeableConcept(t.getConcept()));
152    for (CodeableReference t : src.getReason())
153      if (t.hasReference())
154        tgt.addReasonReference(Reference40_50.convertReference(t.getReference()));
155    if (src.hasIsSubpotent())
156      tgt.setIsSubpotentElement(Boolean40_50.convertBoolean(src.getIsSubpotentElement()));
157    for (org.hl7.fhir.r5.model.CodeableConcept t : src.getSubpotentReason())
158      tgt.addSubpotentReason(CodeableConcept40_50.convertCodeableConcept(t));
159    for (org.hl7.fhir.r5.model.Immunization.ImmunizationEducationComponent t : src.getEducation())
160      tgt.addEducation(convertImmunizationEducationComponent(t));
161    for (org.hl7.fhir.r5.model.CodeableConcept t : src.getProgramEligibility())
162      tgt.addProgramEligibility(CodeableConcept40_50.convertCodeableConcept(t));
163    if (src.hasFundingSource())
164      tgt.setFundingSource(CodeableConcept40_50.convertCodeableConcept(src.getFundingSource()));
165    for (org.hl7.fhir.r5.model.Immunization.ImmunizationReactionComponent t : src.getReaction())
166      tgt.addReaction(convertImmunizationReactionComponent(t));
167    for (org.hl7.fhir.r5.model.Immunization.ImmunizationProtocolAppliedComponent t : src.getProtocolApplied())
168      tgt.addProtocolApplied(convertImmunizationProtocolAppliedComponent(t));
169    return tgt;
170  }
171
172  static public org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Immunization.ImmunizationStatusCodes> convertImmunizationStatus(org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.Immunization.ImmunizationStatus> src) throws FHIRException {
173    if (src == null || src.isEmpty())
174      return null;
175    org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Immunization.ImmunizationStatusCodes> tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.Immunization.ImmunizationStatusCodesEnumFactory());
176    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt);
177    switch (src.getValue()) {
178      case COMPLETED:
179        tgt.setValue(org.hl7.fhir.r5.model.Immunization.ImmunizationStatusCodes.COMPLETED);
180        break;
181      case ENTEREDINERROR:
182        tgt.setValue(org.hl7.fhir.r5.model.Immunization.ImmunizationStatusCodes.ENTEREDINERROR);
183        break;
184      case NOTDONE:
185        tgt.setValue(org.hl7.fhir.r5.model.Immunization.ImmunizationStatusCodes.NOTDONE);
186        break;
187      default:
188        tgt.setValue(org.hl7.fhir.r5.model.Immunization.ImmunizationStatusCodes.NULL);
189        break;
190    }
191    return tgt;
192  }
193
194  static public org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.Immunization.ImmunizationStatus> convertImmunizationStatus(org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Immunization.ImmunizationStatusCodes> src) throws FHIRException {
195    if (src == null || src.isEmpty())
196      return null;
197    org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.Immunization.ImmunizationStatus> tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.Immunization.ImmunizationStatusEnumFactory());
198    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt);
199    switch (src.getValue()) {
200      case COMPLETED:
201        tgt.setValue(org.hl7.fhir.r4.model.Immunization.ImmunizationStatus.COMPLETED);
202        break;
203      case ENTEREDINERROR:
204        tgt.setValue(org.hl7.fhir.r4.model.Immunization.ImmunizationStatus.ENTEREDINERROR);
205        break;
206      case NOTDONE:
207        tgt.setValue(org.hl7.fhir.r4.model.Immunization.ImmunizationStatus.NOTDONE);
208        break;
209      default:
210        tgt.setValue(org.hl7.fhir.r4.model.Immunization.ImmunizationStatus.NULL);
211        break;
212    }
213    return tgt;
214  }
215
216  public static org.hl7.fhir.r5.model.Immunization.ImmunizationPerformerComponent convertImmunizationPerformerComponent(org.hl7.fhir.r4.model.Immunization.ImmunizationPerformerComponent src) throws FHIRException {
217    if (src == null)
218      return null;
219    org.hl7.fhir.r5.model.Immunization.ImmunizationPerformerComponent tgt = new org.hl7.fhir.r5.model.Immunization.ImmunizationPerformerComponent();
220    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt);
221    if (src.hasFunction())
222      tgt.setFunction(CodeableConcept40_50.convertCodeableConcept(src.getFunction()));
223    if (src.hasActor())
224      tgt.setActor(Reference40_50.convertReference(src.getActor()));
225    return tgt;
226  }
227
228  public static org.hl7.fhir.r4.model.Immunization.ImmunizationPerformerComponent convertImmunizationPerformerComponent(org.hl7.fhir.r5.model.Immunization.ImmunizationPerformerComponent src) throws FHIRException {
229    if (src == null)
230      return null;
231    org.hl7.fhir.r4.model.Immunization.ImmunizationPerformerComponent tgt = new org.hl7.fhir.r4.model.Immunization.ImmunizationPerformerComponent();
232    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt);
233    if (src.hasFunction())
234      tgt.setFunction(CodeableConcept40_50.convertCodeableConcept(src.getFunction()));
235    if (src.hasActor())
236      tgt.setActor(Reference40_50.convertReference(src.getActor()));
237    return tgt;
238  }
239
240  public static org.hl7.fhir.r5.model.Immunization.ImmunizationEducationComponent convertImmunizationEducationComponent(org.hl7.fhir.r4.model.Immunization.ImmunizationEducationComponent src) throws FHIRException {
241    if (src == null)
242      return null;
243    org.hl7.fhir.r5.model.Immunization.ImmunizationEducationComponent tgt = new org.hl7.fhir.r5.model.Immunization.ImmunizationEducationComponent();
244    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt);
245    if (src.hasDocumentType())
246      tgt.setDocumentTypeElement(String40_50.convertString(src.getDocumentTypeElement()));
247    if (src.hasReference())
248      tgt.setReferenceElement(Uri40_50.convertUri(src.getReferenceElement()));
249    if (src.hasPublicationDate())
250      tgt.setPublicationDateElement(DateTime40_50.convertDateTime(src.getPublicationDateElement()));
251    if (src.hasPresentationDate())
252      tgt.setPresentationDateElement(DateTime40_50.convertDateTime(src.getPresentationDateElement()));
253    return tgt;
254  }
255
256  public static org.hl7.fhir.r4.model.Immunization.ImmunizationEducationComponent convertImmunizationEducationComponent(org.hl7.fhir.r5.model.Immunization.ImmunizationEducationComponent src) throws FHIRException {
257    if (src == null)
258      return null;
259    org.hl7.fhir.r4.model.Immunization.ImmunizationEducationComponent tgt = new org.hl7.fhir.r4.model.Immunization.ImmunizationEducationComponent();
260    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt);
261    if (src.hasDocumentType())
262      tgt.setDocumentTypeElement(String40_50.convertString(src.getDocumentTypeElement()));
263    if (src.hasReference())
264      tgt.setReferenceElement(Uri40_50.convertUri(src.getReferenceElement()));
265    if (src.hasPublicationDate())
266      tgt.setPublicationDateElement(DateTime40_50.convertDateTime(src.getPublicationDateElement()));
267    if (src.hasPresentationDate())
268      tgt.setPresentationDateElement(DateTime40_50.convertDateTime(src.getPresentationDateElement()));
269    return tgt;
270  }
271
272  public static org.hl7.fhir.r5.model.Immunization.ImmunizationReactionComponent convertImmunizationReactionComponent(org.hl7.fhir.r4.model.Immunization.ImmunizationReactionComponent src) throws FHIRException {
273    if (src == null)
274      return null;
275    org.hl7.fhir.r5.model.Immunization.ImmunizationReactionComponent tgt = new org.hl7.fhir.r5.model.Immunization.ImmunizationReactionComponent();
276    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt);
277    if (src.hasDate())
278      tgt.setDateElement(DateTime40_50.convertDateTime(src.getDateElement()));
279    if (src.hasDetail())
280      tgt.setDetail(Reference40_50.convertReference(src.getDetail()));
281    if (src.hasReported())
282      tgt.setReportedElement(Boolean40_50.convertBoolean(src.getReportedElement()));
283    return tgt;
284  }
285
286  public static org.hl7.fhir.r4.model.Immunization.ImmunizationReactionComponent convertImmunizationReactionComponent(org.hl7.fhir.r5.model.Immunization.ImmunizationReactionComponent src) throws FHIRException {
287    if (src == null)
288      return null;
289    org.hl7.fhir.r4.model.Immunization.ImmunizationReactionComponent tgt = new org.hl7.fhir.r4.model.Immunization.ImmunizationReactionComponent();
290    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt);
291    if (src.hasDate())
292      tgt.setDateElement(DateTime40_50.convertDateTime(src.getDateElement()));
293    if (src.hasDetail())
294      tgt.setDetail(Reference40_50.convertReference(src.getDetail()));
295    if (src.hasReported())
296      tgt.setReportedElement(Boolean40_50.convertBoolean(src.getReportedElement()));
297    return tgt;
298  }
299
300  public static org.hl7.fhir.r5.model.Immunization.ImmunizationProtocolAppliedComponent convertImmunizationProtocolAppliedComponent(org.hl7.fhir.r4.model.Immunization.ImmunizationProtocolAppliedComponent src) throws FHIRException {
301    if (src == null)
302      return null;
303    org.hl7.fhir.r5.model.Immunization.ImmunizationProtocolAppliedComponent tgt = new org.hl7.fhir.r5.model.Immunization.ImmunizationProtocolAppliedComponent();
304    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt);
305    if (src.hasSeries())
306      tgt.setSeriesElement(String40_50.convertString(src.getSeriesElement()));
307    if (src.hasAuthority())
308      tgt.setAuthority(Reference40_50.convertReference(src.getAuthority()));
309    for (org.hl7.fhir.r4.model.CodeableConcept t : src.getTargetDisease())
310      tgt.addTargetDisease(CodeableConcept40_50.convertCodeableConcept(t));
311    if (src.hasDoseNumber())
312      tgt.setDoseNumber(src.getDoseNumber().primitiveValue());
313    if (src.hasSeriesDoses())
314      tgt.setSeriesDoses(src.getSeriesDoses().primitiveValue());
315    return tgt;
316  }
317
318  public static org.hl7.fhir.r4.model.Immunization.ImmunizationProtocolAppliedComponent convertImmunizationProtocolAppliedComponent(org.hl7.fhir.r5.model.Immunization.ImmunizationProtocolAppliedComponent src) throws FHIRException {
319    if (src == null)
320      return null;
321    org.hl7.fhir.r4.model.Immunization.ImmunizationProtocolAppliedComponent tgt = new org.hl7.fhir.r4.model.Immunization.ImmunizationProtocolAppliedComponent();
322    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt);
323    if (src.hasSeries())
324      tgt.setSeriesElement(String40_50.convertString(src.getSeriesElement()));
325    if (src.hasAuthority())
326      tgt.setAuthority(Reference40_50.convertReference(src.getAuthority()));
327    for (org.hl7.fhir.r5.model.CodeableConcept t : src.getTargetDisease())
328      tgt.addTargetDisease(CodeableConcept40_50.convertCodeableConcept(t));
329    if (src.hasDoseNumber())
330      tgt.setDoseNumber(ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().convertType(src.getDoseNumberElement()));
331    if (src.hasSeriesDoses())
332      tgt.setSeriesDoses(ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().convertType(src.getSeriesDosesElement()));
333    return tgt;
334  }
335}