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.*;
005import org.hl7.fhir.convertors.conv40_50.datatypes40_50.primitive40_50.*;
006import org.hl7.fhir.convertors.conv40_50.datatypes40_50.special40_50.Reference40_50;
007import org.hl7.fhir.exceptions.FHIRException;
008import org.hl7.fhir.r5.model.CodeableReference;
009
010/*
011  Copyright (c) 2011+, HL7, Inc.
012  All rights reserved.
013  
014  Redistribution and use in source and binary forms, with or without modification, 
015  are permitted provided that the following conditions are met:
016  
017   * Redistributions of source code must retain the above copyright notice, this 
018     list of conditions and the following disclaimer.
019   * Redistributions in binary form must reproduce the above copyright notice, 
020     this list of conditions and the following disclaimer in the documentation 
021     and/or other materials provided with the distribution.
022   * Neither the name of HL7 nor the names of its contributors may be used to 
023     endorse or promote products derived from this software without specific 
024     prior written permission.
025  
026  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 
027  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
028  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
029  IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 
030  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
031  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 
032  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
033  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
034  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
035  POSSIBILITY OF SUCH DAMAGE.
036  
037*/
038// Generated on Sun, Feb 24, 2019 11:37+1100 for FHIR v4.0.0
039public class CarePlan40_50 {
040
041  public static org.hl7.fhir.r5.model.CarePlan convertCarePlan(org.hl7.fhir.r4.model.CarePlan src) throws FHIRException {
042    if (src == null)
043      return null;
044    org.hl7.fhir.r5.model.CarePlan tgt = new org.hl7.fhir.r5.model.CarePlan();
045    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyDomainResource(src, tgt);
046    for (org.hl7.fhir.r4.model.Identifier t : src.getIdentifier())
047      tgt.addIdentifier(Identifier40_50.convertIdentifier(t));
048    for (org.hl7.fhir.r4.model.CanonicalType t : src.getInstantiatesCanonical())
049      tgt.getInstantiatesCanonical().add(Canonical40_50.convertCanonical(t));
050    for (org.hl7.fhir.r4.model.UriType t : src.getInstantiatesUri())
051      tgt.getInstantiatesUri().add(Uri40_50.convertUri(t));
052    for (org.hl7.fhir.r4.model.Reference t : src.getBasedOn()) tgt.addBasedOn(Reference40_50.convertReference(t));
053    for (org.hl7.fhir.r4.model.Reference t : src.getReplaces()) tgt.addReplaces(Reference40_50.convertReference(t));
054    for (org.hl7.fhir.r4.model.Reference t : src.getPartOf()) tgt.addPartOf(Reference40_50.convertReference(t));
055    if (src.hasStatus())
056      tgt.setStatusElement(convertCarePlanStatus(src.getStatusElement()));
057    if (src.hasIntent())
058      tgt.setIntentElement(convertCarePlanIntent(src.getIntentElement()));
059    for (org.hl7.fhir.r4.model.CodeableConcept t : src.getCategory())
060      tgt.addCategory(CodeableConcept40_50.convertCodeableConcept(t));
061    if (src.hasTitle())
062      tgt.setTitleElement(String40_50.convertString(src.getTitleElement()));
063    if (src.hasDescription())
064      tgt.setDescriptionElement(String40_50.convertString(src.getDescriptionElement()));
065    if (src.hasSubject())
066      tgt.setSubject(Reference40_50.convertReference(src.getSubject()));
067    if (src.hasEncounter())
068      tgt.setEncounter(Reference40_50.convertReference(src.getEncounter()));
069    if (src.hasPeriod())
070      tgt.setPeriod(Period40_50.convertPeriod(src.getPeriod()));
071    if (src.hasCreated())
072      tgt.setCreatedElement(DateTime40_50.convertDateTime(src.getCreatedElement()));
073    if (src.hasAuthor())
074      tgt.setAuthor(Reference40_50.convertReference(src.getAuthor()));
075    for (org.hl7.fhir.r4.model.Reference t : src.getContributor())
076      tgt.addContributor(Reference40_50.convertReference(t));
077    for (org.hl7.fhir.r4.model.Reference t : src.getCareTeam()) tgt.addCareTeam(Reference40_50.convertReference(t));
078    for (org.hl7.fhir.r4.model.Reference t : src.getAddresses())
079      tgt.addAddresses(Reference40_50.convertReferenceToCodeableReference(t));
080    for (org.hl7.fhir.r4.model.Reference t : src.getSupportingInfo())
081      tgt.addSupportingInfo(Reference40_50.convertReference(t));
082    for (org.hl7.fhir.r4.model.Reference t : src.getGoal()) tgt.addGoal(Reference40_50.convertReference(t));
083    for (org.hl7.fhir.r4.model.CarePlan.CarePlanActivityComponent t : src.getActivity())
084      tgt.addActivity(convertCarePlanActivityComponent(t));
085    for (org.hl7.fhir.r4.model.Annotation t : src.getNote()) tgt.addNote(Annotation40_50.convertAnnotation(t));
086    return tgt;
087  }
088
089  public static org.hl7.fhir.r4.model.CarePlan convertCarePlan(org.hl7.fhir.r5.model.CarePlan src) throws FHIRException {
090    if (src == null)
091      return null;
092    org.hl7.fhir.r4.model.CarePlan tgt = new org.hl7.fhir.r4.model.CarePlan();
093    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyDomainResource(src, tgt);
094    for (org.hl7.fhir.r5.model.Identifier t : src.getIdentifier())
095      tgt.addIdentifier(Identifier40_50.convertIdentifier(t));
096    for (org.hl7.fhir.r5.model.CanonicalType t : src.getInstantiatesCanonical())
097      tgt.getInstantiatesCanonical().add(Canonical40_50.convertCanonical(t));
098    for (org.hl7.fhir.r5.model.UriType t : src.getInstantiatesUri())
099      tgt.getInstantiatesUri().add(Uri40_50.convertUri(t));
100    for (org.hl7.fhir.r5.model.Reference t : src.getBasedOn()) tgt.addBasedOn(Reference40_50.convertReference(t));
101    for (org.hl7.fhir.r5.model.Reference t : src.getReplaces()) tgt.addReplaces(Reference40_50.convertReference(t));
102    for (org.hl7.fhir.r5.model.Reference t : src.getPartOf()) tgt.addPartOf(Reference40_50.convertReference(t));
103    if (src.hasStatus())
104      tgt.setStatusElement(convertCarePlanStatus(src.getStatusElement()));
105    if (src.hasIntent())
106      tgt.setIntentElement(convertCarePlanIntent(src.getIntentElement()));
107    for (org.hl7.fhir.r5.model.CodeableConcept t : src.getCategory())
108      tgt.addCategory(CodeableConcept40_50.convertCodeableConcept(t));
109    if (src.hasTitle())
110      tgt.setTitleElement(String40_50.convertString(src.getTitleElement()));
111    if (src.hasDescription())
112      tgt.setDescriptionElement(String40_50.convertString(src.getDescriptionElement()));
113    if (src.hasSubject())
114      tgt.setSubject(Reference40_50.convertReference(src.getSubject()));
115    if (src.hasEncounter())
116      tgt.setEncounter(Reference40_50.convertReference(src.getEncounter()));
117    if (src.hasPeriod())
118      tgt.setPeriod(Period40_50.convertPeriod(src.getPeriod()));
119    if (src.hasCreated())
120      tgt.setCreatedElement(DateTime40_50.convertDateTime(src.getCreatedElement()));
121    if (src.hasAuthor())
122      tgt.setAuthor(Reference40_50.convertReference(src.getAuthor()));
123    for (org.hl7.fhir.r5.model.Reference t : src.getContributor())
124      tgt.addContributor(Reference40_50.convertReference(t));
125    for (org.hl7.fhir.r5.model.Reference t : src.getCareTeam()) tgt.addCareTeam(Reference40_50.convertReference(t));
126    for (CodeableReference t : src.getAddresses())
127      if (t.hasReference())
128        tgt.addAddresses(Reference40_50.convertReference(t.getReference()));
129    for (org.hl7.fhir.r5.model.Reference t : src.getSupportingInfo())
130      tgt.addSupportingInfo(Reference40_50.convertReference(t));
131    for (org.hl7.fhir.r5.model.Reference t : src.getGoal()) tgt.addGoal(Reference40_50.convertReference(t));
132    for (org.hl7.fhir.r5.model.CarePlan.CarePlanActivityComponent t : src.getActivity())
133      tgt.addActivity(convertCarePlanActivityComponent(t));
134    for (org.hl7.fhir.r5.model.Annotation t : src.getNote()) tgt.addNote(Annotation40_50.convertAnnotation(t));
135    return tgt;
136  }
137
138  static public org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Enumerations.RequestStatus> convertCarePlanStatus(org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.CarePlan.CarePlanStatus> src) throws FHIRException {
139    if (src == null || src.isEmpty())
140      return null;
141    org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Enumerations.RequestStatus> tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.Enumerations.RequestStatusEnumFactory());
142    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt);
143    switch (src.getValue()) {
144      case DRAFT:
145        tgt.setValue(org.hl7.fhir.r5.model.Enumerations.RequestStatus.DRAFT);
146        break;
147      case ACTIVE:
148        tgt.setValue(org.hl7.fhir.r5.model.Enumerations.RequestStatus.ACTIVE);
149        break;
150      case ONHOLD:
151        tgt.setValue(org.hl7.fhir.r5.model.Enumerations.RequestStatus.ONHOLD);
152        break;
153      case REVOKED:
154        tgt.setValue(org.hl7.fhir.r5.model.Enumerations.RequestStatus.REVOKED);
155        break;
156      case COMPLETED:
157        tgt.setValue(org.hl7.fhir.r5.model.Enumerations.RequestStatus.COMPLETED);
158        break;
159      case ENTEREDINERROR:
160        tgt.setValue(org.hl7.fhir.r5.model.Enumerations.RequestStatus.ENTEREDINERROR);
161        break;
162      case UNKNOWN:
163        tgt.setValue(org.hl7.fhir.r5.model.Enumerations.RequestStatus.UNKNOWN);
164        break;
165      default:
166        tgt.setValue(org.hl7.fhir.r5.model.Enumerations.RequestStatus.NULL);
167        break;
168    }
169    return tgt;
170  }
171
172  static public org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.CarePlan.CarePlanStatus> convertCarePlanStatus(org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Enumerations.RequestStatus> src) throws FHIRException {
173    if (src == null || src.isEmpty())
174      return null;
175    org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.CarePlan.CarePlanStatus> tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.CarePlan.CarePlanStatusEnumFactory());
176    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt);
177    switch (src.getValue()) {
178      case DRAFT:
179        tgt.setValue(org.hl7.fhir.r4.model.CarePlan.CarePlanStatus.DRAFT);
180        break;
181      case ACTIVE:
182        tgt.setValue(org.hl7.fhir.r4.model.CarePlan.CarePlanStatus.ACTIVE);
183        break;
184      case ONHOLD:
185        tgt.setValue(org.hl7.fhir.r4.model.CarePlan.CarePlanStatus.ONHOLD);
186        break;
187      case REVOKED:
188        tgt.setValue(org.hl7.fhir.r4.model.CarePlan.CarePlanStatus.REVOKED);
189        break;
190      case COMPLETED:
191        tgt.setValue(org.hl7.fhir.r4.model.CarePlan.CarePlanStatus.COMPLETED);
192        break;
193      case ENTEREDINERROR:
194        tgt.setValue(org.hl7.fhir.r4.model.CarePlan.CarePlanStatus.ENTEREDINERROR);
195        break;
196      case UNKNOWN:
197        tgt.setValue(org.hl7.fhir.r4.model.CarePlan.CarePlanStatus.UNKNOWN);
198        break;
199      default:
200        tgt.setValue(org.hl7.fhir.r4.model.CarePlan.CarePlanStatus.NULL);
201        break;
202    }
203    return tgt;
204  }
205
206  static public org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.CarePlan.CarePlanIntent> convertCarePlanIntent(org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.CarePlan.CarePlanIntent> src) throws FHIRException {
207    if (src == null || src.isEmpty())
208      return null;
209    org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.CarePlan.CarePlanIntent> tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.CarePlan.CarePlanIntentEnumFactory());
210    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt);
211    switch (src.getValue()) {
212      case PROPOSAL:
213        tgt.setValue(org.hl7.fhir.r5.model.CarePlan.CarePlanIntent.PROPOSAL);
214        break;
215      case PLAN:
216        tgt.setValue(org.hl7.fhir.r5.model.CarePlan.CarePlanIntent.PLAN);
217        break;
218      case ORDER:
219        tgt.setValue(org.hl7.fhir.r5.model.CarePlan.CarePlanIntent.ORDER);
220        break;
221      case OPTION:
222        tgt.setValue(org.hl7.fhir.r5.model.CarePlan.CarePlanIntent.OPTION);
223        break;
224      default:
225        tgt.setValue(org.hl7.fhir.r5.model.CarePlan.CarePlanIntent.NULL);
226        break;
227    }
228    return tgt;
229  }
230
231  static public org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.CarePlan.CarePlanIntent> convertCarePlanIntent(org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.CarePlan.CarePlanIntent> src) throws FHIRException {
232    if (src == null || src.isEmpty())
233      return null;
234    org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.CarePlan.CarePlanIntent> tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.CarePlan.CarePlanIntentEnumFactory());
235    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt);
236    switch (src.getValue()) {
237      case PROPOSAL:
238        tgt.setValue(org.hl7.fhir.r4.model.CarePlan.CarePlanIntent.PROPOSAL);
239        break;
240      case PLAN:
241        tgt.setValue(org.hl7.fhir.r4.model.CarePlan.CarePlanIntent.PLAN);
242        break;
243      case ORDER:
244        tgt.setValue(org.hl7.fhir.r4.model.CarePlan.CarePlanIntent.ORDER);
245        break;
246      case OPTION:
247        tgt.setValue(org.hl7.fhir.r4.model.CarePlan.CarePlanIntent.OPTION);
248        break;
249      default:
250        tgt.setValue(org.hl7.fhir.r4.model.CarePlan.CarePlanIntent.NULL);
251        break;
252    }
253    return tgt;
254  }
255
256  public static org.hl7.fhir.r5.model.CarePlan.CarePlanActivityComponent convertCarePlanActivityComponent(org.hl7.fhir.r4.model.CarePlan.CarePlanActivityComponent src) throws FHIRException {
257    if (src == null)
258      return null;
259    org.hl7.fhir.r5.model.CarePlan.CarePlanActivityComponent tgt = new org.hl7.fhir.r5.model.CarePlan.CarePlanActivityComponent();
260    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt);
261    for (org.hl7.fhir.r4.model.CodeableConcept t : src.getOutcomeCodeableConcept())
262      tgt.addPerformedActivity(CodeableConcept40_50.convertCodeableConceptToCodeableReference(t));
263    for (org.hl7.fhir.r4.model.Reference t : src.getOutcomeReference())
264      tgt.addPerformedActivity(Reference40_50.convertReferenceToCodeableReference(t));
265    for (org.hl7.fhir.r4.model.Annotation t : src.getProgress()) tgt.addProgress(Annotation40_50.convertAnnotation(t));
266    if (src.hasReference())
267      tgt.setPlannedActivityReference(Reference40_50.convertReference(src.getReference()));
268    if (src.hasDetail())
269      tgt.setPlannedActivityDetail(convertCarePlanActivityDetailComponent(src.getDetail()));
270    return tgt;
271  }
272
273  public static org.hl7.fhir.r4.model.CarePlan.CarePlanActivityComponent convertCarePlanActivityComponent(org.hl7.fhir.r5.model.CarePlan.CarePlanActivityComponent src) throws FHIRException {
274    if (src == null)
275      return null;
276    org.hl7.fhir.r4.model.CarePlan.CarePlanActivityComponent tgt = new org.hl7.fhir.r4.model.CarePlan.CarePlanActivityComponent();
277    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt);
278    for (CodeableReference t : src.getPerformedActivity())
279      if (t.hasConcept())
280        tgt.addOutcomeCodeableConcept(CodeableConcept40_50.convertCodeableConcept(t.getConcept()));
281    for (CodeableReference t : src.getPerformedActivity())
282      if (t.hasReference())
283        tgt.addOutcomeReference(Reference40_50.convertReference(t.getReference()));
284    for (org.hl7.fhir.r5.model.Annotation t : src.getProgress()) tgt.addProgress(Annotation40_50.convertAnnotation(t));
285    if (src.hasPlannedActivityReference())
286      tgt.setReference(Reference40_50.convertReference(src.getPlannedActivityReference()));
287    if (src.hasPlannedActivityDetail())
288      tgt.setDetail(convertCarePlanActivityDetailComponent(src.getPlannedActivityDetail()));
289    return tgt;
290  }
291
292  public static org.hl7.fhir.r5.model.CarePlan.CarePlanActivityPlannedActivityDetailComponent convertCarePlanActivityDetailComponent(org.hl7.fhir.r4.model.CarePlan.CarePlanActivityDetailComponent src) throws FHIRException {
293    if (src == null)
294      return null;
295    org.hl7.fhir.r5.model.CarePlan.CarePlanActivityPlannedActivityDetailComponent tgt = new org.hl7.fhir.r5.model.CarePlan.CarePlanActivityPlannedActivityDetailComponent();
296    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt);
297    if (src.hasKind())
298      tgt.setKindElement(convertCarePlanActivityKind(src.getKindElement()));
299    for (org.hl7.fhir.r4.model.CanonicalType t : src.getInstantiatesCanonical())
300      tgt.getInstantiatesCanonical().add(Canonical40_50.convertCanonical(t));
301    for (org.hl7.fhir.r4.model.UriType t : src.getInstantiatesUri())
302      tgt.getInstantiatesUri().add(Uri40_50.convertUri(t));
303    if (src.hasCode())
304      tgt.setCode(CodeableConcept40_50.convertCodeableConcept(src.getCode()));
305    for (org.hl7.fhir.r4.model.CodeableConcept t : src.getReasonCode())
306      tgt.addReason(CodeableConcept40_50.convertCodeableConceptToCodeableReference(t));
307    for (org.hl7.fhir.r4.model.Reference t : src.getReasonReference())
308      tgt.addReason(Reference40_50.convertReferenceToCodeableReference(t));
309    for (org.hl7.fhir.r4.model.Reference t : src.getGoal()) tgt.addGoal(Reference40_50.convertReference(t));
310    if (src.hasStatus())
311      tgt.setStatusElement(convertCarePlanActivityStatus(src.getStatusElement()));
312    if (src.hasStatusReason())
313      tgt.setStatusReason(CodeableConcept40_50.convertCodeableConcept(src.getStatusReason()));
314    if (src.hasDoNotPerform())
315      tgt.setDoNotPerformElement(Boolean40_50.convertBoolean(src.getDoNotPerformElement()));
316    if (src.hasScheduled())
317      tgt.setScheduled(ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().convertType(src.getScheduled()));
318    if (src.hasLocation())
319      tgt.getLocation().setReference(Reference40_50.convertReference(src.getLocation()));
320    for (org.hl7.fhir.r4.model.Reference t : src.getPerformer()) tgt.addPerformer(Reference40_50.convertReference(t));
321    if (src.hasProduct())
322      tgt.setProduct(ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().convertType(src.getProduct()));
323    if (src.hasDailyAmount())
324      tgt.setDailyAmount(SimpleQuantity40_50.convertSimpleQuantity(src.getDailyAmount()));
325    if (src.hasQuantity())
326      tgt.setQuantity(SimpleQuantity40_50.convertSimpleQuantity(src.getQuantity()));
327    if (src.hasDescription())
328      tgt.setDescriptionElement(String40_50.convertString(src.getDescriptionElement()));
329    return tgt;
330  }
331
332  public static org.hl7.fhir.r4.model.CarePlan.CarePlanActivityDetailComponent convertCarePlanActivityDetailComponent(org.hl7.fhir.r5.model.CarePlan.CarePlanActivityPlannedActivityDetailComponent src) throws FHIRException {
333    if (src == null)
334      return null;
335    org.hl7.fhir.r4.model.CarePlan.CarePlanActivityDetailComponent tgt = new org.hl7.fhir.r4.model.CarePlan.CarePlanActivityDetailComponent();
336    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt);
337    if (src.hasKind())
338      tgt.setKindElement(convertCarePlanActivityKind(src.getKindElement()));
339    for (org.hl7.fhir.r5.model.CanonicalType t : src.getInstantiatesCanonical())
340      tgt.getInstantiatesCanonical().add(Canonical40_50.convertCanonical(t));
341    for (org.hl7.fhir.r5.model.UriType t : src.getInstantiatesUri())
342      tgt.getInstantiatesUri().add(Uri40_50.convertUri(t));
343    if (src.hasCode())
344      tgt.setCode(CodeableConcept40_50.convertCodeableConcept(src.getCode()));
345    for (CodeableReference t : src.getReason())
346      if (t.hasConcept())
347        tgt.addReasonCode(CodeableConcept40_50.convertCodeableConcept(t.getConcept()));
348    for (CodeableReference t : src.getReason())
349      if (t.hasReference())
350        tgt.addReasonReference(Reference40_50.convertReference(t.getReference()));
351    for (org.hl7.fhir.r5.model.Reference t : src.getGoal()) tgt.addGoal(Reference40_50.convertReference(t));
352    if (src.hasStatus())
353      tgt.setStatusElement(convertCarePlanActivityStatus(src.getStatusElement()));
354    if (src.hasStatusReason())
355      tgt.setStatusReason(CodeableConcept40_50.convertCodeableConcept(src.getStatusReason()));
356    if (src.hasDoNotPerform())
357      tgt.setDoNotPerformElement(Boolean40_50.convertBoolean(src.getDoNotPerformElement()));
358    if (src.hasScheduled())
359      tgt.setScheduled(ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().convertType(src.getScheduled()));
360    if (src.getLocation().hasReference())
361      tgt.setLocation(Reference40_50.convertReference(src.getLocation().getReference()));
362    for (org.hl7.fhir.r5.model.Reference t : src.getPerformer()) tgt.addPerformer(Reference40_50.convertReference(t));
363    if (src.hasProduct())
364      tgt.setProduct(ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().convertType(src.getProduct()));
365    if (src.hasDailyAmount())
366      tgt.setDailyAmount(SimpleQuantity40_50.convertSimpleQuantity(src.getDailyAmount()));
367    if (src.hasQuantity())
368      tgt.setQuantity(SimpleQuantity40_50.convertSimpleQuantity(src.getQuantity()));
369    if (src.hasDescription())
370      tgt.setDescriptionElement(String40_50.convertString(src.getDescriptionElement()));
371    return tgt;
372  }
373
374  static public org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.CarePlan.CarePlanActivityKind> convertCarePlanActivityKind(org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.CarePlan.CarePlanActivityKind> src) throws FHIRException {
375    if (src == null || src.isEmpty())
376      return null;
377    org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.CarePlan.CarePlanActivityKind> tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.CarePlan.CarePlanActivityKindEnumFactory());
378    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt);
379    switch (src.getValue()) {
380      case APPOINTMENT:
381        tgt.setValue(org.hl7.fhir.r5.model.CarePlan.CarePlanActivityKind.APPOINTMENT);
382        break;
383      case COMMUNICATIONREQUEST:
384        tgt.setValue(org.hl7.fhir.r5.model.CarePlan.CarePlanActivityKind.COMMUNICATIONREQUEST);
385        break;
386      case DEVICEREQUEST:
387        tgt.setValue(org.hl7.fhir.r5.model.CarePlan.CarePlanActivityKind.DEVICEREQUEST);
388        break;
389      case MEDICATIONREQUEST:
390        tgt.setValue(org.hl7.fhir.r5.model.CarePlan.CarePlanActivityKind.MEDICATIONREQUEST);
391        break;
392      case NUTRITIONORDER:
393        tgt.setValue(org.hl7.fhir.r5.model.CarePlan.CarePlanActivityKind.NUTRITIONORDER);
394        break;
395      case TASK:
396        tgt.setValue(org.hl7.fhir.r5.model.CarePlan.CarePlanActivityKind.TASK);
397        break;
398      case SERVICEREQUEST:
399        tgt.setValue(org.hl7.fhir.r5.model.CarePlan.CarePlanActivityKind.SERVICEREQUEST);
400        break;
401      case VISIONPRESCRIPTION:
402        tgt.setValue(org.hl7.fhir.r5.model.CarePlan.CarePlanActivityKind.VISIONPRESCRIPTION);
403        break;
404      default:
405        tgt.setValue(org.hl7.fhir.r5.model.CarePlan.CarePlanActivityKind.NULL);
406        break;
407    }
408    return tgt;
409  }
410
411  static public org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.CarePlan.CarePlanActivityKind> convertCarePlanActivityKind(org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.CarePlan.CarePlanActivityKind> src) throws FHIRException {
412    if (src == null || src.isEmpty())
413      return null;
414    org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.CarePlan.CarePlanActivityKind> tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.CarePlan.CarePlanActivityKindEnumFactory());
415    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt);
416    switch (src.getValue()) {
417      case APPOINTMENT:
418        tgt.setValue(org.hl7.fhir.r4.model.CarePlan.CarePlanActivityKind.APPOINTMENT);
419        break;
420      case COMMUNICATIONREQUEST:
421        tgt.setValue(org.hl7.fhir.r4.model.CarePlan.CarePlanActivityKind.COMMUNICATIONREQUEST);
422        break;
423      case DEVICEREQUEST:
424        tgt.setValue(org.hl7.fhir.r4.model.CarePlan.CarePlanActivityKind.DEVICEREQUEST);
425        break;
426      case MEDICATIONREQUEST:
427        tgt.setValue(org.hl7.fhir.r4.model.CarePlan.CarePlanActivityKind.MEDICATIONREQUEST);
428        break;
429      case NUTRITIONORDER:
430        tgt.setValue(org.hl7.fhir.r4.model.CarePlan.CarePlanActivityKind.NUTRITIONORDER);
431        break;
432      case TASK:
433        tgt.setValue(org.hl7.fhir.r4.model.CarePlan.CarePlanActivityKind.TASK);
434        break;
435      case SERVICEREQUEST:
436        tgt.setValue(org.hl7.fhir.r4.model.CarePlan.CarePlanActivityKind.SERVICEREQUEST);
437        break;
438      case VISIONPRESCRIPTION:
439        tgt.setValue(org.hl7.fhir.r4.model.CarePlan.CarePlanActivityKind.VISIONPRESCRIPTION);
440        break;
441      default:
442        tgt.setValue(org.hl7.fhir.r4.model.CarePlan.CarePlanActivityKind.NULL);
443        break;
444    }
445    return tgt;
446  }
447
448  static public org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.CarePlan.CarePlanActivityStatus> convertCarePlanActivityStatus(org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.CarePlan.CarePlanActivityStatus> src) throws FHIRException {
449    if (src == null || src.isEmpty())
450      return null;
451    org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.CarePlan.CarePlanActivityStatus> tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.CarePlan.CarePlanActivityStatusEnumFactory());
452    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt);
453    switch (src.getValue()) {
454      case NOTSTARTED:
455        tgt.setValue(org.hl7.fhir.r5.model.CarePlan.CarePlanActivityStatus.NOTSTARTED);
456        break;
457      case SCHEDULED:
458        tgt.setValue(org.hl7.fhir.r5.model.CarePlan.CarePlanActivityStatus.SCHEDULED);
459        break;
460      case INPROGRESS:
461        tgt.setValue(org.hl7.fhir.r5.model.CarePlan.CarePlanActivityStatus.INPROGRESS);
462        break;
463      case ONHOLD:
464        tgt.setValue(org.hl7.fhir.r5.model.CarePlan.CarePlanActivityStatus.ONHOLD);
465        break;
466      case COMPLETED:
467        tgt.setValue(org.hl7.fhir.r5.model.CarePlan.CarePlanActivityStatus.COMPLETED);
468        break;
469      case CANCELLED:
470        tgt.setValue(org.hl7.fhir.r5.model.CarePlan.CarePlanActivityStatus.CANCELLED);
471        break;
472      case STOPPED:
473        tgt.setValue(org.hl7.fhir.r5.model.CarePlan.CarePlanActivityStatus.STOPPED);
474        break;
475      case UNKNOWN:
476        tgt.setValue(org.hl7.fhir.r5.model.CarePlan.CarePlanActivityStatus.UNKNOWN);
477        break;
478      case ENTEREDINERROR:
479        tgt.setValue(org.hl7.fhir.r5.model.CarePlan.CarePlanActivityStatus.ENTEREDINERROR);
480        break;
481      default:
482        tgt.setValue(org.hl7.fhir.r5.model.CarePlan.CarePlanActivityStatus.NULL);
483        break;
484    }
485    return tgt;
486  }
487
488  static public org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.CarePlan.CarePlanActivityStatus> convertCarePlanActivityStatus(org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.CarePlan.CarePlanActivityStatus> src) throws FHIRException {
489    if (src == null || src.isEmpty())
490      return null;
491    org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.CarePlan.CarePlanActivityStatus> tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.CarePlan.CarePlanActivityStatusEnumFactory());
492    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt);
493    switch (src.getValue()) {
494      case NOTSTARTED:
495        tgt.setValue(org.hl7.fhir.r4.model.CarePlan.CarePlanActivityStatus.NOTSTARTED);
496        break;
497      case SCHEDULED:
498        tgt.setValue(org.hl7.fhir.r4.model.CarePlan.CarePlanActivityStatus.SCHEDULED);
499        break;
500      case INPROGRESS:
501        tgt.setValue(org.hl7.fhir.r4.model.CarePlan.CarePlanActivityStatus.INPROGRESS);
502        break;
503      case ONHOLD:
504        tgt.setValue(org.hl7.fhir.r4.model.CarePlan.CarePlanActivityStatus.ONHOLD);
505        break;
506      case COMPLETED:
507        tgt.setValue(org.hl7.fhir.r4.model.CarePlan.CarePlanActivityStatus.COMPLETED);
508        break;
509      case CANCELLED:
510        tgt.setValue(org.hl7.fhir.r4.model.CarePlan.CarePlanActivityStatus.CANCELLED);
511        break;
512      case STOPPED:
513        tgt.setValue(org.hl7.fhir.r4.model.CarePlan.CarePlanActivityStatus.STOPPED);
514        break;
515      case UNKNOWN:
516        tgt.setValue(org.hl7.fhir.r4.model.CarePlan.CarePlanActivityStatus.UNKNOWN);
517        break;
518      case ENTEREDINERROR:
519        tgt.setValue(org.hl7.fhir.r4.model.CarePlan.CarePlanActivityStatus.ENTEREDINERROR);
520        break;
521      default:
522        tgt.setValue(org.hl7.fhir.r4.model.CarePlan.CarePlanActivityStatus.NULL);
523        break;
524    }
525    return tgt;
526  }
527}