001package org.hl7.fhir.convertors.conv30_50.resources30_50;
002
003import org.hl7.fhir.convertors.VersionConvertorConstants;
004import org.hl7.fhir.convertors.context.ConversionContext30_50;
005import org.hl7.fhir.convertors.conv30_50.datatypes30_50.ContactDetail30_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.Period30_50;
009import org.hl7.fhir.convertors.conv30_50.datatypes30_50.primitivetypes30_50.Boolean30_50;
010import org.hl7.fhir.convertors.conv30_50.datatypes30_50.primitivetypes30_50.DateTime30_50;
011import org.hl7.fhir.convertors.conv30_50.datatypes30_50.primitivetypes30_50.MarkDown30_50;
012import org.hl7.fhir.convertors.conv30_50.datatypes30_50.primitivetypes30_50.String30_50;
013import org.hl7.fhir.convertors.conv30_50.datatypes30_50.primitivetypes30_50.Uri30_50;
014import org.hl7.fhir.dstu3.model.Extension;
015import org.hl7.fhir.dstu3.model.StringType;
016import org.hl7.fhir.dstu3.model.UriType;
017import org.hl7.fhir.exceptions.FHIRException;
018
019public class NamingSystem30_50 {
020
021  public static org.hl7.fhir.dstu3.model.NamingSystem convertNamingSystem(org.hl7.fhir.r5.model.NamingSystem src) throws FHIRException {
022    if (src == null)
023      return null;
024    org.hl7.fhir.dstu3.model.NamingSystem tgt = new org.hl7.fhir.dstu3.model.NamingSystem();
025    ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyDomainResource(src, tgt);
026    if (src.hasUrlElement()) 
027      tgt.getExtension().add(new Extension().setUrl(VersionConvertorConstants.EXT_NAMINGSYSTEM_URL).setValue(Uri30_50.convertUri(src.getUrlElement())));
028    if (src.hasVersionElement()) 
029      tgt.getExtension().add(new Extension().setUrl(VersionConvertorConstants.EXT_NAMINGSYSTEM_VERSION).setValue(String30_50.convertString(src.getVersionElement())));
030    if (src.hasName())
031      tgt.setNameElement(String30_50.convertString(src.getNameElement()));
032    if (src.hasTitleElement()) 
033      tgt.getExtension().add(new Extension().setUrl(VersionConvertorConstants.EXT_NAMINGSYSTEM_TITLE).setValue(String30_50.convertString(src.getTitleElement())));
034
035    if (src.hasStatus())
036      tgt.setStatusElement(Enumerations30_50.convertPublicationStatus(src.getStatusElement()));
037    if (src.hasKind())
038      tgt.setKindElement(convertNamingSystemType(src.getKindElement()));
039    if (src.hasDate())
040      tgt.setDateElement(DateTime30_50.convertDateTime(src.getDateElement()));
041    if (src.hasPublisher())
042      tgt.setPublisherElement(String30_50.convertString(src.getPublisherElement()));
043    for (org.hl7.fhir.r5.model.ContactDetail t : src.getContact())
044      tgt.addContact(ContactDetail30_50.convertContactDetail(t));
045    if (src.hasResponsible())
046      tgt.setResponsibleElement(String30_50.convertString(src.getResponsibleElement()));
047    if (src.hasType())
048      tgt.setType(CodeableConcept30_50.convertCodeableConcept(src.getType()));
049    if (src.hasDescription())
050      tgt.setDescriptionElement(MarkDown30_50.convertMarkdown(src.getDescriptionElement()));
051    for (org.hl7.fhir.r5.model.UsageContext t : src.getUseContext())
052      tgt.addUseContext(UsageContext30_50.convertUsageContext(t));
053    for (org.hl7.fhir.r5.model.CodeableConcept t : src.getJurisdiction())
054      tgt.addJurisdiction(CodeableConcept30_50.convertCodeableConcept(t));
055    if (src.hasUsage())
056      tgt.setUsageElement(String30_50.convertString(src.getUsageElement()));
057    for (org.hl7.fhir.r5.model.NamingSystem.NamingSystemUniqueIdComponent t : src.getUniqueId())
058      tgt.addUniqueId(convertNamingSystemUniqueIdComponent(t));
059    return tgt;
060  }
061
062  public static org.hl7.fhir.r5.model.NamingSystem convertNamingSystem(org.hl7.fhir.dstu3.model.NamingSystem src) throws FHIRException {
063    if (src == null)
064      return null;
065    org.hl7.fhir.r5.model.NamingSystem tgt = new org.hl7.fhir.r5.model.NamingSystem();
066    ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyDomainResource(src, tgt, VersionConvertorConstants.EXT_NAMINGSYSTEM_URL, VersionConvertorConstants.EXT_NAMINGSYSTEM_VERSION, VersionConvertorConstants.EXT_NAMINGSYSTEM_TITLE);
067
068    if (src.hasExtension(VersionConvertorConstants.EXT_NAMINGSYSTEM_URL)) {
069      tgt.setUrlElement(Uri30_50.convertUri((UriType) src.getExtensionByUrl(VersionConvertorConstants.EXT_NAMINGSYSTEM_URL).getValue()));
070    }
071    if (src.hasExtension(VersionConvertorConstants.EXT_NAMINGSYSTEM_VERSION)) {
072      tgt.setVersionElement(String30_50.convertString((StringType) src.getExtensionByUrl(VersionConvertorConstants.EXT_NAMINGSYSTEM_VERSION).getValue()));
073    }
074    if (src.hasName())
075      tgt.setNameElement(String30_50.convertString(src.getNameElement()));
076    if (src.hasExtension(VersionConvertorConstants.EXT_NAMINGSYSTEM_TITLE)) {
077      tgt.setTitleElement(String30_50.convertString((StringType) src.getExtensionByUrl(VersionConvertorConstants.EXT_NAMINGSYSTEM_TITLE).getValue()));
078    }
079    if (src.hasStatus())
080      tgt.setStatusElement(Enumerations30_50.convertPublicationStatus(src.getStatusElement()));
081    if (src.hasKind())
082      tgt.setKindElement(convertNamingSystemType(src.getKindElement()));
083    if (src.hasDate())
084      tgt.setDateElement(DateTime30_50.convertDateTime(src.getDateElement()));
085    if (src.hasPublisher())
086      tgt.setPublisherElement(String30_50.convertString(src.getPublisherElement()));
087    for (org.hl7.fhir.dstu3.model.ContactDetail t : src.getContact())
088      tgt.addContact(ContactDetail30_50.convertContactDetail(t));
089    if (src.hasResponsible())
090      tgt.setResponsibleElement(String30_50.convertString(src.getResponsibleElement()));
091    if (src.hasType())
092      tgt.setType(CodeableConcept30_50.convertCodeableConcept(src.getType()));
093    if (src.hasDescription())
094      tgt.setDescriptionElement(MarkDown30_50.convertMarkdown(src.getDescriptionElement()));
095    for (org.hl7.fhir.dstu3.model.UsageContext t : src.getUseContext())
096      tgt.addUseContext(UsageContext30_50.convertUsageContext(t));
097    for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getJurisdiction())
098      tgt.addJurisdiction(CodeableConcept30_50.convertCodeableConcept(t));
099    if (src.hasUsage())
100      tgt.setUsageElement(String30_50.convertString(src.getUsageElement()));
101    for (org.hl7.fhir.dstu3.model.NamingSystem.NamingSystemUniqueIdComponent t : src.getUniqueId())
102      tgt.addUniqueId(convertNamingSystemUniqueIdComponent(t));
103    return tgt;
104  }
105
106  static public org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.NamingSystem.NamingSystemIdentifierType> convertNamingSystemIdentifierType(org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.NamingSystem.NamingSystemIdentifierType> src) throws FHIRException {
107    if (src == null || src.isEmpty())
108      return null;
109    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());
110    ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyElement(src, tgt);
111    switch (src.getValue()) {
112      case OID:
113        tgt.setValue(org.hl7.fhir.r5.model.NamingSystem.NamingSystemIdentifierType.OID);
114        break;
115      case UUID:
116        tgt.setValue(org.hl7.fhir.r5.model.NamingSystem.NamingSystemIdentifierType.UUID);
117        break;
118      case URI:
119        tgt.setValue(org.hl7.fhir.r5.model.NamingSystem.NamingSystemIdentifierType.URI);
120        break;
121      case OTHER:
122        tgt.setValue(org.hl7.fhir.r5.model.NamingSystem.NamingSystemIdentifierType.OTHER);
123        break;
124      default:
125        tgt.setValue(org.hl7.fhir.r5.model.NamingSystem.NamingSystemIdentifierType.NULL);
126        break;
127    }
128    return tgt;
129  }
130
131  static public org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.NamingSystem.NamingSystemIdentifierType> convertNamingSystemIdentifierType(org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.NamingSystem.NamingSystemIdentifierType> src) throws FHIRException {
132    if (src == null || src.isEmpty())
133      return null;
134    org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.NamingSystem.NamingSystemIdentifierType> tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.NamingSystem.NamingSystemIdentifierTypeEnumFactory());
135    ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyElement(src, tgt);
136    switch (src.getValue()) {
137      case OID:
138        tgt.setValue(org.hl7.fhir.dstu3.model.NamingSystem.NamingSystemIdentifierType.OID);
139        break;
140      case UUID:
141        tgt.setValue(org.hl7.fhir.dstu3.model.NamingSystem.NamingSystemIdentifierType.UUID);
142        break;
143      case URI:
144        tgt.setValue(org.hl7.fhir.dstu3.model.NamingSystem.NamingSystemIdentifierType.URI);
145        break;
146      case OTHER:
147        tgt.setValue(org.hl7.fhir.dstu3.model.NamingSystem.NamingSystemIdentifierType.OTHER);
148        break;
149      default:
150        tgt.setValue(org.hl7.fhir.dstu3.model.NamingSystem.NamingSystemIdentifierType.NULL);
151        break;
152    }
153    return tgt;
154  }
155
156  static public org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.NamingSystem.NamingSystemType> convertNamingSystemType(org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.NamingSystem.NamingSystemType> src) throws FHIRException {
157    if (src == null || src.isEmpty())
158      return null;
159    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());
160    ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyElement(src, tgt);
161    switch (src.getValue()) {
162      case CODESYSTEM:
163        tgt.setValue(org.hl7.fhir.r5.model.NamingSystem.NamingSystemType.CODESYSTEM);
164        break;
165      case IDENTIFIER:
166        tgt.setValue(org.hl7.fhir.r5.model.NamingSystem.NamingSystemType.IDENTIFIER);
167        break;
168      case ROOT:
169        tgt.setValue(org.hl7.fhir.r5.model.NamingSystem.NamingSystemType.ROOT);
170        break;
171      default:
172        tgt.setValue(org.hl7.fhir.r5.model.NamingSystem.NamingSystemType.NULL);
173        break;
174    }
175    return tgt;
176  }
177
178  static public org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.NamingSystem.NamingSystemType> convertNamingSystemType(org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.NamingSystem.NamingSystemType> src) throws FHIRException {
179    if (src == null || src.isEmpty())
180      return null;
181    org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.NamingSystem.NamingSystemType> tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.NamingSystem.NamingSystemTypeEnumFactory());
182    ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyElement(src, tgt);
183    switch (src.getValue()) {
184      case CODESYSTEM:
185        tgt.setValue(org.hl7.fhir.dstu3.model.NamingSystem.NamingSystemType.CODESYSTEM);
186        break;
187      case IDENTIFIER:
188        tgt.setValue(org.hl7.fhir.dstu3.model.NamingSystem.NamingSystemType.IDENTIFIER);
189        break;
190      case ROOT:
191        tgt.setValue(org.hl7.fhir.dstu3.model.NamingSystem.NamingSystemType.ROOT);
192        break;
193      default:
194        tgt.setValue(org.hl7.fhir.dstu3.model.NamingSystem.NamingSystemType.NULL);
195        break;
196    }
197    return tgt;
198  }
199
200  public static org.hl7.fhir.r5.model.NamingSystem.NamingSystemUniqueIdComponent convertNamingSystemUniqueIdComponent(org.hl7.fhir.dstu3.model.NamingSystem.NamingSystemUniqueIdComponent src) throws FHIRException {
201    if (src == null)
202      return null;
203    org.hl7.fhir.r5.model.NamingSystem.NamingSystemUniqueIdComponent tgt = new org.hl7.fhir.r5.model.NamingSystem.NamingSystemUniqueIdComponent();
204    ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyBackboneElement(src,tgt);
205    if (src.hasType())
206      tgt.setTypeElement(convertNamingSystemIdentifierType(src.getTypeElement()));
207    if (src.hasValue())
208      tgt.setValueElement(String30_50.convertString(src.getValueElement()));
209    if (src.hasPreferred())
210      tgt.setPreferredElement(Boolean30_50.convertBoolean(src.getPreferredElement()));
211    if (src.hasComment())
212      tgt.setCommentElement(String30_50.convertString(src.getCommentElement()));
213    if (src.hasPeriod())
214      tgt.setPeriod(Period30_50.convertPeriod(src.getPeriod()));
215    return tgt;
216  }
217
218  public static org.hl7.fhir.dstu3.model.NamingSystem.NamingSystemUniqueIdComponent convertNamingSystemUniqueIdComponent(org.hl7.fhir.r5.model.NamingSystem.NamingSystemUniqueIdComponent src) throws FHIRException {
219    if (src == null)
220      return null;
221    org.hl7.fhir.dstu3.model.NamingSystem.NamingSystemUniqueIdComponent tgt = new org.hl7.fhir.dstu3.model.NamingSystem.NamingSystemUniqueIdComponent();
222    ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyBackboneElement(src,tgt);
223    if (src.hasType())
224      tgt.setTypeElement(convertNamingSystemIdentifierType(src.getTypeElement()));
225    if (src.hasValue())
226      tgt.setValueElement(String30_50.convertString(src.getValueElement()));
227    if (src.hasPreferred())
228      tgt.setPreferredElement(Boolean30_50.convertBoolean(src.getPreferredElement()));
229    if (src.hasComment())
230      tgt.setCommentElement(String30_50.convertString(src.getCommentElement()));
231    if (src.hasPeriod())
232      tgt.setPeriod(Period30_50.convertPeriod(src.getPeriod()));
233    return tgt;
234  }
235}