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.Attachment43_50; 005import org.hl7.fhir.convertors.conv43_50.datatypes43_50.general43_50.CodeableConcept43_50; 006import org.hl7.fhir.convertors.conv43_50.datatypes43_50.general43_50.Identifier43_50; 007import org.hl7.fhir.convertors.conv43_50.datatypes43_50.general43_50.Period43_50; 008import org.hl7.fhir.convertors.conv43_50.datatypes43_50.primitive43_50.Instant43_50; 009import org.hl7.fhir.convertors.conv43_50.datatypes43_50.primitive43_50.MarkDown43_50; 010import org.hl7.fhir.convertors.conv43_50.datatypes43_50.primitive43_50.String43_50; 011import org.hl7.fhir.convertors.conv43_50.datatypes43_50.special43_50.Reference43_50; 012import org.hl7.fhir.exceptions.FHIRException; 013import org.hl7.fhir.r5.model.CodeableReference; 014import org.hl7.fhir.r5.model.DocumentReference.DocumentReferenceAttesterComponent; 015 016/* 017 Copyright (c) 2011+, HL7, Inc. 018 All rights reserved. 019 020 Redistribution and use in source and binary forms, with or without modification, 021 are permitted provided that the following conditions are met: 022 023 * Redistributions of source code must retain the above copyright notice, this 024 list of conditions and the following disclaimer. 025 * Redistributions in binary form must reproduce the above copyright notice, 026 this list of conditions and the following disclaimer in the documentation 027 and/or other materials provided with the distribution. 028 * Neither the name of HL7 nor the names of its contributors may be used to 029 endorse or promote products derived from this software without specific 030 prior written permission. 031 032 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 033 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 034 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 035 IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 036 INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 037 NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 038 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 039 WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 040 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 041 POSSIBILITY OF SUCH DAMAGE. 042 043*/ 044// Generated on Sun, Feb 24, 2019 11:37+1100 for FHIR v4.0.0 045public class DocumentReference43_50 { 046 047 public static org.hl7.fhir.r5.model.DocumentReference convertDocumentReference(org.hl7.fhir.r4b.model.DocumentReference src) throws FHIRException { 048 if (src == null) 049 return null; 050 org.hl7.fhir.r5.model.DocumentReference tgt = new org.hl7.fhir.r5.model.DocumentReference(); 051 ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyDomainResource(src, tgt); 052 if (src.hasMasterIdentifier()) 053 tgt.addIdentifier(Identifier43_50.convertIdentifier(src.getMasterIdentifier())); 054 for (org.hl7.fhir.r4b.model.Identifier t : src.getIdentifier()) 055 tgt.addIdentifier(Identifier43_50.convertIdentifier(t)); 056 if (src.hasStatus()) 057 tgt.setStatusElement(Enumerations43_50.convertDocumentReferenceStatus(src.getStatusElement())); 058 if (src.hasDocStatus()) 059 tgt.setDocStatusElement(convertReferredDocumentStatus(src.getDocStatusElement())); 060 if (src.hasType()) 061 tgt.setType(CodeableConcept43_50.convertCodeableConcept(src.getType())); 062 for (org.hl7.fhir.r4b.model.CodeableConcept t : src.getCategory()) 063 tgt.addCategory(CodeableConcept43_50.convertCodeableConcept(t)); 064 if (src.hasSubject()) 065 tgt.setSubject(Reference43_50.convertReference(src.getSubject())); 066 if (src.hasDate()) 067 tgt.setDateElement(Instant43_50.convertInstant(src.getDateElement())); 068 for (org.hl7.fhir.r4b.model.Reference t : src.getAuthor()) tgt.addAuthor(Reference43_50.convertReference(t)); 069 if (src.hasAuthenticator()) 070 tgt.addAttester().setMode(new org.hl7.fhir.r5.model.CodeableConcept().addCoding(new org.hl7.fhir.r5.model.Coding("http://hl7.org/fhir/composition-attestation-mode","official", "Official"))) 071 .setParty(Reference43_50.convertReference(src.getAuthenticator())); 072 if (src.hasCustodian()) 073 tgt.setCustodian(Reference43_50.convertReference(src.getCustodian())); 074 for (org.hl7.fhir.r4b.model.DocumentReference.DocumentReferenceRelatesToComponent t : src.getRelatesTo()) 075 tgt.addRelatesTo(convertDocumentReferenceRelatesToComponent(t)); 076 if (src.hasDescription()) 077 tgt.setDescriptionElement(MarkDown43_50.convertStringToMarkdown(src.getDescriptionElement())); 078 for (org.hl7.fhir.r4b.model.CodeableConcept t : src.getSecurityLabel()) 079 tgt.addSecurityLabel(CodeableConcept43_50.convertCodeableConcept(t)); 080 for (org.hl7.fhir.r4b.model.DocumentReference.DocumentReferenceContentComponent t : src.getContent()) 081 tgt.addContent(convertDocumentReferenceContentComponent(t)); 082 if (src.hasContext()) 083 convertDocumentReferenceContextComponent(src.getContext(), tgt); 084 for (org.hl7.fhir.r4b.model.Reference t : src.getAuthor()) 085 tgt.addAuthor(Reference43_50.convertReference(t)); 086 return tgt; 087 } 088 089 public static org.hl7.fhir.r4b.model.DocumentReference convertDocumentReference(org.hl7.fhir.r5.model.DocumentReference src) throws FHIRException { 090 if (src == null) 091 return null; 092 org.hl7.fhir.r4b.model.DocumentReference tgt = new org.hl7.fhir.r4b.model.DocumentReference(); 093 ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyDomainResource(src, tgt); 094// if (src.hasMasterIdentifier()) 095// tgt.setMasterIdentifier(convertIdentifier(src.getMasterIdentifier())); 096 for (org.hl7.fhir.r5.model.Identifier t : src.getIdentifier()) 097 tgt.addIdentifier(Identifier43_50.convertIdentifier(t)); 098 if (src.hasStatus()) 099 tgt.setStatusElement(Enumerations43_50.convertDocumentReferenceStatus(src.getStatusElement())); 100 if (src.hasDocStatus()) 101 tgt.setDocStatusElement(convertReferredDocumentStatus(src.getDocStatusElement())); 102 if (src.hasType()) 103 tgt.setType(CodeableConcept43_50.convertCodeableConcept(src.getType())); 104 for (org.hl7.fhir.r5.model.CodeableConcept t : src.getCategory()) 105 tgt.addCategory(CodeableConcept43_50.convertCodeableConcept(t)); 106 if (src.hasSubject()) 107 tgt.setSubject(Reference43_50.convertReference(src.getSubject())); 108 if (src.hasDate()) 109 tgt.setDateElement(Instant43_50.convertInstant(src.getDateElement())); 110 for (org.hl7.fhir.r5.model.Reference t : src.getAuthor()) tgt.addAuthor(Reference43_50.convertReference(t)); 111 for (DocumentReferenceAttesterComponent t : src.getAttester()) { 112 if (t.getMode().hasCoding("http://hl7.org/fhir/composition-attestation-mode", "official")) 113 tgt.setAuthenticator(Reference43_50.convertReference(t.getParty())); 114 } 115 if (src.hasCustodian()) 116 tgt.setCustodian(Reference43_50.convertReference(src.getCustodian())); 117 for (org.hl7.fhir.r5.model.DocumentReference.DocumentReferenceRelatesToComponent t : src.getRelatesTo()) 118 tgt.addRelatesTo(convertDocumentReferenceRelatesToComponent(t)); 119 if (src.hasDescription()) 120 tgt.setDescriptionElement(String43_50.convertString(src.getDescriptionElement())); 121 for (org.hl7.fhir.r5.model.CodeableConcept t : src.getSecurityLabel()) 122 tgt.addSecurityLabel(CodeableConcept43_50.convertCodeableConcept(t)); 123 for (org.hl7.fhir.r5.model.DocumentReference.DocumentReferenceContentComponent t : src.getContent()) 124 tgt.addContent(convertDocumentReferenceContentComponent(t)); 125 convertDocumentReferenceContextComponent(src, tgt.getContext()); 126 for (org.hl7.fhir.r5.model.Reference t : src.getAuthor()) 127 tgt.addAuthor(Reference43_50.convertReference(t)); 128 return tgt; 129 } 130 131 static public org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Enumerations.CompositionStatus> convertReferredDocumentStatus(org.hl7.fhir.r4b.model.Enumeration<org.hl7.fhir.r4b.model.Enumerations.CompositionStatus> src) throws FHIRException { 132 if (src == null || src.isEmpty()) 133 return null; 134 org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Enumerations.CompositionStatus> tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.Enumerations.CompositionStatusEnumFactory()); 135 ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyElement(src, tgt); 136 switch (src.getValue()) { 137 case PRELIMINARY: 138 tgt.setValue(org.hl7.fhir.r5.model.Enumerations.CompositionStatus.PRELIMINARY); 139 break; 140 case FINAL: 141 tgt.setValue(org.hl7.fhir.r5.model.Enumerations.CompositionStatus.FINAL); 142 break; 143 case AMENDED: 144 tgt.setValue(org.hl7.fhir.r5.model.Enumerations.CompositionStatus.AMENDED); 145 break; 146 case ENTEREDINERROR: 147 tgt.setValue(org.hl7.fhir.r5.model.Enumerations.CompositionStatus.ENTEREDINERROR); 148 break; 149 default: 150 tgt.setValue(org.hl7.fhir.r5.model.Enumerations.CompositionStatus.NULL); 151 break; 152 } 153 return tgt; 154 } 155 156 static public org.hl7.fhir.r4b.model.Enumeration<org.hl7.fhir.r4b.model.Enumerations.CompositionStatus> convertReferredDocumentStatus(org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Enumerations.CompositionStatus> src) throws FHIRException { 157 if (src == null || src.isEmpty()) 158 return null; 159 org.hl7.fhir.r4b.model.Enumeration<org.hl7.fhir.r4b.model.Enumerations.CompositionStatus> tgt = new org.hl7.fhir.r4b.model.Enumeration<>(new org.hl7.fhir.r4b.model.Enumerations.CompositionStatusEnumFactory()); 160 ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyElement(src, tgt); 161 switch (src.getValue()) { 162 case PRELIMINARY: 163 tgt.setValue(org.hl7.fhir.r4b.model.Enumerations.CompositionStatus.PRELIMINARY); 164 break; 165 case FINAL: 166 tgt.setValue(org.hl7.fhir.r4b.model.Enumerations.CompositionStatus.FINAL); 167 break; 168 case AMENDED: 169 tgt.setValue(org.hl7.fhir.r4b.model.Enumerations.CompositionStatus.AMENDED); 170 break; 171 case ENTEREDINERROR: 172 tgt.setValue(org.hl7.fhir.r4b.model.Enumerations.CompositionStatus.ENTEREDINERROR); 173 break; 174 default: 175 tgt.setValue(org.hl7.fhir.r4b.model.Enumerations.CompositionStatus.NULL); 176 break; 177 } 178 return tgt; 179 } 180 181 public static org.hl7.fhir.r5.model.DocumentReference.DocumentReferenceRelatesToComponent convertDocumentReferenceRelatesToComponent(org.hl7.fhir.r4b.model.DocumentReference.DocumentReferenceRelatesToComponent src) throws FHIRException { 182 if (src == null) 183 return null; 184 org.hl7.fhir.r5.model.DocumentReference.DocumentReferenceRelatesToComponent tgt = new org.hl7.fhir.r5.model.DocumentReference.DocumentReferenceRelatesToComponent(); 185 ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyBackboneElement(src, tgt); 186 if (src.hasCode()) 187 tgt.setCode(convertDocumentRelationshipType(src.getCodeElement())); 188 if (src.hasTarget()) 189 tgt.setTarget(Reference43_50.convertReference(src.getTarget())); 190 return tgt; 191 } 192 193 public static org.hl7.fhir.r4b.model.DocumentReference.DocumentReferenceRelatesToComponent convertDocumentReferenceRelatesToComponent(org.hl7.fhir.r5.model.DocumentReference.DocumentReferenceRelatesToComponent src) throws FHIRException { 194 if (src == null) 195 return null; 196 org.hl7.fhir.r4b.model.DocumentReference.DocumentReferenceRelatesToComponent tgt = new org.hl7.fhir.r4b.model.DocumentReference.DocumentReferenceRelatesToComponent(); 197 ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyBackboneElement(src, tgt); 198 if (src.hasCode()) 199 tgt.setCodeElement(convertDocumentRelationshipType(src.getCode())); 200 if (src.hasTarget()) 201 tgt.setTarget(Reference43_50.convertReference(src.getTarget())); 202 return tgt; 203 } 204 205 static public org.hl7.fhir.r5.model.CodeableConcept convertDocumentRelationshipType(org.hl7.fhir.r4b.model.Enumeration<org.hl7.fhir.r4b.model.Enumerations.DocumentRelationshipType> src) throws FHIRException { 206 if (src == null || src.isEmpty()) 207 return null; 208 org.hl7.fhir.r5.model.CodeableConcept tgt = new org.hl7.fhir.r5.model.CodeableConcept(); 209 ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyElement(src, tgt); 210 switch (src.getValue()) { 211 case REPLACES: 212 tgt.addCoding().setSystem("http://hl7.org/fhir/document-relationship-type").setCode("replaces"); 213 break; 214 case TRANSFORMS: 215 tgt.addCoding().setSystem("http://hl7.org/fhir/document-relationship-type").setCode("transforms"); 216 break; 217 case SIGNS: 218 tgt.addCoding().setSystem("http://hl7.org/fhir/document-relationship-type").setCode("signs"); 219 break; 220 case APPENDS: 221 tgt.addCoding().setSystem("http://hl7.org/fhir/document-relationship-type").setCode("appends"); 222 break; 223 default: 224 break; 225 } 226 return tgt; 227 } 228 229 static public org.hl7.fhir.r4b.model.Enumeration<org.hl7.fhir.r4b.model.Enumerations.DocumentRelationshipType> convertDocumentRelationshipType(org.hl7.fhir.r5.model.CodeableConcept src) throws FHIRException { 230 if (src == null || src.isEmpty()) 231 return null; 232 org.hl7.fhir.r4b.model.Enumeration<org.hl7.fhir.r4b.model.Enumerations.DocumentRelationshipType> tgt = new org.hl7.fhir.r4b.model.Enumeration<>(new org.hl7.fhir.r4b.model.Enumerations.DocumentRelationshipTypeEnumFactory()); 233 ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyElement(src, tgt); 234 switch (src.getCode("http://hl7.org/fhir/document-relationship-type")) { 235 case "replaces": 236 tgt.setValue(org.hl7.fhir.r4b.model.Enumerations.DocumentRelationshipType.REPLACES); 237 break; 238 case "transforms": 239 tgt.setValue(org.hl7.fhir.r4b.model.Enumerations.DocumentRelationshipType.TRANSFORMS); 240 break; 241 case "signs": 242 tgt.setValue(org.hl7.fhir.r4b.model.Enumerations.DocumentRelationshipType.SIGNS); 243 break; 244 case "appends": 245 tgt.setValue(org.hl7.fhir.r4b.model.Enumerations.DocumentRelationshipType.APPENDS); 246 break; 247 default: 248 tgt.setValue(org.hl7.fhir.r4b.model.Enumerations.DocumentRelationshipType.NULL); 249 break; 250 } 251 return tgt; 252 } 253 254 public static org.hl7.fhir.r5.model.DocumentReference.DocumentReferenceContentComponent convertDocumentReferenceContentComponent(org.hl7.fhir.r4b.model.DocumentReference.DocumentReferenceContentComponent src) throws FHIRException { 255 if (src == null) 256 return null; 257 org.hl7.fhir.r5.model.DocumentReference.DocumentReferenceContentComponent tgt = new org.hl7.fhir.r5.model.DocumentReference.DocumentReferenceContentComponent(); 258 ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyBackboneElement(src, tgt); 259 if (src.hasAttachment()) 260 tgt.setAttachment(Attachment43_50.convertAttachment(src.getAttachment())); 261 return tgt; 262 } 263 264 public static org.hl7.fhir.r4b.model.DocumentReference.DocumentReferenceContentComponent convertDocumentReferenceContentComponent(org.hl7.fhir.r5.model.DocumentReference.DocumentReferenceContentComponent src) throws FHIRException { 265 if (src == null) 266 return null; 267 org.hl7.fhir.r4b.model.DocumentReference.DocumentReferenceContentComponent tgt = new org.hl7.fhir.r4b.model.DocumentReference.DocumentReferenceContentComponent(); 268 ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyBackboneElement(src, tgt); 269 if (src.hasAttachment()) 270 tgt.setAttachment(Attachment43_50.convertAttachment(src.getAttachment())); 271 return tgt; 272 } 273 274 public static void convertDocumentReferenceContextComponent(org.hl7.fhir.r4b.model.DocumentReference.DocumentReferenceContextComponent src, org.hl7.fhir.r5.model.DocumentReference tgt) throws FHIRException { 275 for (org.hl7.fhir.r4b.model.Reference t : src.getEncounter()) tgt.addContext(Reference43_50.convertReference(t)); 276 for (org.hl7.fhir.r4b.model.CodeableConcept t : src.getEvent()) 277 tgt.addEvent(new CodeableReference().setConcept(CodeableConcept43_50.convertCodeableConcept(t))); 278 if (src.hasPeriod()) 279 tgt.setPeriod(Period43_50.convertPeriod(src.getPeriod())); 280 if (src.hasFacilityType()) 281 tgt.setFacilityType(CodeableConcept43_50.convertCodeableConcept(src.getFacilityType())); 282 if (src.hasPracticeSetting()) 283 tgt.setPracticeSetting(CodeableConcept43_50.convertCodeableConcept(src.getPracticeSetting())); 284// if (src.hasSourcePatientInfo()) 285// tgt.setSourcePatientInfo(Reference43_50.convertReference(src.getSourcePatientInfo())); 286// for (org.hl7.fhir.r4b.model.Reference t : src.getRelated()) tgt.addRelated(Reference43_50.convertReference(t)); 287 } 288 289 public static void convertDocumentReferenceContextComponent(org.hl7.fhir.r5.model.DocumentReference src, org.hl7.fhir.r4b.model.DocumentReference.DocumentReferenceContextComponent tgt) throws FHIRException { 290 for (org.hl7.fhir.r5.model.Reference t : src.getContext()) tgt.addEncounter(Reference43_50.convertReference(t)); 291 for (CodeableReference t : src.getEvent()) 292 if (t.hasConcept()) 293 tgt.addEvent(CodeableConcept43_50.convertCodeableConcept(t.getConcept())); 294 if (src.hasPeriod()) 295 tgt.setPeriod(Period43_50.convertPeriod(src.getPeriod())); 296 if (src.hasFacilityType()) 297 tgt.setFacilityType(CodeableConcept43_50.convertCodeableConcept(src.getFacilityType())); 298 if (src.hasPracticeSetting()) 299 tgt.setPracticeSetting(CodeableConcept43_50.convertCodeableConcept(src.getPracticeSetting())); 300// if (src.hasSourcePatientInfo()) 301// tgt.setSourcePatientInfo(Reference43_50.convertReference(src.getSourcePatientInfo())); 302// for (org.hl7.fhir.r5.model.Reference t : src.getRelated()) tgt.addRelated(Reference43_50.convertReference(t)); 303 } 304}