001package org.hl7.fhir.convertors.conv30_40.resources30_40;
002
003import org.hl7.fhir.convertors.context.ConversionContext30_40;
004import org.hl7.fhir.convertors.conv30_40.datatypes30_40.ContactDetail30_40;
005import org.hl7.fhir.convertors.conv30_40.datatypes30_40.Reference30_40;
006import org.hl7.fhir.convertors.conv30_40.datatypes30_40.complextypes30_40.CodeableConcept30_40;
007import org.hl7.fhir.convertors.conv30_40.datatypes30_40.complextypes30_40.Coding30_40;
008import org.hl7.fhir.convertors.conv30_40.datatypes30_40.complextypes30_40.Identifier30_40;
009import org.hl7.fhir.convertors.conv30_40.datatypes30_40.complextypes30_40.Timing30_40;
010import org.hl7.fhir.convertors.conv30_40.datatypes30_40.primitivetypes30_40.Boolean30_40;
011import org.hl7.fhir.convertors.conv30_40.datatypes30_40.primitivetypes30_40.Code30_40;
012import org.hl7.fhir.convertors.conv30_40.datatypes30_40.primitivetypes30_40.DateTime30_40;
013import org.hl7.fhir.convertors.conv30_40.datatypes30_40.primitivetypes30_40.MarkDown30_40;
014import org.hl7.fhir.convertors.conv30_40.datatypes30_40.primitivetypes30_40.String30_40;
015import org.hl7.fhir.convertors.conv30_40.datatypes30_40.primitivetypes30_40.UnsignedInt30_40;
016import org.hl7.fhir.convertors.conv30_40.datatypes30_40.primitivetypes30_40.Uri30_40;
017import org.hl7.fhir.exceptions.FHIRException;
018
019public class MessageDefinition30_40 {
020
021  public static org.hl7.fhir.dstu3.model.MessageDefinition convertMessageDefinition(org.hl7.fhir.r4.model.MessageDefinition src) throws FHIRException {
022    if (src == null)
023      return null;
024    org.hl7.fhir.dstu3.model.MessageDefinition tgt = new org.hl7.fhir.dstu3.model.MessageDefinition();
025    ConversionContext30_40.INSTANCE.getVersionConvertor_30_40().copyDomainResource(src, tgt);
026    if (src.hasUrl())
027      tgt.setUrlElement(Uri30_40.convertUri(src.getUrlElement()));
028    if (src.hasIdentifier())
029      tgt.setIdentifier(Identifier30_40.convertIdentifier(src.getIdentifierFirstRep()));
030    if (src.hasVersion())
031      tgt.setVersionElement(String30_40.convertString(src.getVersionElement()));
032    if (src.hasName())
033      tgt.setNameElement(String30_40.convertString(src.getNameElement()));
034    if (src.hasTitle())
035      tgt.setTitleElement(String30_40.convertString(src.getTitleElement()));
036    if (src.hasStatus())
037      tgt.setStatusElement(Enumerations30_40.convertPublicationStatus(src.getStatusElement()));
038    if (src.hasExperimental())
039      tgt.setExperimentalElement(Boolean30_40.convertBoolean(src.getExperimentalElement()));
040    if (src.hasDateElement())
041      tgt.setDateElement(DateTime30_40.convertDateTime(src.getDateElement()));
042    if (src.hasPublisher())
043      tgt.setPublisherElement(String30_40.convertString(src.getPublisherElement()));
044    for (org.hl7.fhir.r4.model.ContactDetail t : src.getContact())
045      tgt.addContact(ContactDetail30_40.convertContactDetail(t));
046    if (src.hasDescription())
047      tgt.setDescriptionElement(MarkDown30_40.convertMarkdown(src.getDescriptionElement()));
048    for (org.hl7.fhir.r4.model.UsageContext t : src.getUseContext())
049      tgt.addUseContext(Timing30_40.convertUsageContext(t));
050    for (org.hl7.fhir.r4.model.CodeableConcept t : src.getJurisdiction())
051      tgt.addJurisdiction(CodeableConcept30_40.convertCodeableConcept(t));
052    if (src.hasPurpose())
053      tgt.setPurposeElement(MarkDown30_40.convertMarkdown(src.getPurposeElement()));
054    if (src.hasCopyright())
055      tgt.setCopyrightElement(MarkDown30_40.convertMarkdown(src.getCopyrightElement()));
056    if (src.hasBase())
057      tgt.setBase(Reference30_40.convertCanonicalToReference(src.getBaseElement()));
058    for (org.hl7.fhir.r4.model.CanonicalType t : src.getParent())
059      tgt.addParent(Reference30_40.convertCanonicalToReference(t));
060    for (org.hl7.fhir.r4.model.CanonicalType t : src.getReplaces())
061      tgt.addReplaces(Reference30_40.convertCanonicalToReference(t));
062    if (src.hasEventCoding())
063      tgt.setEvent(Coding30_40.convertCoding(src.getEventCoding()));
064    if (src.hasCategory())
065      tgt.setCategoryElement(convertMessageSignificanceCategory(src.getCategoryElement()));
066    for (org.hl7.fhir.r4.model.MessageDefinition.MessageDefinitionFocusComponent t : src.getFocus())
067      tgt.addFocus(convertMessageDefinitionFocusComponent(t));
068    if (src.hasResponseRequired())
069      tgt.setResponseRequired(src.getResponseRequired() != org.hl7.fhir.r4.model.MessageDefinition.MessageheaderResponseRequest.NEVER);
070    for (org.hl7.fhir.r4.model.MessageDefinition.MessageDefinitionAllowedResponseComponent t : src.getAllowedResponse())
071      tgt.addAllowedResponse(convertMessageDefinitionAllowedResponseComponent(t));
072    return tgt;
073  }
074
075  public static org.hl7.fhir.r4.model.MessageDefinition convertMessageDefinition(org.hl7.fhir.dstu3.model.MessageDefinition src) throws FHIRException {
076    if (src == null)
077      return null;
078    org.hl7.fhir.r4.model.MessageDefinition tgt = new org.hl7.fhir.r4.model.MessageDefinition();
079    ConversionContext30_40.INSTANCE.getVersionConvertor_30_40().copyDomainResource(src, tgt);
080    if (src.hasUrl())
081      tgt.setUrlElement(Uri30_40.convertUri(src.getUrlElement()));
082    if (src.hasIdentifier())
083      tgt.addIdentifier(Identifier30_40.convertIdentifier(src.getIdentifier()));
084    if (src.hasVersion())
085      tgt.setVersionElement(String30_40.convertString(src.getVersionElement()));
086    if (src.hasName())
087      tgt.setNameElement(String30_40.convertString(src.getNameElement()));
088    if (src.hasTitle())
089      tgt.setTitleElement(String30_40.convertString(src.getTitleElement()));
090    if (src.hasStatus())
091      tgt.setStatusElement(Enumerations30_40.convertPublicationStatus(src.getStatusElement()));
092    if (src.hasExperimental())
093      tgt.setExperimentalElement(Boolean30_40.convertBoolean(src.getExperimentalElement()));
094    if (src.hasDateElement())
095      tgt.setDateElement(DateTime30_40.convertDateTime(src.getDateElement()));
096    if (src.hasPublisher())
097      tgt.setPublisherElement(String30_40.convertString(src.getPublisherElement()));
098    for (org.hl7.fhir.dstu3.model.ContactDetail t : src.getContact())
099      tgt.addContact(ContactDetail30_40.convertContactDetail(t));
100    if (src.hasDescription())
101      tgt.setDescriptionElement(MarkDown30_40.convertMarkdown(src.getDescriptionElement()));
102    for (org.hl7.fhir.dstu3.model.UsageContext t : src.getUseContext())
103      tgt.addUseContext(Timing30_40.convertUsageContext(t));
104    for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getJurisdiction())
105      tgt.addJurisdiction(CodeableConcept30_40.convertCodeableConcept(t));
106    if (src.hasPurpose())
107      tgt.setPurposeElement(MarkDown30_40.convertMarkdown(src.getPurposeElement()));
108    if (src.hasCopyright())
109      tgt.setCopyrightElement(MarkDown30_40.convertMarkdown(src.getCopyrightElement()));
110    if (src.hasBase())
111      tgt.setBaseElement(Reference30_40.convertReferenceToCanonical(src.getBase()));
112    for (org.hl7.fhir.dstu3.model.Reference t : src.getParent())
113      tgt.getParent().add(Reference30_40.convertReferenceToCanonical(t));
114    for (org.hl7.fhir.dstu3.model.Reference t : src.getReplaces())
115      tgt.getReplaces().add(Reference30_40.convertReferenceToCanonical(t));
116    if (src.hasEvent())
117      tgt.setEvent(Coding30_40.convertCoding(src.getEvent()));
118    if (src.hasCategory())
119      tgt.setCategoryElement(convertMessageSignificanceCategory(src.getCategoryElement()));
120    for (org.hl7.fhir.dstu3.model.MessageDefinition.MessageDefinitionFocusComponent t : src.getFocus())
121      tgt.addFocus(convertMessageDefinitionFocusComponent(t));
122    if (src.hasResponseRequired())
123      tgt.setResponseRequired(src.getResponseRequired() ? org.hl7.fhir.r4.model.MessageDefinition.MessageheaderResponseRequest.ALWAYS : org.hl7.fhir.r4.model.MessageDefinition.MessageheaderResponseRequest.NEVER);
124    for (org.hl7.fhir.dstu3.model.MessageDefinition.MessageDefinitionAllowedResponseComponent t : src.getAllowedResponse())
125      tgt.addAllowedResponse(convertMessageDefinitionAllowedResponseComponent(t));
126    return tgt;
127  }
128
129  public static org.hl7.fhir.dstu3.model.MessageDefinition.MessageDefinitionAllowedResponseComponent convertMessageDefinitionAllowedResponseComponent(org.hl7.fhir.r4.model.MessageDefinition.MessageDefinitionAllowedResponseComponent src) throws FHIRException {
130    if (src == null)
131      return null;
132    org.hl7.fhir.dstu3.model.MessageDefinition.MessageDefinitionAllowedResponseComponent tgt = new org.hl7.fhir.dstu3.model.MessageDefinition.MessageDefinitionAllowedResponseComponent();
133    ConversionContext30_40.INSTANCE.getVersionConvertor_30_40().copyBackboneElement(src,tgt);
134    if (src.hasMessage())
135      tgt.setMessage(Reference30_40.convertCanonicalToReference(src.getMessageElement()));
136    if (src.hasSituation())
137      tgt.setSituationElement(MarkDown30_40.convertMarkdown(src.getSituationElement()));
138    return tgt;
139  }
140
141  public static org.hl7.fhir.r4.model.MessageDefinition.MessageDefinitionAllowedResponseComponent convertMessageDefinitionAllowedResponseComponent(org.hl7.fhir.dstu3.model.MessageDefinition.MessageDefinitionAllowedResponseComponent src) throws FHIRException {
142    if (src == null)
143      return null;
144    org.hl7.fhir.r4.model.MessageDefinition.MessageDefinitionAllowedResponseComponent tgt = new org.hl7.fhir.r4.model.MessageDefinition.MessageDefinitionAllowedResponseComponent();
145    ConversionContext30_40.INSTANCE.getVersionConvertor_30_40().copyBackboneElement(src,tgt);
146    if (src.hasMessage())
147      tgt.setMessageElement(Reference30_40.convertReferenceToCanonical(src.getMessage()));
148    if (src.hasSituation())
149      tgt.setSituationElement(MarkDown30_40.convertMarkdown(src.getSituationElement()));
150    return tgt;
151  }
152
153  public static org.hl7.fhir.r4.model.MessageDefinition.MessageDefinitionFocusComponent convertMessageDefinitionFocusComponent(org.hl7.fhir.dstu3.model.MessageDefinition.MessageDefinitionFocusComponent src) throws FHIRException {
154    if (src == null)
155      return null;
156    org.hl7.fhir.r4.model.MessageDefinition.MessageDefinitionFocusComponent tgt = new org.hl7.fhir.r4.model.MessageDefinition.MessageDefinitionFocusComponent();
157    ConversionContext30_40.INSTANCE.getVersionConvertor_30_40().copyBackboneElement(src,tgt);
158    if (src.hasCode())
159      tgt.setCodeElement(Code30_40.convertCode(src.getCodeElement()));
160    if (src.hasProfile())
161      tgt.setProfileElement(Reference30_40.convertReferenceToCanonical(src.getProfile()));
162    if (src.hasMin())
163      tgt.setMinElement(UnsignedInt30_40.convertUnsignedInt(src.getMinElement()));
164    if (src.hasMax())
165      tgt.setMaxElement(String30_40.convertString(src.getMaxElement()));
166    return tgt;
167  }
168
169  public static org.hl7.fhir.dstu3.model.MessageDefinition.MessageDefinitionFocusComponent convertMessageDefinitionFocusComponent(org.hl7.fhir.r4.model.MessageDefinition.MessageDefinitionFocusComponent src) throws FHIRException {
170    if (src == null)
171      return null;
172    org.hl7.fhir.dstu3.model.MessageDefinition.MessageDefinitionFocusComponent tgt = new org.hl7.fhir.dstu3.model.MessageDefinition.MessageDefinitionFocusComponent();
173    ConversionContext30_40.INSTANCE.getVersionConvertor_30_40().copyBackboneElement(src,tgt);
174    if (src.hasCode())
175      tgt.setCodeElement(Code30_40.convertCode(src.getCodeElement()));
176    if (src.hasProfile())
177      tgt.setProfile(Reference30_40.convertCanonicalToReference(src.getProfileElement()));
178    if (src.hasMin())
179      tgt.setMinElement(UnsignedInt30_40.convertUnsignedInt(src.getMinElement()));
180    if (src.hasMax())
181      tgt.setMaxElement(String30_40.convertString(src.getMaxElement()));
182    return tgt;
183  }
184
185  static public org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.MessageDefinition.MessageSignificanceCategory> convertMessageSignificanceCategory(org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.MessageDefinition.MessageSignificanceCategory> src) throws FHIRException {
186    if (src == null || src.isEmpty())
187      return null;
188    org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.MessageDefinition.MessageSignificanceCategory> tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.MessageDefinition.MessageSignificanceCategoryEnumFactory());
189    ConversionContext30_40.INSTANCE.getVersionConvertor_30_40().copyElement(src, tgt);
190    switch (src.getValue()) {
191      case CONSEQUENCE:
192        tgt.setValue(org.hl7.fhir.dstu3.model.MessageDefinition.MessageSignificanceCategory.CONSEQUENCE);
193        break;
194      case CURRENCY:
195        tgt.setValue(org.hl7.fhir.dstu3.model.MessageDefinition.MessageSignificanceCategory.CURRENCY);
196        break;
197      case NOTIFICATION:
198        tgt.setValue(org.hl7.fhir.dstu3.model.MessageDefinition.MessageSignificanceCategory.NOTIFICATION);
199        break;
200      default:
201        tgt.setValue(org.hl7.fhir.dstu3.model.MessageDefinition.MessageSignificanceCategory.NULL);
202        break;
203    }
204    return tgt;
205  }
206
207  static public org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.MessageDefinition.MessageSignificanceCategory> convertMessageSignificanceCategory(org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.MessageDefinition.MessageSignificanceCategory> src) throws FHIRException {
208    if (src == null || src.isEmpty())
209      return null;
210    org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.MessageDefinition.MessageSignificanceCategory> tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.MessageDefinition.MessageSignificanceCategoryEnumFactory());
211    ConversionContext30_40.INSTANCE.getVersionConvertor_30_40().copyElement(src, tgt);
212    switch (src.getValue()) {
213      case CONSEQUENCE:
214        tgt.setValue(org.hl7.fhir.r4.model.MessageDefinition.MessageSignificanceCategory.CONSEQUENCE);
215        break;
216      case CURRENCY:
217        tgt.setValue(org.hl7.fhir.r4.model.MessageDefinition.MessageSignificanceCategory.CURRENCY);
218        break;
219      case NOTIFICATION:
220        tgt.setValue(org.hl7.fhir.r4.model.MessageDefinition.MessageSignificanceCategory.NOTIFICATION);
221        break;
222      default:
223        tgt.setValue(org.hl7.fhir.r4.model.MessageDefinition.MessageSignificanceCategory.NULL);
224        break;
225    }
226    return tgt;
227  }
228}