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.Identifier40_50;
006import org.hl7.fhir.convertors.conv40_50.datatypes40_50.metadata40_50.ContactDetail40_50;
007import org.hl7.fhir.convertors.conv40_50.datatypes40_50.metadata40_50.UsageContext40_50;
008import org.hl7.fhir.convertors.conv40_50.datatypes40_50.primitive40_50.Boolean40_50;
009import org.hl7.fhir.convertors.conv40_50.datatypes40_50.primitive40_50.Canonical40_50;
010import org.hl7.fhir.convertors.conv40_50.datatypes40_50.primitive40_50.DateTime40_50;
011import org.hl7.fhir.convertors.conv40_50.datatypes40_50.primitive40_50.MarkDown40_50;
012import org.hl7.fhir.convertors.conv40_50.datatypes40_50.primitive40_50.String40_50;
013import org.hl7.fhir.convertors.conv40_50.datatypes40_50.primitive40_50.Uri40_50;
014import org.hl7.fhir.exceptions.FHIRException;
015import org.hl7.fhir.r4.model.BooleanType;
016import org.hl7.fhir.r4.model.Extension;
017import org.hl7.fhir.r4.model.MarkdownType;
018import org.hl7.fhir.r4.model.UriType;
019import org.hl7.fhir.r5.model.CanonicalType;
020import org.hl7.fhir.r5.model.CodeableConcept;
021import org.hl7.fhir.r5.model.ContactDetail;
022import org.hl7.fhir.r5.model.Enumeration;
023import org.hl7.fhir.r5.model.Enumerations.PublicationStatus;
024import org.hl7.fhir.r5.model.Enumerations.SearchComparator;
025import org.hl7.fhir.r5.model.Enumerations.SearchModifierCode;
026import org.hl7.fhir.r5.model.StringType;
027import org.hl7.fhir.r5.model.SubscriptionTopic.InteractionTrigger;
028import org.hl7.fhir.r5.model.SubscriptionTopic.SubscriptionTopicCanFilterByComponent;
029import org.hl7.fhir.r5.model.SubscriptionTopic.SubscriptionTopicEventTriggerComponent;
030import org.hl7.fhir.r5.model.SubscriptionTopic.SubscriptionTopicNotificationShapeComponent;
031import org.hl7.fhir.r5.model.SubscriptionTopic.SubscriptionTopicResourceTriggerComponent;
032import org.hl7.fhir.r5.model.SubscriptionTopic.SubscriptionTopicResourceTriggerQueryCriteriaComponent;
033import org.hl7.fhir.r5.model.UsageContext;
034
035/*
036  Copyright (c) 2011+, HL7, Inc.
037  All rights reserved.
038  
039  Redistribution and use in source and binary forms, with or without modification, 
040  are permitted provided that the following conditions are met:
041  
042   * Redistributions of source code must retain the above copyright notice, this 
043     list of conditions and the following disclaimer.
044   * Redistributions in binary form must reproduce the above copyright notice, 
045     this list of conditions and the following disclaimer in the documentation 
046     and/or other materials provided with the distribution.
047   * Neither the name of HL7 nor the names of its contributors may be used to 
048     endorse or promote products derived from this software without specific 
049     prior written permission.
050  
051  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 
052  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
053  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
054  IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 
055  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
056  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 
057  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
058  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
059  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
060  POSSIBILITY OF SUCH DAMAGE.
061  
062*/
063// Generated on Sun, Feb 24, 2019 11:37+1100 for FHIR v4.0.0
064public class SubscriptionTopic40_50 {
065
066  public static final String URL_EXTENSION_URL = "http://hl7.org/fhir/5.0/StructureDefinition/extension-SubscriptionTopic.url";
067  public static final String VERSION_EXTENSION_URL = "http://hl7.org/fhir/5.0/StructureDefinition/extension-SubscriptionTopic.version";
068  public static final String NAME_EXTENSION_URL = "http://hl7.org/fhir/5.0/StructureDefinition/extension-SubscriptionTopic.name";
069  public static final String TITLE_EXTENSION_URL = "http://hl7.org/fhir/5.0/StructureDefinition/extension-SubscriptionTopic.title";
070  public static final String STATUS_EXTENSION_URL = "http://hl7.org/fhir/5.0/StructureDefinition/extension-SubscriptionTopic.status";
071  public static final String EXPERIMENTAL_EXTENSION_URL = "http://hl7.org/fhir/5.0/StructureDefinition/extension-SubscriptionTopic.experimental";
072  public static final String DATE_EXTENSION_URL = "http://hl7.org/fhir/5.0/StructureDefinition/extension-SubscriptionTopic.date";
073  public static final String PUBLISHER_EXTENSION_URL = "http://hl7.org/fhir/5.0/StructureDefinition/extension-SubscriptionTopic.publisher";
074  public static final String CONTACT_EXTENSION_URL = "http://hl7.org/fhir/5.0/StructureDefinition/extension-SubscriptionTopic.contact";
075  public static final String DESCRIPTION_EXTENSION_URL = "http://hl7.org/fhir/5.0/StructureDefinition/extension-SubscriptionTopic.description";
076  public static final String USE_CONTEXT_EXTENSION_URL = "http://hl7.org/fhir/5.0/StructureDefinition/extension-SubscriptionTopic.useContext";
077  public static final String JURISDICTION_EXTENSION_URL = "http://hl7.org/fhir/5.0/StructureDefinition/extension-SubscriptionTopic.jurisdiction";
078  public static final String PURPOSE_EXTENSION_URL = "http://hl7.org/fhir/5.0/StructureDefinition/extension-SubscriptionTopic.purpose";
079  public static final String COPYRIGHT_EXTENSION_URL = "http://hl7.org/fhir/5.0/StructureDefinition/extension-SubscriptionTopic.copyright";
080  public static final String COPYRIGHT_LABEL_EXTENSION_URL = "http://hl7.org/fhir/5.0/StructureDefinition/extension-SubscriptionTopic.copyrightLabel";
081  public static final String APPROVAL_DATE_EXTENSION_URL = "http://hl7.org/fhir/5.0/StructureDefinition/extension-SubscriptionTopic.approvalDate";
082  public static final String LAST_REVIEW_EXTENSION_URL = "http://hl7.org/fhir/5.0/StructureDefinition/extension-SubscriptionTopic.lastReviewDate";
083  public static final String EFFECTIVE_PERIOD_EXTENSION_URL = "http://hl7.org/fhir/5.0/StructureDefinition/extension-SubscriptionTopic.effectivePeriod";
084  public static final String DERIVED_FROM_EXTENSION_URL = "http://hl7.org/fhir/5.0/StructureDefinition/extension-SubscriptionTopic.derivedFrom";
085  
086  public static final String RESOURCE_TRIGGER_EXTENSION_URL = "http://hl7.org/fhir/5.0/StructureDefinition/extension-SubscriptionTopic.resourceTrigger";
087  public static final String RESOURCE_TRIGGER_DESCRIPTION_EXTENSION_URL = /*http://hl7.org/fhir/5.0/StructureDefinition/extension-SubscriptionTopic.resourceTrigger.*/"description";
088  public static final String RESOURCE_TRIGGER_RESOURCE_EXTENSION_URL = /*http://hl7.org/fhir/5.0/StructureDefinition/extension-SubscriptionTopic.resourceTrigger.*/"resource";
089  public static final String RESOURCE_TRIGGER_SUPPORTED_INTERACTION_EXTENSION_URL = /*http://hl7.org/fhir/5.0/StructureDefinition/extension-SubscriptionTopic.resourceTrigger.*/"supportedInteraction";
090  public static final String RESOURCE_TRIGGER_QUERY_CRITERIA_EXTENSION_URL = /*http://hl7.org/fhir/5.0/StructureDefinition/extension-SubscriptionTopic.resourceTrigger.*/"queryCriteria";
091  public static final String RESOURCE_TRIGGER_QUERY_CRITERIA_PREVIOUS_EXTENSION_URL = /*http://hl7.org/fhir/5.0/StructureDefinition/extension-SubscriptionTopic.resourceTrigger.queryCriteria.*/"previous";
092  public static final String RESOURCE_TRIGGER_QUERY_CRITERIA_RESULT_FOR_CREATE_EXTENSION_URL = /*http://hl7.org/fhir/5.0/StructureDefinition/extension-SubscriptionTopic.resourceTrigger.queryCriteria.*/"resultForCreate";
093  public static final String RESOURCE_TRIGGER_QUERY_CRITERIA_CURRENT_EXTENSION_URL = /*http://hl7.org/fhir/5.0/StructureDefinition/extension-SubscriptionTopic.resourceTrigger.queryCriteria.*/"current";
094  public static final String RESOURCE_TRIGGER_QUERY_CRITERIA_RESULT_FOR_DELETE_EXTENSION_URL = /*http://hl7.org/fhir/5.0/StructureDefinition/extension-SubscriptionTopic.resourceTrigger.queryCriteria.*/"resultForDelete";
095  public static final String RESOURCE_TRIGGER_QUERY_CRITERIA_REQUIRE_BOTH_EXTENSION_URL = /*http://hl7.org/fhir/5.0/StructureDefinition/extension-SubscriptionTopic.resourceTrigger.queryCriteria.*/"requireBoth";
096  public static final String RESOURCE_TRIGGER_FHIRPATH_CRITERIA_EXTENSION_URL = /*http://hl7.org/fhir/5.0/StructureDefinition/extension-SubscriptionTopic.resourceTrigger.*/"fhirPathCriteria";
097  
098  public static final String EVENT_TRIGGER_EXTENSION_URL = "http://hl7.org/fhir/5.0/StructureDefinition/extension-SubscriptionTopic.eventTrigger";
099  public static final String EVENT_TRIGGER_DESCRIPTION_EXTENSION_URL = /*"http://hl7.org/fhir/5.0/StructureDefinition/extension-SubscriptionTopic.eventTrigger.*/"description";
100  public static final String EVENT_TRIGGER_EVENT_EXTENSION_URL = /*"http://hl7.org/fhir/5.0/StructureDefinition/extension-SubscriptionTopic.eventTrigger.*/"event";
101  public static final String EVENT_TRIGGER_RESOURCE_EXTENSION_URL = /*"http://hl7.org/fhir/5.0/StructureDefinition/extension-SubscriptionTopic.eventTrigger.*/"resource";
102  
103  public static final String CAN_FILTER_BY_EXTENSION_URL = "http://hl7.org/fhir/5.0/StructureDefinition/extension-SubscriptionTopic.canFilterBy";
104  public static final String CAN_FILTER_BY_DESCRIPTION_EXTENSION_URL = /*http://hl7.org/fhir/5.0/StructureDefinition/extension-SubscriptionTopic.canFilterBy.*/"description";
105  public static final String CAN_FILTER_BY_RESOURCE_EXTENSION_URL = /*http://hl7.org/fhir/5.0/StructureDefinition/extension-SubscriptionTopic.canFilterBy.*/"resource";
106  public static final String CAN_FILTER_BY_FILTER_PARMETER_EXTENSION_URL = /*http://hl7.org/fhir/5.0/StructureDefinition/extension-SubscriptionTopic.canFilterBy.*/"filterParameter";
107  public static final String CAN_FILTER_BY_FILTER_DEFINITION_EXTENSION_URL = /*http://hl7.org/fhir/5.0/StructureDefinition/extension-SubscriptionTopic.canFilterBy.*/"filterDefinition";
108  public static final String CAN_FILTER_BY_COMPARATOR_EXTENSION_URL = /*http://hl7.org/fhir/5.0/StructureDefinition/extension-SubscriptionTopic.canFilterBy.*/"comparator";
109  public static final String CAN_FILTER_BY_MODIFIER_EXTENSION_URL = /*http://hl7.org/fhir/5.0/StructureDefinition/extension-SubscriptionTopic.canFilterBy.*/"modifier";
110  
111  public static final String NOTIFICATION_SHAPE_EXTENSION_URL = "http://hl7.org/fhir/5.0/StructureDefinition/extension-SubscriptionTopic.notificationShape";
112  public static final String NOTIFICATION_SHAPE_RESOURCE_EXTENSION_URL = /*http://hl7.org/fhir/5.0/StructureDefinition/extension-SubscriptionTopic.notificationShape.*/"resource";
113  public static final String NOTIFICATION_SHAPE_INCLUDE_EXTENSION_URL = /*http://hl7.org/fhir/5.0/StructureDefinition/extension-SubscriptionTopic.notificationShape.*/"include";
114  public static final String NOTIFICATION_SHAPE_REV_INCLUDE_EXTENSION_URL = /*http://hl7.org/fhir/5.0/StructureDefinition/extension-SubscriptionTopic.notificationShape.*/"revInclude";
115  
116
117  private static final String[] IGNORED_EXTENSION_URLS = new String[]{
118    URL_EXTENSION_URL,
119    VERSION_EXTENSION_URL,
120    NAME_EXTENSION_URL,
121    TITLE_EXTENSION_URL,
122    STATUS_EXTENSION_URL,
123    EXPERIMENTAL_EXTENSION_URL,
124    DATE_EXTENSION_URL,
125    PUBLISHER_EXTENSION_URL,
126    CONTACT_EXTENSION_URL,
127    DESCRIPTION_EXTENSION_URL,
128    USE_CONTEXT_EXTENSION_URL,
129    JURISDICTION_EXTENSION_URL,
130    PURPOSE_EXTENSION_URL,
131    COPYRIGHT_EXTENSION_URL,
132    COPYRIGHT_LABEL_EXTENSION_URL,
133    RESOURCE_TRIGGER_EXTENSION_URL,
134    EVENT_TRIGGER_EXTENSION_URL,
135    CAN_FILTER_BY_EXTENSION_URL,
136    NOTIFICATION_SHAPE_EXTENSION_URL
137  };
138
139  public static org.hl7.fhir.r5.model.SubscriptionTopic convertSubscriptionTopic(org.hl7.fhir.r4.model.Basic src) throws FHIRException {
140    if (src == null)
141      return null;
142    if (!src.getCode().hasCoding("http://hl7.org/fhir/fhir-types", "SubscriptionTopic")) {
143      throw new FHIRException("Error in logic: this basic resource is not an SubscriptionTopic");
144    }
145    org.hl7.fhir.r5.model.SubscriptionTopic tgt = new org.hl7.fhir.r5.model.SubscriptionTopic();
146
147    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyDomainResource(src, tgt, IGNORED_EXTENSION_URLS);
148    
149    for (org.hl7.fhir.r4.model.Identifier t : src.getIdentifier())
150      tgt.addIdentifier(Identifier40_50.convertIdentifier(t));
151
152    if (src.hasExtension(URL_EXTENSION_URL)) {
153      tgt.setUrlElement(Uri40_50.convertUri((org.hl7.fhir.r4.model.UriType) src.getExtensionByUrl(URL_EXTENSION_URL).getValue()));
154    }
155    if (src.hasExtension(VERSION_EXTENSION_URL)) {
156      tgt.setVersionElement(String40_50.convertString((org.hl7.fhir.r4.model.StringType) src.getExtensionByUrl(VERSION_EXTENSION_URL).getValue()));
157    }
158    if (src.hasExtension(NAME_EXTENSION_URL)) {
159      tgt.setNameElement(String40_50.convertString((org.hl7.fhir.r4.model.StringType) src.getExtensionByUrl(NAME_EXTENSION_URL).getValue()));
160    }
161    if (src.hasExtension(TITLE_EXTENSION_URL)) {
162      tgt.setTitleElement(String40_50.convertString((org.hl7.fhir.r4.model.StringType) src.getExtensionByUrl(TITLE_EXTENSION_URL).getValue()));
163    }
164    if (src.hasExtension(STATUS_EXTENSION_URL)) {
165      tgt.setStatus(PublicationStatus.fromCode(src.getExtensionByUrl(STATUS_EXTENSION_URL).getValue().primitiveValue()));
166    }
167    if (src.hasExtension(EXPERIMENTAL_EXTENSION_URL)) {
168      tgt.setExperimentalElement(Boolean40_50.convertBoolean((org.hl7.fhir.r4.model.BooleanType) src.getExtensionByUrl(EXPERIMENTAL_EXTENSION_URL).getValue()));
169    }
170    if (src.hasExtension(DATE_EXTENSION_URL)) {
171      tgt.setDateElement(DateTime40_50.convertDateTime((org.hl7.fhir.r4.model.DateTimeType) src.getExtensionByUrl(DATE_EXTENSION_URL).getValue()));
172    }
173    if (src.hasExtension(PUBLISHER_EXTENSION_URL)) {
174      tgt.setPublisherElement(String40_50.convertString((org.hl7.fhir.r4.model.StringType) src.getExtensionByUrl(PUBLISHER_EXTENSION_URL).getValue()));
175    }
176    for (org.hl7.fhir.r4.model.Extension ext : src.getExtensionsByUrl(CONTACT_EXTENSION_URL)) {
177      tgt.addContact(ContactDetail40_50.convertContactDetail((org.hl7.fhir.r4.model.ContactDetail) ext.getValue()));
178    }
179    if (src.hasExtension(DESCRIPTION_EXTENSION_URL)) {
180      tgt.setDescriptionElement(MarkDown40_50.convertMarkdown((org.hl7.fhir.r4.model.MarkdownType) src.getExtensionByUrl(DESCRIPTION_EXTENSION_URL).getValue()));
181    }
182    for (org.hl7.fhir.r4.model.Extension ext : src.getExtensionsByUrl(USE_CONTEXT_EXTENSION_URL)) {
183      tgt.addUseContext(UsageContext40_50.convertUsageContext((org.hl7.fhir.r4.model.UsageContext) ext.getValue()));
184    }
185    for (org.hl7.fhir.r4.model.Extension ext : src.getExtensionsByUrl(JURISDICTION_EXTENSION_URL)) {
186      tgt.addJurisdiction(CodeableConcept40_50.convertCodeableConcept((org.hl7.fhir.r4.model.CodeableConcept) ext.getValue()));
187    }
188    if (src.hasExtension(PURPOSE_EXTENSION_URL)) {
189      tgt.setPurposeElement(MarkDown40_50.convertMarkdown((org.hl7.fhir.r4.model.MarkdownType) src.getExtensionByUrl(PURPOSE_EXTENSION_URL).getValue()));
190    }
191    if (src.hasExtension(COPYRIGHT_EXTENSION_URL)) {
192      tgt.setCopyrightElement(MarkDown40_50.convertMarkdown((org.hl7.fhir.r4.model.MarkdownType) src.getExtensionByUrl(COPYRIGHT_EXTENSION_URL).getValue()));
193    }
194    if (src.hasExtension(COPYRIGHT_LABEL_EXTENSION_URL)) {
195      tgt.setCopyrightLabelElement(String40_50.convertString((org.hl7.fhir.r4.model.StringType) src.getExtensionByUrl(COPYRIGHT_LABEL_EXTENSION_URL).getValue()));
196    }
197    for (org.hl7.fhir.r4.model.Extension ext : src.getExtensionsByUrl(DERIVED_FROM_EXTENSION_URL)) {
198      tgt.getDerivedFrom().add(Canonical40_50.convertCanonical((org.hl7.fhir.r4.model.CanonicalType) ext.getValue()));
199    }
200    
201    for (org.hl7.fhir.r4.model.Extension ext : src.getExtensionsByUrl(RESOURCE_TRIGGER_EXTENSION_URL)) {
202      convertSubscriptionResourceTrigger(ext, tgt.addResourceTrigger());
203    }
204    for (org.hl7.fhir.r4.model.Extension ext : src.getExtensionsByUrl(EVENT_TRIGGER_EXTENSION_URL)) {
205      convertSubscriptionEventTrigger(ext, tgt.addEventTrigger());
206    }
207    for (org.hl7.fhir.r4.model.Extension ext : src.getExtensionsByUrl(CAN_FILTER_BY_EXTENSION_URL)) {
208      convertSubscriptionCanFilterBy(ext, tgt.addCanFilterBy());
209    }    
210    for (org.hl7.fhir.r4.model.Extension ext : src.getExtensionsByUrl(NOTIFICATION_SHAPE_EXTENSION_URL)) {
211      convertSubscriptionNotificationShape(ext, tgt.addNotificationShape());
212    }
213    
214    return tgt;
215  }
216
217
218  public static org.hl7.fhir.r4.model.Basic convertSubscriptionTopic(org.hl7.fhir.r5.model.SubscriptionTopic src) throws FHIRException {
219    if (src == null)
220      return null;
221    org.hl7.fhir.r4.model.Basic tgt = new org.hl7.fhir.r4.model.Basic();
222    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyDomainResource(src, tgt);
223    tgt.getCode().getCodingFirstRep().setSystem("http://hl7.org/fhir/fhir-types").setCode("SubscriptionTopic"); // note use of R5 type system
224    
225    for (org.hl7.fhir.r5.model.Identifier t : src.getIdentifier())
226      tgt.addIdentifier(Identifier40_50.convertIdentifier(t));
227    if (src.hasUrl()) {
228      tgt.addExtension(URL_EXTENSION_URL, Uri40_50.convertUri(src.getUrlElement()));
229    }
230    if (src.hasVersion()) {
231      tgt.addExtension(VERSION_EXTENSION_URL, String40_50.convertString(src.getVersionElement()));
232    }
233    if (src.hasName()) {
234      tgt.addExtension(NAME_EXTENSION_URL, String40_50.convertString(src.getNameElement()));
235    }
236    if (src.hasTitle()) {
237      tgt.addExtension(TITLE_EXTENSION_URL, String40_50.convertString(src.getTitleElement()));
238    }
239    if (src.hasStatus()) {
240      tgt.addExtension(STATUS_EXTENSION_URL, new org.hl7.fhir.r4.model.CodeType(src.getStatus().toCode()));
241    }
242    if (src.hasExperimental()) {
243      tgt.addExtension(EXPERIMENTAL_EXTENSION_URL, Boolean40_50.convertBoolean(src.getExperimentalElement()));
244    }
245    if (src.hasDate()) {
246      tgt.addExtension(DATE_EXTENSION_URL, DateTime40_50.convertDateTime(src.getDateElement()));
247    }
248    if (src.hasPublisher()) {
249      tgt.addExtension(PUBLISHER_EXTENSION_URL, String40_50.convertString(src.getPublisherElement()));
250    }
251    for (ContactDetail cd : src.getContact()) {
252      tgt.addExtension(CONTACT_EXTENSION_URL, ContactDetail40_50.convertContactDetail(cd));
253    }
254    if (src.hasDescription()) {
255      tgt.addExtension(DESCRIPTION_EXTENSION_URL, MarkDown40_50.convertMarkdown(src.getDescriptionElement()));
256    }
257    for (UsageContext cd : src.getUseContext()) {
258      tgt.addExtension(USE_CONTEXT_EXTENSION_URL, UsageContext40_50.convertUsageContext(cd));
259    }
260    for (CodeableConcept cd : src.getJurisdiction()) {
261      tgt.addExtension(JURISDICTION_EXTENSION_URL, CodeableConcept40_50.convertCodeableConcept(cd));
262    }
263    if (src.hasPurpose()) {
264      tgt.addExtension(PURPOSE_EXTENSION_URL, MarkDown40_50.convertMarkdown(src.getPurposeElement()));
265    }
266    if (src.hasCopyright()) {
267      tgt.addExtension(COPYRIGHT_EXTENSION_URL, MarkDown40_50.convertMarkdown(src.getCopyrightElement()));
268    }
269    if (src.hasCopyrightLabel()) {
270      tgt.addExtension(COPYRIGHT_LABEL_EXTENSION_URL, String40_50.convertString(src.getCopyrightLabelElement()));
271    }
272    for (CanonicalType ref : src.getDerivedFrom()) {
273      tgt.addExtension(DERIVED_FROM_EXTENSION_URL, Canonical40_50.convertCanonical(ref));
274    }
275
276    for (SubscriptionTopicResourceTriggerComponent ref : src.getResourceTrigger()) {
277      org.hl7.fhir.r4.model.Extension tgte = new org.hl7.fhir.r4.model.Extension(RESOURCE_TRIGGER_EXTENSION_URL);
278      tgt.addExtension(tgte);
279      convertSubscriptionResourceTrigger(ref, tgte);
280    }
281    for (SubscriptionTopicEventTriggerComponent ref : src.getEventTrigger()) {
282      org.hl7.fhir.r4.model.Extension tgte = new org.hl7.fhir.r4.model.Extension(EVENT_TRIGGER_EXTENSION_URL);
283      tgt.addExtension(tgte);
284      convertSubscriptionEventTrigger(ref, tgte);
285    }
286    for (SubscriptionTopicCanFilterByComponent ref : src.getCanFilterBy()) {
287      org.hl7.fhir.r4.model.Extension tgte = new org.hl7.fhir.r4.model.Extension(CAN_FILTER_BY_EXTENSION_URL);
288      tgt.addExtension(tgte);
289      convertSubscriptionCanFilterBy(ref, tgte);
290    }
291    for (SubscriptionTopicNotificationShapeComponent ref : src.getNotificationShape()) {
292      org.hl7.fhir.r4.model.Extension tgte = new org.hl7.fhir.r4.model.Extension(NOTIFICATION_SHAPE_EXTENSION_URL);
293      tgt.addExtension(tgte);
294      convertSubscriptionNotificationShape(ref, tgte);
295    }
296
297    return tgt;
298  }
299
300  private static void convertSubscriptionResourceTrigger(SubscriptionTopicResourceTriggerComponent src, Extension tgt) {
301    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt);
302    if (src.hasDescription()) {
303      tgt.addExtension(RESOURCE_TRIGGER_DESCRIPTION_EXTENSION_URL, MarkDown40_50.convertMarkdown(src.getDescriptionElement()));
304    }
305    if (src.hasResource()) {
306      tgt.addExtension(RESOURCE_TRIGGER_RESOURCE_EXTENSION_URL, Uri40_50.convertUri(src.getResourceElement()));
307    }
308    for (Enumeration<InteractionTrigger> t : src.getSupportedInteraction()) {
309      tgt.addExtension(RESOURCE_TRIGGER_SUPPORTED_INTERACTION_EXTENSION_URL, new org.hl7.fhir.r4.model.CodeType(t.getCode()));
310    }
311    if (src.hasQueryCriteria()) {
312      Extension tgtQF = new Extension(RESOURCE_TRIGGER_QUERY_CRITERIA_EXTENSION_URL);
313      tgt.addExtension(tgtQF);
314      if (src.getQueryCriteria().hasPrevious()) {
315        tgtQF.addExtension(RESOURCE_TRIGGER_QUERY_CRITERIA_PREVIOUS_EXTENSION_URL, String40_50.convertString(src.getQueryCriteria().getPreviousElement()));
316      }
317      if (src.getQueryCriteria().hasResultForCreate()) {
318        tgtQF.addExtension(RESOURCE_TRIGGER_QUERY_CRITERIA_RESULT_FOR_CREATE_EXTENSION_URL, new org.hl7.fhir.r4.model.CodeType(src.getQueryCriteria().getResultForCreate().toCode()));
319      }
320      if (src.getQueryCriteria().hasCurrent()) {
321        tgtQF.addExtension(RESOURCE_TRIGGER_QUERY_CRITERIA_CURRENT_EXTENSION_URL, String40_50.convertString(src.getQueryCriteria().getCurrentElement()));
322      }
323      if (src.getQueryCriteria().hasResultForDelete()) {
324        tgtQF.addExtension(RESOURCE_TRIGGER_QUERY_CRITERIA_RESULT_FOR_DELETE_EXTENSION_URL, new org.hl7.fhir.r4.model.CodeType(src.getQueryCriteria().getResultForDelete().toCode()));
325      }
326      if (src.getQueryCriteria().hasRequireBoth()) {
327        tgtQF.addExtension(RESOURCE_TRIGGER_QUERY_CRITERIA_REQUIRE_BOTH_EXTENSION_URL, Boolean40_50.convertBoolean(src.getQueryCriteria().getRequireBothElement()));
328      }
329    }
330    if (src.hasFhirPathCriteria()) {
331      tgt.addExtension(RESOURCE_TRIGGER_FHIRPATH_CRITERIA_EXTENSION_URL, String40_50.convertString(src.getFhirPathCriteriaElement()));
332    }
333  }
334
335  private static void convertSubscriptionResourceTrigger(Extension src, SubscriptionTopicResourceTriggerComponent tgt) {
336    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt, 
337        RESOURCE_TRIGGER_DESCRIPTION_EXTENSION_URL, RESOURCE_TRIGGER_RESOURCE_EXTENSION_URL, RESOURCE_TRIGGER_QUERY_CRITERIA_EXTENSION_URL,
338        RESOURCE_TRIGGER_SUPPORTED_INTERACTION_EXTENSION_URL, RESOURCE_TRIGGER_FHIRPATH_CRITERIA_EXTENSION_URL);
339    if (src.hasExtension(RESOURCE_TRIGGER_DESCRIPTION_EXTENSION_URL)) {
340      tgt.setDescriptionElement(MarkDown40_50.convertMarkdown((MarkdownType) src.getExtensionByUrl(RESOURCE_TRIGGER_DESCRIPTION_EXTENSION_URL).getValue()));
341    }
342    if (src.hasExtension(RESOURCE_TRIGGER_RESOURCE_EXTENSION_URL)) {
343      tgt.setResourceElement(Uri40_50.convertUri((UriType) src.getExtensionByUrl(RESOURCE_TRIGGER_RESOURCE_EXTENSION_URL).getValue()));
344    }
345    for (Extension ext : src.getExtensionsByUrl(RESOURCE_TRIGGER_SUPPORTED_INTERACTION_EXTENSION_URL)) {
346      tgt.addSupportedInteractionElement().setValueAsString(ext.getValue().primitiveValue());
347    }
348    if (src.hasExtension(RESOURCE_TRIGGER_QUERY_CRITERIA_EXTENSION_URL)) {
349      Extension srcQF = src.getExtensionByUrl(RESOURCE_TRIGGER_QUERY_CRITERIA_EXTENSION_URL); 
350      SubscriptionTopicResourceTriggerQueryCriteriaComponent tgtQF = tgt.getQueryCriteria();
351      if (srcQF.hasExtension(RESOURCE_TRIGGER_QUERY_CRITERIA_PREVIOUS_EXTENSION_URL)) {
352        tgtQF.setPreviousElement(String40_50.convertString((org.hl7.fhir.r4.model.StringType) srcQF.getExtensionByUrl(RESOURCE_TRIGGER_QUERY_CRITERIA_PREVIOUS_EXTENSION_URL).getValue()));
353      }
354      if (srcQF.hasExtension(RESOURCE_TRIGGER_QUERY_CRITERIA_RESULT_FOR_CREATE_EXTENSION_URL)) {
355        tgtQF.getResultForCreateElement().setValueAsString(srcQF.getExtensionByUrl(RESOURCE_TRIGGER_QUERY_CRITERIA_RESULT_FOR_CREATE_EXTENSION_URL).getValue().primitiveValue());
356      }
357      if (srcQF.hasExtension(RESOURCE_TRIGGER_QUERY_CRITERIA_CURRENT_EXTENSION_URL)) {
358        tgtQF.setCurrentElement(String40_50.convertString((org.hl7.fhir.r4.model.StringType) srcQF.getExtensionByUrl(RESOURCE_TRIGGER_QUERY_CRITERIA_CURRENT_EXTENSION_URL).getValue()));
359      }
360      if (srcQF.hasExtension(RESOURCE_TRIGGER_QUERY_CRITERIA_RESULT_FOR_DELETE_EXTENSION_URL)) {
361        tgtQF.getResultForDeleteElement().setValueAsString(srcQF.getExtensionByUrl(RESOURCE_TRIGGER_QUERY_CRITERIA_RESULT_FOR_DELETE_EXTENSION_URL).getValue().primitiveValue());
362      }
363      if (srcQF.hasExtension(RESOURCE_TRIGGER_QUERY_CRITERIA_REQUIRE_BOTH_EXTENSION_URL)) {
364        tgtQF.setRequireBothElement(Boolean40_50.convertBoolean((BooleanType) srcQF.getExtensionByUrl(RESOURCE_TRIGGER_QUERY_CRITERIA_REQUIRE_BOTH_EXTENSION_URL).getValue()));
365      }
366    }
367    if (src.hasExtension(RESOURCE_TRIGGER_FHIRPATH_CRITERIA_EXTENSION_URL)) {
368      tgt.setFhirPathCriteriaElement(String40_50.convertString((org.hl7.fhir.r4.model.StringType) src.getExtensionByUrl(RESOURCE_TRIGGER_FHIRPATH_CRITERIA_EXTENSION_URL).getValue()));
369    }
370  }
371
372  private static void convertSubscriptionEventTrigger(SubscriptionTopicEventTriggerComponent src, Extension tgt) {
373    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt);
374    if (src.hasDescription()) {
375      tgt.addExtension(EVENT_TRIGGER_DESCRIPTION_EXTENSION_URL, MarkDown40_50.convertMarkdown(src.getDescriptionElement()));
376    }
377    if (src.hasResource()) {
378      tgt.addExtension(EVENT_TRIGGER_RESOURCE_EXTENSION_URL, Uri40_50.convertUri(src.getResourceElement()));
379    }
380    if (src.hasEvent()) {
381      tgt.addExtension(EVENT_TRIGGER_EVENT_EXTENSION_URL, CodeableConcept40_50.convertCodeableConcept(src.getEvent()));
382    }
383  }
384  
385  private static void convertSubscriptionEventTrigger(Extension src, SubscriptionTopicEventTriggerComponent tgt) {
386    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt, EVENT_TRIGGER_DESCRIPTION_EXTENSION_URL, EVENT_TRIGGER_RESOURCE_EXTENSION_URL, EVENT_TRIGGER_EVENT_EXTENSION_URL);
387    if (src.hasExtension(EVENT_TRIGGER_DESCRIPTION_EXTENSION_URL)) {
388      tgt.setDescriptionElement(MarkDown40_50.convertMarkdown((MarkdownType) src.getExtensionByUrl(EVENT_TRIGGER_DESCRIPTION_EXTENSION_URL).getValue()));
389    }
390    if (src.hasExtension(EVENT_TRIGGER_RESOURCE_EXTENSION_URL)) {
391      tgt.setResourceElement(Uri40_50.convertUri((UriType) src.getExtensionByUrl(EVENT_TRIGGER_RESOURCE_EXTENSION_URL).getValue()));
392    }
393    if (src.hasExtension(EVENT_TRIGGER_EVENT_EXTENSION_URL)) {
394      tgt.setEvent(CodeableConcept40_50.convertCodeableConcept((org.hl7.fhir.r4.model.CodeableConcept) src.getExtensionByUrl(EVENT_TRIGGER_EVENT_EXTENSION_URL).getValue()));
395    }
396  }
397
398  private static void convertSubscriptionCanFilterBy(SubscriptionTopicCanFilterByComponent src, Extension tgt) {
399    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt);
400    if (src.hasDescription()) {
401      tgt.addExtension(CAN_FILTER_BY_DESCRIPTION_EXTENSION_URL, MarkDown40_50.convertMarkdown(src.getDescriptionElement()));
402    }
403    if (src.hasResource()) {
404      tgt.addExtension(CAN_FILTER_BY_RESOURCE_EXTENSION_URL, Uri40_50.convertUri(src.getResourceElement()));
405    }
406    if (src.hasFilterParameter()) {
407      tgt.addExtension(CAN_FILTER_BY_FILTER_PARMETER_EXTENSION_URL, String40_50.convertString(src.getFilterParameterElement()));
408    }
409    if (src.hasFilterDefinition()) {
410      tgt.addExtension(CAN_FILTER_BY_FILTER_DEFINITION_EXTENSION_URL, Uri40_50.convertUri(src.getFilterDefinitionElement()));
411    }
412
413    for (Enumeration<SearchComparator> t : src.getComparator()) {
414      tgt.addExtension(CAN_FILTER_BY_COMPARATOR_EXTENSION_URL, new org.hl7.fhir.r4.model.CodeType(t.getCode()));
415    }
416    for (Enumeration<SearchModifierCode> t : src.getModifier()) {
417      tgt.addExtension(CAN_FILTER_BY_MODIFIER_EXTENSION_URL, new org.hl7.fhir.r4.model.CodeType(t.getCode()));
418    }
419  }
420
421  private static void convertSubscriptionCanFilterBy(Extension src, SubscriptionTopicCanFilterByComponent tgt) {
422    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt,
423        CAN_FILTER_BY_DESCRIPTION_EXTENSION_URL, CAN_FILTER_BY_RESOURCE_EXTENSION_URL, CAN_FILTER_BY_FILTER_PARMETER_EXTENSION_URL, 
424        CAN_FILTER_BY_FILTER_DEFINITION_EXTENSION_URL, CAN_FILTER_BY_COMPARATOR_EXTENSION_URL, CAN_FILTER_BY_MODIFIER_EXTENSION_URL);
425    
426    if (src.hasExtension(CAN_FILTER_BY_DESCRIPTION_EXTENSION_URL)) {
427      tgt.setDescriptionElement(MarkDown40_50.convertMarkdown((MarkdownType) src.getExtensionByUrl(CAN_FILTER_BY_DESCRIPTION_EXTENSION_URL).getValue()));
428    }
429    if (src.hasExtension(CAN_FILTER_BY_RESOURCE_EXTENSION_URL)) {
430      tgt.setResourceElement(Uri40_50.convertUri((UriType) src.getExtensionByUrl(CAN_FILTER_BY_RESOURCE_EXTENSION_URL).getValue()));
431    }
432    if (src.hasExtension(CAN_FILTER_BY_FILTER_PARMETER_EXTENSION_URL)) {
433      tgt.setFilterParameterElement(String40_50.convertString((org.hl7.fhir.r4.model.StringType) src.getExtensionByUrl(CAN_FILTER_BY_FILTER_PARMETER_EXTENSION_URL).getValue()));
434    }
435    if (src.hasExtension(CAN_FILTER_BY_FILTER_DEFINITION_EXTENSION_URL)) {
436      tgt.setFilterDefinitionElement(Uri40_50.convertUri((UriType) src.getExtensionByUrl(CAN_FILTER_BY_FILTER_DEFINITION_EXTENSION_URL).getValue()));
437    }
438
439    for (Extension ext : src.getExtensionsByUrl(CAN_FILTER_BY_COMPARATOR_EXTENSION_URL)) {
440      tgt.addComparatorElement().setValueAsString(ext.getValue().primitiveValue());
441    }
442    for (Extension ext : src.getExtensionsByUrl(CAN_FILTER_BY_MODIFIER_EXTENSION_URL)) {
443      tgt.addModifierElement().setValueAsString(ext.getValue().primitiveValue());
444    }
445  }
446
447  
448  private static void convertSubscriptionNotificationShape(SubscriptionTopicNotificationShapeComponent src, Extension tgt) {
449    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt);
450    if (src.hasResource()) {
451      tgt.addExtension(NOTIFICATION_SHAPE_RESOURCE_EXTENSION_URL, Uri40_50.convertUri(src.getResourceElement()));
452    }
453
454    for (StringType t : src.getInclude()) {
455      tgt.addExtension(NOTIFICATION_SHAPE_INCLUDE_EXTENSION_URL, String40_50.convertString(t));
456    }
457    for (StringType t : src.getRevInclude()) {
458      tgt.addExtension(NOTIFICATION_SHAPE_REV_INCLUDE_EXTENSION_URL, String40_50.convertString(t));
459    }
460  }
461
462
463  private static void convertSubscriptionNotificationShape(Extension src, SubscriptionTopicNotificationShapeComponent tgt) {
464    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt, NOTIFICATION_SHAPE_RESOURCE_EXTENSION_URL, NOTIFICATION_SHAPE_INCLUDE_EXTENSION_URL, NOTIFICATION_SHAPE_REV_INCLUDE_EXTENSION_URL);
465    if (src.hasExtension(NOTIFICATION_SHAPE_RESOURCE_EXTENSION_URL)) {
466      tgt.setResourceElement(Uri40_50.convertUri((UriType) src.getExtensionByUrl(NOTIFICATION_SHAPE_RESOURCE_EXTENSION_URL).getValue()));
467    }
468    for (Extension ext : src.getExtensionsByUrl(NOTIFICATION_SHAPE_INCLUDE_EXTENSION_URL)) {
469      tgt.addIncludeElement().setValueAsString(ext.getValue().primitiveValue());
470    }
471    for (Extension ext : src.getExtensionsByUrl(NOTIFICATION_SHAPE_REV_INCLUDE_EXTENSION_URL)) {
472      tgt.addRevIncludeElement().setValueAsString(ext.getValue().primitiveValue());
473    }
474  }
475
476}