
001package org.hl7.fhir.convertors.conv30_50.resources30_50; 002 003import org.hl7.fhir.convertors.context.ConversionContext30_50; 004import org.hl7.fhir.convertors.conv30_50.datatypes30_50.ContactDetail30_50; 005import org.hl7.fhir.convertors.conv30_50.datatypes30_50.Reference30_50; 006import org.hl7.fhir.convertors.conv30_50.datatypes30_50.UsageContext30_50; 007import org.hl7.fhir.convertors.conv30_50.datatypes30_50.complextypes30_50.CodeableConcept30_50; 008import org.hl7.fhir.convertors.conv30_50.datatypes30_50.complextypes30_50.Identifier30_50; 009import org.hl7.fhir.convertors.conv30_50.datatypes30_50.primitivetypes30_50.Boolean30_50; 010import org.hl7.fhir.convertors.conv30_50.datatypes30_50.primitivetypes30_50.DateTime30_50; 011import org.hl7.fhir.convertors.conv30_50.datatypes30_50.primitivetypes30_50.Id30_50; 012import org.hl7.fhir.convertors.conv30_50.datatypes30_50.primitivetypes30_50.MarkDown30_50; 013import org.hl7.fhir.convertors.conv30_50.datatypes30_50.primitivetypes30_50.String30_50; 014import org.hl7.fhir.convertors.conv30_50.datatypes30_50.primitivetypes30_50.Uri30_50; 015import org.hl7.fhir.dstu3.model.Extension; 016import org.hl7.fhir.exceptions.FHIRException; 017import org.hl7.fhir.r5.model.CanonicalType; 018import org.hl7.fhir.r5.model.CodeableConcept; 019import org.hl7.fhir.r5.model.ContactDetail; 020import org.hl7.fhir.r5.model.Enumeration; 021import org.hl7.fhir.r5.model.Enumerations.PublicationStatus; 022import org.hl7.fhir.r5.model.Reference; 023import org.hl7.fhir.r5.model.Requirements.ConformanceExpectation; 024import org.hl7.fhir.r5.model.Requirements.RequirementsStatementComponent; 025import org.hl7.fhir.r5.model.UrlType; 026import org.hl7.fhir.r5.model.UsageContext; 027 028/* 029 Copyright (c) 2011+, HL7, Inc. 030 All rights reserved. 031 032 Redistribution and use in source and binary forms, with or without modification, 033 are permitted provided that the following conditions are met: 034 035 * Redistributions of source code must retain the above copyright notice, this 036 list of conditions and the following disclaimer. 037 * Redistributions in binary form must reproduce the above copyright notice, 038 this list of conditions and the following disclaimer in the documentation 039 and/or other materials provided with the distribution. 040 * Neither the name of HL7 nor the names of its contributors may be used to 041 endorse or promote products derived from this software without specific 042 prior written permission. 043 044 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 045 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 046 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 047 IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 048 INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 049 NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 050 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 051 WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 052 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 053 POSSIBILITY OF SUCH DAMAGE. 054 055*/ 056// Generated on Sun, Feb 24, 2019 11:37+1100 for FHIR v4.0.0 057public class Requirements30_50 { 058 059 public static final String URL_EXTENSION_URL = "http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.url"; 060 public static final String VERSION_EXTENSION_URL = "http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.version"; 061 public static final String NAME_EXTENSION_URL = "http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.name"; 062 public static final String TITLE_EXTENSION_URL = "http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.title"; 063 public static final String STATUS_EXTENSION_URL = "http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.status"; 064 public static final String EXPERIMENTAL_EXTENSION_URL = "http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.experimental"; 065 public static final String DATE_EXTENSION_URL = "http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.date"; 066 public static final String PUBLISHER_EXTENSION_URL = "http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.publisher"; 067 public static final String CONTACT_EXTENSION_URL = "http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.contact"; 068 public static final String DESCRIPTION_EXTENSION_URL = "http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.description"; 069 public static final String USE_CONTEXT_EXTENSION_URL = "http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.useContext"; 070 public static final String JURISDICTION_EXTENSION_URL = "http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.jurisdiction"; 071 public static final String PURPOSE_EXTENSION_URL = "http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.purpose"; 072 public static final String COPYRIGHT_EXTENSION_URL = "http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.copyright"; 073 public static final String COPYRIGHT_LABEL_EXTENSION_URL = "http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.copyrightLabel"; 074 public static final String DERIVED_FROM_EXTENSION_URL = "http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.derivedFrom"; 075 public static final String ACTOR_EXTENSION_URL = "http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.actor"; 076 public static final String STATEMENT_EXTENSION_URL = "http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.statement"; 077 078 private static final String[] IGNORED_EXTENSION_URLS = new String[]{ 079 URL_EXTENSION_URL, 080 VERSION_EXTENSION_URL, 081 NAME_EXTENSION_URL, 082 TITLE_EXTENSION_URL, 083 STATUS_EXTENSION_URL, 084 EXPERIMENTAL_EXTENSION_URL, 085 DATE_EXTENSION_URL, 086 PUBLISHER_EXTENSION_URL, 087 CONTACT_EXTENSION_URL, 088 DESCRIPTION_EXTENSION_URL, 089 USE_CONTEXT_EXTENSION_URL, 090 JURISDICTION_EXTENSION_URL, 091 PURPOSE_EXTENSION_URL, 092 COPYRIGHT_EXTENSION_URL, 093 COPYRIGHT_LABEL_EXTENSION_URL, 094 DERIVED_FROM_EXTENSION_URL, 095 ACTOR_EXTENSION_URL, 096 STATEMENT_EXTENSION_URL 097 }; 098 public static org.hl7.fhir.r5.model.Requirements convertRequirements(org.hl7.fhir.dstu3.model.Basic src) throws FHIRException { 099 if (src == null) 100 return null; 101 if (!src.getCode().hasCoding("http://hl7.org/fhir/fhir-types", "Requirements")) { 102 throw new FHIRException("Error in logic: this basic resource is not an Requirements"); 103 } 104 org.hl7.fhir.r5.model.Requirements tgt = new org.hl7.fhir.r5.model.Requirements(); 105 106 ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyDomainResource(src, tgt, IGNORED_EXTENSION_URLS); 107 108 for (org.hl7.fhir.dstu3.model.Identifier t : src.getIdentifier()) 109 tgt.addIdentifier(Identifier30_50.convertIdentifier(t)); 110 111 if (src.hasExtension(URL_EXTENSION_URL)) { 112 tgt.setUrlElement(Uri30_50.convertUri((org.hl7.fhir.dstu3.model.UriType) src.getExtensionByUrl(URL_EXTENSION_URL).getValue())); 113 } 114 if (src.hasExtension(VERSION_EXTENSION_URL)) { 115 tgt.setVersionElement(String30_50.convertString((org.hl7.fhir.dstu3.model.StringType) src.getExtensionByUrl(VERSION_EXTENSION_URL).getValue())); 116 } 117 if (src.hasExtension(NAME_EXTENSION_URL)) { 118 tgt.setNameElement(String30_50.convertString((org.hl7.fhir.dstu3.model.StringType) src.getExtensionByUrl(NAME_EXTENSION_URL).getValue())); 119 } 120 if (src.hasExtension(TITLE_EXTENSION_URL)) { 121 tgt.setTitleElement(String30_50.convertString((org.hl7.fhir.dstu3.model.StringType) src.getExtensionByUrl(TITLE_EXTENSION_URL).getValue())); 122 } 123 if (src.hasExtension(STATUS_EXTENSION_URL)) { 124 tgt.setStatus(PublicationStatus.fromCode(src.getExtensionByUrl(STATUS_EXTENSION_URL).getValue().primitiveValue())); 125 } 126 if (src.hasExtension(EXPERIMENTAL_EXTENSION_URL)) { 127 tgt.setExperimentalElement(Boolean30_50.convertBoolean((org.hl7.fhir.dstu3.model.BooleanType) src.getExtensionByUrl(EXPERIMENTAL_EXTENSION_URL).getValue())); 128 } 129 if (src.hasExtension(DATE_EXTENSION_URL)) { 130 tgt.setDateElement(DateTime30_50.convertDateTime((org.hl7.fhir.dstu3.model.DateTimeType) src.getExtensionByUrl(DATE_EXTENSION_URL).getValue())); 131 } 132 if (src.hasExtension(PUBLISHER_EXTENSION_URL)) { 133 tgt.setPublisherElement(String30_50.convertString((org.hl7.fhir.dstu3.model.StringType) src.getExtensionByUrl(PUBLISHER_EXTENSION_URL).getValue())); 134 } 135 for (org.hl7.fhir.dstu3.model.Extension ext : src.getExtensionsByUrl(CONTACT_EXTENSION_URL)) { 136 tgt.addContact(ContactDetail30_50.convertContactDetail((org.hl7.fhir.dstu3.model.ContactDetail) ext.getValue())); 137 } 138 if (src.hasExtension(DESCRIPTION_EXTENSION_URL)) { 139 tgt.setPublisherElement(MarkDown30_50.convertMarkdown((org.hl7.fhir.dstu3.model.MarkdownType) src.getExtensionByUrl(DESCRIPTION_EXTENSION_URL).getValue())); 140 } 141 for (org.hl7.fhir.dstu3.model.Extension ext : src.getExtensionsByUrl(USE_CONTEXT_EXTENSION_URL)) { 142 tgt.addUseContext(UsageContext30_50.convertUsageContext((org.hl7.fhir.dstu3.model.UsageContext) ext.getValue())); 143 } 144 for (org.hl7.fhir.dstu3.model.Extension ext : src.getExtensionsByUrl(JURISDICTION_EXTENSION_URL)) { 145 tgt.addJurisdiction(CodeableConcept30_50.convertCodeableConcept((org.hl7.fhir.dstu3.model.CodeableConcept) ext.getValue())); 146 } 147 if (src.hasExtension(PURPOSE_EXTENSION_URL)) { 148 tgt.setPurposeElement(MarkDown30_50.convertMarkdown((org.hl7.fhir.dstu3.model.MarkdownType) src.getExtensionByUrl(PURPOSE_EXTENSION_URL).getValue())); 149 } 150 if (src.hasExtension(COPYRIGHT_EXTENSION_URL)) { 151 tgt.setCopyrightElement(MarkDown30_50.convertMarkdown((org.hl7.fhir.dstu3.model.MarkdownType) src.getExtensionByUrl(COPYRIGHT_EXTENSION_URL).getValue())); 152 } 153 if (src.hasExtension(COPYRIGHT_LABEL_EXTENSION_URL)) { 154 tgt.setCopyrightLabelElement(String30_50.convertString((org.hl7.fhir.dstu3.model.StringType) src.getExtensionByUrl(COPYRIGHT_LABEL_EXTENSION_URL).getValue())); 155 } 156 for (org.hl7.fhir.dstu3.model.Extension ext : src.getExtensionsByUrl(DERIVED_FROM_EXTENSION_URL)) { 157 tgt.getDerivedFrom().add(Uri30_50.convertCanonical((org.hl7.fhir.dstu3.model.UriType) ext.getValue())); 158 } 159 for (org.hl7.fhir.dstu3.model.Extension ext : src.getExtensionsByUrl(ACTOR_EXTENSION_URL)) { 160 tgt.getActor().add(Uri30_50.convertCanonical((org.hl7.fhir.dstu3.model.UriType) ext.getValue())); 161 } 162 for (org.hl7.fhir.dstu3.model.Extension ext : src.getExtensionsByUrl(STATEMENT_EXTENSION_URL)) { 163 convertRequirementsStatement(ext, tgt.addStatement()); 164 } 165 return tgt; 166 } 167 168 169 public static org.hl7.fhir.dstu3.model.Basic convertRequirements(org.hl7.fhir.r5.model.Requirements src) throws FHIRException { 170 if (src == null) 171 return null; 172 org.hl7.fhir.dstu3.model.Basic tgt = new org.hl7.fhir.dstu3.model.Basic(); 173 ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyDomainResource(src, tgt); 174 tgt.getCode().getCodingFirstRep().setSystem("http://hl7.org/fhir/fhir-types").setCode("Requirements"); // note use of R5 type system 175 176 for (org.hl7.fhir.r5.model.Identifier t : src.getIdentifier()) 177 tgt.addIdentifier(Identifier30_50.convertIdentifier(t)); 178 if (src.hasUrl()) { 179 tgt.addExtension(URL_EXTENSION_URL, Uri30_50.convertUri(src.getUrlElement())); 180 } 181 if (src.hasVersion()) { 182 tgt.addExtension(VERSION_EXTENSION_URL, String30_50.convertString(src.getVersionElement())); 183 } 184 if (src.hasName()) { 185 tgt.addExtension(NAME_EXTENSION_URL, String30_50.convertString(src.getNameElement())); 186 } 187 if (src.hasTitle()) { 188 tgt.addExtension(TITLE_EXTENSION_URL, String30_50.convertString(src.getTitleElement())); 189 } 190 if (src.hasStatus()) { 191 tgt.addExtension(STATUS_EXTENSION_URL, new org.hl7.fhir.dstu3.model.CodeType(src.getStatus().toCode())); 192 } 193 if (src.hasExperimental()) { 194 tgt.addExtension(EXPERIMENTAL_EXTENSION_URL, Boolean30_50.convertBoolean(src.getExperimentalElement())); 195 } 196 if (src.hasDate()) { 197 tgt.addExtension(DATE_EXTENSION_URL, DateTime30_50.convertDateTime(src.getDateElement())); 198 } 199 if (src.hasPublisher()) { 200 tgt.addExtension(PUBLISHER_EXTENSION_URL, String30_50.convertString(src.getPublisherElement())); 201 } 202 for (ContactDetail cd : src.getContact()) { 203 tgt.addExtension(CONTACT_EXTENSION_URL, ContactDetail30_50.convertContactDetail(cd)); 204 } 205 if (src.hasDescription()) { 206 tgt.addExtension(DESCRIPTION_EXTENSION_URL, MarkDown30_50.convertMarkdown(src.getDescriptionElement())); 207 } 208 for (UsageContext cd : src.getUseContext()) { 209 tgt.addExtension(USE_CONTEXT_EXTENSION_URL, UsageContext30_50.convertUsageContext(cd)); 210 } 211 for (CodeableConcept cd : src.getJurisdiction()) { 212 tgt.addExtension(JURISDICTION_EXTENSION_URL, CodeableConcept30_50.convertCodeableConcept(cd)); 213 } 214 if (src.hasPurpose()) { 215 tgt.addExtension(PURPOSE_EXTENSION_URL, MarkDown30_50.convertMarkdown(src.getPurposeElement())); 216 } 217 if (src.hasCopyright()) { 218 tgt.addExtension(COPYRIGHT_EXTENSION_URL, MarkDown30_50.convertMarkdown(src.getCopyrightElement())); 219 } 220 if (src.hasCopyrightLabel()) { 221 tgt.addExtension(COPYRIGHT_LABEL_EXTENSION_URL, String30_50.convertString(src.getCopyrightLabelElement())); 222 } 223 for (CanonicalType ref : src.getDerivedFrom()) { 224 tgt.addExtension(DERIVED_FROM_EXTENSION_URL, Uri30_50.convertCanonical(ref)); 225 } 226 for (CanonicalType ref : src.getActor()) { 227 tgt.addExtension(ACTOR_EXTENSION_URL, Uri30_50.convertCanonical(ref)); 228 } 229 for (RequirementsStatementComponent ref : src.getStatement()) { 230 org.hl7.fhir.dstu3.model.Extension tgte = new org.hl7.fhir.dstu3.model.Extension(STATEMENT_EXTENSION_URL); 231 tgt.addExtension(tgte); 232 convertRequirementsStatement(ref, tgte); 233 } 234 235 return tgt; 236 } 237 238 private static void convertRequirementsStatement(RequirementsStatementComponent src, Extension tgt) { 239 ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyElement(src, tgt); 240 if (src.hasKey()) { 241 tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.statement.key", Id30_50.convertId(src.getKeyElement())); 242 } 243 if (src.hasLabel()) { 244 tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.statement.label", String30_50.convertString(src.getLabelElement())); 245 } 246 for (Enumeration<ConformanceExpectation> t : src.getConformance()) { 247 tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.statement.conformance", new org.hl7.fhir.dstu3.model.CodeType(t.getCode())); 248 } 249 if (src.hasRequirement()) { 250 tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.statement.requirement", MarkDown30_50.convertMarkdown(src.getRequirementElement())); 251 } 252 if (src.hasDerivedFrom()) { 253 tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.statement.derivedFrom", String30_50.convertString(src.getDerivedFromElement())); 254 } 255 for (UrlType ref : src.getSatisfiedBy()) { 256 tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.statement.satisfiedBy", Uri30_50.convertUrl(ref)); 257 } 258 for (UrlType ref : src.getReference()) { 259 tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.statement.reference", Uri30_50.convertUrl(ref)); 260 } 261 for (Reference ref : src.getSource()) { 262 tgt.addExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.statement.source", Reference30_50.convertReference(ref)); 263 } 264 } 265 266 267 private static void convertRequirementsStatement(Extension src, RequirementsStatementComponent tgt) { 268 ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyElement(src, tgt, 269 "http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.statement.key", 270 "http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.statement.label", 271 "http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.statement.conformance", 272 "http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.statement.requirement", 273 "http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.statement.derivedFrom", 274 "http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.statement.satisfiedBy", 275 "http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.statement.reference", 276 "http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.statement.source" 277 ); 278 if (src.hasExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.statement.key")) { 279 tgt.setKeyElement(Id30_50.convertId((org.hl7.fhir.dstu3.model.IdType) src.getExtensionByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.statement.key").getValue())); 280 } 281 if (src.hasExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.statement.label")) { 282 tgt.setLabelElement(String30_50.convertString((org.hl7.fhir.dstu3.model.StringType) src.getExtensionByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.statement.label").getValue())); 283 } 284 for (org.hl7.fhir.dstu3.model.Extension ext : src.getExtensionsByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.statement.conformance")) { 285 tgt.addConformance(ConformanceExpectation.fromCode(ext.getValue().primitiveValue())); 286 } 287 if (src.hasExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.statement.requirement")) { 288 tgt.setRequirementElement(MarkDown30_50.convertMarkdown((org.hl7.fhir.dstu3.model.MarkdownType) src.getExtensionByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.statement.requirement").getValue())); 289 } 290 if (src.hasExtension("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.statement.derivedFrom")) { 291 tgt.setDerivedFromElement(String30_50.convertString((org.hl7.fhir.dstu3.model.StringType) src.getExtensionByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.statement.derivedFrom").getValue())); 292 } 293 for (org.hl7.fhir.dstu3.model.Extension ext : src.getExtensionsByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.statement.satisfiedBy")) { 294 tgt.getSatisfiedBy().add(Uri30_50.convertUrl((org.hl7.fhir.dstu3.model.UriType) ext.getValue())); 295 } 296 for (org.hl7.fhir.dstu3.model.Extension ext : src.getExtensionsByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.statement.reference")) { 297 tgt.getReference().add(Uri30_50.convertUrl((org.hl7.fhir.dstu3.model.UriType) ext.getValue())); 298 } 299 for (org.hl7.fhir.dstu3.model.Extension ext : src.getExtensionsByUrl("http://hl7.org/fhir/5.0/StructureDefinition/extension-Requirements.statement.source")) { 300 tgt.getSource().add(Reference30_50.convertReference((org.hl7.fhir.dstu3.model.Reference) ext.getValue())); 301 } 302 } 303}