Search in sources :

Example 6 with VersionConvertor_10_50

use of org.hl7.fhir.convertors.conv10_50.VersionConvertor_10_50 in project org.hl7.fhir.core by hapifhir.

the class StructureDefinition10_50 method convertStructureDefinition.

public static org.hl7.fhir.r5.model.StructureDefinition convertStructureDefinition(org.hl7.fhir.dstu2.model.StructureDefinition src) throws FHIRException {
    if (src == null || src.isEmpty())
        return null;
    org.hl7.fhir.r5.model.StructureDefinition tgt = new org.hl7.fhir.r5.model.StructureDefinition();
    ConversionContext10_50.INSTANCE.getVersionConvertor_10_50().copyDomainResource(src, tgt);
    if (src.hasUrlElement())
        tgt.setUrlElement(Uri10_50.convertUri(src.getUrlElement()));
    for (org.hl7.fhir.dstu2.model.Identifier t : src.getIdentifier()) tgt.addIdentifier(Identifier10_50.convertIdentifier(t));
    if (src.hasVersionElement())
        tgt.setVersionElement(String10_50.convertString(src.getVersionElement()));
    if (src.hasNameElement())
        tgt.setNameElement(String10_50.convertString(src.getNameElement()));
    if (src.hasDisplayElement())
        tgt.setTitleElement(String10_50.convertString(src.getDisplayElement()));
    if (src.hasStatus())
        tgt.setStatusElement(Enumerations10_50.convertConformanceResourceStatus(src.getStatusElement()));
    if (src.hasExperimental())
        tgt.setExperimentalElement(Boolean10_50.convertBoolean(src.getExperimentalElement()));
    if (src.hasPublisherElement())
        tgt.setPublisherElement(String10_50.convertString(src.getPublisherElement()));
    for (org.hl7.fhir.dstu2.model.StructureDefinition.StructureDefinitionContactComponent t : src.getContact()) tgt.addContact(convertStructureDefinitionContactComponent(t));
    if (src.hasDate())
        tgt.setDateElement(DateTime10_50.convertDateTime(src.getDateElement()));
    if (src.hasDescription())
        tgt.setDescription(src.getDescription());
    for (org.hl7.fhir.dstu2.model.CodeableConcept t : src.getUseContext()) if (VersionConvertor_10_50.isJurisdiction(t))
        tgt.addJurisdiction(CodeableConcept10_50.convertCodeableConcept(t));
    else
        tgt.addUseContext(CodeableConcept10_50.convertCodeableConceptToUsageContext(t));
    if (src.hasRequirements())
        tgt.setPurpose(src.getRequirements());
    if (src.hasCopyright())
        tgt.setCopyright(src.getCopyright());
    for (org.hl7.fhir.dstu2.model.Coding t : src.getCode()) tgt.addKeyword(Coding10_50.convertCoding(t));
    if (src.hasFhirVersion())
        tgt.setFhirVersion(org.hl7.fhir.r5.model.Enumerations.FHIRVersion.fromCode(src.getFhirVersion()));
    for (org.hl7.fhir.dstu2.model.StructureDefinition.StructureDefinitionMappingComponent t : src.getMapping()) tgt.addMapping(convertStructureDefinitionMappingComponent(t));
    if (src.hasKind())
        tgt.setKindElement(convertStructureDefinitionKind(src.getKindElement(), tgt.getIdElement().getIdPart()));
    if (src.hasAbstractElement())
        tgt.setAbstractElement(Boolean10_50.convertBoolean(src.getAbstractElement()));
    for (org.hl7.fhir.dstu2.model.StringType t : src.getContext()) {
        org.hl7.fhir.r5.model.StructureDefinition.StructureDefinitionContextComponent ec = tgt.addContext();
        ec.setTypeElement(convertExtensionContext(src.getContextTypeElement()));
        ec.setExpression("*".equals(t.getValue()) ? "Element" : t.getValue());
    }
    if (src.hasConstrainedType())
        tgt.setType(src.getConstrainedType());
    else if (src.getSnapshot().hasElement())
        tgt.setType(src.getSnapshot().getElement().get(0).getPath());
    else if (src.getDifferential().hasElement() && !src.getDifferential().getElement().get(0).getPath().contains("."))
        tgt.setType(src.getDifferential().getElement().get(0).getPath());
    else
        tgt.setType(src.getDifferential().getElement().get(0).getPath().substring(0, src.getDifferential().getElement().get(0).getPath().indexOf(".")));
    if (src.hasBase())
        tgt.setBaseDefinition(src.getBase());
    tgt.setDerivation(src.hasConstrainedType() ? org.hl7.fhir.r5.model.StructureDefinition.TypeDerivationRule.CONSTRAINT : org.hl7.fhir.r5.model.StructureDefinition.TypeDerivationRule.SPECIALIZATION);
    if (src.hasSnapshot())
        tgt.setSnapshot(convertStructureDefinitionSnapshotComponent(src.getSnapshot()));
    if (src.hasDifferential())
        tgt.setDifferential(convertStructureDefinitionDifferentialComponent(src.getDifferential()));
    if (tgt.hasSnapshot())
        tgt.getSnapshot().getElementFirstRep().getType().clear();
    if (tgt.hasDifferential())
        tgt.getDifferential().getElementFirstRep().getType().clear();
    if (tgt.getKind() == StructureDefinitionKind.PRIMITIVETYPE && !tgt.getType().equals(tgt.getIdElement().getIdPart())) {
        tgt.setDerivation(TypeDerivationRule.SPECIALIZATION);
        tgt.setBaseDefinition("http://hl7.org/fhir/StructureDefinition/" + tgt.getType());
        tgt.setType(tgt.getIdElement().getIdPart());
    }
    if (tgt.getDerivation() == TypeDerivationRule.SPECIALIZATION) {
        for (ElementDefinition ed : tgt.getSnapshot().getElement()) {
            if (!ed.hasBase()) {
                ed.getBase().setPath(ed.getPath()).setMin(ed.getMin()).setMax(ed.getMax());
            }
        }
    }
    return tgt;
}
Also used : ElementDefinition(org.hl7.fhir.r5.model.ElementDefinition)

