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.general43_50.SimpleQuantity43_50;
008import org.hl7.fhir.convertors.conv43_50.datatypes43_50.primitive43_50.Boolean43_50;
009import org.hl7.fhir.convertors.conv43_50.datatypes43_50.primitive43_50.Date43_50;
010import org.hl7.fhir.convertors.conv43_50.datatypes43_50.primitive43_50.DateTime43_50;
011import org.hl7.fhir.convertors.conv43_50.datatypes43_50.primitive43_50.String43_50;
012import org.hl7.fhir.convertors.conv43_50.datatypes43_50.special43_50.Reference43_50;
013import org.hl7.fhir.exceptions.FHIRException;
014import org.hl7.fhir.r5.model.CodeableReference;
015
016/*
017  Copyright (c) 2011+, HL7, Inc.
018  All rights reserved.
019  
020  Redistribution and use in source and binary forms, with or without modification, 
021  are permitted provided that the following conditions are met:
022  
023   * Redistributions of source code must retain the above copyright notice, this 
024     list of conditions and the following disclaimer.
025   * Redistributions in binary form must reproduce the above copyright notice, 
026     this list of conditions and the following disclaimer in the documentation 
027     and/or other materials provided with the distribution.
028   * Neither the name of HL7 nor the names of its contributors may be used to 
029     endorse or promote products derived from this software without specific 
030     prior written permission.
031  
032  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 
033  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
034  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
035  IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 
036  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
037  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 
038  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
039  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
040  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
041  POSSIBILITY OF SUCH DAMAGE.
042  
043*/
044// Generated on Sun, Feb 24, 2019 11:37+1100 for FHIR v4.0.0
045public class Immunization43_50 {
046
047  public static org.hl7.fhir.r5.model.Immunization convertImmunization(org.hl7.fhir.r4b.model.Immunization src) throws FHIRException {
048    if (src == null)
049      return null;
050    org.hl7.fhir.r5.model.Immunization tgt = new org.hl7.fhir.r5.model.Immunization();
051    ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyDomainResource(src, tgt);
052    for (org.hl7.fhir.r4b.model.Identifier t : src.getIdentifier())
053      tgt.addIdentifier(Identifier43_50.convertIdentifier(t));
054    if (src.hasStatus())
055      tgt.setStatusElement(convertImmunizationStatus(src.getStatusElement()));
056    if (src.hasStatusReason())
057      tgt.setStatusReason(CodeableConcept43_50.convertCodeableConcept(src.getStatusReason()));
058    if (src.hasVaccineCode())
059      tgt.setVaccineCode(CodeableConcept43_50.convertCodeableConcept(src.getVaccineCode()));
060    if (src.hasPatient())
061      tgt.setPatient(Reference43_50.convertReference(src.getPatient()));
062    if (src.hasEncounter())
063      tgt.setEncounter(Reference43_50.convertReference(src.getEncounter()));
064    if (src.hasOccurrence())
065      tgt.setOccurrence(ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().convertType(src.getOccurrence()));
066//    if (src.hasRecorded())
067//      tgt.setRecordedElement(DateTime43_50.convertDateTime(src.getRecordedElement()));
068    if (src.hasPrimarySource())
069      tgt.setPrimarySourceElement(Boolean43_50.convertBoolean(src.getPrimarySourceElement()));
070    if (src.hasReportOrigin())
071      tgt.setInformationSource(new CodeableReference(CodeableConcept43_50.convertCodeableConcept(src.getReportOrigin())));
072    if (src.hasLocation())
073      tgt.setLocation(Reference43_50.convertReference(src.getLocation()));
074    if (src.hasManufacturer())
075      tgt.setManufacturer(Reference43_50.convertReferenceToCodeableReference(src.getManufacturer()));
076    if (src.hasLotNumber())
077      tgt.setLotNumberElement(String43_50.convertString(src.getLotNumberElement()));
078    if (src.hasExpirationDate())
079      tgt.setExpirationDateElement(Date43_50.convertDate(src.getExpirationDateElement()));
080    if (src.hasSite())
081      tgt.setSite(CodeableConcept43_50.convertCodeableConcept(src.getSite()));
082    if (src.hasRoute())
083      tgt.setRoute(CodeableConcept43_50.convertCodeableConcept(src.getRoute()));
084    if (src.hasDoseQuantity())
085      tgt.setDoseQuantity(SimpleQuantity43_50.convertSimpleQuantity(src.getDoseQuantity()));
086    for (org.hl7.fhir.r4b.model.Immunization.ImmunizationPerformerComponent t : src.getPerformer())
087      tgt.addPerformer(convertImmunizationPerformerComponent(t));
088    for (org.hl7.fhir.r4b.model.Annotation t : src.getNote()) tgt.addNote(Annotation43_50.convertAnnotation(t));
089    for (org.hl7.fhir.r4b.model.CodeableConcept t : src.getReasonCode())
090      tgt.addReason(CodeableConcept43_50.convertCodeableConceptToCodeableReference(t));
091    for (org.hl7.fhir.r4b.model.Reference t : src.getReasonReference())
092      tgt.addReason(Reference43_50.convertReferenceToCodeableReference(t));
093    if (src.hasIsSubpotent())
094      tgt.setIsSubpotentElement(Boolean43_50.convertBoolean(src.getIsSubpotentElement()));
095    for (org.hl7.fhir.r4b.model.CodeableConcept t : src.getSubpotentReason())
096      tgt.addSubpotentReason(CodeableConcept43_50.convertCodeableConcept(t));
097//    for (org.hl7.fhir.r4b.model.Immunization.ImmunizationEducationComponent t : src.getEducation())
098//      tgt.addEducation(convertImmunizationEducationComponent(t));
099//    for (org.hl7.fhir.r4b.model.CodeableConcept t : src.getProgramEligibility())
100//      tgt.addProgramEligibility(CodeableConcept43_50.convertCodeableConcept(t));
101    if (src.hasFundingSource())
102      tgt.setFundingSource(CodeableConcept43_50.convertCodeableConcept(src.getFundingSource()));
103    for (org.hl7.fhir.r4b.model.Immunization.ImmunizationReactionComponent t : src.getReaction())
104      tgt.addReaction(convertImmunizationReactionComponent(t));
105    for (org.hl7.fhir.r4b.model.Immunization.ImmunizationProtocolAppliedComponent t : src.getProtocolApplied())
106      tgt.addProtocolApplied(convertImmunizationProtocolAppliedComponent(t));
107    return tgt;
108  }
109
110  public static org.hl7.fhir.r4b.model.Immunization convertImmunization(org.hl7.fhir.r5.model.Immunization src) throws FHIRException {
111    if (src == null)
112      return null;
113    org.hl7.fhir.r4b.model.Immunization tgt = new org.hl7.fhir.r4b.model.Immunization();
114    ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyDomainResource(src, tgt);
115    for (org.hl7.fhir.r5.model.Identifier t : src.getIdentifier())
116      tgt.addIdentifier(Identifier43_50.convertIdentifier(t));
117    if (src.hasStatus())
118      tgt.setStatusElement(convertImmunizationStatus(src.getStatusElement()));
119    if (src.hasStatusReason())
120      tgt.setStatusReason(CodeableConcept43_50.convertCodeableConcept(src.getStatusReason()));
121    if (src.hasVaccineCode())
122      tgt.setVaccineCode(CodeableConcept43_50.convertCodeableConcept(src.getVaccineCode()));
123    if (src.hasPatient())
124      tgt.setPatient(Reference43_50.convertReference(src.getPatient()));
125    if (src.hasEncounter())
126      tgt.setEncounter(Reference43_50.convertReference(src.getEncounter()));
127    if (src.hasOccurrence())
128      tgt.setOccurrence(ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().convertType(src.getOccurrence()));
129//    if (src.hasRecorded())
130//      tgt.setRecordedElement(DateTime43_50.convertDateTime(src.getRecordedElement()));
131    if (src.hasPrimarySource())
132      tgt.setPrimarySourceElement(Boolean43_50.convertBoolean(src.getPrimarySourceElement()));
133    if (src.getInformationSource().hasConcept())
134      tgt.setReportOrigin(CodeableConcept43_50.convertCodeableConcept(src.getInformationSource().getConcept()));
135    if (src.hasLocation())
136      tgt.setLocation(Reference43_50.convertReference(src.getLocation()));
137    if (src.hasManufacturer())
138      tgt.setManufacturer(Reference43_50.convertCodeableReferenceToReference(src.getManufacturer()));
139    if (src.hasLotNumber())
140      tgt.setLotNumberElement(String43_50.convertString(src.getLotNumberElement()));
141    if (src.hasExpirationDate())
142      tgt.setExpirationDateElement(Date43_50.convertDate(src.getExpirationDateElement()));
143    if (src.hasSite())
144      tgt.setSite(CodeableConcept43_50.convertCodeableConcept(src.getSite()));
145    if (src.hasRoute())
146      tgt.setRoute(CodeableConcept43_50.convertCodeableConcept(src.getRoute()));
147    if (src.hasDoseQuantity())
148      tgt.setDoseQuantity(SimpleQuantity43_50.convertSimpleQuantity(src.getDoseQuantity()));
149    for (org.hl7.fhir.r5.model.Immunization.ImmunizationPerformerComponent t : src.getPerformer())
150      tgt.addPerformer(convertImmunizationPerformerComponent(t));
151    for (org.hl7.fhir.r5.model.Annotation t : src.getNote()) tgt.addNote(Annotation43_50.convertAnnotation(t));
152    for (CodeableReference t : src.getReason())
153      if (t.hasConcept())
154        tgt.addReasonCode(CodeableConcept43_50.convertCodeableConcept(t.getConcept()));
155    for (CodeableReference t : src.getReason())
156      if (t.hasReference())
157        tgt.addReasonReference(Reference43_50.convertReference(t.getReference()));
158    if (src.hasIsSubpotent())
159      tgt.setIsSubpotentElement(Boolean43_50.convertBoolean(src.getIsSubpotentElement()));
160    for (org.hl7.fhir.r5.model.CodeableConcept t : src.getSubpotentReason())
161      tgt.addSubpotentReason(CodeableConcept43_50.convertCodeableConcept(t));
162//    for (org.hl7.fhir.r5.model.Immunization.ImmunizationEducationComponent t : src.getEducation())
163//      tgt.addEducation(convertImmunizationEducationComponent(t));
164//    for (org.hl7.fhir.r5.model.CodeableConcept t : src.getProgramEligibility())
165//      tgt.addProgramEligibility(CodeableConcept43_50.convertCodeableConcept(t));
166    if (src.hasFundingSource())
167      tgt.setFundingSource(CodeableConcept43_50.convertCodeableConcept(src.getFundingSource()));
168    for (org.hl7.fhir.r5.model.Immunization.ImmunizationReactionComponent t : src.getReaction())
169      tgt.addReaction(convertImmunizationReactionComponent(t));
170    for (org.hl7.fhir.r5.model.Immunization.ImmunizationProtocolAppliedComponent t : src.getProtocolApplied())
171      tgt.addProtocolApplied(convertImmunizationProtocolAppliedComponent(t));
172    return tgt;
173  }
174
175  static public org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Immunization.ImmunizationStatusCodes> convertImmunizationStatus(org.hl7.fhir.r4b.model.Enumeration<org.hl7.fhir.r4b.model.Immunization.ImmunizationStatusCodes> src) throws FHIRException {
176    if (src == null || src.isEmpty())
177      return null;
178    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());
179    ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyElement(src, tgt);
180    switch (src.getValue()) {
181      case COMPLETED:
182        tgt.setValue(org.hl7.fhir.r5.model.Immunization.ImmunizationStatusCodes.COMPLETED);
183        break;
184      case ENTEREDINERROR:
185        tgt.setValue(org.hl7.fhir.r5.model.Immunization.ImmunizationStatusCodes.ENTEREDINERROR);
186        break;
187      case NOTDONE:
188        tgt.setValue(org.hl7.fhir.r5.model.Immunization.ImmunizationStatusCodes.NOTDONE);
189        break;
190      default:
191        tgt.setValue(org.hl7.fhir.r5.model.Immunization.ImmunizationStatusCodes.NULL);
192        break;
193    }
194    return tgt;
195  }
196
197  static public org.hl7.fhir.r4b.model.Enumeration<org.hl7.fhir.r4b.model.Immunization.ImmunizationStatusCodes> convertImmunizationStatus(org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Immunization.ImmunizationStatusCodes> src) throws FHIRException {
198    if (src == null || src.isEmpty())
199      return null;
200    org.hl7.fhir.r4b.model.Enumeration<org.hl7.fhir.r4b.model.Immunization.ImmunizationStatusCodes> tgt = new org.hl7.fhir.r4b.model.Enumeration<>(new org.hl7.fhir.r4b.model.Immunization.ImmunizationStatusCodesEnumFactory());
201    ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyElement(src, tgt);
202    switch (src.getValue()) {
203      case COMPLETED:
204        tgt.setValue(org.hl7.fhir.r4b.model.Immunization.ImmunizationStatusCodes.COMPLETED);
205        break;
206      case ENTEREDINERROR:
207        tgt.setValue(org.hl7.fhir.r4b.model.Immunization.ImmunizationStatusCodes.ENTEREDINERROR);
208        break;
209      case NOTDONE:
210        tgt.setValue(org.hl7.fhir.r4b.model.Immunization.ImmunizationStatusCodes.NOTDONE);
211        break;
212      default:
213        tgt.setValue(org.hl7.fhir.r4b.model.Immunization.ImmunizationStatusCodes.NULL);
214        break;
215    }
216    return tgt;
217  }
218
219  public static org.hl7.fhir.r5.model.Immunization.ImmunizationPerformerComponent convertImmunizationPerformerComponent(org.hl7.fhir.r4b.model.Immunization.ImmunizationPerformerComponent src) throws FHIRException {
220    if (src == null)
221      return null;
222    org.hl7.fhir.r5.model.Immunization.ImmunizationPerformerComponent tgt = new org.hl7.fhir.r5.model.Immunization.ImmunizationPerformerComponent();
223    ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyBackboneElement(src, tgt);
224    if (src.hasFunction())
225      tgt.setFunction(CodeableConcept43_50.convertCodeableConcept(src.getFunction()));
226    if (src.hasActor())
227      tgt.setActor(Reference43_50.convertReference(src.getActor()));
228    return tgt;
229  }
230
231  public static org.hl7.fhir.r4b.model.Immunization.ImmunizationPerformerComponent convertImmunizationPerformerComponent(org.hl7.fhir.r5.model.Immunization.ImmunizationPerformerComponent src) throws FHIRException {
232    if (src == null)
233      return null;
234    org.hl7.fhir.r4b.model.Immunization.ImmunizationPerformerComponent tgt = new org.hl7.fhir.r4b.model.Immunization.ImmunizationPerformerComponent();
235    ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyBackboneElement(src, tgt);
236    if (src.hasFunction())
237      tgt.setFunction(CodeableConcept43_50.convertCodeableConcept(src.getFunction()));
238    if (src.hasActor())
239      tgt.setActor(Reference43_50.convertReference(src.getActor()));
240    return tgt;
241  }
242
243//  public static org.hl7.fhir.r5.model.Immunization.ImmunizationEducationComponent convertImmunizationEducationComponent(org.hl7.fhir.r4b.model.Immunization.ImmunizationEducationComponent src) throws FHIRException {
244//    if (src == null)
245//      return null;
246//    org.hl7.fhir.r5.model.Immunization.ImmunizationEducationComponent tgt = new org.hl7.fhir.r5.model.Immunization.ImmunizationEducationComponent();
247//    ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyBackboneElement(src, tgt);
248//    if (src.hasDocumentType())
249//      tgt.setDocumentTypeElement(String43_50.convertString(src.getDocumentTypeElement()));
250//    if (src.hasReference())
251//      tgt.setReferenceElement(Uri43_50.convertUri(src.getReferenceElement()));
252//    if (src.hasPublicationDate())
253//      tgt.setPublicationDateElement(DateTime43_50.convertDateTime(src.getPublicationDateElement()));
254//    if (src.hasPresentationDate())
255//      tgt.setPresentationDateElement(DateTime43_50.convertDateTime(src.getPresentationDateElement()));
256//    return tgt;
257//  }
258//
259//  public static org.hl7.fhir.r4b.model.Immunization.ImmunizationEducationComponent convertImmunizationEducationComponent(org.hl7.fhir.r5.model.Immunization.ImmunizationEducationComponent src) throws FHIRException {
260//    if (src == null)
261//      return null;
262//    org.hl7.fhir.r4b.model.Immunization.ImmunizationEducationComponent tgt = new org.hl7.fhir.r4b.model.Immunization.ImmunizationEducationComponent();
263//    ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyBackboneElement(src, tgt);
264//    if (src.hasDocumentType())
265//      tgt.setDocumentTypeElement(String43_50.convertString(src.getDocumentTypeElement()));
266//    if (src.hasReference())
267//      tgt.setReferenceElement(Uri43_50.convertUri(src.getReferenceElement()));
268//    if (src.hasPublicationDate())
269//      tgt.setPublicationDateElement(DateTime43_50.convertDateTime(src.getPublicationDateElement()));
270//    if (src.hasPresentationDate())
271//      tgt.setPresentationDateElement(DateTime43_50.convertDateTime(src.getPresentationDateElement()));
272//    return tgt;
273//  }
274
275  public static org.hl7.fhir.r5.model.Immunization.ImmunizationReactionComponent convertImmunizationReactionComponent(org.hl7.fhir.r4b.model.Immunization.ImmunizationReactionComponent src) throws FHIRException {
276    if (src == null)
277      return null;
278    org.hl7.fhir.r5.model.Immunization.ImmunizationReactionComponent tgt = new org.hl7.fhir.r5.model.Immunization.ImmunizationReactionComponent();
279    ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyBackboneElement(src, tgt);
280    if (src.hasDate())
281      tgt.setDateElement(DateTime43_50.convertDateTime(src.getDateElement()));
282    if (src.hasDetail())
283      tgt.setManifestation(new CodeableReference(Reference43_50.convertReference(src.getDetail())));
284    if (src.hasReported())
285      tgt.setReportedElement(Boolean43_50.convertBoolean(src.getReportedElement()));
286    return tgt;
287  }
288
289  public static org.hl7.fhir.r4b.model.Immunization.ImmunizationReactionComponent convertImmunizationReactionComponent(org.hl7.fhir.r5.model.Immunization.ImmunizationReactionComponent src) throws FHIRException {
290    if (src == null)
291      return null;
292    org.hl7.fhir.r4b.model.Immunization.ImmunizationReactionComponent tgt = new org.hl7.fhir.r4b.model.Immunization.ImmunizationReactionComponent();
293    ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyBackboneElement(src, tgt);
294    if (src.hasDate())
295      tgt.setDateElement(DateTime43_50.convertDateTime(src.getDateElement()));
296    if (src.hasManifestation())
297      tgt.setDetail(Reference43_50.convertReference(src.getManifestation().getReference()));
298    if (src.hasReported())
299      tgt.setReportedElement(Boolean43_50.convertBoolean(src.getReportedElement()));
300    return tgt;
301  }
302
303  public static org.hl7.fhir.r5.model.Immunization.ImmunizationProtocolAppliedComponent convertImmunizationProtocolAppliedComponent(org.hl7.fhir.r4b.model.Immunization.ImmunizationProtocolAppliedComponent src) throws FHIRException {
304    if (src == null)
305      return null;
306    org.hl7.fhir.r5.model.Immunization.ImmunizationProtocolAppliedComponent tgt = new org.hl7.fhir.r5.model.Immunization.ImmunizationProtocolAppliedComponent();
307    ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyBackboneElement(src, tgt);
308    if (src.hasSeries())
309      tgt.setSeriesElement(String43_50.convertString(src.getSeriesElement()));
310    if (src.hasAuthority())
311      tgt.setAuthority(Reference43_50.convertReference(src.getAuthority()));
312    for (org.hl7.fhir.r4b.model.CodeableConcept t : src.getTargetDisease())
313      tgt.addTargetDisease(CodeableConcept43_50.convertCodeableConcept(t));
314    if (src.hasDoseNumber())
315      tgt.setDoseNumber(src.getDoseNumber().primitiveValue());
316    if (src.hasSeriesDoses())
317      tgt.setSeriesDoses(src.getSeriesDoses().primitiveValue());
318    return tgt;
319  }
320
321  public static org.hl7.fhir.r4b.model.Immunization.ImmunizationProtocolAppliedComponent convertImmunizationProtocolAppliedComponent(org.hl7.fhir.r5.model.Immunization.ImmunizationProtocolAppliedComponent src) throws FHIRException {
322    if (src == null)
323      return null;
324    org.hl7.fhir.r4b.model.Immunization.ImmunizationProtocolAppliedComponent tgt = new org.hl7.fhir.r4b.model.Immunization.ImmunizationProtocolAppliedComponent();
325    ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyBackboneElement(src, tgt);
326    if (src.hasSeries())
327      tgt.setSeriesElement(String43_50.convertString(src.getSeriesElement()));
328    if (src.hasAuthority())
329      tgt.setAuthority(Reference43_50.convertReference(src.getAuthority()));
330    for (org.hl7.fhir.r5.model.CodeableConcept t : src.getTargetDisease())
331      tgt.addTargetDisease(CodeableConcept43_50.convertCodeableConcept(t));
332    if (src.hasDoseNumber())
333      tgt.setDoseNumber(ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().convertType(src.getDoseNumberElement()));
334    if (src.hasSeriesDoses())
335      tgt.setSeriesDoses(ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().convertType(src.getSeriesDosesElement()));
336    return tgt;
337  }
338}