use of org.hl7.elm.r1.Expression in project org.hl7.fhir.core by hapifhir.
the class Expression50Test method testAdvisorExpressionConversion50_10.
@Test
@DisplayName("Test Advisor is used in Expression R5 -> DSTU3 conversion.")
public void testAdvisorExpressionConversion50_10() throws IOException {
InputStream r5_stream = this.getClass().getResourceAsStream("/questionnaire_with_expression_50.json");
org.hl7.fhir.r5.model.Questionnaire r5_input = (org.hl7.fhir.r5.model.Questionnaire) new org.hl7.fhir.r5.formats.JsonParser().parse(r5_stream);
InputStream r2_stream = this.getClass().getResourceAsStream("/questionnaire_with_converted_expression_40_10.json");
org.hl7.fhir.dstu2.model.Questionnaire r2_expected_output = (org.hl7.fhir.dstu2.model.Questionnaire) new org.hl7.fhir.dstu2.formats.JsonParser().parse(r2_stream);
org.hl7.fhir.dstu2.model.Questionnaire convertedDstu2Questionnaire = (org.hl7.fhir.dstu2.model.Questionnaire) VersionConvertorFactory_10_50.convertResource(r5_input, new ExpressionAdvisor50());
org.hl7.fhir.dstu2.formats.JsonParser dstu2_parser = new org.hl7.fhir.dstu2.formats.JsonParser();
String composeString1 = dstu2_parser.composeString(convertedDstu2Questionnaire);
String composeString2 = dstu2_parser.composeString(r2_expected_output);
System.out.println("Expected out ->\n" + composeString2 + "\n\nActual out ->\n" + composeString1);
Assertions.assertTrue(r2_expected_output.equalsDeep(convertedDstu2Questionnaire));
}
use of org.hl7.elm.r1.Expression in project org.hl7.fhir.core by hapifhir.
the class ExpressionAdvisor50 method handleExtension.
public void handleExtension(@Nonnull String path, @Nonnull org.hl7.fhir.r5.model.Extension src, @Nonnull org.hl7.fhir.dstu2.model.Extension tgt) {
if (src.getValue() instanceof org.hl7.fhir.r5.model.Expression) {
StringType type = new StringType();
if (src.getValue() == null) {
throw new NullPointerException("null cannot be cast to non-null type org.hl7.fhir.r5.model.Expression");
} else {
type.setValueAsString(((Expression) src.getValue()).getExpression());
tgt.setValue(type);
if (src.hasUrlElement()) {
tgt.setUrlElement(Uri10_50.convertUri(src.getUrlElement()));
}
}
} else {
throw new FHIRException("Unknown extension type passed in to custom convertor method.");
}
}
use of org.hl7.elm.r1.Expression in project org.hl7.fhir.core by hapifhir.
the class RdfParser method composeActionDefinitionActionDefinitionCustomizationComponent.
protected void composeActionDefinitionActionDefinitionCustomizationComponent(Complex parent, String parentType, String name, ActionDefinition.ActionDefinitionCustomizationComponent element, int index) {
if (element == null)
return;
Complex t;
if (Utilities.noString(parentType))
t = parent;
else {
t = parent.predicate("fhir:" + parentType + '.' + name);
}
composeElement(t, "customization", name, element, index);
if (element.hasPathElement())
composeString(t, "ActionDefinition", "path", element.getPathElement(), -1);
if (element.hasExpressionElement())
composeString(t, "ActionDefinition", "expression", element.getExpressionElement(), -1);
}
use of org.hl7.elm.r1.Expression in project org.hl7.fhir.core by hapifhir.
the class RdfParser method composeSearchParameter.
protected void composeSearchParameter(Complex parent, String parentType, String name, SearchParameter element, int index) {
if (element == null)
return;
Complex t;
if (Utilities.noString(parentType))
t = parent;
else {
t = parent.predicate("fhir:" + parentType + '.' + name);
}
composeDomainResource(t, "SearchParameter", name, element, index);
if (element.hasUrlElement())
composeUri(t, "SearchParameter", "url", element.getUrlElement(), -1);
if (element.hasNameElement())
composeString(t, "SearchParameter", "name", element.getNameElement(), -1);
if (element.hasStatusElement())
composeEnum(t, "SearchParameter", "status", element.getStatusElement(), -1);
if (element.hasExperimentalElement())
composeBoolean(t, "SearchParameter", "experimental", element.getExperimentalElement(), -1);
if (element.hasDateElement())
composeDateTime(t, "SearchParameter", "date", element.getDateElement(), -1);
if (element.hasPublisherElement())
composeString(t, "SearchParameter", "publisher", element.getPublisherElement(), -1);
for (int i = 0; i < element.getContact().size(); i++) composeSearchParameterSearchParameterContactComponent(t, "SearchParameter", "contact", element.getContact().get(i), i);
for (int i = 0; i < element.getUseContext().size(); i++) composeCodeableConcept(t, "SearchParameter", "useContext", element.getUseContext().get(i), i);
if (element.hasRequirementsElement())
composeString(t, "SearchParameter", "requirements", element.getRequirementsElement(), -1);
if (element.hasCodeElement())
composeCode(t, "SearchParameter", "code", element.getCodeElement(), -1);
if (element.hasBaseElement())
composeCode(t, "SearchParameter", "base", element.getBaseElement(), -1);
if (element.hasTypeElement())
composeEnum(t, "SearchParameter", "type", element.getTypeElement(), -1);
if (element.hasDescriptionElement())
composeString(t, "SearchParameter", "description", element.getDescriptionElement(), -1);
if (element.hasExpressionElement())
composeString(t, "SearchParameter", "expression", element.getExpressionElement(), -1);
if (element.hasXpathElement())
composeString(t, "SearchParameter", "xpath", element.getXpathElement(), -1);
if (element.hasXpathUsageElement())
composeEnum(t, "SearchParameter", "xpathUsage", element.getXpathUsageElement(), -1);
for (int i = 0; i < element.getTarget().size(); i++) composeCode(t, "SearchParameter", "target", element.getTarget().get(i), i);
}
use of org.hl7.elm.r1.Expression in project org.hl7.fhir.core by hapifhir.
the class RdfParser method composeSearchParameter.
protected void composeSearchParameter(Complex parent, String parentType, String name, SearchParameter element, int index) {
if (element == null)
return;
Complex t;
if (Utilities.noString(parentType))
t = parent;
else {
t = parent.predicate("fhir:" + parentType + '.' + name);
}
composeDomainResource(t, "SearchParameter", name, element, index);
if (element.hasUrlElement())
composeUri(t, "SearchParameter", "url", element.getUrlElement(), -1);
if (element.hasVersionElement())
composeString(t, "SearchParameter", "version", element.getVersionElement(), -1);
if (element.hasNameElement())
composeString(t, "SearchParameter", "name", element.getNameElement(), -1);
if (element.hasStatusElement())
composeEnum(t, "SearchParameter", "status", element.getStatusElement(), -1);
if (element.hasExperimentalElement())
composeBoolean(t, "SearchParameter", "experimental", element.getExperimentalElement(), -1);
if (element.hasDateElement())
composeDateTime(t, "SearchParameter", "date", element.getDateElement(), -1);
if (element.hasPublisherElement())
composeString(t, "SearchParameter", "publisher", element.getPublisherElement(), -1);
for (int i = 0; i < element.getContact().size(); i++) composeContactDetail(t, "SearchParameter", "contact", element.getContact().get(i), i);
for (int i = 0; i < element.getUseContext().size(); i++) composeUsageContext(t, "SearchParameter", "useContext", element.getUseContext().get(i), i);
for (int i = 0; i < element.getJurisdiction().size(); i++) composeCodeableConcept(t, "SearchParameter", "jurisdiction", element.getJurisdiction().get(i), i);
if (element.hasPurposeElement())
composeMarkdown(t, "SearchParameter", "purpose", element.getPurposeElement(), -1);
if (element.hasCodeElement())
composeCode(t, "SearchParameter", "code", element.getCodeElement(), -1);
for (int i = 0; i < element.getBase().size(); i++) composeCode(t, "SearchParameter", "base", element.getBase().get(i), i);
if (element.hasTypeElement())
composeEnum(t, "SearchParameter", "type", element.getTypeElement(), -1);
if (element.hasDerivedFromElement())
composeUri(t, "SearchParameter", "derivedFrom", element.getDerivedFromElement(), -1);
if (element.hasDescriptionElement())
composeMarkdown(t, "SearchParameter", "description", element.getDescriptionElement(), -1);
if (element.hasExpressionElement())
composeString(t, "SearchParameter", "expression", element.getExpressionElement(), -1);
if (element.hasXpathElement())
composeString(t, "SearchParameter", "xpath", element.getXpathElement(), -1);
if (element.hasXpathUsageElement())
composeEnum(t, "SearchParameter", "xpathUsage", element.getXpathUsageElement(), -1);
for (int i = 0; i < element.getTarget().size(); i++) composeCode(t, "SearchParameter", "target", element.getTarget().get(i), i);
for (int i = 0; i < element.getComparator().size(); i++) composeEnum(t, "SearchParameter", "comparator", element.getComparator().get(i), i);
for (int i = 0; i < element.getModifier().size(); i++) composeEnum(t, "SearchParameter", "modifier", element.getModifier().get(i), i);
for (int i = 0; i < element.getChain().size(); i++) composeString(t, "SearchParameter", "chain", element.getChain().get(i), i);
for (int i = 0; i < element.getComponent().size(); i++) composeSearchParameterSearchParameterComponentComponent(t, "SearchParameter", "component", element.getComponent().get(i), i);
}
Aggregations