Example 7 with VersionConvertor_10_50

use of org.hl7.fhir.convertors.conv10_50.VersionConvertor_10_50 in project org.hl7.fhir.core by hapifhir.

the class TestScript10_50 method convertTestScript.

public static org.hl7.fhir.r5.model.TestScript convertTestScript(org.hl7.fhir.dstu2.model.TestScript src) throws FHIRException {
    if (src == null || src.isEmpty())
        return null;
    org.hl7.fhir.r5.model.TestScript tgt = new org.hl7.fhir.r5.model.TestScript();
    ConversionContext10_50.INSTANCE.getVersionConvertor_10_50().copyDomainResource(src, tgt);
    if (src.hasUrlElement())
        tgt.setUrlElement(Uri10_50.convertUri(src.getUrlElement()));
    if (src.hasVersionElement())
        tgt.setVersionElement(String10_50.convertString(src.getVersionElement()));
    if (src.hasNameElement())
        tgt.setNameElement(String10_50.convertString(src.getNameElement()));
    if (src.hasStatus())
        tgt.setStatusElement(Enumerations10_50.convertConformanceResourceStatus(src.getStatusElement()));
    if (src.hasIdentifier())
        tgt.addIdentifier(Identifier10_50.convertIdentifier(src.getIdentifier()));
    if (src.hasExperimental())
        tgt.setExperimentalElement(Boolean10_50.convertBoolean(src.getExperimentalElement()));
    if (src.hasPublisherElement())
        tgt.setPublisherElement(String10_50.convertString(src.getPublisherElement()));
    for (org.hl7.fhir.dstu2.model.TestScript.TestScriptContactComponent t : src.getContact()) tgt.addContact(convertTestScriptContactComponent(t));
    if (src.hasDate())
        tgt.setDateElement(DateTime10_50.convertDateTime(src.getDateElement()));
    if (src.hasDescription())
        tgt.setDescription(src.getDescription());
    for (org.hl7.fhir.dstu2.model.CodeableConcept t : src.getUseContext()) if (VersionConvertor_10_50.isJurisdiction(t))
        tgt.addJurisdiction(CodeableConcept10_50.convertCodeableConcept(t));
    else
        tgt.addUseContext(CodeableConcept10_50.convertCodeableConceptToUsageContext(t));
    if (src.hasRequirements())
        tgt.setPurpose(src.getRequirements());
    if (src.hasCopyright())
        tgt.setCopyright(src.getCopyright());
    if (src.hasMetadata())
        tgt.setMetadata(convertTestScriptMetadataComponent(src.getMetadata()));
    for (org.hl7.fhir.dstu2.model.TestScript.TestScriptFixtureComponent t : src.getFixture()) tgt.addFixture(convertTestScriptFixtureComponent(t));
    for (org.hl7.fhir.dstu2.model.Reference t : src.getProfile()) tgt.addProfile(Reference10_50.convertReference(t));
    for (org.hl7.fhir.dstu2.model.TestScript.TestScriptVariableComponent t : src.getVariable()) tgt.addVariable(convertTestScriptVariableComponent(t));
    if (src.hasSetup())
        tgt.setSetup(convertTestScriptSetupComponent(src.getSetup()));
    for (org.hl7.fhir.dstu2.model.TestScript.TestScriptTestComponent t : src.getTest()) tgt.addTest(convertTestScriptTestComponent(t));
    if (src.hasTeardown())
        tgt.setTeardown(convertTestScriptTeardownComponent(src.getTeardown()));
    return tgt;
}
Also used : TestScript(org.hl7.fhir.r5.model.TestScript) TestScript(org.hl7.fhir.r5.model.TestScript)

