001package org.hl7.fhir.convertors.conv30_40.resources30_40; 002 003 004import org.hl7.fhir.convertors.context.ConversionContext30_40; 005import org.hl7.fhir.convertors.conv30_40.datatypes30_40.Reference30_40; 006import org.hl7.fhir.convertors.conv30_40.datatypes30_40.complextypes30_40.CodeableConcept30_40; 007import org.hl7.fhir.convertors.conv30_40.datatypes30_40.complextypes30_40.Identifier30_40; 008import org.hl7.fhir.convertors.conv30_40.datatypes30_40.complextypes30_40.Period30_40; 009import org.hl7.fhir.convertors.conv30_40.datatypes30_40.primitivetypes30_40.PositiveInt30_40; 010import org.hl7.fhir.convertors.conv30_40.datatypes30_40.primitivetypes30_40.String30_40; 011import org.hl7.fhir.exceptions.FHIRException; 012 013/* 014 Copyright (c) 2011+, HL7, Inc. 015 All rights reserved. 016 017 Redistribution and use in source and binary forms, with or without modification, 018 are permitted provided that the following conditions are met: 019 020 * Redistributions of source code must retain the above copyright notice, this 021 list of conditions and the following disclaimer. 022 * Redistributions in binary form must reproduce the above copyright notice, 023 this list of conditions and the following disclaimer in the documentation 024 and/or other materials provided with the distribution. 025 * Neither the name of HL7 nor the names of its contributors may be used to 026 endorse or promote products derived from this software without specific 027 prior written permission. 028 029 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 030 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 031 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 032 IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 033 INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 034 NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 035 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 036 WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 037 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 038 POSSIBILITY OF SUCH DAMAGE. 039 040*/ 041// Generated on Sun, Feb 24, 2019 11:37+1100 for FHIR v4.0.0 042public class Coverage30_40 { 043 044 public static org.hl7.fhir.dstu3.model.Coverage convertCoverage(org.hl7.fhir.r4.model.Coverage src) throws FHIRException { 045 if (src == null) 046 return null; 047 org.hl7.fhir.dstu3.model.Coverage tgt = new org.hl7.fhir.dstu3.model.Coverage(); 048 ConversionContext30_40.INSTANCE.getVersionConvertor_30_40().copyDomainResource(src, tgt); 049 for (org.hl7.fhir.r4.model.Identifier t : src.getIdentifier()) 050 tgt.addIdentifier(Identifier30_40.convertIdentifier(t)); 051 if (src.hasStatus()) 052 tgt.setStatusElement(convertCoverageStatus(src.getStatusElement())); 053 if (src.hasType()) 054 tgt.setType(CodeableConcept30_40.convertCodeableConcept(src.getType())); 055 if (src.hasPolicyHolder()) 056 tgt.setPolicyHolder(Reference30_40.convertReference(src.getPolicyHolder())); 057 if (src.hasSubscriber()) 058 tgt.setSubscriber(Reference30_40.convertReference(src.getSubscriber())); 059 if (src.hasSubscriberId()) 060 tgt.setSubscriberIdElement(String30_40.convertString(src.getSubscriberIdElement())); 061 if (src.hasBeneficiary()) 062 tgt.setBeneficiary(Reference30_40.convertReference(src.getBeneficiary())); 063 if (src.hasDependent()) 064 tgt.setDependentElement(String30_40.convertString(src.getDependentElement())); 065 if (src.hasRelationship()) 066 tgt.setRelationship(CodeableConcept30_40.convertCodeableConcept(src.getRelationship())); 067 if (src.hasPeriod()) 068 tgt.setPeriod(Period30_40.convertPeriod(src.getPeriod())); 069 for (org.hl7.fhir.r4.model.Reference t : src.getPayor()) tgt.addPayor(Reference30_40.convertReference(t)); 070 if (src.hasOrder()) 071 tgt.setOrderElement(PositiveInt30_40.convertPositiveInt(src.getOrderElement())); 072 if (src.hasNetwork()) 073 tgt.setNetworkElement(String30_40.convertString(src.getNetworkElement())); 074 for (org.hl7.fhir.r4.model.Reference t : src.getContract()) tgt.addContract(Reference30_40.convertReference(t)); 075 return tgt; 076 } 077 078 public static org.hl7.fhir.r4.model.Coverage convertCoverage(org.hl7.fhir.dstu3.model.Coverage src) throws FHIRException { 079 if (src == null) 080 return null; 081 org.hl7.fhir.r4.model.Coverage tgt = new org.hl7.fhir.r4.model.Coverage(); 082 ConversionContext30_40.INSTANCE.getVersionConvertor_30_40().copyDomainResource(src, tgt); 083 for (org.hl7.fhir.dstu3.model.Identifier t : src.getIdentifier()) 084 tgt.addIdentifier(Identifier30_40.convertIdentifier(t)); 085 if (src.hasStatus()) 086 tgt.setStatusElement(convertCoverageStatus(src.getStatusElement())); 087 if (src.hasType()) 088 tgt.setType(CodeableConcept30_40.convertCodeableConcept(src.getType())); 089 if (src.hasPolicyHolder()) 090 tgt.setPolicyHolder(Reference30_40.convertReference(src.getPolicyHolder())); 091 if (src.hasSubscriber()) 092 tgt.setSubscriber(Reference30_40.convertReference(src.getSubscriber())); 093 if (src.hasSubscriberId()) 094 tgt.setSubscriberIdElement(String30_40.convertString(src.getSubscriberIdElement())); 095 if (src.hasBeneficiary()) 096 tgt.setBeneficiary(Reference30_40.convertReference(src.getBeneficiary())); 097 if (src.hasDependent()) 098 tgt.setDependentElement(String30_40.convertString(src.getDependentElement())); 099 if (src.hasRelationship()) 100 tgt.setRelationship(CodeableConcept30_40.convertCodeableConcept(src.getRelationship())); 101 if (src.hasPeriod()) 102 tgt.setPeriod(Period30_40.convertPeriod(src.getPeriod())); 103 for (org.hl7.fhir.dstu3.model.Reference t : src.getPayor()) tgt.addPayor(Reference30_40.convertReference(t)); 104 if (src.hasOrder()) 105 tgt.setOrderElement(PositiveInt30_40.convertPositiveInt(src.getOrderElement())); 106 if (src.hasNetwork()) 107 tgt.setNetworkElement(String30_40.convertString(src.getNetworkElement())); 108 for (org.hl7.fhir.dstu3.model.Reference t : src.getContract()) tgt.addContract(Reference30_40.convertReference(t)); 109 return tgt; 110 } 111 112 static public org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.Coverage.CoverageStatus> convertCoverageStatus(org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.Coverage.CoverageStatus> src) throws FHIRException { 113 if (src == null || src.isEmpty()) 114 return null; 115 org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.Coverage.CoverageStatus> tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.Coverage.CoverageStatusEnumFactory()); 116 ConversionContext30_40.INSTANCE.getVersionConvertor_30_40().copyElement(src, tgt); 117 switch (src.getValue()) { 118 case ACTIVE: 119 tgt.setValue(org.hl7.fhir.dstu3.model.Coverage.CoverageStatus.ACTIVE); 120 break; 121 case CANCELLED: 122 tgt.setValue(org.hl7.fhir.dstu3.model.Coverage.CoverageStatus.CANCELLED); 123 break; 124 case DRAFT: 125 tgt.setValue(org.hl7.fhir.dstu3.model.Coverage.CoverageStatus.DRAFT); 126 break; 127 case ENTEREDINERROR: 128 tgt.setValue(org.hl7.fhir.dstu3.model.Coverage.CoverageStatus.ENTEREDINERROR); 129 break; 130 default: 131 tgt.setValue(org.hl7.fhir.dstu3.model.Coverage.CoverageStatus.NULL); 132 break; 133 } 134 return tgt; 135 } 136 137 static public org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.Coverage.CoverageStatus> convertCoverageStatus(org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.Coverage.CoverageStatus> src) throws FHIRException { 138 if (src == null || src.isEmpty()) 139 return null; 140 org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.Coverage.CoverageStatus> tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.Coverage.CoverageStatusEnumFactory()); 141 ConversionContext30_40.INSTANCE.getVersionConvertor_30_40().copyElement(src, tgt); 142 switch (src.getValue()) { 143 case ACTIVE: 144 tgt.setValue(org.hl7.fhir.r4.model.Coverage.CoverageStatus.ACTIVE); 145 break; 146 case CANCELLED: 147 tgt.setValue(org.hl7.fhir.r4.model.Coverage.CoverageStatus.CANCELLED); 148 break; 149 case DRAFT: 150 tgt.setValue(org.hl7.fhir.r4.model.Coverage.CoverageStatus.DRAFT); 151 break; 152 case ENTEREDINERROR: 153 tgt.setValue(org.hl7.fhir.r4.model.Coverage.CoverageStatus.ENTEREDINERROR); 154 break; 155 default: 156 tgt.setValue(org.hl7.fhir.r4.model.Coverage.CoverageStatus.NULL); 157 break; 158 } 159 return tgt; 160 } 161 162}