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.Code40_50;
011import org.hl7.fhir.convertors.conv40_50.datatypes40_50.primitive40_50.DateTime40_50;
012import org.hl7.fhir.convertors.conv40_50.datatypes40_50.primitive40_50.MarkDown40_50;
013import org.hl7.fhir.convertors.conv40_50.datatypes40_50.primitive40_50.String40_50;
014import org.hl7.fhir.convertors.conv40_50.datatypes40_50.primitive40_50.UnsignedInt40_50;
015import org.hl7.fhir.convertors.conv40_50.datatypes40_50.primitive40_50.Uri40_50;
016import org.hl7.fhir.exceptions.FHIRException;
017
018/*
019  Copyright (c) 2011+, HL7, Inc.
020  All rights reserved.
021  
022  Redistribution and use in source and binary forms, with or without modification, 
023  are permitted provided that the following conditions are met:
024  
025   * Redistributions of source code must retain the above copyright notice, this 
026     list of conditions and the following disclaimer.
027   * Redistributions in binary form must reproduce the above copyright notice, 
028     this list of conditions and the following disclaimer in the documentation 
029     and/or other materials provided with the distribution.
030   * Neither the name of HL7 nor the names of its contributors may be used to 
031     endorse or promote products derived from this software without specific 
032     prior written permission.
033  
034  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 
035  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
036  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
037  IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 
038  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
039  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 
040  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
041  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
042  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
043  POSSIBILITY OF SUCH DAMAGE.
044  
045*/
046// Generated on Sun, Feb 24, 2019 11:37+1100 for FHIR v4.0.0
047public class MessageDefinition40_50 {
048
049  public static org.hl7.fhir.r5.model.MessageDefinition convertMessageDefinition(org.hl7.fhir.r4.model.MessageDefinition src) throws FHIRException {
050    if (src == null)
051      return null;
052    org.hl7.fhir.r5.model.MessageDefinition tgt = new org.hl7.fhir.r5.model.MessageDefinition();
053    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyDomainResource(src, tgt);
054    if (src.hasUrl())
055      tgt.setUrlElement(Uri40_50.convertUri(src.getUrlElement()));
056    for (org.hl7.fhir.r4.model.Identifier t : src.getIdentifier())
057      tgt.addIdentifier(Identifier40_50.convertIdentifier(t));
058    if (src.hasVersion())
059      tgt.setVersionElement(String40_50.convertString(src.getVersionElement()));
060    if (src.hasName())
061      tgt.setNameElement(String40_50.convertString(src.getNameElement()));
062    if (src.hasTitle())
063      tgt.setTitleElement(String40_50.convertString(src.getTitleElement()));
064    for (org.hl7.fhir.r4.model.CanonicalType t : src.getReplaces())
065      tgt.getReplaces().add(Canonical40_50.convertCanonical(t));
066    if (src.hasStatus())
067      tgt.setStatusElement(Enumerations40_50.convertPublicationStatus(src.getStatusElement()));
068    if (src.hasExperimental())
069      tgt.setExperimentalElement(Boolean40_50.convertBoolean(src.getExperimentalElement()));
070    if (src.hasDate())
071      tgt.setDateElement(DateTime40_50.convertDateTime(src.getDateElement()));
072    if (src.hasPublisher())
073      tgt.setPublisherElement(String40_50.convertString(src.getPublisherElement()));
074    for (org.hl7.fhir.r4.model.ContactDetail t : src.getContact())
075      tgt.addContact(ContactDetail40_50.convertContactDetail(t));
076    if (src.hasDescription())
077      tgt.setDescriptionElement(MarkDown40_50.convertMarkdown(src.getDescriptionElement()));
078    for (org.hl7.fhir.r4.model.UsageContext t : src.getUseContext())
079      tgt.addUseContext(UsageContext40_50.convertUsageContext(t));
080    for (org.hl7.fhir.r4.model.CodeableConcept t : src.getJurisdiction())
081      tgt.addJurisdiction(CodeableConcept40_50.convertCodeableConcept(t));
082    if (src.hasPurpose())
083      tgt.setPurposeElement(MarkDown40_50.convertMarkdown(src.getPurposeElement()));
084    if (src.hasCopyright())
085      tgt.setCopyrightElement(MarkDown40_50.convertMarkdown(src.getCopyrightElement()));
086    if (src.hasBase())
087      tgt.setBaseElement(Canonical40_50.convertCanonical(src.getBaseElement()));
088    for (org.hl7.fhir.r4.model.CanonicalType t : src.getParent())
089      tgt.getParent().add(Canonical40_50.convertCanonical(t));
090    if (src.hasEvent())
091      tgt.setEvent(ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().convertType(src.getEvent()));
092    if (src.hasCategory())
093      tgt.setCategoryElement(convertMessageSignificanceCategory(src.getCategoryElement()));
094    for (org.hl7.fhir.r4.model.MessageDefinition.MessageDefinitionFocusComponent t : src.getFocus())
095      tgt.addFocus(convertMessageDefinitionFocusComponent(t));
096    if (src.hasResponseRequired())
097      tgt.setResponseRequiredElement(convertMessageheaderResponseRequest(src.getResponseRequiredElement()));
098    for (org.hl7.fhir.r4.model.MessageDefinition.MessageDefinitionAllowedResponseComponent t : src.getAllowedResponse())
099      tgt.addAllowedResponse(convertMessageDefinitionAllowedResponseComponent(t));
100    for (org.hl7.fhir.r4.model.CanonicalType t : src.getGraph()) tgt.setGraphElement(Canonical40_50.convertCanonical(t));
101    return tgt;
102  }
103
104  public static org.hl7.fhir.r4.model.MessageDefinition convertMessageDefinition(org.hl7.fhir.r5.model.MessageDefinition src) throws FHIRException {
105    if (src == null)
106      return null;
107    org.hl7.fhir.r4.model.MessageDefinition tgt = new org.hl7.fhir.r4.model.MessageDefinition();
108    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyDomainResource(src, tgt);
109    if (src.hasUrl())
110      tgt.setUrlElement(Uri40_50.convertUri(src.getUrlElement()));
111    for (org.hl7.fhir.r5.model.Identifier t : src.getIdentifier())
112      tgt.addIdentifier(Identifier40_50.convertIdentifier(t));
113    if (src.hasVersion())
114      tgt.setVersionElement(String40_50.convertString(src.getVersionElement()));
115    if (src.hasName())
116      tgt.setNameElement(String40_50.convertString(src.getNameElement()));
117    if (src.hasTitle())
118      tgt.setTitleElement(String40_50.convertString(src.getTitleElement()));
119    for (org.hl7.fhir.r5.model.CanonicalType t : src.getReplaces())
120      tgt.getReplaces().add(Canonical40_50.convertCanonical(t));
121    if (src.hasStatus())
122      tgt.setStatusElement(Enumerations40_50.convertPublicationStatus(src.getStatusElement()));
123    if (src.hasExperimental())
124      tgt.setExperimentalElement(Boolean40_50.convertBoolean(src.getExperimentalElement()));
125    if (src.hasDate())
126      tgt.setDateElement(DateTime40_50.convertDateTime(src.getDateElement()));
127    if (src.hasPublisher())
128      tgt.setPublisherElement(String40_50.convertString(src.getPublisherElement()));
129    for (org.hl7.fhir.r5.model.ContactDetail t : src.getContact())
130      tgt.addContact(ContactDetail40_50.convertContactDetail(t));
131    if (src.hasDescription())
132      tgt.setDescriptionElement(MarkDown40_50.convertMarkdown(src.getDescriptionElement()));
133    for (org.hl7.fhir.r5.model.UsageContext t : src.getUseContext())
134      tgt.addUseContext(UsageContext40_50.convertUsageContext(t));
135    for (org.hl7.fhir.r5.model.CodeableConcept t : src.getJurisdiction())
136      tgt.addJurisdiction(CodeableConcept40_50.convertCodeableConcept(t));
137    if (src.hasPurpose())
138      tgt.setPurposeElement(MarkDown40_50.convertMarkdown(src.getPurposeElement()));
139    if (src.hasCopyright())
140      tgt.setCopyrightElement(MarkDown40_50.convertMarkdown(src.getCopyrightElement()));
141    if (src.hasBase())
142      tgt.setBaseElement(Canonical40_50.convertCanonical(src.getBaseElement()));
143    for (org.hl7.fhir.r5.model.CanonicalType t : src.getParent())
144      tgt.getParent().add(Canonical40_50.convertCanonical(t));
145    if (src.hasEvent())
146      tgt.setEvent(ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().convertType(src.getEvent()));
147    if (src.hasCategory())
148      tgt.setCategoryElement(convertMessageSignificanceCategory(src.getCategoryElement()));
149    for (org.hl7.fhir.r5.model.MessageDefinition.MessageDefinitionFocusComponent t : src.getFocus())
150      tgt.addFocus(convertMessageDefinitionFocusComponent(t));
151    if (src.hasResponseRequired())
152      tgt.setResponseRequiredElement(convertMessageheaderResponseRequest(src.getResponseRequiredElement()));
153    for (org.hl7.fhir.r5.model.MessageDefinition.MessageDefinitionAllowedResponseComponent t : src.getAllowedResponse())
154      tgt.addAllowedResponse(convertMessageDefinitionAllowedResponseComponent(t));
155    if (src.hasGraph()) 
156      tgt.getGraph().add(Canonical40_50.convertCanonical(src.getGraphElement()));
157    return tgt;
158  }
159
160  static public org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.MessageDefinition.MessageSignificanceCategory> convertMessageSignificanceCategory(org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.MessageDefinition.MessageSignificanceCategory> src) throws FHIRException {
161    if (src == null || src.isEmpty())
162      return null;
163    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());
164    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt);
165    switch (src.getValue()) {
166      case CONSEQUENCE:
167        tgt.setValue(org.hl7.fhir.r5.model.MessageDefinition.MessageSignificanceCategory.CONSEQUENCE);
168        break;
169      case CURRENCY:
170        tgt.setValue(org.hl7.fhir.r5.model.MessageDefinition.MessageSignificanceCategory.CURRENCY);
171        break;
172      case NOTIFICATION:
173        tgt.setValue(org.hl7.fhir.r5.model.MessageDefinition.MessageSignificanceCategory.NOTIFICATION);
174        break;
175      default:
176        tgt.setValue(org.hl7.fhir.r5.model.MessageDefinition.MessageSignificanceCategory.NULL);
177        break;
178    }
179    return tgt;
180  }
181
182  static public org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.MessageDefinition.MessageSignificanceCategory> convertMessageSignificanceCategory(org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.MessageDefinition.MessageSignificanceCategory> src) throws FHIRException {
183    if (src == null || src.isEmpty())
184      return null;
185    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());
186    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt);
187    switch (src.getValue()) {
188      case CONSEQUENCE:
189        tgt.setValue(org.hl7.fhir.r4.model.MessageDefinition.MessageSignificanceCategory.CONSEQUENCE);
190        break;
191      case CURRENCY:
192        tgt.setValue(org.hl7.fhir.r4.model.MessageDefinition.MessageSignificanceCategory.CURRENCY);
193        break;
194      case NOTIFICATION:
195        tgt.setValue(org.hl7.fhir.r4.model.MessageDefinition.MessageSignificanceCategory.NOTIFICATION);
196        break;
197      default:
198        tgt.setValue(org.hl7.fhir.r4.model.MessageDefinition.MessageSignificanceCategory.NULL);
199        break;
200    }
201    return tgt;
202  }
203
204  static public org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.MessageDefinition.MessageheaderResponseRequest> convertMessageheaderResponseRequest(org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.MessageDefinition.MessageheaderResponseRequest> src) throws FHIRException {
205    if (src == null || src.isEmpty())
206      return null;
207    org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.MessageDefinition.MessageheaderResponseRequest> tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.MessageDefinition.MessageheaderResponseRequestEnumFactory());
208    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt);
209    switch (src.getValue()) {
210      case ALWAYS:
211        tgt.setValue(org.hl7.fhir.r5.model.MessageDefinition.MessageheaderResponseRequest.ALWAYS);
212        break;
213      case ONERROR:
214        tgt.setValue(org.hl7.fhir.r5.model.MessageDefinition.MessageheaderResponseRequest.ONERROR);
215        break;
216      case NEVER:
217        tgt.setValue(org.hl7.fhir.r5.model.MessageDefinition.MessageheaderResponseRequest.NEVER);
218        break;
219      case ONSUCCESS:
220        tgt.setValue(org.hl7.fhir.r5.model.MessageDefinition.MessageheaderResponseRequest.ONSUCCESS);
221        break;
222      default:
223        tgt.setValue(org.hl7.fhir.r5.model.MessageDefinition.MessageheaderResponseRequest.NULL);
224        break;
225    }
226    return tgt;
227  }
228
229  static public org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.MessageDefinition.MessageheaderResponseRequest> convertMessageheaderResponseRequest(org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.MessageDefinition.MessageheaderResponseRequest> src) throws FHIRException {
230    if (src == null || src.isEmpty())
231      return null;
232    org.hl7.fhir.r4.model.Enumeration<org.hl7.fhir.r4.model.MessageDefinition.MessageheaderResponseRequest> tgt = new org.hl7.fhir.r4.model.Enumeration<>(new org.hl7.fhir.r4.model.MessageDefinition.MessageheaderResponseRequestEnumFactory());
233    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt);
234    switch (src.getValue()) {
235      case ALWAYS:
236        tgt.setValue(org.hl7.fhir.r4.model.MessageDefinition.MessageheaderResponseRequest.ALWAYS);
237        break;
238      case ONERROR:
239        tgt.setValue(org.hl7.fhir.r4.model.MessageDefinition.MessageheaderResponseRequest.ONERROR);
240        break;
241      case NEVER:
242        tgt.setValue(org.hl7.fhir.r4.model.MessageDefinition.MessageheaderResponseRequest.NEVER);
243        break;
244      case ONSUCCESS:
245        tgt.setValue(org.hl7.fhir.r4.model.MessageDefinition.MessageheaderResponseRequest.ONSUCCESS);
246        break;
247      default:
248        tgt.setValue(org.hl7.fhir.r4.model.MessageDefinition.MessageheaderResponseRequest.NULL);
249        break;
250    }
251    return tgt;
252  }
253
254  public static org.hl7.fhir.r5.model.MessageDefinition.MessageDefinitionFocusComponent convertMessageDefinitionFocusComponent(org.hl7.fhir.r4.model.MessageDefinition.MessageDefinitionFocusComponent src) throws FHIRException {
255    if (src == null)
256      return null;
257    org.hl7.fhir.r5.model.MessageDefinition.MessageDefinitionFocusComponent tgt = new org.hl7.fhir.r5.model.MessageDefinition.MessageDefinitionFocusComponent();
258    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyBackboneElement(src, tgt);
259    if (src.hasCode())
260      tgt.setCodeElement(Code40_50.convertCode(src.getCodeElement()));
261    if (src.hasProfile())
262      tgt.setProfileElement(Canonical40_50.convertCanonical(src.getProfileElement()));
263    if (src.hasMin())
264      tgt.setMinElement(UnsignedInt40_50.convertUnsignedInt(src.getMinElement()));
265    if (src.hasMax())
266      tgt.setMaxElement(String40_50.convertString(src.getMaxElement()));
267    return tgt;
268  }
269
270  public static org.hl7.fhir.r4.model.MessageDefinition.MessageDefinitionFocusComponent convertMessageDefinitionFocusComponent(org.hl7.fhir.r5.model.MessageDefinition.MessageDefinitionFocusComponent src) throws FHIRException {
271    if (src == null)
272      return null;
273    org.hl7.fhir.r4.model.MessageDefinition.MessageDefinitionFocusComponent tgt = new org.hl7.fhir.r4.model.MessageDefinition.MessageDefinitionFocusComponent();
274    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyBackboneElement(src, tgt);
275    if (src.hasCode())
276      tgt.setCodeElement(Code40_50.convertCode(src.getCodeElement()));
277    if (src.hasProfile())
278      tgt.setProfileElement(Canonical40_50.convertCanonical(src.getProfileElement()));
279    if (src.hasMin())
280      tgt.setMinElement(UnsignedInt40_50.convertUnsignedInt(src.getMinElement()));
281    if (src.hasMax())
282      tgt.setMaxElement(String40_50.convertString(src.getMaxElement()));
283    return tgt;
284  }
285
286  public static org.hl7.fhir.r5.model.MessageDefinition.MessageDefinitionAllowedResponseComponent convertMessageDefinitionAllowedResponseComponent(org.hl7.fhir.r4.model.MessageDefinition.MessageDefinitionAllowedResponseComponent src) throws FHIRException {
287    if (src == null)
288      return null;
289    org.hl7.fhir.r5.model.MessageDefinition.MessageDefinitionAllowedResponseComponent tgt = new org.hl7.fhir.r5.model.MessageDefinition.MessageDefinitionAllowedResponseComponent();
290    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyBackboneElement(src, tgt);
291    if (src.hasMessage())
292      tgt.setMessageElement(Canonical40_50.convertCanonical(src.getMessageElement()));
293    if (src.hasSituation())
294      tgt.setSituationElement(MarkDown40_50.convertMarkdown(src.getSituationElement()));
295    return tgt;
296  }
297
298  public static org.hl7.fhir.r4.model.MessageDefinition.MessageDefinitionAllowedResponseComponent convertMessageDefinitionAllowedResponseComponent(org.hl7.fhir.r5.model.MessageDefinition.MessageDefinitionAllowedResponseComponent src) throws FHIRException {
299    if (src == null)
300      return null;
301    org.hl7.fhir.r4.model.MessageDefinition.MessageDefinitionAllowedResponseComponent tgt = new org.hl7.fhir.r4.model.MessageDefinition.MessageDefinitionAllowedResponseComponent();
302    ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyBackboneElement(src, tgt);
303    if (src.hasMessage())
304      tgt.setMessageElement(Canonical40_50.convertCanonical(src.getMessageElement()));
305    if (src.hasSituation())
306      tgt.setSituationElement(MarkDown40_50.convertMarkdown(src.getSituationElement()));
307    return tgt;
308  }
309}