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.CodeableConcept43_50;
005import org.hl7.fhir.convertors.conv43_50.datatypes43_50.general43_50.Identifier43_50;
006import org.hl7.fhir.convertors.conv43_50.datatypes43_50.metadata43_50.ContactDetail43_50;
007import org.hl7.fhir.convertors.conv43_50.datatypes43_50.metadata43_50.UsageContext43_50;
008import org.hl7.fhir.convertors.conv43_50.datatypes43_50.primitive43_50.Boolean43_50;
009import org.hl7.fhir.convertors.conv43_50.datatypes43_50.primitive43_50.Canonical43_50;
010import org.hl7.fhir.convertors.conv43_50.datatypes43_50.primitive43_50.DateTime43_50;
011import org.hl7.fhir.convertors.conv43_50.datatypes43_50.primitive43_50.MarkDown43_50;
012import org.hl7.fhir.convertors.conv43_50.datatypes43_50.primitive43_50.String43_50;
013import org.hl7.fhir.convertors.conv43_50.datatypes43_50.primitive43_50.Uri43_50;
014import org.hl7.fhir.convertors.conv43_50.datatypes43_50.primitive43_50.Url43_50;
015import org.hl7.fhir.exceptions.FHIRException;
016import org.hl7.fhir.r5.model.CanonicalType;
017import org.hl7.fhir.r5.model.CodeableConcept;
018import org.hl7.fhir.r5.model.ContactDetail;
019import org.hl7.fhir.r5.model.Enumerations.ExampleScenarioActorType;
020import org.hl7.fhir.r5.model.Enumerations.PublicationStatus;
021import org.hl7.fhir.r5.model.UrlType;
022import org.hl7.fhir.r5.model.UsageContext;
023
024/*
025  Copyright (c) 2011+, HL7, Inc.
026  All rights reserved.
027  
028  Redistribution and use in source and binary forms, with or without modification, 
029  are permitted provided that the following conditions are met:
030  
031   * Redistributions of source code must retain the above copyright notice, this 
032     list of conditions and the following disclaimer.
033   * Redistributions in binary form must reproduce the above copyright notice, 
034     this list of conditions and the following disclaimer in the documentation 
035     and/or other materials provided with the distribution.
036   * Neither the name of HL7 nor the names of its contributors may be used to 
037     endorse or promote products derived from this software without specific 
038     prior written permission.
039  
040  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 
041  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
042  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
043  IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 
044  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
045  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 
046  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
047  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
048  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
049  POSSIBILITY OF SUCH DAMAGE.
050  
051*/
052// Generated on Sun, Feb 24, 2019 11:37+1100 for FHIR v4.0.0
053public class ActorDefinition43_50 {
054
055  public static final String URL_EXTENSION_URL = "http://hl7.org/fhir/5.0/StructureDefinition/extension-ActorDefinition.url";
056  public static final String VERSION_EXTENSION_URL = "http://hl7.org/fhir/5.0/StructureDefinition/extension-ActorDefinition.version";
057  public static final String NAME_EXTENSION_URL = "http://hl7.org/fhir/5.0/StructureDefinition/extension-ActorDefinition.name";
058  public static final String TITLE_EXTENSION_URL = "http://hl7.org/fhir/5.0/StructureDefinition/extension-ActorDefinition.title";
059  public static final String STATUS_EXTENSION_URL = "http://hl7.org/fhir/5.0/StructureDefinition/extension-ActorDefinition.status";
060  public static final String EXPERIMENTAL_EXTENSION_URL = "http://hl7.org/fhir/5.0/StructureDefinition/extension-ActorDefinition.experimental";
061  public static final String DATE_EXTENSION_URL = "http://hl7.org/fhir/5.0/StructureDefinition/extension-ActorDefinition.date";
062  public static final String PUBLISHER_EXTENSION_URL = "http://hl7.org/fhir/5.0/StructureDefinition/extension-ActorDefinition.publisher";
063  public static final String CONTACT_EXTENSION_URL = "http://hl7.org/fhir/5.0/StructureDefinition/extension-ActorDefinition.contact";
064  public static final String DESCRIPTION_EXTENSION_URL = "http://hl7.org/fhir/5.0/StructureDefinition/extension-ActorDefinition.description";
065  public static final String USE_CONTEXT_EXTENSION_URL = "http://hl7.org/fhir/5.0/StructureDefinition/extension-ActorDefinition.useContext";
066  public static final String JURISDICTION_EXTENSION_URL = "http://hl7.org/fhir/5.0/StructureDefinition/extension-ActorDefinition.jurisdiction";
067  public static final String PURPOSE_EXTENSION_URL = "http://hl7.org/fhir/5.0/StructureDefinition/extension-ActorDefinition.purpose";
068  public static final String COPYRIGHT_EXTENSION_URL = "http://hl7.org/fhir/5.0/StructureDefinition/extension-ActorDefinition.copyright";
069  public static final String COPYRIGHT_LABEL_EXTENSION_URL = "http://hl7.org/fhir/5.0/StructureDefinition/extension-ActorDefinition.copyrightLabel";
070  public static final String TYPE_EXTENSION_URL = "http://hl7.org/fhir/5.0/StructureDefinition/extension-ActorDefinition.type";
071  public static final String DOCUMENTATION_EXTENSION_URL = "http://hl7.org/fhir/5.0/StructureDefinition/extension-ActorDefinition.documentation";
072  public static final String REFERENCE_EXTENSION_URL = "http://hl7.org/fhir/5.0/StructureDefinition/extension-ActorDefinition.reference";
073  public static final String CAPABILITIES_EXTENSION_URL = "http://hl7.org/fhir/5.0/StructureDefinition/extension-ActorDefinition.capabilities";
074  public static final String DERIVED_FROM_EXTENSION_URL = "http://hl7.org/fhir/5.0/StructureDefinition/extension-ActorDefinition.derivedFrom";
075
076  private static final String[] IGNORED_EXTENSION_URLS = new String[]{
077    URL_EXTENSION_URL,
078    VERSION_EXTENSION_URL,
079    NAME_EXTENSION_URL,
080    TITLE_EXTENSION_URL,
081    STATUS_EXTENSION_URL,
082    EXPERIMENTAL_EXTENSION_URL,
083    DATE_EXTENSION_URL,
084    PUBLISHER_EXTENSION_URL,
085    CONTACT_EXTENSION_URL,
086    DESCRIPTION_EXTENSION_URL,
087    USE_CONTEXT_EXTENSION_URL,
088    JURISDICTION_EXTENSION_URL,
089    PURPOSE_EXTENSION_URL,
090    COPYRIGHT_EXTENSION_URL,
091    COPYRIGHT_LABEL_EXTENSION_URL,
092    TYPE_EXTENSION_URL,
093    DOCUMENTATION_EXTENSION_URL,
094    REFERENCE_EXTENSION_URL,
095    CAPABILITIES_EXTENSION_URL,
096    DERIVED_FROM_EXTENSION_URL
097  };
098
099  public static org.hl7.fhir.r5.model.ActorDefinition convertActorDefinition(org.hl7.fhir.r4b.model.Basic src) throws FHIRException {
100    if (src == null)
101      return null;
102    if (!src.getCode().hasCoding("http://hl7.org/fhir/fhir-types", "ActorDefinition")) {
103      throw new FHIRException("Error in logic: this basic resource is not an ActorDefinition");
104    }
105    org.hl7.fhir.r5.model.ActorDefinition tgt = new org.hl7.fhir.r5.model.ActorDefinition();
106
107    ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyDomainResource(src, tgt, IGNORED_EXTENSION_URLS);
108    
109    for (org.hl7.fhir.r4b.model.Identifier t : src.getIdentifier())
110      tgt.addIdentifier(Identifier43_50.convertIdentifier(t));
111
112    if (src.hasExtension(URL_EXTENSION_URL)) {
113      tgt.setUrlElement(Uri43_50.convertUri((org.hl7.fhir.r4b.model.UriType) src.getExtensionByUrl(URL_EXTENSION_URL).getValue()));
114    }
115    if (src.hasExtension(VERSION_EXTENSION_URL)) {
116      tgt.setVersionElement(String43_50.convertString((org.hl7.fhir.r4b.model.StringType) src.getExtensionByUrl(VERSION_EXTENSION_URL).getValue()));
117    }
118    if (src.hasExtension(NAME_EXTENSION_URL)) {
119      tgt.setNameElement(String43_50.convertString((org.hl7.fhir.r4b.model.StringType) src.getExtensionByUrl(NAME_EXTENSION_URL).getValue()));
120    }
121    if (src.hasExtension(TITLE_EXTENSION_URL)) {
122      tgt.setTitleElement(String43_50.convertString((org.hl7.fhir.r4b.model.StringType) src.getExtensionByUrl(TITLE_EXTENSION_URL).getValue()));
123    }
124    if (src.hasExtension(STATUS_EXTENSION_URL)) {
125      tgt.setStatus(PublicationStatus.fromCode(src.getExtensionByUrl(STATUS_EXTENSION_URL).getValue().primitiveValue()));
126    }
127    if (src.hasExtension(EXPERIMENTAL_EXTENSION_URL)) {
128      tgt.setExperimentalElement(Boolean43_50.convertBoolean((org.hl7.fhir.r4b.model.BooleanType) src.getExtensionByUrl(EXPERIMENTAL_EXTENSION_URL).getValue()));
129    }
130    if (src.hasExtension(DATE_EXTENSION_URL)) {
131      tgt.setDateElement(DateTime43_50.convertDateTime((org.hl7.fhir.r4b.model.DateTimeType) src.getExtensionByUrl(DATE_EXTENSION_URL).getValue()));
132    }
133    if (src.hasExtension(PUBLISHER_EXTENSION_URL)) {
134      tgt.setPublisherElement(String43_50.convertString((org.hl7.fhir.r4b.model.StringType) src.getExtensionByUrl(PUBLISHER_EXTENSION_URL).getValue()));
135    }
136    for (org.hl7.fhir.r4b.model.Extension ext : src.getExtensionsByUrl(CONTACT_EXTENSION_URL)) {
137      tgt.addContact(ContactDetail43_50.convertContactDetail((org.hl7.fhir.r4b.model.ContactDetail) ext.getValue()));
138    }
139    if (src.hasExtension(DESCRIPTION_EXTENSION_URL)) {
140      tgt.setPublisherElement(MarkDown43_50.convertMarkdown((org.hl7.fhir.r4b.model.MarkdownType) src.getExtensionByUrl(DESCRIPTION_EXTENSION_URL).getValue()));
141    }
142    for (org.hl7.fhir.r4b.model.Extension ext : src.getExtensionsByUrl(USE_CONTEXT_EXTENSION_URL)) {
143      tgt.addUseContext(UsageContext43_50.convertUsageContext((org.hl7.fhir.r4b.model.UsageContext) ext.getValue()));
144    }
145    for (org.hl7.fhir.r4b.model.Extension ext : src.getExtensionsByUrl(JURISDICTION_EXTENSION_URL)) {
146      tgt.addJurisdiction(CodeableConcept43_50.convertCodeableConcept((org.hl7.fhir.r4b.model.CodeableConcept) ext.getValue()));
147    }
148    if (src.hasExtension(PURPOSE_EXTENSION_URL)) {
149      tgt.setPurposeElement(MarkDown43_50.convertMarkdown((org.hl7.fhir.r4b.model.MarkdownType) src.getExtensionByUrl(PURPOSE_EXTENSION_URL).getValue()));
150    }
151    if (src.hasExtension(COPYRIGHT_EXTENSION_URL)) {
152      tgt.setCopyrightElement(MarkDown43_50.convertMarkdown((org.hl7.fhir.r4b.model.MarkdownType) src.getExtensionByUrl(COPYRIGHT_EXTENSION_URL).getValue()));
153    }
154    if (src.hasExtension(COPYRIGHT_LABEL_EXTENSION_URL)) {
155      tgt.setCopyrightLabelElement(String43_50.convertString((org.hl7.fhir.r4b.model.StringType) src.getExtensionByUrl(COPYRIGHT_LABEL_EXTENSION_URL).getValue()));
156    }
157    if (src.hasExtension(TYPE_EXTENSION_URL)) {
158      tgt.setType(ExampleScenarioActorType.fromCode(src.getExtensionByUrl(TYPE_EXTENSION_URL).getValue().primitiveValue()));
159    }
160    if (src.hasExtension(DOCUMENTATION_EXTENSION_URL)) {
161      tgt.setDocumentationElement(MarkDown43_50.convertMarkdown((org.hl7.fhir.r4b.model.MarkdownType) src.getExtensionByUrl(DOCUMENTATION_EXTENSION_URL).getValue()));
162    }
163    for (org.hl7.fhir.r4b.model.Extension ext : src.getExtensionsByUrl(REFERENCE_EXTENSION_URL)) {
164      tgt.getReference().add(Url43_50.convertUrl((org.hl7.fhir.r4b.model.UrlType) ext.getValue()));
165    }
166    if (src.hasExtension(CAPABILITIES_EXTENSION_URL)) {
167      tgt.setCapabilitiesElement(Canonical43_50.convertCanonical((org.hl7.fhir.r4b.model.CanonicalType) src.getExtensionByUrl(CAPABILITIES_EXTENSION_URL).getValue()));
168    }
169    for (org.hl7.fhir.r4b.model.Extension ext : src.getExtensionsByUrl(DERIVED_FROM_EXTENSION_URL)) {
170      tgt.getDerivedFrom().add(Canonical43_50.convertCanonical((org.hl7.fhir.r4b.model.CanonicalType) ext.getValue()));
171    }
172    return tgt;
173  }
174
175  public static org.hl7.fhir.r4b.model.Basic convertActorDefinition(org.hl7.fhir.r5.model.ActorDefinition src) throws FHIRException {
176    if (src == null)
177      return null;
178    org.hl7.fhir.r4b.model.Basic tgt = new org.hl7.fhir.r4b.model.Basic();
179    ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyDomainResource(src, tgt);
180    tgt.getCode().getCodingFirstRep().setSystem("http://hl7.org/fhir/fhir-types").setCode("ActorDefinition"); // note use of R5 type system
181    
182    for (org.hl7.fhir.r5.model.Identifier t : src.getIdentifier())
183      tgt.addIdentifier(Identifier43_50.convertIdentifier(t));
184    if (src.hasUrl()) {
185      tgt.addExtension(URL_EXTENSION_URL, Uri43_50.convertUri(src.getUrlElement()));
186    }
187    if (src.hasVersion()) {
188      tgt.addExtension(VERSION_EXTENSION_URL, String43_50.convertString(src.getVersionElement()));
189    }
190    if (src.hasName()) {
191      tgt.addExtension(NAME_EXTENSION_URL, String43_50.convertString(src.getNameElement()));
192    }
193    if (src.hasTitle()) {
194      tgt.addExtension(TITLE_EXTENSION_URL, String43_50.convertString(src.getTitleElement()));
195    }
196    if (src.hasStatus()) {
197      tgt.addExtension(STATUS_EXTENSION_URL, new org.hl7.fhir.r4b.model.CodeType(src.getStatus().toCode()));
198    }
199    if (src.hasExperimental()) {
200      tgt.addExtension(EXPERIMENTAL_EXTENSION_URL, Boolean43_50.convertBoolean(src.getExperimentalElement()));
201    }
202    if (src.hasDate()) {
203      tgt.addExtension(DATE_EXTENSION_URL, DateTime43_50.convertDateTime(src.getDateElement()));
204    }
205    if (src.hasPublisher()) {
206      tgt.addExtension(PUBLISHER_EXTENSION_URL, String43_50.convertString(src.getPublisherElement()));
207    }
208    for (ContactDetail cd : src.getContact()) {
209      tgt.addExtension(CONTACT_EXTENSION_URL, ContactDetail43_50.convertContactDetail(cd));
210    }
211    if (src.hasDescription()) {
212      tgt.addExtension(DESCRIPTION_EXTENSION_URL, MarkDown43_50.convertMarkdown(src.getDescriptionElement()));
213    }
214    for (UsageContext cd : src.getUseContext()) {
215      tgt.addExtension(USE_CONTEXT_EXTENSION_URL, UsageContext43_50.convertUsageContext(cd));
216    }
217    for (CodeableConcept cd : src.getJurisdiction()) {
218      tgt.addExtension(JURISDICTION_EXTENSION_URL, CodeableConcept43_50.convertCodeableConcept(cd));
219    }
220    if (src.hasPurpose()) {
221      tgt.addExtension(PURPOSE_EXTENSION_URL, MarkDown43_50.convertMarkdown(src.getPurposeElement()));
222    }
223    if (src.hasCopyright()) {
224      tgt.addExtension(COPYRIGHT_EXTENSION_URL, MarkDown43_50.convertMarkdown(src.getCopyrightElement()));
225    }
226    if (src.hasCopyrightLabel()) {
227      tgt.addExtension(COPYRIGHT_LABEL_EXTENSION_URL, String43_50.convertString(src.getCopyrightLabelElement()));
228    }
229    if (src.hasType()) {
230      tgt.addExtension(TYPE_EXTENSION_URL, new org.hl7.fhir.r4b.model.CodeType(src.getType().toCode()));
231    }
232    if (src.hasDocumentation()) {
233      tgt.addExtension(DOCUMENTATION_EXTENSION_URL, MarkDown43_50.convertMarkdown(src.getDocumentationElement()));
234    }   
235    for (UrlType ref : src.getReference()) {
236      tgt.addExtension(REFERENCE_EXTENSION_URL, Url43_50.convertUrl(ref));
237    }
238    if (src.hasCapabilities()) {
239      tgt.addExtension(CAPABILITIES_EXTENSION_URL, Canonical43_50.convertCanonical(src.getCapabilitiesElement()));
240    }   
241    for (CanonicalType ct : src.getDerivedFrom()) {
242      tgt.addExtension(DERIVED_FROM_EXTENSION_URL, Canonical43_50.convertCanonical(ct));
243    }
244
245    return tgt;
246  }
247
248}