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.Boolean40_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.Uri40_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 Consent40_50 {
041
042  public static org.hl7.fhir.r5.model.Consent convertConsent(org.hl7.fhir.r4.model.Consent src) throws FHIRException {
043    if (src == null)
044      return null;
045    org.hl7.fhir.r5.model.Consent tgt = new org.hl7.fhir.r5.model.Consent();
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(convertConsentState(src.getStatusElement()));
051//    if (src.hasScope())
052//      tgt.setScope(CodeableConcept40_50.convertCodeableConcept(src.getScope()));
053    for (org.hl7.fhir.r4.model.CodeableConcept t : src.getCategory())
054      tgt.addCategory(CodeableConcept40_50.convertCodeableConcept(t));
055    if (src.hasPatient())
056      tgt.setSubject(Reference40_50.convertReference(src.getPatient()));
057    if (src.hasDateTime())
058      tgt.setDateTimeElement(DateTime40_50.convertDateTime(src.getDateTimeElement()));
059    for (org.hl7.fhir.r4.model.Reference t : src.getPerformer()) tgt.addGrantee(Reference40_50.convertReference(t));
060    for (org.hl7.fhir.r4.model.Reference t : src.getOrganization()) tgt.addManager(Reference40_50.convertReference(t));
061    if (src.hasSourceAttachment())
062      tgt.addSourceAttachment(Attachment40_50.convertAttachment(src.getSourceAttachment()));
063    if (src.hasSourceReference())
064      tgt.addSourceReference(Reference40_50.convertReference(src.getSourceReference()));
065    for (org.hl7.fhir.r4.model.Consent.ConsentPolicyComponent t : src.getPolicy())
066      tgt.addPolicy(convertConsentPolicyComponent(t));
067    if (src.hasPolicyRule())
068      tgt.setPolicyRule(CodeableConcept40_50.convertCodeableConcept(src.getPolicyRule()));
069    for (org.hl7.fhir.r4.model.Consent.ConsentVerificationComponent t : src.getVerification())
070      tgt.addVerification(convertConsentVerificationComponent(t));
071    if (src.hasProvision())
072      tgt.setProvision(convertprovisionComponent(src.getProvision()));
073    return tgt;
074  }
075
076  public static org.hl7.fhir.r4.model.Consent convertConsent(org.hl7.fhir.r5.model.Consent src) throws FHIRException {
077    if (src == null)
078      return null;
079    org.hl7.fhir.r4.model.Consent tgt = new org.hl7.fhir.r4.model.Consent();
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(convertConsentState(src.getStatusElement()));
085//    if (src.hasScope())
086//      tgt.setScope(CodeableConcept40_50.convertCodeableConcept(src.getScope()));
087    for (org.hl7.fhir.r5.model.CodeableConcept t : src.getCategory())
088      tgt.addCategory(CodeableConcept40_50.convertCodeableConcept(t));
089    if (src.hasSubject())
090      tgt.setPatient(Reference40_50.convertReference(src.getSubject()));
091    if (src.hasDateTime())
092      tgt.setDateTimeElement(DateTime40_50.convertDateTime(src.getDateTimeElement()));
093    for (org.hl7.fhir.r5.model.Reference t : src.getGrantee()) tgt.addPerformer(Reference40_50.convertReference(t));
094    for (org.hl7.fhir.r5.model.Reference t : src.getManager()) tgt.addOrganization(Reference40_50.convertReference(t));
095    for (org.hl7.fhir.r5.model.Reference t : src.getController())
096      tgt.addOrganization(Reference40_50.convertReference(t));
097    if (src.hasSourceAttachment())
098      tgt.setSource(ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().convertType(src.getSourceAttachmentFirstRep()));
099    if (src.hasSourceReference())
100      tgt.setSource(ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().convertType(src.getSourceReferenceFirstRep()));
101    for (org.hl7.fhir.r5.model.Consent.ConsentPolicyComponent t : src.getPolicy())
102      tgt.addPolicy(convertConsentPolicyComponent(t));
103    if (src.hasPolicyRule())
104      tgt.setPolicyRule(CodeableConcept40_50.convertCodeableConcept(src.getPolicyRule()));
105    for (org.hl7.fhir.r5.model.Consent.ConsentVerificationComponent t : src.getVerification())
106      tgt.addVerification(convertConsentVerificationComponent(t));
107    if (src.hasProvision())
108      tgt.setProvision(convertprovisionComponent(src.getProvision()));
109    return tgt;
110  }
111
112  static public org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Consent.ConsentState> convertConsentState(org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.Consent.ConsentState> src) throws FHIRException {
113    if (src == null || src.isEmpty())
114      return null;
115    org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Consent.ConsentState> tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.Consent.ConsentStateEnumFactory());
116    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt);
117    switch (src.getValue()) {
118      case DRAFT:
119        tgt.setValue(org.hl7.fhir.r5.model.Consent.ConsentState.DRAFT);
120        break;
121      case PROPOSED:
122        tgt.setValue(org.hl7.fhir.r5.model.Consent.ConsentState.DRAFT);
123        break;
124      case ACTIVE:
125        tgt.setValue(org.hl7.fhir.r5.model.Consent.ConsentState.ACTIVE);
126        break;
127      case REJECTED:
128        tgt.setValue(org.hl7.fhir.r5.model.Consent.ConsentState.INACTIVE);
129        break;
130      case INACTIVE:
131        tgt.setValue(org.hl7.fhir.r5.model.Consent.ConsentState.INACTIVE);
132        break;
133      case ENTEREDINERROR:
134        tgt.setValue(org.hl7.fhir.r5.model.Consent.ConsentState.ENTEREDINERROR);
135        break;
136      default:
137        tgt.setValue(org.hl7.fhir.r5.model.Consent.ConsentState.NULL);
138        break;
139    }
140    return tgt;
141  }
142
143  static public org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.Consent.ConsentState> convertConsentState(org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Consent.ConsentState> src) throws FHIRException {
144    if (src == null || src.isEmpty())
145      return null;
146    org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.Consent.ConsentState> tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.Consent.ConsentStateEnumFactory());
147    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt);
148    switch (src.getValue()) {
149      case DRAFT:
150        tgt.setValue(org.hl7.fhir.r4.model.Consent.ConsentState.DRAFT);
151        break;
152      case ACTIVE:
153        tgt.setValue(org.hl7.fhir.r4.model.Consent.ConsentState.ACTIVE);
154        break;
155      case INACTIVE:
156        tgt.setValue(org.hl7.fhir.r4.model.Consent.ConsentState.INACTIVE);
157        break;
158      case ENTEREDINERROR:
159        tgt.setValue(org.hl7.fhir.r4.model.Consent.ConsentState.ENTEREDINERROR);
160        break;
161      default:
162        tgt.setValue(org.hl7.fhir.r4.model.Consent.ConsentState.NULL);
163        break;
164    }
165    return tgt;
166  }
167
168  public static org.hl7.fhir.r5.model.Consent.ConsentPolicyComponent convertConsentPolicyComponent(org.hl7.fhir.r4.model.Consent.ConsentPolicyComponent src) throws FHIRException {
169    if (src == null)
170      return null;
171    org.hl7.fhir.r5.model.Consent.ConsentPolicyComponent tgt = new org.hl7.fhir.r5.model.Consent.ConsentPolicyComponent();
172    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt);
173    if (src.hasAuthority())
174      tgt.setAuthorityElement(Uri40_50.convertUri(src.getAuthorityElement()));
175    if (src.hasUri())
176      tgt.setUriElement(Uri40_50.convertUri(src.getUriElement()));
177    return tgt;
178  }
179
180  public static org.hl7.fhir.r4.model.Consent.ConsentPolicyComponent convertConsentPolicyComponent(org.hl7.fhir.r5.model.Consent.ConsentPolicyComponent src) throws FHIRException {
181    if (src == null)
182      return null;
183    org.hl7.fhir.r4.model.Consent.ConsentPolicyComponent tgt = new org.hl7.fhir.r4.model.Consent.ConsentPolicyComponent();
184    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt);
185    if (src.hasAuthority())
186      tgt.setAuthorityElement(Uri40_50.convertUri(src.getAuthorityElement()));
187    if (src.hasUri())
188      tgt.setUriElement(Uri40_50.convertUri(src.getUriElement()));
189    return tgt;
190  }
191
192  public static org.hl7.fhir.r5.model.Consent.ConsentVerificationComponent convertConsentVerificationComponent(org.hl7.fhir.r4.model.Consent.ConsentVerificationComponent src) throws FHIRException {
193    if (src == null)
194      return null;
195    org.hl7.fhir.r5.model.Consent.ConsentVerificationComponent tgt = new org.hl7.fhir.r5.model.Consent.ConsentVerificationComponent();
196    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt);
197    if (src.hasVerified())
198      tgt.setVerifiedElement(Boolean40_50.convertBoolean(src.getVerifiedElement()));
199    if (src.hasVerifiedWith())
200      tgt.setVerifiedWith(Reference40_50.convertReference(src.getVerifiedWith()));
201    if (src.hasVerificationDate())
202      tgt.getVerificationDate().add(DateTime40_50.convertDateTime(src.getVerificationDateElement()));
203    return tgt;
204  }
205
206  public static org.hl7.fhir.r4.model.Consent.ConsentVerificationComponent convertConsentVerificationComponent(org.hl7.fhir.r5.model.Consent.ConsentVerificationComponent src) throws FHIRException {
207    if (src == null)
208      return null;
209    org.hl7.fhir.r4.model.Consent.ConsentVerificationComponent tgt = new org.hl7.fhir.r4.model.Consent.ConsentVerificationComponent();
210    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt);
211    if (src.hasVerified())
212      tgt.setVerifiedElement(Boolean40_50.convertBoolean(src.getVerifiedElement()));
213    if (src.hasVerifiedWith())
214      tgt.setVerifiedWith(Reference40_50.convertReference(src.getVerifiedWith()));
215    if (src.hasVerificationDate())
216      tgt.setVerificationDateElement(DateTime40_50.convertDateTime(src.getVerificationDate().get(0)));
217    return tgt;
218  }
219
220  public static org.hl7.fhir.r5.model.Consent.ProvisionComponent convertprovisionComponent(org.hl7.fhir.r4.model.Consent.provisionComponent src) throws FHIRException {
221    if (src == null)
222      return null;
223    org.hl7.fhir.r5.model.Consent.ProvisionComponent tgt = new org.hl7.fhir.r5.model.Consent.ProvisionComponent();
224    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt);
225    if (src.hasType())
226      tgt.setTypeElement(convertConsentProvisionType(src.getTypeElement()));
227    if (src.hasPeriod())
228      tgt.setPeriod(Period40_50.convertPeriod(src.getPeriod()));
229    for (org.hl7.fhir.r4.model.Consent.provisionActorComponent t : src.getActor())
230      tgt.addActor(convertprovisionActorComponent(t));
231    for (org.hl7.fhir.r4.model.CodeableConcept t : src.getAction())
232      tgt.addAction(CodeableConcept40_50.convertCodeableConcept(t));
233    for (org.hl7.fhir.r4.model.Coding t : src.getSecurityLabel()) tgt.addSecurityLabel(Coding40_50.convertCoding(t));
234    for (org.hl7.fhir.r4.model.Coding t : src.getPurpose()) tgt.addPurpose(Coding40_50.convertCoding(t));
235    for (org.hl7.fhir.r4.model.Coding t : src.getClass_()) tgt.addClass_(Coding40_50.convertCoding(t));
236    for (org.hl7.fhir.r4.model.CodeableConcept t : src.getCode())
237      tgt.addCode(CodeableConcept40_50.convertCodeableConcept(t));
238    if (src.hasDataPeriod())
239      tgt.setDataPeriod(Period40_50.convertPeriod(src.getDataPeriod()));
240    for (org.hl7.fhir.r4.model.Consent.provisionDataComponent t : src.getData())
241      tgt.addData(convertprovisionDataComponent(t));
242    for (org.hl7.fhir.r4.model.Consent.provisionComponent t : src.getProvision())
243      tgt.addProvision(convertprovisionComponent(t));
244    return tgt;
245  }
246
247  public static org.hl7.fhir.r4.model.Consent.provisionComponent convertprovisionComponent(org.hl7.fhir.r5.model.Consent.ProvisionComponent src) throws FHIRException {
248    if (src == null)
249      return null;
250    org.hl7.fhir.r4.model.Consent.provisionComponent tgt = new org.hl7.fhir.r4.model.Consent.provisionComponent();
251    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt);
252    if (src.hasType())
253      tgt.setTypeElement(convertConsentProvisionType(src.getTypeElement()));
254    if (src.hasPeriod())
255      tgt.setPeriod(Period40_50.convertPeriod(src.getPeriod()));
256    for (org.hl7.fhir.r5.model.Consent.ProvisionActorComponent t : src.getActor())
257      tgt.addActor(convertprovisionActorComponent(t));
258    for (org.hl7.fhir.r5.model.CodeableConcept t : src.getAction())
259      tgt.addAction(CodeableConcept40_50.convertCodeableConcept(t));
260    for (org.hl7.fhir.r5.model.Coding t : src.getSecurityLabel()) tgt.addSecurityLabel(Coding40_50.convertCoding(t));
261    for (org.hl7.fhir.r5.model.Coding t : src.getPurpose()) tgt.addPurpose(Coding40_50.convertCoding(t));
262    for (org.hl7.fhir.r5.model.Coding t : src.getClass_()) tgt.addClass_(Coding40_50.convertCoding(t));
263    for (org.hl7.fhir.r5.model.CodeableConcept t : src.getCode())
264      tgt.addCode(CodeableConcept40_50.convertCodeableConcept(t));
265    if (src.hasDataPeriod())
266      tgt.setDataPeriod(Period40_50.convertPeriod(src.getDataPeriod()));
267    for (org.hl7.fhir.r5.model.Consent.ProvisionDataComponent t : src.getData())
268      tgt.addData(convertprovisionDataComponent(t));
269    for (org.hl7.fhir.r5.model.Consent.ProvisionComponent t : src.getProvision())
270      tgt.addProvision(convertprovisionComponent(t));
271    return tgt;
272  }
273
274  static public org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Consent.ConsentProvisionType> convertConsentProvisionType(org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.Consent.ConsentProvisionType> src) throws FHIRException {
275    if (src == null || src.isEmpty())
276      return null;
277    org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Consent.ConsentProvisionType> tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.Consent.ConsentProvisionTypeEnumFactory());
278    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt);
279    switch (src.getValue()) {
280      case DENY:
281        tgt.setValue(org.hl7.fhir.r5.model.Consent.ConsentProvisionType.DENY);
282        break;
283      case PERMIT:
284        tgt.setValue(org.hl7.fhir.r5.model.Consent.ConsentProvisionType.PERMIT);
285        break;
286      default:
287        tgt.setValue(org.hl7.fhir.r5.model.Consent.ConsentProvisionType.NULL);
288        break;
289    }
290    return tgt;
291  }
292
293  static public org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.Consent.ConsentProvisionType> convertConsentProvisionType(org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Consent.ConsentProvisionType> src) throws FHIRException {
294    if (src == null || src.isEmpty())
295      return null;
296    org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.Consent.ConsentProvisionType> tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.Consent.ConsentProvisionTypeEnumFactory());
297    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt);
298    switch (src.getValue()) {
299      case DENY:
300        tgt.setValue(org.hl7.fhir.r4.model.Consent.ConsentProvisionType.DENY);
301        break;
302      case PERMIT:
303        tgt.setValue(org.hl7.fhir.r4.model.Consent.ConsentProvisionType.PERMIT);
304        break;
305      default:
306        tgt.setValue(org.hl7.fhir.r4.model.Consent.ConsentProvisionType.NULL);
307        break;
308    }
309    return tgt;
310  }
311
312  public static org.hl7.fhir.r5.model.Consent.ProvisionActorComponent convertprovisionActorComponent(org.hl7.fhir.r4.model.Consent.provisionActorComponent src) throws FHIRException {
313    if (src == null)
314      return null;
315    org.hl7.fhir.r5.model.Consent.ProvisionActorComponent tgt = new org.hl7.fhir.r5.model.Consent.ProvisionActorComponent();
316    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt);
317    if (src.hasRole())
318      tgt.setRole(CodeableConcept40_50.convertCodeableConcept(src.getRole()));
319    if (src.hasReference())
320      tgt.setReference(Reference40_50.convertReference(src.getReference()));
321    return tgt;
322  }
323
324  public static org.hl7.fhir.r4.model.Consent.provisionActorComponent convertprovisionActorComponent(org.hl7.fhir.r5.model.Consent.ProvisionActorComponent src) throws FHIRException {
325    if (src == null)
326      return null;
327    org.hl7.fhir.r4.model.Consent.provisionActorComponent tgt = new org.hl7.fhir.r4.model.Consent.provisionActorComponent();
328    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt);
329    if (src.hasRole())
330      tgt.setRole(CodeableConcept40_50.convertCodeableConcept(src.getRole()));
331    if (src.hasReference())
332      tgt.setReference(Reference40_50.convertReference(src.getReference()));
333    return tgt;
334  }
335
336  public static org.hl7.fhir.r5.model.Consent.ProvisionDataComponent convertprovisionDataComponent(org.hl7.fhir.r4.model.Consent.provisionDataComponent src) throws FHIRException {
337    if (src == null)
338      return null;
339    org.hl7.fhir.r5.model.Consent.ProvisionDataComponent tgt = new org.hl7.fhir.r5.model.Consent.ProvisionDataComponent();
340    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt);
341    if (src.hasMeaning())
342      tgt.setMeaningElement(convertConsentDataMeaning(src.getMeaningElement()));
343    if (src.hasReference())
344      tgt.setReference(Reference40_50.convertReference(src.getReference()));
345    return tgt;
346  }
347
348  public static org.hl7.fhir.r4.model.Consent.provisionDataComponent convertprovisionDataComponent(org.hl7.fhir.r5.model.Consent.ProvisionDataComponent src) throws FHIRException {
349    if (src == null)
350      return null;
351    org.hl7.fhir.r4.model.Consent.provisionDataComponent tgt = new org.hl7.fhir.r4.model.Consent.provisionDataComponent();
352    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt);
353    if (src.hasMeaning())
354      tgt.setMeaningElement(convertConsentDataMeaning(src.getMeaningElement()));
355    if (src.hasReference())
356      tgt.setReference(Reference40_50.convertReference(src.getReference()));
357    return tgt;
358  }
359
360  static public org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Consent.ConsentDataMeaning> convertConsentDataMeaning(org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.Consent.ConsentDataMeaning> src) throws FHIRException {
361    if (src == null || src.isEmpty())
362      return null;
363    org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Consent.ConsentDataMeaning> tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.Consent.ConsentDataMeaningEnumFactory());
364    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt);
365    switch (src.getValue()) {
366      case INSTANCE:
367        tgt.setValue(org.hl7.fhir.r5.model.Consent.ConsentDataMeaning.INSTANCE);
368        break;
369      case RELATED:
370        tgt.setValue(org.hl7.fhir.r5.model.Consent.ConsentDataMeaning.RELATED);
371        break;
372      case DEPENDENTS:
373        tgt.setValue(org.hl7.fhir.r5.model.Consent.ConsentDataMeaning.DEPENDENTS);
374        break;
375      case AUTHOREDBY:
376        tgt.setValue(org.hl7.fhir.r5.model.Consent.ConsentDataMeaning.AUTHOREDBY);
377        break;
378      default:
379        tgt.setValue(org.hl7.fhir.r5.model.Consent.ConsentDataMeaning.NULL);
380        break;
381    }
382    return tgt;
383  }
384
385  static public org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.Consent.ConsentDataMeaning> convertConsentDataMeaning(org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Consent.ConsentDataMeaning> src) throws FHIRException {
386    if (src == null || src.isEmpty())
387      return null;
388    org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.Consent.ConsentDataMeaning> tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.Consent.ConsentDataMeaningEnumFactory());
389    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt);
390    switch (src.getValue()) {
391      case INSTANCE:
392        tgt.setValue(org.hl7.fhir.r4.model.Consent.ConsentDataMeaning.INSTANCE);
393        break;
394      case RELATED:
395        tgt.setValue(org.hl7.fhir.r4.model.Consent.ConsentDataMeaning.RELATED);
396        break;
397      case DEPENDENTS:
398        tgt.setValue(org.hl7.fhir.r4.model.Consent.ConsentDataMeaning.DEPENDENTS);
399        break;
400      case AUTHOREDBY:
401        tgt.setValue(org.hl7.fhir.r4.model.Consent.ConsentDataMeaning.AUTHOREDBY);
402        break;
403      default:
404        tgt.setValue(org.hl7.fhir.r4.model.Consent.ConsentDataMeaning.NULL);
405        break;
406    }
407    return tgt;
408  }
409}