001package org.hl7.fhir.convertors.conv30_50.resources30_50;
002
003import org.hl7.fhir.convertors.context.ConversionContext30_50;
004import org.hl7.fhir.convertors.conv30_50.datatypes30_50.ContactDetail30_50;
005import org.hl7.fhir.convertors.conv30_50.datatypes30_50.ElementDefinition30_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.Identifier30_50;
009import org.hl7.fhir.convertors.conv30_50.datatypes30_50.primitivetypes30_50.*;
010import org.hl7.fhir.exceptions.FHIRException;
011
012public class DataElement30_50 {
013
014  public static org.hl7.fhir.r5.model.StructureDefinition convertDataElement(org.hl7.fhir.dstu3.model.DataElement src) throws FHIRException {
015    if (src == null)
016      return null;
017    org.hl7.fhir.r5.model.StructureDefinition tgt = new org.hl7.fhir.r5.model.StructureDefinition();
018    ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyDomainResource(src, tgt);
019    if (src.hasUrl())
020      tgt.setUrl(src.getUrl().replace("/DataElement/", "/StructureDefinition/de-"));
021    for (org.hl7.fhir.dstu3.model.Identifier t : src.getIdentifier())
022      tgt.addIdentifier(Identifier30_50.convertIdentifier(t));
023    if (src.hasVersion())
024      tgt.setVersionElement(String30_50.convertString(src.getVersionElement()));
025    if (src.hasStatus())
026      tgt.setStatusElement(Enumerations30_50.convertPublicationStatus(src.getStatusElement()));
027    if (src.hasExperimental())
028      tgt.setExperimentalElement(Boolean30_50.convertBoolean(src.getExperimentalElement()));
029    if (src.hasDate())
030      tgt.setDateElement(DateTime30_50.convertDateTime(src.getDateElement()));
031    if (src.hasPublisher())
032      tgt.setPublisherElement(String30_50.convertString(src.getPublisherElement()));
033    if (src.hasName())
034      tgt.setNameElement(String30_50.convertString(src.getNameElement()));
035    if (src.hasTitle())
036      tgt.setTitleElement(String30_50.convertString(src.getTitleElement()));
037    for (org.hl7.fhir.dstu3.model.ContactDetail t : src.getContact())
038      tgt.addContact(ContactDetail30_50.convertContactDetail(t));
039    for (org.hl7.fhir.dstu3.model.UsageContext t : src.getUseContext())
040      tgt.addUseContext(UsageContext30_50.convertUsageContext(t));
041    for (org.hl7.fhir.dstu3.model.CodeableConcept t : src.getJurisdiction())
042      tgt.addJurisdiction(CodeableConcept30_50.convertCodeableConcept(t));
043    if (src.hasCopyright())
044      tgt.setCopyrightElement(MarkDown30_50.convertMarkdown(src.getCopyrightElement()));
045    for (org.hl7.fhir.dstu3.model.DataElement.DataElementMappingComponent t : src.getMapping())
046      tgt.addMapping(convertDataElementMappingComponent(t));
047    for (org.hl7.fhir.dstu3.model.ElementDefinition t : src.getElement())
048      tgt.getSnapshot().addElement(ElementDefinition30_50.convertElementDefinition(t));
049    tgt.setKind(org.hl7.fhir.r5.model.StructureDefinition.StructureDefinitionKind.COMPLEXTYPE);
050    tgt.setAbstract(false);
051    tgt.setType(tgt.getName());
052    tgt.setBaseDefinition("http://hl7.org/fhir/StructureDefinition/Element");
053    tgt.setDerivation(org.hl7.fhir.r5.model.StructureDefinition.TypeDerivationRule.SPECIALIZATION);
054    return tgt;
055  }
056
057  public static org.hl7.fhir.r5.model.StructureDefinition.StructureDefinitionMappingComponent convertDataElementMappingComponent(org.hl7.fhir.dstu3.model.DataElement.DataElementMappingComponent src) throws FHIRException {
058    if (src == null)
059      return null;
060    org.hl7.fhir.r5.model.StructureDefinition.StructureDefinitionMappingComponent tgt = new org.hl7.fhir.r5.model.StructureDefinition.StructureDefinitionMappingComponent();
061    ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyElement(src, tgt);
062    if (src.hasIdentity())
063      tgt.setIdentityElement(Id30_50.convertId(src.getIdentityElement()));
064    if (src.hasUri())
065      tgt.setUriElement(Uri30_50.convertUri(src.getUriElement()));
066    if (src.hasName())
067      tgt.setNameElement(String30_50.convertString(src.getNameElement()));
068    if (src.hasComment())
069      tgt.setCommentElement(String30_50.convertString(src.getCommentElement()));
070    return tgt;
071  }
072}