001package org.hl7.fhir.convertors.conv14_30.resources14_30;
002
003import org.hl7.fhir.convertors.context.ConversionContext14_30;
004import org.hl7.fhir.convertors.conv14_30.VersionConvertor_14_30;
005import org.hl7.fhir.convertors.conv14_30.datatypes14_30.ElementDefinition14_30;
006import org.hl7.fhir.convertors.conv14_30.datatypes14_30.complextypes14_30.CodeableConcept14_30;
007import org.hl7.fhir.convertors.conv14_30.datatypes14_30.complextypes14_30.ContactPoint14_30;
008import org.hl7.fhir.convertors.conv14_30.datatypes14_30.complextypes14_30.Identifier14_30;
009import org.hl7.fhir.convertors.conv14_30.datatypes14_30.primitivetypes14_30.*;
010import org.hl7.fhir.exceptions.FHIRException;
011
012public class DataElement14_30 {
013
014  public static org.hl7.fhir.dstu3.model.DataElement convertDataElement(org.hl7.fhir.dstu2016may.model.DataElement src) throws FHIRException {
015    if (src == null || src.isEmpty())
016      return null;
017    org.hl7.fhir.dstu3.model.DataElement tgt = new org.hl7.fhir.dstu3.model.DataElement();
018    ConversionContext14_30.INSTANCE.getVersionConvertor_14_30().copyDomainResource(src, tgt);
019    if (src.hasUrl())
020      tgt.setUrlElement(Uri14_30.convertUri(src.getUrlElement()));
021    for (org.hl7.fhir.dstu2016may.model.Identifier t : src.getIdentifier())
022      tgt.addIdentifier(Identifier14_30.convertIdentifier(t));
023    if (src.hasVersion())
024      tgt.setVersionElement(String14_30.convertString(src.getVersionElement()));
025    if (src.hasStatus())
026      tgt.setStatusElement(Enumerations14_30.convertConformanceResourceStatus(src.getStatusElement()));
027    if (src.hasExperimental())
028      tgt.setExperimentalElement(Boolean14_30.convertBoolean(src.getExperimentalElement()));
029    if (src.hasPublisher())
030      tgt.setPublisherElement(String14_30.convertString(src.getPublisherElement()));
031    if (src.hasDate())
032      tgt.setDateElement(DateTime14_30.convertDateTime(src.getDateElement()));
033    if (src.hasName())
034      tgt.setNameElement(String14_30.convertString(src.getNameElement()));
035    for (org.hl7.fhir.dstu2016may.model.DataElement.DataElementContactComponent t : src.getContact())
036      tgt.addContact(convertDataElementContactComponent(t));
037    for (org.hl7.fhir.dstu2016may.model.CodeableConcept t : src.getUseContext())
038      if (VersionConvertor_14_30.isJurisdiction(t))
039        tgt.addJurisdiction(CodeableConcept14_30.convertCodeableConcept(t));
040      else
041        tgt.addUseContext(CodeableConcept14_30.convertCodeableConceptToUsageContext(t));
042    if (src.hasCopyright())
043      tgt.setCopyright(src.getCopyright());
044    if (src.hasStringency())
045      tgt.setStringencyElement(convertDataElementStringency(src.getStringencyElement()));
046    for (org.hl7.fhir.dstu2016may.model.DataElement.DataElementMappingComponent t : src.getMapping())
047      tgt.addMapping(convertDataElementMappingComponent(t));
048    for (org.hl7.fhir.dstu2016may.model.ElementDefinition t : src.getElement())
049      tgt.addElement(ElementDefinition14_30.convertElementDefinition(t));
050    return tgt;
051  }
052
053  public static org.hl7.fhir.dstu2016may.model.DataElement convertDataElement(org.hl7.fhir.dstu3.model.DataElement src) throws FHIRException {
054    if (src == null || src.isEmpty())
055      return null;
056    org.hl7.fhir.dstu2016may.model.DataElement tgt = new org.hl7.fhir.dstu2016may.model.DataElement();
057    ConversionContext14_30.INSTANCE.getVersionConvertor_14_30().copyDomainResource(src, tgt);
058    if (src.hasUrl())
059      tgt.setUrlElement(Uri14_30.convertUri(src.getUrlElement()));
060    for (org.hl7.fhir.dstu3.model.Identifier t : src.getIdentifier())
061      tgt.addIdentifier(Identifier14_30.convertIdentifier(t));
062    if (src.hasVersion())
063      tgt.setVersionElement(String14_30.convertString(src.getVersionElement()));
064    if (src.hasStatus())
065      tgt.setStatusElement(Enumerations14_30.convertConformanceResourceStatus(src.getStatusElement()));
066    if (src.hasExperimental())
067      tgt.setExperimentalElement(Boolean14_30.convertBoolean(src.getExperimentalElement()));
068    if (src.hasPublisher())
069      tgt.setPublisherElement(String14_30.convertString(src.getPublisherElement()));
070    if (src.hasDate())
071      tgt.setDateElement(DateTime14_30.convertDateTime(src.getDateElement()));
072    if (src.hasName())
073      tgt.setNameElement(String14_30.convertString(src.getNameElement()));
074    for (org.hl7.fhir.dstu3.model.ContactDetail t : src.getContact())
075      tgt.addContact(convertDataElementContactComponent(t));
076    for (org.hl7.fhir.dstu3.model.UsageContext t : src.getUseContext())
077      if (t.hasValueCodeableConcept())
078        tgt.addUseContext(CodeableConcept14_30.convertCodeableConcept(t.getValueCodeableConcept()));
079    for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getJurisdiction())
080      tgt.addUseContext(CodeableConcept14_30.convertCodeableConcept(t));
081    if (src.hasCopyright())
082      tgt.setCopyright(src.getCopyright());
083    if (src.hasStringency())
084      tgt.setStringencyElement(convertDataElementStringency(src.getStringencyElement()));
085    for (org.hl7.fhir.dstu3.model.DataElement.DataElementMappingComponent t : src.getMapping())
086      tgt.addMapping(convertDataElementMappingComponent(t));
087    for (org.hl7.fhir.dstu3.model.ElementDefinition t : src.getElement())
088      tgt.addElement(ElementDefinition14_30.convertElementDefinition(t));
089    return tgt;
090  }
091
092  public static org.hl7.fhir.dstu3.model.ContactDetail convertDataElementContactComponent(org.hl7.fhir.dstu2016may.model.DataElement.DataElementContactComponent src) throws FHIRException {
093    if (src == null || src.isEmpty())
094      return null;
095    org.hl7.fhir.dstu3.model.ContactDetail tgt = new org.hl7.fhir.dstu3.model.ContactDetail();
096    ConversionContext14_30.INSTANCE.getVersionConvertor_14_30().copyElement(src, tgt);
097    if (src.hasName())
098      tgt.setNameElement(String14_30.convertString(src.getNameElement()));
099    for (org.hl7.fhir.dstu2016may.model.ContactPoint t : src.getTelecom())
100      tgt.addTelecom(ContactPoint14_30.convertContactPoint(t));
101    return tgt;
102  }
103
104  public static org.hl7.fhir.dstu2016may.model.DataElement.DataElementContactComponent convertDataElementContactComponent(org.hl7.fhir.dstu3.model.ContactDetail src) throws FHIRException {
105    if (src == null || src.isEmpty())
106      return null;
107    org.hl7.fhir.dstu2016may.model.DataElement.DataElementContactComponent tgt = new org.hl7.fhir.dstu2016may.model.DataElement.DataElementContactComponent();
108    ConversionContext14_30.INSTANCE.getVersionConvertor_14_30().copyElement(src, tgt);
109    if (src.hasName())
110      tgt.setNameElement(String14_30.convertString(src.getNameElement()));
111    for (org.hl7.fhir.dstu3.model.ContactPoint t : src.getTelecom())
112      tgt.addTelecom(ContactPoint14_30.convertContactPoint(t));
113    return tgt;
114  }
115
116  public static org.hl7.fhir.dstu3.model.DataElement.DataElementMappingComponent convertDataElementMappingComponent(org.hl7.fhir.dstu2016may.model.DataElement.DataElementMappingComponent src) throws FHIRException {
117    if (src == null || src.isEmpty())
118      return null;
119    org.hl7.fhir.dstu3.model.DataElement.DataElementMappingComponent tgt = new org.hl7.fhir.dstu3.model.DataElement.DataElementMappingComponent();
120    ConversionContext14_30.INSTANCE.getVersionConvertor_14_30().copyElement(src, tgt);
121    if (src.hasIdentityElement())
122      tgt.setIdentityElement(Id14_30.convertId(src.getIdentityElement()));
123    if (src.hasUri())
124      tgt.setUriElement(Uri14_30.convertUri(src.getUriElement()));
125    if (src.hasName())
126      tgt.setNameElement(String14_30.convertString(src.getNameElement()));
127    if (src.hasComment())
128      tgt.setCommentElement(String14_30.convertString(src.getCommentElement()));
129    return tgt;
130  }
131
132  public static org.hl7.fhir.dstu2016may.model.DataElement.DataElementMappingComponent convertDataElementMappingComponent(org.hl7.fhir.dstu3.model.DataElement.DataElementMappingComponent src) throws FHIRException {
133    if (src == null || src.isEmpty())
134      return null;
135    org.hl7.fhir.dstu2016may.model.DataElement.DataElementMappingComponent tgt = new org.hl7.fhir.dstu2016may.model.DataElement.DataElementMappingComponent();
136    ConversionContext14_30.INSTANCE.getVersionConvertor_14_30().copyElement(src, tgt);
137    if (src.hasIdentityElement())
138      tgt.setIdentityElement(Id14_30.convertId(src.getIdentityElement()));
139    if (src.hasUri())
140      tgt.setUriElement(Uri14_30.convertUri(src.getUriElement()));
141    if (src.hasName())
142      tgt.setNameElement(String14_30.convertString(src.getNameElement()));
143    if (src.hasComment())
144      tgt.setCommentElement(String14_30.convertString(src.getCommentElement()));
145    return tgt;
146  }
147
148  static public org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.DataElement.DataElementStringency> convertDataElementStringency(org.hl7.fhir.dstu2016may.model.Enumeration<org.hl7.fhir.dstu2016may.model.DataElement.DataElementStringency> src) throws FHIRException {
149    if (src == null || src.isEmpty())
150      return null;
151    org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.DataElement.DataElementStringency> tgt = new org.hl7.fhir.dstu3.model.Enumeration<>(new org.hl7.fhir.dstu3.model.DataElement.DataElementStringencyEnumFactory());
152    ConversionContext14_30.INSTANCE.getVersionConvertor_14_30().copyElement(src, tgt);
153    switch (src.getValue()) {
154      case COMPARABLE:
155        tgt.setValue(org.hl7.fhir.dstu3.model.DataElement.DataElementStringency.COMPARABLE);
156        break;
157      case FULLYSPECIFIED:
158        tgt.setValue(org.hl7.fhir.dstu3.model.DataElement.DataElementStringency.FULLYSPECIFIED);
159        break;
160      case EQUIVALENT:
161        tgt.setValue(org.hl7.fhir.dstu3.model.DataElement.DataElementStringency.EQUIVALENT);
162        break;
163      case CONVERTABLE:
164        tgt.setValue(org.hl7.fhir.dstu3.model.DataElement.DataElementStringency.CONVERTABLE);
165        break;
166      case SCALEABLE:
167        tgt.setValue(org.hl7.fhir.dstu3.model.DataElement.DataElementStringency.SCALEABLE);
168        break;
169      case FLEXIBLE:
170        tgt.setValue(org.hl7.fhir.dstu3.model.DataElement.DataElementStringency.FLEXIBLE);
171        break;
172      default:
173        tgt.setValue(org.hl7.fhir.dstu3.model.DataElement.DataElementStringency.NULL);
174        break;
175    }
176    return tgt;
177  }
178
179  static public org.hl7.fhir.dstu2016may.model.Enumeration<org.hl7.fhir.dstu2016may.model.DataElement.DataElementStringency> convertDataElementStringency(org.hl7.fhir.dstu3.model.Enumeration<org.hl7.fhir.dstu3.model.DataElement.DataElementStringency> src) throws FHIRException {
180    if (src == null || src.isEmpty())
181      return null;
182    org.hl7.fhir.dstu2016may.model.Enumeration<org.hl7.fhir.dstu2016may.model.DataElement.DataElementStringency> tgt = new org.hl7.fhir.dstu2016may.model.Enumeration<>(new org.hl7.fhir.dstu2016may.model.DataElement.DataElementStringencyEnumFactory());
183    ConversionContext14_30.INSTANCE.getVersionConvertor_14_30().copyElement(src, tgt);
184    switch (src.getValue()) {
185      case COMPARABLE:
186        tgt.setValue(org.hl7.fhir.dstu2016may.model.DataElement.DataElementStringency.COMPARABLE);
187        break;
188      case FULLYSPECIFIED:
189        tgt.setValue(org.hl7.fhir.dstu2016may.model.DataElement.DataElementStringency.FULLYSPECIFIED);
190        break;
191      case EQUIVALENT:
192        tgt.setValue(org.hl7.fhir.dstu2016may.model.DataElement.DataElementStringency.EQUIVALENT);
193        break;
194      case CONVERTABLE:
195        tgt.setValue(org.hl7.fhir.dstu2016may.model.DataElement.DataElementStringency.CONVERTABLE);
196        break;
197      case SCALEABLE:
198        tgt.setValue(org.hl7.fhir.dstu2016may.model.DataElement.DataElementStringency.SCALEABLE);
199        break;
200      case FLEXIBLE:
201        tgt.setValue(org.hl7.fhir.dstu2016may.model.DataElement.DataElementStringency.FLEXIBLE);
202        break;
203      default:
204        tgt.setValue(org.hl7.fhir.dstu2016may.model.DataElement.DataElementStringency.NULL);
205        break;
206    }
207    return tgt;
208  }
209}