001package org.hl7.fhir.convertors.conv43_50.resources43_50;
002
003import org.hl7.fhir.convertors.VersionConvertorConstants;
004import org.hl7.fhir.convertors.context.ConversionContext43_50;
005import org.hl7.fhir.convertors.conv43_50.datatypes43_50.general43_50.CodeableConcept43_50;
006import org.hl7.fhir.convertors.conv43_50.datatypes43_50.general43_50.Period43_50;
007import org.hl7.fhir.convertors.conv43_50.datatypes43_50.metadata43_50.ContactDetail43_50;
008import org.hl7.fhir.convertors.conv43_50.datatypes43_50.metadata43_50.UsageContext43_50;
009import org.hl7.fhir.convertors.conv43_50.datatypes43_50.primitive43_50.Boolean43_50;
010import org.hl7.fhir.convertors.conv43_50.datatypes43_50.primitive43_50.DateTime43_50;
011import org.hl7.fhir.convertors.conv43_50.datatypes43_50.primitive43_50.MarkDown43_50;
012import org.hl7.fhir.convertors.conv43_50.datatypes43_50.primitive43_50.String43_50;
013import org.hl7.fhir.convertors.conv43_50.datatypes43_50.primitive43_50.Uri43_50;
014import org.hl7.fhir.exceptions.FHIRException;
015import org.hl7.fhir.r4b.model.Extension;
016
017/*
018  Copyright (c) 2011+, HL7, Inc.
019  All rights reserved.
020  
021  Redistribution and use in source and binary forms, with or without modification, 
022  are permitted provided that the following conditions are met:
023  
024   * Redistributions of source code must retain the above copyright notice, this 
025     list of conditions and the following disclaimer.
026   * Redistributions in binary form must reproduce the above copyright notice, 
027     this list of conditions and the following disclaimer in the documentation 
028     and/or other materials provided with the distribution.
029   * Neither the name of HL7 nor the names of its contributors may be used to 
030     endorse or promote products derived from this software without specific 
031     prior written permission.
032  
033  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 
034  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
035  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
036  IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 
037  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
038  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 
039  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
040  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
041  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
042  POSSIBILITY OF SUCH DAMAGE.
043  
044*/
045// Generated on Sun, Feb 24, 2019 11:37+1100 for FHIR v4.0.0
046public class NamingSystem43_50 {
047
048  public static org.hl7.fhir.r5.model.NamingSystem convertNamingSystem(org.hl7.fhir.r4b.model.NamingSystem src) throws FHIRException {
049    if (src == null)
050      return null;
051    org.hl7.fhir.r5.model.NamingSystem tgt = new org.hl7.fhir.r5.model.NamingSystem();
052    ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyDomainResource(src, tgt, VersionConvertorConstants.EXT_NAMINGSYSTEM_TITLE);
053
054    if (src.hasExtension(VersionConvertorConstants.EXT_NAMINGSYSTEM_URL)) {
055      tgt.setUrlElement(Uri43_50.convertToUri(src.getExtensionByUrl(VersionConvertorConstants.EXT_NAMINGSYSTEM_URL).getValue()));
056    }
057    if (src.hasExtension(VersionConvertorConstants.EXT_NAMINGSYSTEM_VERSION)) {
058      tgt.setVersionElement(String43_50.convertString(src.getExtensionByUrl(VersionConvertorConstants.EXT_NAMINGSYSTEM_VERSION).getValueStringType()));
059    }
060    if (src.hasName())
061      tgt.setNameElement(String43_50.convertString(src.getNameElement()));
062    if (src.hasExtension(VersionConvertorConstants.EXT_NAMINGSYSTEM_TITLE)) {
063      tgt.setTitleElement(String43_50.convertString(src.getExtensionByUrl(VersionConvertorConstants.EXT_NAMINGSYSTEM_TITLE).getValueStringType()));
064    }
065    if (src.hasStatus())
066      tgt.setStatusElement(Enumerations43_50.convertPublicationStatus(src.getStatusElement()));
067    if (src.hasKind())
068      tgt.setKindElement(convertNamingSystemType(src.getKindElement()));
069    if (src.hasDate())
070      tgt.setDateElement(DateTime43_50.convertDateTime(src.getDateElement()));
071    if (src.hasPublisher())
072      tgt.setPublisherElement(String43_50.convertString(src.getPublisherElement()));
073    for (org.hl7.fhir.r4b.model.ContactDetail t : src.getContact())
074      tgt.addContact(ContactDetail43_50.convertContactDetail(t));
075    if (src.hasResponsible())
076      tgt.setResponsibleElement(String43_50.convertString(src.getResponsibleElement()));
077    if (src.hasType())
078      tgt.setType(CodeableConcept43_50.convertCodeableConcept(src.getType()));
079    if (src.hasDescription())
080      tgt.setDescriptionElement(MarkDown43_50.convertMarkdown(src.getDescriptionElement()));
081    for (org.hl7.fhir.r4b.model.UsageContext t : src.getUseContext())
082      tgt.addUseContext(UsageContext43_50.convertUsageContext(t));
083    for (org.hl7.fhir.r4b.model.CodeableConcept t : src.getJurisdiction())
084      tgt.addJurisdiction(CodeableConcept43_50.convertCodeableConcept(t));
085    if (src.hasUsage())
086      tgt.setUsageElement(String43_50.convertString(src.getUsageElement()));
087    for (org.hl7.fhir.r4b.model.NamingSystem.NamingSystemUniqueIdComponent t : src.getUniqueId())
088      tgt.addUniqueId(convertNamingSystemUniqueIdComponent(t));
089    return tgt;
090  }
091
092  public static org.hl7.fhir.r4b.model.NamingSystem convertNamingSystem(org.hl7.fhir.r5.model.NamingSystem src) throws FHIRException {
093    if (src == null)
094      return null;
095    org.hl7.fhir.r4b.model.NamingSystem tgt = new org.hl7.fhir.r4b.model.NamingSystem();
096    ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyDomainResource(src, tgt);
097
098    if (src.hasUrlElement()) 
099      tgt.getExtension().add(new Extension().setUrl(VersionConvertorConstants.EXT_NAMINGSYSTEM_URL).setValue(Uri43_50.convertUri(src.getUrlElement())));
100    if (src.hasVersionElement()) 
101      tgt.getExtension().add(new Extension().setUrl(VersionConvertorConstants.EXT_NAMINGSYSTEM_VERSION).setValue(String43_50.convertString(src.getVersionElement())));
102    if (src.hasName())
103      tgt.setNameElement(String43_50.convertString(src.getNameElement()));
104    if (src.hasTitleElement()) 
105      tgt.getExtension().add(new Extension().setUrl(VersionConvertorConstants.EXT_NAMINGSYSTEM_TITLE).setValue(String43_50.convertString(src.getTitleElement())));
106
107    if (src.hasStatus())
108      tgt.setStatusElement(Enumerations43_50.convertPublicationStatus(src.getStatusElement()));
109    if (src.hasKind())
110      tgt.setKindElement(convertNamingSystemType(src.getKindElement()));
111    if (src.hasDate())
112      tgt.setDateElement(DateTime43_50.convertDateTime(src.getDateElement()));
113    if (src.hasPublisher())
114      tgt.setPublisherElement(String43_50.convertString(src.getPublisherElement()));
115    for (org.hl7.fhir.r5.model.ContactDetail t : src.getContact())
116      tgt.addContact(ContactDetail43_50.convertContactDetail(t));
117    if (src.hasResponsible())
118      tgt.setResponsibleElement(String43_50.convertString(src.getResponsibleElement()));
119    if (src.hasType())
120      tgt.setType(CodeableConcept43_50.convertCodeableConcept(src.getType()));
121    if (src.hasDescription())
122      tgt.setDescriptionElement(MarkDown43_50.convertMarkdown(src.getDescriptionElement()));
123    for (org.hl7.fhir.r5.model.UsageContext t : src.getUseContext())
124      tgt.addUseContext(UsageContext43_50.convertUsageContext(t));
125    for (org.hl7.fhir.r5.model.CodeableConcept t : src.getJurisdiction())
126      tgt.addJurisdiction(CodeableConcept43_50.convertCodeableConcept(t));
127    if (src.hasUsage())
128      tgt.setUsageElement(String43_50.convertString(src.getUsageElement()));
129    for (org.hl7.fhir.r5.model.NamingSystem.NamingSystemUniqueIdComponent t : src.getUniqueId())
130      tgt.addUniqueId(convertNamingSystemUniqueIdComponent(t));
131    return tgt;
132  }
133
134  static public org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.NamingSystem.NamingSystemType> convertNamingSystemType(org.hl7.fhir.r4b.model.Enumeration<org.hl7.fhir.r4b.model.NamingSystem.NamingSystemType> src) throws FHIRException {
135    if (src == null || src.isEmpty())
136      return null;
137    org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.NamingSystem.NamingSystemType> tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.NamingSystem.NamingSystemTypeEnumFactory());
138    ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyElement(src, tgt);
139    switch (src.getValue()) {
140      case CODESYSTEM:
141        tgt.setValue(org.hl7.fhir.r5.model.NamingSystem.NamingSystemType.CODESYSTEM);
142        break;
143      case IDENTIFIER:
144        tgt.setValue(org.hl7.fhir.r5.model.NamingSystem.NamingSystemType.IDENTIFIER);
145        break;
146      case ROOT:
147        tgt.setValue(org.hl7.fhir.r5.model.NamingSystem.NamingSystemType.ROOT);
148        break;
149      default:
150        tgt.setValue(org.hl7.fhir.r5.model.NamingSystem.NamingSystemType.NULL);
151        break;
152    }
153    return tgt;
154  }
155
156  static public org.hl7.fhir.r4b.model.Enumeration<org.hl7.fhir.r4b.model.NamingSystem.NamingSystemType> convertNamingSystemType(org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.NamingSystem.NamingSystemType> src) throws FHIRException {
157    if (src == null || src.isEmpty())
158      return null;
159    org.hl7.fhir.r4b.model.Enumeration<org.hl7.fhir.r4b.model.NamingSystem.NamingSystemType> tgt = new org.hl7.fhir.r4b.model.Enumeration<>(new org.hl7.fhir.r4b.model.NamingSystem.NamingSystemTypeEnumFactory());
160    ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyElement(src, tgt);
161    switch (src.getValue()) {
162      case CODESYSTEM:
163        tgt.setValue(org.hl7.fhir.r4b.model.NamingSystem.NamingSystemType.CODESYSTEM);
164        break;
165      case IDENTIFIER:
166        tgt.setValue(org.hl7.fhir.r4b.model.NamingSystem.NamingSystemType.IDENTIFIER);
167        break;
168      case ROOT:
169        tgt.setValue(org.hl7.fhir.r4b.model.NamingSystem.NamingSystemType.ROOT);
170        break;
171      default:
172        tgt.setValue(org.hl7.fhir.r4b.model.NamingSystem.NamingSystemType.NULL);
173        break;
174    }
175    return tgt;
176  }
177
178  public static org.hl7.fhir.r5.model.NamingSystem.NamingSystemUniqueIdComponent convertNamingSystemUniqueIdComponent(org.hl7.fhir.r4b.model.NamingSystem.NamingSystemUniqueIdComponent src) throws FHIRException {
179    if (src == null)
180      return null;
181    org.hl7.fhir.r5.model.NamingSystem.NamingSystemUniqueIdComponent tgt = new org.hl7.fhir.r5.model.NamingSystem.NamingSystemUniqueIdComponent();
182    ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyBackboneElement(src, tgt);
183    if (src.hasType())
184      tgt.setTypeElement(convertNamingSystemIdentifierType(src.getTypeElement()));
185    if (src.hasValue())
186      tgt.setValueElement(String43_50.convertString(src.getValueElement()));
187    if (src.hasPreferred())
188      tgt.setPreferredElement(Boolean43_50.convertBoolean(src.getPreferredElement()));
189    if (src.hasComment())
190      tgt.setCommentElement(String43_50.convertString(src.getCommentElement()));
191    if (src.hasPeriod())
192      tgt.setPeriod(Period43_50.convertPeriod(src.getPeriod()));
193    return tgt;
194  }
195
196  public static org.hl7.fhir.r4b.model.NamingSystem.NamingSystemUniqueIdComponent convertNamingSystemUniqueIdComponent(org.hl7.fhir.r5.model.NamingSystem.NamingSystemUniqueIdComponent src) throws FHIRException {
197    if (src == null)
198      return null;
199    org.hl7.fhir.r4b.model.NamingSystem.NamingSystemUniqueIdComponent tgt = new org.hl7.fhir.r4b.model.NamingSystem.NamingSystemUniqueIdComponent();
200    ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyBackboneElement(src, tgt);
201    if (src.hasType())
202      tgt.setTypeElement(convertNamingSystemIdentifierType(src.getTypeElement()));
203    if (src.hasValue())
204      tgt.setValueElement(String43_50.convertString(src.getValueElement()));
205    if (src.hasPreferred())
206      tgt.setPreferredElement(Boolean43_50.convertBoolean(src.getPreferredElement()));
207    if (src.hasComment())
208      tgt.setCommentElement(String43_50.convertString(src.getCommentElement()));
209    if (src.hasPeriod())
210      tgt.setPeriod(Period43_50.convertPeriod(src.getPeriod()));
211    return tgt;
212  }
213
214  static public org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.NamingSystem.NamingSystemIdentifierType> convertNamingSystemIdentifierType(org.hl7.fhir.r4b.model.Enumeration<org.hl7.fhir.r4b.model.NamingSystem.NamingSystemIdentifierType> src) throws FHIRException {
215    if (src == null || src.isEmpty())
216      return null;
217    org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.NamingSystem.NamingSystemIdentifierType> tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.NamingSystem.NamingSystemIdentifierTypeEnumFactory());
218    ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyElement(src, tgt);
219    switch (src.getValue()) {
220      case OID:
221        tgt.setValue(org.hl7.fhir.r5.model.NamingSystem.NamingSystemIdentifierType.OID);
222        break;
223      case UUID:
224        tgt.setValue(org.hl7.fhir.r5.model.NamingSystem.NamingSystemIdentifierType.UUID);
225        break;
226      case URI:
227        tgt.setValue(org.hl7.fhir.r5.model.NamingSystem.NamingSystemIdentifierType.URI);
228        break;
229      case OTHER:
230        tgt.setValue(org.hl7.fhir.r5.model.NamingSystem.NamingSystemIdentifierType.OTHER);
231        break;
232      default:
233        tgt.setValue(org.hl7.fhir.r5.model.NamingSystem.NamingSystemIdentifierType.NULL);
234        break;
235    }
236    return tgt;
237  }
238
239  static public org.hl7.fhir.r4b.model.Enumeration<org.hl7.fhir.r4b.model.NamingSystem.NamingSystemIdentifierType> convertNamingSystemIdentifierType(org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.NamingSystem.NamingSystemIdentifierType> src) throws FHIRException {
240    if (src == null || src.isEmpty())
241      return null;
242    org.hl7.fhir.r4b.model.Enumeration<org.hl7.fhir.r4b.model.NamingSystem.NamingSystemIdentifierType> tgt = new org.hl7.fhir.r4b.model.Enumeration<>(new org.hl7.fhir.r4b.model.NamingSystem.NamingSystemIdentifierTypeEnumFactory());
243    ConversionContext43_50.INSTANCE.getVersionConvertor_43_50().copyElement(src, tgt);
244    switch (src.getValue()) {
245      case OID:
246        tgt.setValue(org.hl7.fhir.r4b.model.NamingSystem.NamingSystemIdentifierType.OID);
247        break;
248      case UUID:
249        tgt.setValue(org.hl7.fhir.r4b.model.NamingSystem.NamingSystemIdentifierType.UUID);
250        break;
251      case URI:
252        tgt.setValue(org.hl7.fhir.r4b.model.NamingSystem.NamingSystemIdentifierType.URI);
253        break;
254      case OTHER:
255        tgt.setValue(org.hl7.fhir.r4b.model.NamingSystem.NamingSystemIdentifierType.OTHER);
256        break;
257      default:
258        tgt.setValue(org.hl7.fhir.r4b.model.NamingSystem.NamingSystemIdentifierType.NULL);
259        break;
260    }
261    return tgt;
262  }
263}