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