
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.CodeableConcept40_50; 005import org.hl7.fhir.convertors.conv40_50.datatypes40_50.general40_50.Signature40_50; 006import org.hl7.fhir.convertors.conv40_50.datatypes40_50.primitive40_50.Instant40_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; 010import org.hl7.fhir.r5.model.CodeableReference; 011import org.hl7.fhir.r5.model.Enumeration; 012import org.hl7.fhir.r5.model.Provenance; 013 014/* 015 Copyright (c) 2011+, HL7, Inc. 016 All rights reserved. 017 018 Redistribution and use in source and binary forms, with or without modification, 019 are permitted provided that the following conditions are met: 020 021 * Redistributions of source code must retain the above copyright notice, this 022 list of conditions and the following disclaimer. 023 * Redistributions in binary form must reproduce the above copyright notice, 024 this list of conditions and the following disclaimer in the documentation 025 and/or other materials provided with the distribution. 026 * Neither the name of HL7 nor the names of its contributors may be used to 027 endorse or promote products derived from this software without specific 028 prior written permission. 029 030 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 031 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 032 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 033 IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 034 INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 035 NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 036 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 037 WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 038 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 039 POSSIBILITY OF SUCH DAMAGE. 040 041*/ 042// Generated on Sun, Feb 24, 2019 11:37+1100 for FHIR v4.0.0 043public class Provenance40_50 { 044 045 public static org.hl7.fhir.r5.model.Provenance convertProvenance(org.hl7.fhir.r4.model.Provenance src) throws FHIRException { 046 if (src == null) 047 return null; 048 org.hl7.fhir.r5.model.Provenance tgt = new org.hl7.fhir.r5.model.Provenance(); 049 ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyDomainResource(src, tgt); 050 for (org.hl7.fhir.r4.model.Reference t : src.getTarget()) tgt.addTarget(Reference40_50.convertReference(t)); 051 if (src.hasOccurred()) 052 tgt.setOccurred(ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().convertType(src.getOccurred())); 053 if (src.hasRecorded()) 054 tgt.setRecordedElement(Instant40_50.convertInstant(src.getRecordedElement())); 055 for (org.hl7.fhir.r4.model.UriType t : src.getPolicy()) tgt.getPolicy().add(Uri40_50.convertUri(t)); 056 if (src.hasLocation()) 057 tgt.setLocation(Reference40_50.convertReference(src.getLocation())); 058 for (org.hl7.fhir.r4.model.CodeableConcept t : src.getReason()) 059 tgt.addAuthorization().setConcept(CodeableConcept40_50.convertCodeableConcept(t)); 060 if (src.hasActivity()) 061 tgt.setActivity(CodeableConcept40_50.convertCodeableConcept(src.getActivity())); 062 for (org.hl7.fhir.r4.model.Provenance.ProvenanceAgentComponent t : src.getAgent()) 063 tgt.addAgent(convertProvenanceAgentComponent(t)); 064 for (org.hl7.fhir.r4.model.Provenance.ProvenanceEntityComponent t : src.getEntity()) 065 tgt.addEntity(convertProvenanceEntityComponent(t)); 066 for (org.hl7.fhir.r4.model.Signature t : src.getSignature()) tgt.addSignature(Signature40_50.convertSignature(t)); 067 return tgt; 068 } 069 070 public static org.hl7.fhir.r4.model.Provenance convertProvenance(org.hl7.fhir.r5.model.Provenance src) throws FHIRException { 071 if (src == null) 072 return null; 073 org.hl7.fhir.r4.model.Provenance tgt = new org.hl7.fhir.r4.model.Provenance(); 074 ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyDomainResource(src, tgt); 075 for (org.hl7.fhir.r5.model.Reference t : src.getTarget()) tgt.addTarget(Reference40_50.convertReference(t)); 076 if (src.hasOccurred()) 077 tgt.setOccurred(ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().convertType(src.getOccurred())); 078 if (src.hasRecorded()) 079 tgt.setRecordedElement(Instant40_50.convertInstant(src.getRecordedElement())); 080 for (org.hl7.fhir.r5.model.UriType t : src.getPolicy()) tgt.getPolicy().add(Uri40_50.convertUri(t)); 081 if (src.hasLocation()) 082 tgt.setLocation(Reference40_50.convertReference(src.getLocation())); 083 for (CodeableReference t : src.getAuthorization()) 084 if (t.hasConcept()) 085 tgt.addReason(CodeableConcept40_50.convertCodeableConcept(t.getConcept())); 086 if (src.hasActivity()) 087 tgt.setActivity(CodeableConcept40_50.convertCodeableConcept(src.getActivity())); 088 for (org.hl7.fhir.r5.model.Provenance.ProvenanceAgentComponent t : src.getAgent()) 089 tgt.addAgent(convertProvenanceAgentComponent(t)); 090 for (org.hl7.fhir.r5.model.Provenance.ProvenanceEntityComponent t : src.getEntity()) 091 tgt.addEntity(convertProvenanceEntityComponent(t)); 092 for (org.hl7.fhir.r5.model.Signature t : src.getSignature()) tgt.addSignature(Signature40_50.convertSignature(t)); 093 return tgt; 094 } 095 096 public static org.hl7.fhir.r5.model.Provenance.ProvenanceAgentComponent convertProvenanceAgentComponent(org.hl7.fhir.r4.model.Provenance.ProvenanceAgentComponent src) throws FHIRException { 097 if (src == null) 098 return null; 099 org.hl7.fhir.r5.model.Provenance.ProvenanceAgentComponent tgt = new org.hl7.fhir.r5.model.Provenance.ProvenanceAgentComponent(); 100 ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyBackboneElement(src, tgt); 101 if (src.hasType()) 102 tgt.setType(CodeableConcept40_50.convertCodeableConcept(src.getType())); 103 for (org.hl7.fhir.r4.model.CodeableConcept t : src.getRole()) 104 tgt.addRole(CodeableConcept40_50.convertCodeableConcept(t)); 105 if (src.hasWho()) 106 tgt.setWho(Reference40_50.convertReference(src.getWho())); 107 if (src.hasOnBehalfOf()) 108 tgt.setOnBehalfOf(Reference40_50.convertReference(src.getOnBehalfOf())); 109 return tgt; 110 } 111 112 public static org.hl7.fhir.r4.model.Provenance.ProvenanceAgentComponent convertProvenanceAgentComponent(org.hl7.fhir.r5.model.Provenance.ProvenanceAgentComponent src) throws FHIRException { 113 if (src == null) 114 return null; 115 org.hl7.fhir.r4.model.Provenance.ProvenanceAgentComponent tgt = new org.hl7.fhir.r4.model.Provenance.ProvenanceAgentComponent(); 116 ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyBackboneElement(src, tgt); 117 if (src.hasType()) 118 tgt.setType(CodeableConcept40_50.convertCodeableConcept(src.getType())); 119 for (org.hl7.fhir.r5.model.CodeableConcept t : src.getRole()) 120 tgt.addRole(CodeableConcept40_50.convertCodeableConcept(t)); 121 if (src.hasWho()) 122 tgt.setWho(Reference40_50.convertReference(src.getWho())); 123 if (src.hasOnBehalfOf()) 124 tgt.setOnBehalfOf(Reference40_50.convertReference(src.getOnBehalfOf())); 125 return tgt; 126 } 127 128 public static org.hl7.fhir.r5.model.Provenance.ProvenanceEntityComponent convertProvenanceEntityComponent(org.hl7.fhir.r4.model.Provenance.ProvenanceEntityComponent src) throws FHIRException { 129 if (src == null) 130 return null; 131 org.hl7.fhir.r5.model.Provenance.ProvenanceEntityComponent tgt = new org.hl7.fhir.r5.model.Provenance.ProvenanceEntityComponent(); 132 ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyBackboneElement(src, tgt); 133 if (src.hasRole()) 134 tgt.setRoleElement(convertProvenanceEntityRole(src.getRoleElement())); 135 if (src.hasWhat()) 136 tgt.setWhat(Reference40_50.convertReference(src.getWhat())); 137 for (org.hl7.fhir.r4.model.Provenance.ProvenanceAgentComponent t : src.getAgent()) 138 tgt.addAgent(convertProvenanceAgentComponent(t)); 139 return tgt; 140 } 141 142 public static org.hl7.fhir.r4.model.Provenance.ProvenanceEntityComponent convertProvenanceEntityComponent(org.hl7.fhir.r5.model.Provenance.ProvenanceEntityComponent src) throws FHIRException { 143 if (src == null) 144 return null; 145 org.hl7.fhir.r4.model.Provenance.ProvenanceEntityComponent tgt = new org.hl7.fhir.r4.model.Provenance.ProvenanceEntityComponent(); 146 ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyBackboneElement(src, tgt); 147 if (src.hasRole()) 148 tgt.setRoleElement(convertProvenanceEntityRole(src.getRoleElement())); 149 if (src.hasWhat()) 150 tgt.setWhat(Reference40_50.convertReference(src.getWhat())); 151 for (org.hl7.fhir.r5.model.Provenance.ProvenanceAgentComponent t : src.getAgent()) 152 tgt.addAgent(convertProvenanceAgentComponent(t)); 153 return tgt; 154 } 155 156 static public org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Provenance.ProvenanceEntityRole> convertProvenanceEntityRole(org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.Provenance.ProvenanceEntityRole> src) throws FHIRException { 157 if (src == null || src.isEmpty()) 158 return null; 159 Enumeration<Provenance.ProvenanceEntityRole> tgt = new Enumeration<>(new Provenance.ProvenanceEntityRoleEnumFactory()); 160 ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt); 161 if (src.getValue() == null) { 162 tgt.setValue(null); 163 } else { 164 switch (src.getValue()) { 165 case DERIVATION: 166 tgt.setValue(Provenance.ProvenanceEntityRole.INSTANTIATES); 167 break; 168 case REVISION: 169 tgt.setValue(Provenance.ProvenanceEntityRole.REVISION); 170 break; 171 case QUOTATION: 172 tgt.setValue(Provenance.ProvenanceEntityRole.QUOTATION); 173 break; 174 case SOURCE: 175 tgt.setValue(Provenance.ProvenanceEntityRole.SOURCE); 176 break; 177 case REMOVAL: 178 tgt.setValue(Provenance.ProvenanceEntityRole.REMOVAL); 179 break; 180 default: 181 tgt.setValue(Provenance.ProvenanceEntityRole.NULL); 182 break; 183 } 184 } 185 return tgt; 186 } 187 188 static public org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.Provenance.ProvenanceEntityRole> convertProvenanceEntityRole(org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Provenance.ProvenanceEntityRole> src) throws FHIRException { 189 if (src == null || src.isEmpty()) 190 return null; 191 org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.Provenance.ProvenanceEntityRole> tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.Provenance.ProvenanceEntityRoleEnumFactory()); 192 ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt); 193 if (src.getValue() == null) { 194 tgt.setValue(null); 195 } else { 196 switch (src.getValue()) { 197 case INSTANTIATES: 198 tgt.setValue(org.hl7.fhir.r4.model.Provenance.ProvenanceEntityRole.DERIVATION); 199 break; 200 case REVISION: 201 tgt.setValue(org.hl7.fhir.r4.model.Provenance.ProvenanceEntityRole.REVISION); 202 break; 203 case QUOTATION: 204 tgt.setValue(org.hl7.fhir.r4.model.Provenance.ProvenanceEntityRole.QUOTATION); 205 break; 206 case SOURCE: 207 tgt.setValue(org.hl7.fhir.r4.model.Provenance.ProvenanceEntityRole.SOURCE); 208 break; 209 case REMOVAL: 210 tgt.setValue(org.hl7.fhir.r4.model.Provenance.ProvenanceEntityRole.REMOVAL); 211 break; 212 default: 213 tgt.setValue(org.hl7.fhir.r4.model.Provenance.ProvenanceEntityRole.NULL); 214 break; 215 } 216 } 217 return tgt; 218 } 219}