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