001package org.hl7.fhir.convertors.conv43_50.resources43_50;
002
003import java.util.List;
004import java.util.stream.Collectors;
005import java.util.stream.Stream;
006
007import org.hl7.fhir.convertors.context.ConversionContext43_50;
008import org.hl7.fhir.convertors.conv43_50.datatypes43_50.general43_50.CodeableConcept43_50;
009import org.hl7.fhir.convertors.conv43_50.datatypes43_50.general43_50.Identifier43_50;
010import org.hl7.fhir.convertors.conv43_50.datatypes43_50.general43_50.Period43_50;
011import org.hl7.fhir.convertors.conv43_50.datatypes43_50.metadata43_50.ContactDetail43_50;
012import org.hl7.fhir.convertors.conv43_50.datatypes43_50.metadata43_50.UsageContext43_50;
013import org.hl7.fhir.convertors.conv43_50.datatypes43_50.primitive43_50.Boolean43_50;
014import org.hl7.fhir.convertors.conv43_50.datatypes43_50.primitive43_50.Canonical43_50;
015import org.hl7.fhir.convertors.conv43_50.datatypes43_50.primitive43_50.Date43_50;
016import org.hl7.fhir.convertors.conv43_50.datatypes43_50.primitive43_50.DateTime43_50;
017import org.hl7.fhir.convertors.conv43_50.datatypes43_50.primitive43_50.MarkDown43_50;
018import org.hl7.fhir.convertors.conv43_50.datatypes43_50.primitive43_50.String43_50;
019import org.hl7.fhir.convertors.conv43_50.datatypes43_50.primitive43_50.Uri43_50;
020import org.hl7.fhir.r4b.model.Enumeration;
021import org.hl7.fhir.r4b.model.SubscriptionTopic;
022import org.hl7.fhir.r5.model.Enumerations;
023
024public class SubscriptionTopic43_50 {
025
026
027  public static final String NAME_EXTENSION_URL = "http://hl7.org/fhir/5.0/StructureDefinition/extension-SubscriptionTopic.name";
028  public static final String COPYRIGHT_LABEL_EXTENSION_URL = "http://hl7.org/fhir/5.0/StructureDefinition/extension-SubscriptionTopic.copyrightLabel";
029
030  private static final String[] IGNORED_EXTENSION_URLS = new String[]{
031    NAME_EXTENSION_URL,
032    COPYRIGHT_LABEL_EXTENSION_URL
033  };
034
035  public static org.hl7.fhir.r4b.model.SubscriptionTopic convertSubscriptionTopic(org.hl7.fhir.r5.model.SubscriptionTopic src) {
036    if (src == null)
037      return null;
038    org.hl7.fhir.r4b.model.SubscriptionTopic tgt = new org.hl7.fhir.r4b.model.SubscriptionTopic();
039    ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyResource(src, tgt);
040    ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyDomainResource(src, tgt);
041    if (src.hasUrl())
042      tgt.setUrlElement(Uri43_50.convertUri(src.getUrlElement()));
043    for (org.hl7.fhir.r5.model.Identifier t : src.getIdentifier())
044      tgt.addIdentifier(Identifier43_50.convertIdentifier(t));
045    if (src.hasTitle())
046      tgt.setTitleElement(String43_50.convertString(src.getTitleElement()));
047    for (org.hl7.fhir.r5.model.CanonicalType t : src.getDerivedFrom())
048      tgt.getDerivedFrom().add(Canonical43_50.convertCanonical(t));
049    if (src.hasStatus())
050      tgt.setStatusElement(Enumerations43_50.convertPublicationStatus(src.getStatusElement()));
051    if (src.hasVersion())
052      tgt.setVersionElement(String43_50.convertString(src.getVersionElement()));
053    if (src.hasTitle())
054      tgt.setTitleElement(String43_50.convertString(src.getTitleElement()));
055    if (src.hasStatus())
056      tgt.setStatusElement(Enumerations43_50.convertPublicationStatus(src.getStatusElement()));
057    if (src.hasExperimental())
058      tgt.setExperimentalElement(Boolean43_50.convertBoolean(src.getExperimentalElement()));
059    if (src.hasDate())
060      tgt.setDateElement(DateTime43_50.convertDateTime(src.getDateElement()));
061    if (src.hasPublisher())
062      tgt.setPublisherElement(String43_50.convertString(src.getPublisherElement()));
063    for (org.hl7.fhir.r5.model.ContactDetail t : src.getContact())
064      tgt.addContact(ContactDetail43_50.convertContactDetail(t));
065    if (src.hasDescription())
066      tgt.setDescriptionElement(MarkDown43_50.convertMarkdown(src.getDescriptionElement()));
067    for (org.hl7.fhir.r5.model.UsageContext t : src.getUseContext())
068      tgt.addUseContext(UsageContext43_50.convertUsageContext(t));
069    for (org.hl7.fhir.r5.model.CodeableConcept t : src.getJurisdiction())
070      tgt.addJurisdiction(CodeableConcept43_50.convertCodeableConcept(t));
071    if (src.hasPurpose())
072      tgt.setPurposeElement(MarkDown43_50.convertMarkdown(src.getPurposeElement()));
073    if (src.hasCopyright())
074      tgt.setCopyrightElement(MarkDown43_50.convertMarkdown(src.getCopyrightElement()));
075    if (src.hasCopyrightLabel()) {
076      tgt.addExtension(COPYRIGHT_LABEL_EXTENSION_URL, String43_50.convertString(src.getCopyrightLabelElement()));
077    }
078    if (src.hasName()) {
079      tgt.addExtension(NAME_EXTENSION_URL, String43_50.convertString(src.getNameElement()));
080    }
081    if (src.hasApprovalDate())
082      tgt.setApprovalDateElement(Date43_50.convertDate(src.getApprovalDateElement()));
083    if (src.hasLastReviewDate())
084      tgt.setLastReviewDateElement(Date43_50.convertDate(src.getLastReviewDateElement()));
085    if (src.hasEffectivePeriod())
086      tgt.setEffectivePeriod(Period43_50.convertPeriod(src.getEffectivePeriod()));
087    for(org.hl7.fhir.r5.model.SubscriptionTopic.SubscriptionTopicResourceTriggerComponent triggerComponent : src.getResourceTrigger()) {
088     tgt.addResourceTrigger(convertResourceTrigger(triggerComponent));}
089    for (org.hl7.fhir.r5.model.SubscriptionTopic.SubscriptionTopicCanFilterByComponent canFilterByComponent : src.getCanFilterBy()) {
090      tgt.addCanFilterBy(convertCanFilterBy(canFilterByComponent));
091    }
092    for (org.hl7.fhir.r5.model.SubscriptionTopic.SubscriptionTopicEventTriggerComponent eventTrigger : src.getEventTrigger()) {
093      tgt.addEventTrigger(convertEventTrigger(eventTrigger));
094    }
095    for (org.hl7.fhir.r5.model.SubscriptionTopic.SubscriptionTopicNotificationShapeComponent notificationShape : src.getNotificationShape()) {
096      tgt.addNotificationShape(convertNotificationShape(notificationShape));
097    }
098    return tgt;
099  }
100
101  private static SubscriptionTopic.SubscriptionTopicEventTriggerComponent convertEventTrigger(org.hl7.fhir.r5.model.SubscriptionTopic.SubscriptionTopicEventTriggerComponent src) {
102    org.hl7.fhir.r4b.model.SubscriptionTopic.SubscriptionTopicEventTriggerComponent tgt = new org.hl7.fhir.r4b.model.SubscriptionTopic.SubscriptionTopicEventTriggerComponent();
103    if (src.hasDescription()) {
104      tgt.setDescriptionElement(MarkDown43_50.convertMarkdown(src.getDescriptionElement()));
105    }
106    if (src.hasEvent()) {
107      tgt.setEvent(CodeableConcept43_50.convertCodeableConcept(src.getEvent()));
108    }
109    if (src.hasResource()) {
110      tgt.setResourceElement(Uri43_50.convertUri(src.getResourceElement()));
111    }
112    return tgt;
113  }
114
115  private static org.hl7.fhir.r4b.model.SubscriptionTopic.SubscriptionTopicNotificationShapeComponent convertNotificationShape(org.hl7.fhir.r5.model.SubscriptionTopic.SubscriptionTopicNotificationShapeComponent src) {
116    org.hl7.fhir.r4b.model.SubscriptionTopic.SubscriptionTopicNotificationShapeComponent tgt = new org.hl7.fhir.r4b.model.SubscriptionTopic.SubscriptionTopicNotificationShapeComponent();
117    if (src.hasResource()) {
118      tgt.setResourceElement(Uri43_50.convertUri(src.getResourceElement()));
119    }
120    if (src.hasInclude()) {
121      tgt.setInclude(src.getInclude().stream().map(String43_50::convertString).collect(Collectors.toList()));
122    }
123    if (src.hasRevInclude()) {
124      tgt.setRevInclude(src.getRevInclude().stream().map(String43_50::convertString).collect(Collectors.toList()));
125    }
126    return tgt;
127  }
128
129  private static org.hl7.fhir.r4b.model.SubscriptionTopic.SubscriptionTopicCanFilterByComponent convertCanFilterBy(org.hl7.fhir.r5.model.SubscriptionTopic.SubscriptionTopicCanFilterByComponent src) {
130    org.hl7.fhir.r4b.model.SubscriptionTopic.SubscriptionTopicCanFilterByComponent tgt = new org.hl7.fhir.r4b.model.SubscriptionTopic.SubscriptionTopicCanFilterByComponent();
131    if (src.hasDescription()) {
132      tgt.setDescriptionElement(MarkDown43_50.convertMarkdown(src.getDescriptionElement()));
133    }
134    if (src.hasResource()) {
135      tgt.setResourceElement(Uri43_50.convertUri(src.getResourceElement()));
136    }
137    if (src.hasFilterParameter()) {
138      tgt.setFilterParameterElement(String43_50.convertString(src.getFilterParameterElement()));
139    }
140    if (src.hasFilterDefinition()) {
141      // TODO r4b spec has this, but the Java model does not
142    }
143    if (src.hasModifier() || src.hasComparator()) {
144      List<org.hl7.fhir.r4b.model.Enumeration<org.hl7.fhir.r4b.model.SubscriptionTopic.SubscriptionSearchModifier>> tgtModifiers = convertR5ModifierToR4BModifier(src.getModifier());
145
146      List<org.hl7.fhir.r4b.model.Enumeration<org.hl7.fhir.r4b.model.SubscriptionTopic.SubscriptionSearchModifier>> tgtComparatorModifiers = convertR5ComparatorToR4BModifier(src.getComparator());
147
148      tgt.setModifier(Stream.concat(tgtModifiers.stream(), tgtComparatorModifiers.stream())
149        .collect(Collectors.toList()));
150    }
151
152    return tgt;
153  }
154
155  private static List<org.hl7.fhir.r4b.model.Enumeration<org.hl7.fhir.r4b.model.SubscriptionTopic.SubscriptionSearchModifier>> convertR5ComparatorToR4BModifier(List<org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Enumerations.SearchComparator>> srcList) {
156    return srcList.stream().map(SubscriptionTopic43_50::convertR5ComparatorToR4BModifier).filter(x -> x != null).collect(Collectors.toList());
157  }
158
159  private static org.hl7.fhir.r4b.model.Enumeration<org.hl7.fhir.r4b.model.SubscriptionTopic.SubscriptionSearchModifier> convertR5ComparatorToR4BModifier(org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Enumerations.SearchComparator> src) {
160      SubscriptionTopic.SubscriptionSearchModifierEnumFactory enumFactory = new SubscriptionTopic.SubscriptionSearchModifierEnumFactory();
161      if (src.getValue() == null) {
162          return null;
163      } else {
164          switch (src.getValue()) {
165              case NULL:
166                  return new Enumeration<>(enumFactory, SubscriptionTopic.SubscriptionSearchModifier.NULL);
167              case EQ:
168                  return new Enumeration<>(enumFactory, SubscriptionTopic.SubscriptionSearchModifier.EQ);
169              case NE:
170                  return new Enumeration<>(enumFactory, SubscriptionTopic.SubscriptionSearchModifier.NE);
171              case GT:
172                  return new Enumeration<>(enumFactory, SubscriptionTopic.SubscriptionSearchModifier.GT);
173              case LT:
174                  return new Enumeration<>(enumFactory, SubscriptionTopic.SubscriptionSearchModifier.LT);
175              case GE:
176                  return new Enumeration<>(enumFactory, SubscriptionTopic.SubscriptionSearchModifier.GE);
177              case LE:
178                  return new Enumeration<>(enumFactory, SubscriptionTopic.SubscriptionSearchModifier.LE);
179              case SA:
180                  return new Enumeration<>(enumFactory, SubscriptionTopic.SubscriptionSearchModifier.SA);
181              case EB:
182                  return new Enumeration<>(enumFactory, SubscriptionTopic.SubscriptionSearchModifier.EB);
183              case AP:
184                  return new Enumeration<>(enumFactory, SubscriptionTopic.SubscriptionSearchModifier.AP);
185          }
186      }
187      return null;
188  }
189
190  private static List<org.hl7.fhir.r4b.model.Enumeration<org.hl7.fhir.r4b.model.SubscriptionTopic.SubscriptionSearchModifier>> convertR5ModifierToR4BModifier(List<org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Enumerations.SearchModifierCode>> srcList) {
191    return srcList.stream().map(SubscriptionTopic43_50::convertR5ModifierToR4BModifier).filter(x -> x != null).collect(Collectors.toList());
192  }
193
194  private static org.hl7.fhir.r4b.model.Enumeration<org.hl7.fhir.r4b.model.SubscriptionTopic.SubscriptionSearchModifier> convertR5ModifierToR4BModifier(org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Enumerations.SearchModifierCode> src) {
195      SubscriptionTopic.SubscriptionSearchModifierEnumFactory enumFactory = new SubscriptionTopic.SubscriptionSearchModifierEnumFactory();
196      if (src.getValue() == null) {
197          return null;
198      } else {
199          switch (src.getValue()) {
200              case NULL:
201                  return new Enumeration<>(enumFactory, SubscriptionTopic.SubscriptionSearchModifier.NULL);
202              case IN:
203                  return new Enumeration<>(enumFactory, SubscriptionTopic.SubscriptionSearchModifier.IN);
204              case NOTIN:
205                  return new Enumeration<>(enumFactory, SubscriptionTopic.SubscriptionSearchModifier.NOTIN);
206              case BELOW:
207                  return new Enumeration<>(enumFactory, SubscriptionTopic.SubscriptionSearchModifier.BELOW);
208              case ABOVE:
209                  return new Enumeration<>(enumFactory, SubscriptionTopic.SubscriptionSearchModifier.ABOVE);
210              case OFTYPE:
211                  return new Enumeration<>(enumFactory, SubscriptionTopic.SubscriptionSearchModifier.OFTYPE);
212          }
213      }
214      return null;
215  }
216  private static org.hl7.fhir.r4b.model.SubscriptionTopic.SubscriptionTopicResourceTriggerComponent convertResourceTrigger(org.hl7.fhir.r5.model.SubscriptionTopic.SubscriptionTopicResourceTriggerComponent src) {
217    org.hl7.fhir.r4b.model.SubscriptionTopic.SubscriptionTopicResourceTriggerComponent tgt = new org.hl7.fhir.r4b.model.SubscriptionTopic.SubscriptionTopicResourceTriggerComponent();
218    ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyBackboneElement(src, tgt);
219  if (src.hasDescription()) {
220    tgt.setDescriptionElement(MarkDown43_50.convertMarkdown(src.getDescriptionElement()));
221  }
222    if (src.hasResource()) {
223      tgt.setResourceElement(Uri43_50.convertUri(src.getResourceElement()));
224    }
225    if (src.hasSupportedInteraction()) {
226      for (org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.SubscriptionTopic.InteractionTrigger> srcItem : src.getSupportedInteraction()) {
227        org.hl7.fhir.r4b.model.Enumeration<org.hl7.fhir.r4b.model.SubscriptionTopic.InteractionTrigger> newElement = tgt.addSupportedInteractionElement();
228        newElement.setValue(convertInteractionTrigger(srcItem.getValue()));
229      }
230    }
231    if (src.hasQueryCriteria()) {
232      tgt.setQueryCriteria(convertResourceTriggerQueryCriteriaComponent(src.getQueryCriteria()));
233    }
234    if (src.hasFhirPathCriteria()) {
235      tgt.setFhirPathCriteriaElement(String43_50.convertString(src.getFhirPathCriteriaElement()));
236    }
237    return tgt;
238  }
239
240  private static org.hl7.fhir.r4b.model.SubscriptionTopic.SubscriptionTopicResourceTriggerQueryCriteriaComponent convertResourceTriggerQueryCriteriaComponent(org.hl7.fhir.r5.model.SubscriptionTopic.SubscriptionTopicResourceTriggerQueryCriteriaComponent src) {
241    org.hl7.fhir.r4b.model.SubscriptionTopic.SubscriptionTopicResourceTriggerQueryCriteriaComponent tgt = new org.hl7.fhir.r4b.model.SubscriptionTopic.SubscriptionTopicResourceTriggerQueryCriteriaComponent();
242    if (src.hasPrevious()) {
243      tgt.setPreviousElement(String43_50.convertString(src.getPreviousElement()));
244    }
245    if (src.hasResultForCreate()) {
246      tgt.setResultForCreateElement(convertCriteriaNotExistsBehavior(src.getResultForCreateElement()));
247    }
248    if (src.hasCurrent()) {
249      tgt.setCurrentElement(String43_50.convertString(src.getCurrentElement()));
250    }
251    if (src.hasResultForDelete()) {
252      tgt.setResultForDeleteElement(convertCriteriaNotExistsBehavior(src.getResultForDeleteElement()));
253    }
254    if (src.hasRequireBoth()) {
255      tgt.setRequireBothElement(Boolean43_50.convertBoolean(src.getRequireBothElement()));
256    }
257
258    return tgt;
259  }
260
261  private static org.hl7.fhir.r4b.model.Enumeration<org.hl7.fhir.r4b.model.SubscriptionTopic.CriteriaNotExistsBehavior> convertCriteriaNotExistsBehavior(org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.SubscriptionTopic.CriteriaNotExistsBehavior> src) {
262      SubscriptionTopic.CriteriaNotExistsBehaviorEnumFactory enumFactory = new SubscriptionTopic.CriteriaNotExistsBehaviorEnumFactory();
263      if (src.getValue() == null) {
264          return null;
265      } else {
266          switch (src.getValue()) {
267              case TESTFAILS:
268                  return new Enumeration<>(enumFactory, SubscriptionTopic.CriteriaNotExistsBehavior.TESTFAILS);
269              case TESTPASSES:
270                  return new Enumeration<>(enumFactory, SubscriptionTopic.CriteriaNotExistsBehavior.TESTPASSES);
271              case NULL:
272                  return new Enumeration<>(enumFactory, SubscriptionTopic.CriteriaNotExistsBehavior.NULL);
273          }
274      }
275      return null;
276  }
277
278  private static org.hl7.fhir.r4b.model.SubscriptionTopic.InteractionTrigger convertInteractionTrigger(org.hl7.fhir.r5.model.SubscriptionTopic.InteractionTrigger value) {
279    switch(value) {
280      case CREATE : return org.hl7.fhir.r4b.model.SubscriptionTopic.InteractionTrigger.CREATE;
281      case UPDATE: return org.hl7.fhir.r4b.model.SubscriptionTopic.InteractionTrigger.UPDATE;
282      case DELETE: return org.hl7.fhir.r4b.model.SubscriptionTopic.InteractionTrigger.DELETE;
283      case NULL: return org.hl7.fhir.r4b.model.SubscriptionTopic.InteractionTrigger.NULL;
284    }
285    return null;
286  }
287
288
289
290  public static org.hl7.fhir.r5.model.SubscriptionTopic convertSubscriptionTopic(org.hl7.fhir.r4b.model.SubscriptionTopic src) {
291    if (src == null)
292      return null;
293    org.hl7.fhir.r5.model.SubscriptionTopic tgt = new org.hl7.fhir.r5.model.SubscriptionTopic();
294    ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyResource(src, tgt);
295
296    ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyDomainResource(src, tgt, IGNORED_EXTENSION_URLS);
297
298    if (src.hasExtension(NAME_EXTENSION_URL)) {
299      tgt.setNameElement(String43_50.convertString((org.hl7.fhir.r4b.model.StringType) src.getExtensionByUrl(NAME_EXTENSION_URL).getValue()));
300    }
301    if (src.hasExtension(COPYRIGHT_LABEL_EXTENSION_URL)) {
302      tgt.setCopyrightLabelElement(String43_50.convertString((org.hl7.fhir.r4b.model.StringType) src.getExtensionByUrl(COPYRIGHT_LABEL_EXTENSION_URL).getValue()));
303    }
304    if (src.hasUrl())
305      tgt.setUrlElement(Uri43_50.convertUri(src.getUrlElement()));
306    for (org.hl7.fhir.r4b.model.Identifier t : src.getIdentifier())
307      tgt.addIdentifier(Identifier43_50.convertIdentifier(t));
308    if (src.hasTitle())
309      tgt.setTitleElement(String43_50.convertString(src.getTitleElement()));
310    for (org.hl7.fhir.r4b.model.CanonicalType t : src.getDerivedFrom())
311      tgt.getDerivedFrom().add(Canonical43_50.convertCanonical(t));
312    if (src.hasStatus())
313      tgt.setStatusElement(Enumerations43_50.convertPublicationStatus(src.getStatusElement()));
314    if (src.hasVersion())
315      tgt.setVersionElement(String43_50.convertString(src.getVersionElement()));
316    if (src.hasTitle())
317      tgt.setTitleElement(String43_50.convertString(src.getTitleElement()));
318    if (src.hasStatus())
319      tgt.setStatusElement(Enumerations43_50.convertPublicationStatus(src.getStatusElement()));
320    if (src.hasExperimental())
321      tgt.setExperimentalElement(Boolean43_50.convertBoolean(src.getExperimentalElement()));
322    if (src.hasDate())
323      tgt.setDateElement(DateTime43_50.convertDateTime(src.getDateElement()));
324    if (src.hasPublisher())
325      tgt.setPublisherElement(String43_50.convertString(src.getPublisherElement()));
326    for (org.hl7.fhir.r4b.model.ContactDetail t : src.getContact())
327      tgt.addContact(ContactDetail43_50.convertContactDetail(t));
328    if (src.hasDescription())
329      tgt.setDescriptionElement(MarkDown43_50.convertMarkdown(src.getDescriptionElement()));
330    for (org.hl7.fhir.r4b.model.UsageContext t : src.getUseContext())
331      tgt.addUseContext(UsageContext43_50.convertUsageContext(t));
332    for (org.hl7.fhir.r4b.model.CodeableConcept t : src.getJurisdiction())
333      tgt.addJurisdiction(CodeableConcept43_50.convertCodeableConcept(t));
334    if (src.hasPurpose())
335      tgt.setPurposeElement(MarkDown43_50.convertMarkdown(src.getPurposeElement()));
336    if (src.hasCopyright())
337      tgt.setCopyrightElement(MarkDown43_50.convertMarkdown(src.getCopyrightElement()));
338    if (src.hasApprovalDate())
339      tgt.setApprovalDateElement(Date43_50.convertDate(src.getApprovalDateElement()));
340    if (src.hasLastReviewDate())
341      tgt.setLastReviewDateElement(Date43_50.convertDate(src.getLastReviewDateElement()));
342    if (src.hasEffectivePeriod())
343      tgt.setEffectivePeriod(Period43_50.convertPeriod(src.getEffectivePeriod()));
344    for(org.hl7.fhir.r4b.model.SubscriptionTopic.SubscriptionTopicResourceTriggerComponent triggerComponent : src.getResourceTrigger()) {
345      tgt.addResourceTrigger(convertResourceTrigger(triggerComponent));
346    }
347    for (org.hl7.fhir.r4b.model.SubscriptionTopic.SubscriptionTopicEventTriggerComponent eventTrigger : src.getEventTrigger()) {
348      tgt.addEventTrigger(convertEventTrigger(eventTrigger));
349    }
350    for (org.hl7.fhir.r4b.model.SubscriptionTopic.SubscriptionTopicCanFilterByComponent canFilterByComponent : src.getCanFilterBy()) {
351      tgt.addCanFilterBy(convertCanFilterBy(canFilterByComponent));
352    }
353    for (org.hl7.fhir.r4b.model.SubscriptionTopic.SubscriptionTopicNotificationShapeComponent notificationShape : src.getNotificationShape()) {
354      tgt.addNotificationShape(convertNotificationShape(notificationShape));
355    }
356    return tgt;
357  }
358
359  private static org.hl7.fhir.r5.model.SubscriptionTopic.SubscriptionTopicNotificationShapeComponent convertNotificationShape(org.hl7.fhir.r4b.model.SubscriptionTopic.SubscriptionTopicNotificationShapeComponent src) {
360    org.hl7.fhir.r5.model.SubscriptionTopic.SubscriptionTopicNotificationShapeComponent tgt = new org.hl7.fhir.r5.model.SubscriptionTopic.SubscriptionTopicNotificationShapeComponent();
361    if (src.hasResource()) {
362      tgt.setResourceElement(Uri43_50.convertUri(src.getResourceElement()));
363    }
364    if (src.hasInclude()) {
365      tgt.setInclude(src.getInclude().stream().map(String43_50::convertString).collect(Collectors.toList()));
366    }
367    if (src.hasRevInclude()) {
368      tgt.setRevInclude(src.getRevInclude().stream().map(String43_50::convertString).collect(Collectors.toList()));
369    }
370    return tgt;
371
372  }
373
374  private static org.hl7.fhir.r5.model.SubscriptionTopic.SubscriptionTopicEventTriggerComponent convertEventTrigger(org.hl7.fhir.r4b.model.SubscriptionTopic.SubscriptionTopicEventTriggerComponent src) {
375    org.hl7.fhir.r5.model.SubscriptionTopic.SubscriptionTopicEventTriggerComponent tgt = new org.hl7.fhir.r5.model.SubscriptionTopic.SubscriptionTopicEventTriggerComponent();
376    if (src.hasDescription()) {
377      tgt.setDescriptionElement(MarkDown43_50.convertMarkdown(src.getDescriptionElement()));
378    }
379    if (src.hasEvent()) {
380      tgt.setEvent(CodeableConcept43_50.convertCodeableConcept(src.getEvent()));
381    }
382    if (src.hasResource()) {
383      tgt.setResourceElement(Uri43_50.convertUri(src.getResourceElement()));
384    }
385    return tgt;
386  }
387
388  private static org.hl7.fhir.r5.model.SubscriptionTopic.SubscriptionTopicCanFilterByComponent convertCanFilterBy(org.hl7.fhir.r4b.model.SubscriptionTopic.SubscriptionTopicCanFilterByComponent src) {
389    org.hl7.fhir.r5.model.SubscriptionTopic.SubscriptionTopicCanFilterByComponent tgt = new org.hl7.fhir.r5.model.SubscriptionTopic.SubscriptionTopicCanFilterByComponent();
390    if (src.hasDescription()) {
391      tgt.setDescriptionElement(MarkDown43_50.convertMarkdown(src.getDescriptionElement()));
392    }
393    if (src.hasResource()) {
394      tgt.setResourceElement(Uri43_50.convertUri(src.getResourceElement()));
395    }
396    if (src.hasFilterParameter()) {
397      tgt.setFilterParameterElement(String43_50.convertString(src.getFilterParameterElement()));
398    }
399
400    if (src.hasModifier()) {
401      List<org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Enumerations.SearchModifierCode>> tgtModifiers = convertR4BModifierToR5Modifier(src.getModifier());
402      tgt.setModifier(tgtModifiers);
403
404      List<org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Enumerations.SearchComparator>> tgtComparators = covertR4BModifierToR5Comparator(src.getModifier());
405      tgt.setComparator(tgtComparators);
406    }
407
408    return tgt;
409  }
410
411  private static List<org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Enumerations.SearchComparator>> covertR4BModifierToR5Comparator(List<org.hl7.fhir.r4b.model.Enumeration<org.hl7.fhir.r4b.model.SubscriptionTopic.SubscriptionSearchModifier>> srcList) {
412    return srcList.stream().map(SubscriptionTopic43_50::convertR4BModifierToR5Comparator).filter(x -> x != null).collect(Collectors.toList());
413  }
414
415
416  private static org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Enumerations.SearchComparator> convertR4BModifierToR5Comparator(org.hl7.fhir.r4b.model.Enumeration<org.hl7.fhir.r4b.model.SubscriptionTopic.SubscriptionSearchModifier> src) {
417      Enumerations.SearchComparatorEnumFactory enumFactory = new Enumerations.SearchComparatorEnumFactory();
418      if (src.getValue() == null) {
419          return null;
420      } else {
421          switch (src.getValue()) {
422              case NULL:
423                  return new org.hl7.fhir.r5.model.Enumeration<>(enumFactory, Enumerations.SearchComparator.NULL);
424              case EQ:
425                  return new org.hl7.fhir.r5.model.Enumeration<>(enumFactory, Enumerations.SearchComparator.EQ);
426              case NE:
427                  return new org.hl7.fhir.r5.model.Enumeration<>(enumFactory, Enumerations.SearchComparator.NE);
428              case GT:
429                  return new org.hl7.fhir.r5.model.Enumeration<>(enumFactory, Enumerations.SearchComparator.GT);
430              case LT:
431                  return new org.hl7.fhir.r5.model.Enumeration<>(enumFactory, Enumerations.SearchComparator.LT);
432              case GE:
433                  return new org.hl7.fhir.r5.model.Enumeration<>(enumFactory, Enumerations.SearchComparator.GE);
434              case LE:
435                  return new org.hl7.fhir.r5.model.Enumeration<>(enumFactory, Enumerations.SearchComparator.LE);
436              case SA:
437                  return new org.hl7.fhir.r5.model.Enumeration<>(enumFactory, Enumerations.SearchComparator.SA);
438              case EB:
439                  return new org.hl7.fhir.r5.model.Enumeration<>(enumFactory, Enumerations.SearchComparator.EB);
440              case AP:
441                  return new org.hl7.fhir.r5.model.Enumeration<>(enumFactory, Enumerations.SearchComparator.AP);
442          }
443      }
444      return null;
445  }
446
447  private static List<org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Enumerations.SearchModifierCode>> convertR4BModifierToR5Modifier(
448    List
449      <org.hl7.fhir.r4b.model.Enumeration<org.hl7.fhir.r4b.model.SubscriptionTopic.SubscriptionSearchModifier>> srcList) {
450    return srcList.stream().map(SubscriptionTopic43_50::convertR4BModifierToR5Modifier).filter(x -> x != null).collect(Collectors.toList());
451  }
452  private static org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Enumerations.SearchModifierCode> convertR4BModifierToR5Modifier(org.hl7.fhir.r4b.model.Enumeration<org.hl7.fhir.r4b.model.SubscriptionTopic.SubscriptionSearchModifier> src) {
453      Enumerations.SearchModifierCodeEnumFactory enumFactory = new Enumerations.SearchModifierCodeEnumFactory();
454      if (src.getValue() == null) {
455          return null;
456      } else {
457          switch (src.getValue()) {
458              case NULL:
459                  return new org.hl7.fhir.r5.model.Enumeration<>(enumFactory, Enumerations.SearchModifierCode.NULL);
460              case IN:
461                  return new org.hl7.fhir.r5.model.Enumeration<>(enumFactory, Enumerations.SearchModifierCode.IN);
462              case NOTIN:
463                  return new org.hl7.fhir.r5.model.Enumeration<>(enumFactory, Enumerations.SearchModifierCode.NOTIN);
464              case BELOW:
465                  return new org.hl7.fhir.r5.model.Enumeration<>(enumFactory, Enumerations.SearchModifierCode.BELOW);
466              case ABOVE:
467                  return new org.hl7.fhir.r5.model.Enumeration<>(enumFactory, Enumerations.SearchModifierCode.ABOVE);
468              case OFTYPE:
469                  return new org.hl7.fhir.r5.model.Enumeration<>(enumFactory, Enumerations.SearchModifierCode.OFTYPE);
470          }
471      }
472      return null;
473  }
474
475  private static org.hl7.fhir.r5.model.SubscriptionTopic.SubscriptionTopicResourceTriggerComponent convertResourceTrigger(org.hl7.fhir.r4b.model.SubscriptionTopic.SubscriptionTopicResourceTriggerComponent src) {
476    org.hl7.fhir.r5.model.SubscriptionTopic.SubscriptionTopicResourceTriggerComponent tgt = new org.hl7.fhir.r5.model.SubscriptionTopic.SubscriptionTopicResourceTriggerComponent();
477    ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyBackboneElement(src, tgt);
478    if (src.hasDescription()) {
479      tgt.setDescriptionElement(MarkDown43_50.convertMarkdown(src.getDescriptionElement()));
480    }
481    if (src.hasResource()) {
482      tgt.setResourceElement(Uri43_50.convertUri(src.getResourceElement()));
483    }
484    if (src.hasSupportedInteraction()) {
485      for (org.hl7.fhir.r4b.model.Enumeration<org.hl7.fhir.r4b.model.SubscriptionTopic.InteractionTrigger> srcItem : src.getSupportedInteraction()) {
486        org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.SubscriptionTopic.InteractionTrigger> tgtElement = tgt.addSupportedInteractionElement();
487        tgtElement.setValue(convertInteractionTrigger(srcItem.getValue()));
488      }
489    }
490    if (src.hasQueryCriteria()) {
491      tgt.setQueryCriteria(convertResourceTriggerQueryCriteriaComponent(src.getQueryCriteria()));
492    }
493    if (src.hasFhirPathCriteria()) {
494      tgt.setFhirPathCriteriaElement(String43_50.convertString(src.getFhirPathCriteriaElement()));
495    }
496    return tgt;
497
498  }
499
500  private static org.hl7.fhir.r5.model.SubscriptionTopic.SubscriptionTopicResourceTriggerQueryCriteriaComponent convertResourceTriggerQueryCriteriaComponent(org.hl7.fhir.r4b.model.SubscriptionTopic.SubscriptionTopicResourceTriggerQueryCriteriaComponent src) {
501    org.hl7.fhir.r5.model.SubscriptionTopic.SubscriptionTopicResourceTriggerQueryCriteriaComponent tgt = new org.hl7.fhir.r5.model.SubscriptionTopic.SubscriptionTopicResourceTriggerQueryCriteriaComponent();
502    if (src.hasPrevious()) {
503      tgt.setPreviousElement(String43_50.convertString(src.getPreviousElement()));
504    }
505    if (src.hasResultForCreate()) {
506      tgt.setResultForCreateElement(convertCriteriaNotExistsBehavior(src.getResultForCreateElement()));
507    }
508    if (src.hasCurrent()) {
509      tgt.setCurrentElement(String43_50.convertString(src.getCurrentElement()));
510    }
511    if (src.hasResultForDelete()) {
512      tgt.setResultForDeleteElement(convertCriteriaNotExistsBehavior(src.getResultForDeleteElement()));
513    }
514    if (src.hasRequireBoth()) {
515      tgt.setRequireBothElement(Boolean43_50.convertBoolean(src.getRequireBothElement()));
516    }
517    return tgt;
518  }
519
520  private static org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.SubscriptionTopic.CriteriaNotExistsBehavior> convertCriteriaNotExistsBehavior(org.hl7.fhir.r4b.model.Enumeration<org.hl7.fhir.r4b.model.SubscriptionTopic.CriteriaNotExistsBehavior> src) {
521      org.hl7.fhir.r5.model.SubscriptionTopic.CriteriaNotExistsBehaviorEnumFactory enumFactory = new org.hl7.fhir.r5.model.SubscriptionTopic.CriteriaNotExistsBehaviorEnumFactory();
522      if (src.getValue() == null) {
523          return null;
524      } else {
525          switch (src.getValue()) {
526              case TESTFAILS:
527                  return new org.hl7.fhir.r5.model.Enumeration<>(enumFactory, org.hl7.fhir.r5.model.SubscriptionTopic.CriteriaNotExistsBehavior.TESTFAILS);
528              case TESTPASSES:
529                  return new org.hl7.fhir.r5.model.Enumeration<>(enumFactory, org.hl7.fhir.r5.model.SubscriptionTopic.CriteriaNotExistsBehavior.TESTPASSES);
530              case NULL:
531                  return new org.hl7.fhir.r5.model.Enumeration<>(enumFactory, org.hl7.fhir.r5.model.SubscriptionTopic.CriteriaNotExistsBehavior.NULL);
532          }
533      }
534      return null;
535  }
536
537  private static org.hl7.fhir.r5.model.SubscriptionTopic.InteractionTrigger convertInteractionTrigger(org.hl7.fhir.r4b.model.SubscriptionTopic.InteractionTrigger value) {
538    switch(value) {
539      case CREATE : return org.hl7.fhir.r5.model.SubscriptionTopic.InteractionTrigger.CREATE;
540      case UPDATE: return org.hl7.fhir.r5.model.SubscriptionTopic.InteractionTrigger.UPDATE;
541      case DELETE: return org.hl7.fhir.r5.model.SubscriptionTopic.InteractionTrigger.DELETE;
542      case NULL: return org.hl7.fhir.r5.model.SubscriptionTopic.InteractionTrigger.NULL;
543    }
544    return null;
545
546  }
547}