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.Identifier43_50;
005import org.hl7.fhir.convertors.conv43_50.datatypes43_50.primitive43_50.DateTime43_50;
006import org.hl7.fhir.convertors.conv43_50.datatypes43_50.special43_50.Reference43_50;
007import org.hl7.fhir.exceptions.FHIRException;
008
009/*
010  Copyright (c) 2011+, HL7, Inc.
011  All rights reserved.
012  
013  Redistribution and use in source and binary forms, with or without modification, 
014  are permitted provided that the following conditions are met:
015  
016   * Redistributions of source code must retain the above copyright notice, this 
017     list of conditions and the following disclaimer.
018   * Redistributions in binary form must reproduce the above copyright notice, 
019     this list of conditions and the following disclaimer in the documentation 
020     and/or other materials provided with the distribution.
021   * Neither the name of HL7 nor the names of its contributors may be used to 
022     endorse or promote products derived from this software without specific 
023     prior written permission.
024  
025  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 
026  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
027  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
028  IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 
029  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
030  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 
031  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
032  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
033  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
034  POSSIBILITY OF SUCH DAMAGE.
035  
036*/
037// Generated on Sun, Feb 24, 2019 11:37+1100 for FHIR v4.0.0
038public class EnrollmentRequest43_50 {
039
040  public static org.hl7.fhir.r5.model.EnrollmentRequest convertEnrollmentRequest(org.hl7.fhir.r4b.model.EnrollmentRequest src) throws FHIRException {
041    if (src == null)
042      return null;
043    org.hl7.fhir.r5.model.EnrollmentRequest tgt = new org.hl7.fhir.r5.model.EnrollmentRequest();
044    ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyDomainResource(src, tgt);
045    for (org.hl7.fhir.r4b.model.Identifier t : src.getIdentifier())
046      tgt.addIdentifier(Identifier43_50.convertIdentifier(t));
047    if (src.hasStatus())
048      tgt.setStatusElement(convertEnrollmentRequestStatus(src.getStatusElement()));
049    if (src.hasCreated())
050      tgt.setCreatedElement(DateTime43_50.convertDateTime(src.getCreatedElement()));
051    if (src.hasInsurer())
052      tgt.setInsurer(Reference43_50.convertReference(src.getInsurer()));
053    if (src.hasProvider())
054      tgt.setProvider(Reference43_50.convertReference(src.getProvider()));
055    if (src.hasCandidate())
056      tgt.setCandidate(Reference43_50.convertReference(src.getCandidate()));
057    if (src.hasCoverage())
058      tgt.setCoverage(Reference43_50.convertReference(src.getCoverage()));
059    return tgt;
060  }
061
062  public static org.hl7.fhir.r4b.model.EnrollmentRequest convertEnrollmentRequest(org.hl7.fhir.r5.model.EnrollmentRequest src) throws FHIRException {
063    if (src == null)
064      return null;
065    org.hl7.fhir.r4b.model.EnrollmentRequest tgt = new org.hl7.fhir.r4b.model.EnrollmentRequest();
066    ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyDomainResource(src, tgt);
067    for (org.hl7.fhir.r5.model.Identifier t : src.getIdentifier())
068      tgt.addIdentifier(Identifier43_50.convertIdentifier(t));
069    if (src.hasStatus())
070      tgt.setStatusElement(convertEnrollmentRequestStatus(src.getStatusElement()));
071    if (src.hasCreated())
072      tgt.setCreatedElement(DateTime43_50.convertDateTime(src.getCreatedElement()));
073    if (src.hasInsurer())
074      tgt.setInsurer(Reference43_50.convertReference(src.getInsurer()));
075    if (src.hasProvider())
076      tgt.setProvider(Reference43_50.convertReference(src.getProvider()));
077    if (src.hasCandidate())
078      tgt.setCandidate(Reference43_50.convertReference(src.getCandidate()));
079    if (src.hasCoverage())
080      tgt.setCoverage(Reference43_50.convertReference(src.getCoverage()));
081    return tgt;
082  }
083
084  static public org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Enumerations.FinancialResourceStatusCodes> convertEnrollmentRequestStatus(org.hl7.fhir.r4b.model.Enumeration<org.hl7.fhir.r4b.model.Enumerations.FinancialResourceStatusCodes> src) throws FHIRException {
085    if (src == null || src.isEmpty())
086      return null;
087    org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Enumerations.FinancialResourceStatusCodes> tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.Enumerations.FinancialResourceStatusCodesEnumFactory());
088    ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyElement(src, tgt);
089    switch (src.getValue()) {
090      case ACTIVE:
091        tgt.setValue(org.hl7.fhir.r5.model.Enumerations.FinancialResourceStatusCodes.ACTIVE);
092        break;
093      case CANCELLED:
094        tgt.setValue(org.hl7.fhir.r5.model.Enumerations.FinancialResourceStatusCodes.CANCELLED);
095        break;
096      case DRAFT:
097        tgt.setValue(org.hl7.fhir.r5.model.Enumerations.FinancialResourceStatusCodes.DRAFT);
098        break;
099      case ENTEREDINERROR:
100        tgt.setValue(org.hl7.fhir.r5.model.Enumerations.FinancialResourceStatusCodes.ENTEREDINERROR);
101        break;
102      default:
103        tgt.setValue(org.hl7.fhir.r5.model.Enumerations.FinancialResourceStatusCodes.NULL);
104        break;
105    }
106    return tgt;
107  }
108
109  static public org.hl7.fhir.r4b.model.Enumeration<org.hl7.fhir.r4b.model.Enumerations.FinancialResourceStatusCodes> convertEnrollmentRequestStatus(org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Enumerations.FinancialResourceStatusCodes> src) throws FHIRException {
110    if (src == null || src.isEmpty())
111      return null;
112    org.hl7.fhir.r4b.model.Enumeration<org.hl7.fhir.r4b.model.Enumerations.FinancialResourceStatusCodes> tgt = new org.hl7.fhir.r4b.model.Enumeration<>(new org.hl7.fhir.r4b.model.Enumerations.FinancialResourceStatusCodesEnumFactory());
113    ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyElement(src, tgt);
114    switch (src.getValue()) {
115      case ACTIVE:
116        tgt.setValue(org.hl7.fhir.r4b.model.Enumerations.FinancialResourceStatusCodes.ACTIVE);
117        break;
118      case CANCELLED:
119        tgt.setValue(org.hl7.fhir.r4b.model.Enumerations.FinancialResourceStatusCodes.CANCELLED);
120        break;
121      case DRAFT:
122        tgt.setValue(org.hl7.fhir.r4b.model.Enumerations.FinancialResourceStatusCodes.DRAFT);
123        break;
124      case ENTEREDINERROR:
125        tgt.setValue(org.hl7.fhir.r4b.model.Enumerations.FinancialResourceStatusCodes.ENTEREDINERROR);
126        break;
127      default:
128        tgt.setValue(org.hl7.fhir.r4b.model.Enumerations.FinancialResourceStatusCodes.NULL);
129        break;
130    }
131    return tgt;
132  }
133}