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;
}
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;
}
Aggregations