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;
008import org.hl7.fhir.r5.model.Enumeration;
009import org.hl7.fhir.r5.model.Enumerations;
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 EnrollmentRequest43_50 {
041
042  public static org.hl7.fhir.r5.model.EnrollmentRequest convertEnrollmentRequest(org.hl7.fhir.r4b.model.EnrollmentRequest src) throws FHIRException {
043    if (src == null)
044      return null;
045    org.hl7.fhir.r5.model.EnrollmentRequest tgt = new org.hl7.fhir.r5.model.EnrollmentRequest();
046    ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyDomainResource(src, tgt);
047    for (org.hl7.fhir.r4b.model.Identifier t : src.getIdentifier())
048      tgt.addIdentifier(Identifier43_50.convertIdentifier(t));
049    if (src.hasStatus())
050      tgt.setStatusElement(convertEnrollmentRequestStatus(src.getStatusElement()));
051    if (src.hasCreated())
052      tgt.setCreatedElement(DateTime43_50.convertDateTime(src.getCreatedElement()));
053    if (src.hasInsurer())
054      tgt.setInsurer(Reference43_50.convertReference(src.getInsurer()));
055    if (src.hasProvider())
056      tgt.setProvider(Reference43_50.convertReference(src.getProvider()));
057    if (src.hasCandidate())
058      tgt.setCandidate(Reference43_50.convertReference(src.getCandidate()));
059    if (src.hasCoverage())
060      tgt.setCoverage(Reference43_50.convertReference(src.getCoverage()));
061    return tgt;
062  }
063
064  public static org.hl7.fhir.r4b.model.EnrollmentRequest convertEnrollmentRequest(org.hl7.fhir.r5.model.EnrollmentRequest src) throws FHIRException {
065    if (src == null)
066      return null;
067    org.hl7.fhir.r4b.model.EnrollmentRequest tgt = new org.hl7.fhir.r4b.model.EnrollmentRequest();
068    ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyDomainResource(src, tgt);
069    for (org.hl7.fhir.r5.model.Identifier t : src.getIdentifier())
070      tgt.addIdentifier(Identifier43_50.convertIdentifier(t));
071    if (src.hasStatus())
072      tgt.setStatusElement(convertEnrollmentRequestStatus(src.getStatusElement()));
073    if (src.hasCreated())
074      tgt.setCreatedElement(DateTime43_50.convertDateTime(src.getCreatedElement()));
075    if (src.hasInsurer())
076      tgt.setInsurer(Reference43_50.convertReference(src.getInsurer()));
077    if (src.hasProvider())
078      tgt.setProvider(Reference43_50.convertReference(src.getProvider()));
079    if (src.hasCandidate())
080      tgt.setCandidate(Reference43_50.convertReference(src.getCandidate()));
081    if (src.hasCoverage())
082      tgt.setCoverage(Reference43_50.convertReference(src.getCoverage()));
083    return tgt;
084  }
085
086  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 {
087      if (src == null || src.isEmpty())
088          return null;
089      Enumeration<Enumerations.FinancialResourceStatusCodes> tgt = new Enumeration<>(new Enumerations.FinancialResourceStatusCodesEnumFactory());
090      ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyElement(src, tgt);
091      if (src.getValue() == null) {
092          tgt.setValue(null);
093      } else {
094          switch (src.getValue()) {
095              case ACTIVE:
096                  tgt.setValue(Enumerations.FinancialResourceStatusCodes.ACTIVE);
097                  break;
098              case CANCELLED:
099                  tgt.setValue(Enumerations.FinancialResourceStatusCodes.CANCELLED);
100                  break;
101              case DRAFT:
102                  tgt.setValue(Enumerations.FinancialResourceStatusCodes.DRAFT);
103                  break;
104              case ENTEREDINERROR:
105                  tgt.setValue(Enumerations.FinancialResourceStatusCodes.ENTEREDINERROR);
106                  break;
107              default:
108                  tgt.setValue(Enumerations.FinancialResourceStatusCodes.NULL);
109                  break;
110          }
111      }
112      return tgt;
113  }
114
115  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 {
116      if (src == null || src.isEmpty())
117          return null;
118      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());
119      ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyElement(src, tgt);
120      if (src.getValue() == null) {
121          tgt.setValue(null);
122      } else {
123          switch (src.getValue()) {
124              case ACTIVE:
125                  tgt.setValue(org.hl7.fhir.r4b.model.Enumerations.FinancialResourceStatusCodes.ACTIVE);
126                  break;
127              case CANCELLED:
128                  tgt.setValue(org.hl7.fhir.r4b.model.Enumerations.FinancialResourceStatusCodes.CANCELLED);
129                  break;
130              case DRAFT:
131                  tgt.setValue(org.hl7.fhir.r4b.model.Enumerations.FinancialResourceStatusCodes.DRAFT);
132                  break;
133              case ENTEREDINERROR:
134                  tgt.setValue(org.hl7.fhir.r4b.model.Enumerations.FinancialResourceStatusCodes.ENTEREDINERROR);
135                  break;
136              default:
137                  tgt.setValue(org.hl7.fhir.r4b.model.Enumerations.FinancialResourceStatusCodes.NULL);
138                  break;
139          }
140      }
141      return tgt;
142  }
143}