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