
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.Annotation40_50; 005import org.hl7.fhir.convertors.conv40_50.datatypes40_50.general40_50.CodeableConcept40_50; 006import org.hl7.fhir.convertors.conv40_50.datatypes40_50.general40_50.Identifier40_50; 007import org.hl7.fhir.convertors.conv40_50.datatypes40_50.primitive40_50.Boolean40_50; 008import org.hl7.fhir.convertors.conv40_50.datatypes40_50.primitive40_50.DateTime40_50; 009import org.hl7.fhir.convertors.conv40_50.datatypes40_50.primitive40_50.String40_50; 010import org.hl7.fhir.convertors.conv40_50.datatypes40_50.special40_50.Reference40_50; 011import org.hl7.fhir.exceptions.FHIRException; 012import org.hl7.fhir.r5.model.Enumeration; 013import org.hl7.fhir.r5.model.Enumerations; 014import org.hl7.fhir.r5.model.ListResource; 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 ListResource40_50 { 046 047 public static org.hl7.fhir.r5.model.ListResource convertListResource(org.hl7.fhir.r4.model.ListResource src) throws FHIRException { 048 if (src == null) 049 return null; 050 org.hl7.fhir.r5.model.ListResource tgt = new org.hl7.fhir.r5.model.ListResource(); 051 ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyDomainResource(src, tgt); 052 for (org.hl7.fhir.r4.model.Identifier t : src.getIdentifier()) 053 tgt.addIdentifier(Identifier40_50.convertIdentifier(t)); 054 if (src.hasStatus()) 055 tgt.setStatusElement(convertListStatus(src.getStatusElement())); 056 if (src.hasMode()) 057 tgt.setModeElement(convertListMode(src.getModeElement())); 058 if (src.hasTitle()) 059 tgt.setTitleElement(String40_50.convertString(src.getTitleElement())); 060 if (src.hasCode()) 061 tgt.setCode(CodeableConcept40_50.convertCodeableConcept(src.getCode())); 062 if (src.hasSubject()) 063 tgt.addSubject(Reference40_50.convertReference(src.getSubject())); 064 if (src.hasEncounter()) 065 tgt.setEncounter(Reference40_50.convertReference(src.getEncounter())); 066 if (src.hasDate()) 067 tgt.setDateElement(DateTime40_50.convertDateTime(src.getDateElement())); 068 if (src.hasSource()) 069 tgt.setSource(Reference40_50.convertReference(src.getSource())); 070 if (src.hasOrderedBy()) 071 tgt.setOrderedBy(CodeableConcept40_50.convertCodeableConcept(src.getOrderedBy())); 072 for (org.hl7.fhir.r4.model.Annotation t : src.getNote()) tgt.addNote(Annotation40_50.convertAnnotation(t)); 073 for (org.hl7.fhir.r4.model.ListResource.ListEntryComponent t : src.getEntry()) 074 tgt.addEntry(convertListEntryComponent(t)); 075 if (src.hasEmptyReason()) 076 tgt.setEmptyReason(CodeableConcept40_50.convertCodeableConcept(src.getEmptyReason())); 077 return tgt; 078 } 079 080 public static org.hl7.fhir.r4.model.ListResource convertListResource(org.hl7.fhir.r5.model.ListResource src) throws FHIRException { 081 if (src == null) 082 return null; 083 org.hl7.fhir.r4.model.ListResource tgt = new org.hl7.fhir.r4.model.ListResource(); 084 ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyDomainResource(src, tgt); 085 for (org.hl7.fhir.r5.model.Identifier t : src.getIdentifier()) 086 tgt.addIdentifier(Identifier40_50.convertIdentifier(t)); 087 if (src.hasStatus()) 088 tgt.setStatusElement(convertListStatus(src.getStatusElement())); 089 if (src.hasMode()) 090 tgt.setModeElement(convertListMode(src.getModeElement())); 091 if (src.hasTitle()) 092 tgt.setTitleElement(String40_50.convertString(src.getTitleElement())); 093 if (src.hasCode()) 094 tgt.setCode(CodeableConcept40_50.convertCodeableConcept(src.getCode())); 095 if (src.hasSubject()) 096 tgt.setSubject(Reference40_50.convertReference(src.getSubjectFirstRep())); 097 if (src.hasEncounter()) 098 tgt.setEncounter(Reference40_50.convertReference(src.getEncounter())); 099 if (src.hasDate()) 100 tgt.setDateElement(DateTime40_50.convertDateTime(src.getDateElement())); 101 if (src.hasSource()) 102 tgt.setSource(Reference40_50.convertReference(src.getSource())); 103 if (src.hasOrderedBy()) 104 tgt.setOrderedBy(CodeableConcept40_50.convertCodeableConcept(src.getOrderedBy())); 105 for (org.hl7.fhir.r5.model.Annotation t : src.getNote()) tgt.addNote(Annotation40_50.convertAnnotation(t)); 106 for (org.hl7.fhir.r5.model.ListResource.ListResourceEntryComponent t : src.getEntry()) 107 tgt.addEntry(convertListEntryComponent(t)); 108 if (src.hasEmptyReason()) 109 tgt.setEmptyReason(CodeableConcept40_50.convertCodeableConcept(src.getEmptyReason())); 110 return tgt; 111 } 112 113 static public org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.ListResource.ListStatus> convertListStatus(org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.ListResource.ListStatus> src) throws FHIRException { 114 if (src == null || src.isEmpty()) 115 return null; 116 Enumeration<ListResource.ListStatus> tgt = new Enumeration<>(new ListResource.ListStatusEnumFactory()); 117 ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt); 118 if (src.getValue() == null) { 119 tgt.setValue(null); 120 } else { 121 switch (src.getValue()) { 122 case CURRENT: 123 tgt.setValue(ListResource.ListStatus.CURRENT); 124 break; 125 case RETIRED: 126 tgt.setValue(ListResource.ListStatus.RETIRED); 127 break; 128 case ENTEREDINERROR: 129 tgt.setValue(ListResource.ListStatus.ENTEREDINERROR); 130 break; 131 default: 132 tgt.setValue(ListResource.ListStatus.NULL); 133 break; 134 } 135 } 136 return tgt; 137 } 138 139 static public org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.ListResource.ListStatus> convertListStatus(org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.ListResource.ListStatus> src) throws FHIRException { 140 if (src == null || src.isEmpty()) 141 return null; 142 org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.ListResource.ListStatus> tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.ListResource.ListStatusEnumFactory()); 143 ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt); 144 if (src.getValue() == null) { 145 tgt.setValue(null); 146 } else { 147 switch (src.getValue()) { 148 case CURRENT: 149 tgt.setValue(org.hl7.fhir.r4.model.ListResource.ListStatus.CURRENT); 150 break; 151 case RETIRED: 152 tgt.setValue(org.hl7.fhir.r4.model.ListResource.ListStatus.RETIRED); 153 break; 154 case ENTEREDINERROR: 155 tgt.setValue(org.hl7.fhir.r4.model.ListResource.ListStatus.ENTEREDINERROR); 156 break; 157 default: 158 tgt.setValue(org.hl7.fhir.r4.model.ListResource.ListStatus.NULL); 159 break; 160 } 161 } 162 return tgt; 163 } 164 165 static public org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Enumerations.ListMode> convertListMode(org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.ListResource.ListMode> src) throws FHIRException { 166 if (src == null || src.isEmpty()) 167 return null; 168 Enumeration<Enumerations.ListMode> tgt = new Enumeration<>(new Enumerations.ListModeEnumFactory()); 169 ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt); 170 if (src.getValue() == null) { 171 tgt.setValue(null); 172 } else { 173 switch (src.getValue()) { 174 case WORKING: 175 tgt.setValue(Enumerations.ListMode.WORKING); 176 break; 177 case SNAPSHOT: 178 tgt.setValue(Enumerations.ListMode.SNAPSHOT); 179 break; 180 case CHANGES: 181 tgt.setValue(Enumerations.ListMode.CHANGES); 182 break; 183 default: 184 tgt.setValue(Enumerations.ListMode.NULL); 185 break; 186 } 187 } 188 return tgt; 189 } 190 191 static public org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.ListResource.ListMode> convertListMode(org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Enumerations.ListMode> src) throws FHIRException { 192 if (src == null || src.isEmpty()) 193 return null; 194 org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.ListResource.ListMode> tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.ListResource.ListModeEnumFactory()); 195 ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt); 196 if (src.getValue() == null) { 197 tgt.setValue(null); 198 } else { 199 switch (src.getValue()) { 200 case WORKING: 201 tgt.setValue(org.hl7.fhir.r4.model.ListResource.ListMode.WORKING); 202 break; 203 case SNAPSHOT: 204 tgt.setValue(org.hl7.fhir.r4.model.ListResource.ListMode.SNAPSHOT); 205 break; 206 case CHANGES: 207 tgt.setValue(org.hl7.fhir.r4.model.ListResource.ListMode.CHANGES); 208 break; 209 default: 210 tgt.setValue(org.hl7.fhir.r4.model.ListResource.ListMode.NULL); 211 break; 212 } 213 } 214 return tgt; 215 } 216 217 public static org.hl7.fhir.r5.model.ListResource.ListResourceEntryComponent convertListEntryComponent(org.hl7.fhir.r4.model.ListResource.ListEntryComponent src) throws FHIRException { 218 if (src == null) 219 return null; 220 org.hl7.fhir.r5.model.ListResource.ListResourceEntryComponent tgt = new org.hl7.fhir.r5.model.ListResource.ListResourceEntryComponent(); 221 ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyBackboneElement(src, tgt); 222 if (src.hasFlag()) 223 tgt.setFlag(CodeableConcept40_50.convertCodeableConcept(src.getFlag())); 224 if (src.hasDeleted()) 225 tgt.setDeletedElement(Boolean40_50.convertBoolean(src.getDeletedElement())); 226 if (src.hasDate()) 227 tgt.setDateElement(DateTime40_50.convertDateTime(src.getDateElement())); 228 if (src.hasItem()) 229 tgt.setItem(Reference40_50.convertReference(src.getItem())); 230 return tgt; 231 } 232 233 public static org.hl7.fhir.r4.model.ListResource.ListEntryComponent convertListEntryComponent(org.hl7.fhir.r5.model.ListResource.ListResourceEntryComponent src) throws FHIRException { 234 if (src == null) 235 return null; 236 org.hl7.fhir.r4.model.ListResource.ListEntryComponent tgt = new org.hl7.fhir.r4.model.ListResource.ListEntryComponent(); 237 ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyBackboneElement(src, tgt); 238 if (src.hasFlag()) 239 tgt.setFlag(CodeableConcept40_50.convertCodeableConcept(src.getFlag())); 240 if (src.hasDeleted()) 241 tgt.setDeletedElement(Boolean40_50.convertBoolean(src.getDeletedElement())); 242 if (src.hasDate()) 243 tgt.setDateElement(DateTime40_50.convertDateTime(src.getDateElement())); 244 if (src.hasItem()) 245 tgt.setItem(Reference40_50.convertReference(src.getItem())); 246 return tgt; 247 } 248}