Aggregations

FileInputStream (java.io.FileInputStream)1 FileOutputStream (java.io.FileOutputStream)1 Method (java.lang.reflect.Method)1 SourceElementComponentWrapper (org.hl7.fhir.convertors.SourceElementComponentWrapper)1 VersionConvertor_10_30 (org.hl7.fhir.convertors.conv10_30.VersionConvertor_10_30)1 VersionConvertor_10_40 (org.hl7.fhir.convertors.conv10_40.VersionConvertor_10_40)1 VersionConvertor_10_50 (org.hl7.fhir.convertors.conv10_50.VersionConvertor_10_50)1 VersionConvertor_14_50 (org.hl7.fhir.convertors.conv14_50.VersionConvertor_14_50)1 VersionConvertor_30_50 (org.hl7.fhir.convertors.conv30_50.VersionConvertor_30_50)1 VersionConvertor_40_50 (org.hl7.fhir.convertors.conv40_50.VersionConvertor_40_50)1 ValueSet (org.hl7.fhir.dstu2.model.ValueSet)1 XmlParser (org.hl7.fhir.r5.formats.XmlParser)1 org.hl7.fhir.r5.model (org.hl7.fhir.r5.model)1 BooleanType (org.hl7.fhir.r5.model.BooleanType)1 CanonicalType (org.hl7.fhir.r5.model.CanonicalType)1 CodeSystem (org.hl7.fhir.r5.model.CodeSystem)1 ConceptMap (org.hl7.fhir.r5.model.ConceptMap)1 DocumentReferenceAttesterComponent (org.hl7.fhir.r5.model.DocumentReference.DocumentReferenceAttesterComponent)1 ElementDefinition (org.hl7.fhir.r5.model.ElementDefinition)1 TestScript (org.hl7.fhir.r5.model.TestScript)1