Compare commits
8 Commits
dba997a7ca
...
c2647dce86
Author | SHA1 | Date |
---|---|---|
Oliver Egger | c2647dce86 | |
markiantorno | e8a0bba072 | |
markiantorno | 53ec745184 | |
Grahame Grieve | 10921bef1f | |
Grahame Grieve | 7bd5d3b7ce | |
Grahame Grieve | bd53f7c011 | |
oliveregger | 2f165863e7 | |
oliveregger | d69a8e3e43 |
|
@ -5,7 +5,7 @@
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||||
<artifactId>org.hl7.fhir.core</artifactId>
|
<artifactId>org.hl7.fhir.core</artifactId>
|
||||||
<version>6.3.29-SNAPSHOT</version>
|
<version>6.3.30-SNAPSHOT</version>
|
||||||
<relativePath>../pom.xml</relativePath>
|
<relativePath>../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||||
<artifactId>org.hl7.fhir.core</artifactId>
|
<artifactId>org.hl7.fhir.core</artifactId>
|
||||||
<version>6.3.29-SNAPSHOT</version>
|
<version>6.3.30-SNAPSHOT</version>
|
||||||
<relativePath>../pom.xml</relativePath>
|
<relativePath>../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||||
<artifactId>org.hl7.fhir.core</artifactId>
|
<artifactId>org.hl7.fhir.core</artifactId>
|
||||||
<version>6.3.29-SNAPSHOT</version>
|
<version>6.3.30-SNAPSHOT</version>
|
||||||
<relativePath>../pom.xml</relativePath>
|
<relativePath>../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||||
<artifactId>org.hl7.fhir.core</artifactId>
|
<artifactId>org.hl7.fhir.core</artifactId>
|
||||||
<version>6.3.29-SNAPSHOT</version>
|
<version>6.3.30-SNAPSHOT</version>
|
||||||
<relativePath>../pom.xml</relativePath>
|
<relativePath>../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||||
<artifactId>org.hl7.fhir.core</artifactId>
|
<artifactId>org.hl7.fhir.core</artifactId>
|
||||||
<version>6.3.29-SNAPSHOT</version>
|
<version>6.3.30-SNAPSHOT</version>
|
||||||
<relativePath>../pom.xml</relativePath>
|
<relativePath>../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||||
<artifactId>org.hl7.fhir.core</artifactId>
|
<artifactId>org.hl7.fhir.core</artifactId>
|
||||||
<version>6.3.29-SNAPSHOT</version>
|
<version>6.3.30-SNAPSHOT</version>
|
||||||
<relativePath>../pom.xml</relativePath>
|
<relativePath>../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||||
<artifactId>org.hl7.fhir.core</artifactId>
|
<artifactId>org.hl7.fhir.core</artifactId>
|
||||||
<version>6.3.29-SNAPSHOT</version>
|
<version>6.3.30-SNAPSHOT</version>
|
||||||
<relativePath>../pom.xml</relativePath>
|
<relativePath>../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
|
|
|
@ -1331,7 +1331,7 @@ public abstract class BaseWorkerContext extends I18nBase implements IWorkerConte
|
||||||
issues.add(iss);
|
issues.add(iss);
|
||||||
return new ValidationResult(IssueSeverity.FATAL, e.getMessage(), e.getError(), issues);
|
return new ValidationResult(IssueSeverity.FATAL, e.getMessage(), e.getError(), issues);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
// e.printStackTrace();
|
||||||
localError = e.getMessage();
|
localError = e.getMessage();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1087,7 +1087,7 @@ public class StructureMapUtilities {
|
||||||
if (lexer.hasToken("log")) {
|
if (lexer.hasToken("log")) {
|
||||||
lexer.take();
|
lexer.take();
|
||||||
ExpressionNode node = fpe.parse(lexer);
|
ExpressionNode node = fpe.parse(lexer);
|
||||||
source.setUserData(MAP_WHERE_CHECK, node);
|
source.setUserData(MAP_WHERE_LOG, node);
|
||||||
source.setLogMessage(node.toString());
|
source.setLogMessage(node.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1634,12 +1634,15 @@ public class StructureMapUtilities {
|
||||||
ExpressionNode expr = (ExpressionNode) src.getUserData(MAP_WHERE_EXPRESSION);
|
ExpressionNode expr = (ExpressionNode) src.getUserData(MAP_WHERE_EXPRESSION);
|
||||||
if (expr == null) {
|
if (expr == null) {
|
||||||
expr = fpe.parse(src.getCondition());
|
expr = fpe.parse(src.getCondition());
|
||||||
// fpe.check(context.appInfo, ??, ??, expr)
|
|
||||||
src.setUserData(MAP_WHERE_EXPRESSION, expr);
|
src.setUserData(MAP_WHERE_EXPRESSION, expr);
|
||||||
}
|
}
|
||||||
List<Base> remove = new ArrayList<Base>();
|
List<Base> remove = new ArrayList<Base>();
|
||||||
for (Base item : items) {
|
for (Base item : items) {
|
||||||
if (!fpe.evaluateToBoolean(vars, null, null, item, expr)) {
|
Variables varsForSource = vars.copy();
|
||||||
|
if (src.hasVariable()) {
|
||||||
|
varsForSource.add(VariableMode.INPUT, src.getVariable(), item);
|
||||||
|
}
|
||||||
|
if (!fpe.evaluateToBoolean(varsForSource, null, null, item, expr)) {
|
||||||
log(indent + " condition [" + src.getCondition() + "] for " + item.toString() + " : false");
|
log(indent + " condition [" + src.getCondition() + "] for " + item.toString() + " : false");
|
||||||
remove.add(item);
|
remove.add(item);
|
||||||
} else
|
} else
|
||||||
|
@ -1652,12 +1655,14 @@ public class StructureMapUtilities {
|
||||||
ExpressionNode expr = (ExpressionNode) src.getUserData(MAP_WHERE_CHECK);
|
ExpressionNode expr = (ExpressionNode) src.getUserData(MAP_WHERE_CHECK);
|
||||||
if (expr == null) {
|
if (expr == null) {
|
||||||
expr = fpe.parse(src.getCheck());
|
expr = fpe.parse(src.getCheck());
|
||||||
// fpe.check(context.appInfo, ??, ??, expr)
|
|
||||||
src.setUserData(MAP_WHERE_CHECK, expr);
|
src.setUserData(MAP_WHERE_CHECK, expr);
|
||||||
}
|
}
|
||||||
List<Base> remove = new ArrayList<Base>();
|
|
||||||
for (Base item : items) {
|
for (Base item : items) {
|
||||||
if (!fpe.evaluateToBoolean(vars, null, null, item, expr))
|
Variables varsForSource = vars.copy();
|
||||||
|
if (src.hasVariable()) {
|
||||||
|
varsForSource.add(VariableMode.INPUT, src.getVariable(), item);
|
||||||
|
}
|
||||||
|
if (!fpe.evaluateToBoolean(varsForSource, null, null, item, expr))
|
||||||
throw new FHIRException("Rule \"" + ruleId + "\": Check condition failed");
|
throw new FHIRException("Rule \"" + ruleId + "\": Check condition failed");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1666,12 +1671,16 @@ public class StructureMapUtilities {
|
||||||
ExpressionNode expr = (ExpressionNode) src.getUserData(MAP_WHERE_LOG);
|
ExpressionNode expr = (ExpressionNode) src.getUserData(MAP_WHERE_LOG);
|
||||||
if (expr == null) {
|
if (expr == null) {
|
||||||
expr = fpe.parse(src.getLogMessage());
|
expr = fpe.parse(src.getLogMessage());
|
||||||
// fpe.check(context.appInfo, ??, ??, expr)
|
|
||||||
src.setUserData(MAP_WHERE_LOG, expr);
|
src.setUserData(MAP_WHERE_LOG, expr);
|
||||||
}
|
}
|
||||||
CommaSeparatedStringBuilder b = new CommaSeparatedStringBuilder();
|
CommaSeparatedStringBuilder b = new CommaSeparatedStringBuilder();
|
||||||
for (Base item : items)
|
for (Base item : items) {
|
||||||
b.appendIfNotNull(fpe.evaluateToString(vars, null, null, item, expr));
|
Variables varsForSource = vars.copy();
|
||||||
|
if (src.hasVariable()) {
|
||||||
|
varsForSource.add(VariableMode.INPUT, src.getVariable(), item);
|
||||||
|
}
|
||||||
|
b.appendIfNotNull(fpe.evaluateToString(varsForSource, null, null, item, expr));
|
||||||
|
}
|
||||||
if (b.length() > 0)
|
if (b.length() > 0)
|
||||||
services.log(b.toString());
|
services.log(b.toString());
|
||||||
}
|
}
|
||||||
|
@ -2520,7 +2529,6 @@ public class StructureMapUtilities {
|
||||||
ExpressionNode expr = (ExpressionNode) tgt.getUserData(MAP_EXPRESSION);
|
ExpressionNode expr = (ExpressionNode) tgt.getUserData(MAP_EXPRESSION);
|
||||||
if (expr == null) {
|
if (expr == null) {
|
||||||
expr = fpe.parse(getParamString(vars, tgt.getParameter().get(tgt.getParameter().size() - 1)));
|
expr = fpe.parse(getParamString(vars, tgt.getParameter().get(tgt.getParameter().size() - 1)));
|
||||||
tgt.setUserData(MAP_WHERE_EXPRESSION, expr);
|
|
||||||
}
|
}
|
||||||
return fpe.check(vars, null, expr);
|
return fpe.check(vars, null, expr);
|
||||||
case TRANSLATE:
|
case TRANSLATE:
|
||||||
|
|
|
@ -72,6 +72,19 @@ public class StructureMapUtilitiesTest implements ITransformerServices {
|
||||||
assertEquals("2023-09-20T13:19:13.502Z", fp.evaluateToString(target, "deceased"));
|
assertEquals("2023-09-20T13:19:13.502Z", fp.evaluateToString(target, "deceased"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testWhereClause() throws IOException, FHIRException {
|
||||||
|
StructureMapUtilities scu = new StructureMapUtilities(context, this);
|
||||||
|
scu.setDebug(true);
|
||||||
|
String fileMap = TestingUtilities.loadTestResource("r5", "structure-mapping", "whereclause.map");
|
||||||
|
Element source = Manager.parseSingle(context, TestingUtilities.loadTestResourceStream("r4", "examples", "capabilitystatement-example.json"), FhirFormat.JSON);
|
||||||
|
StructureMap structureMap = scu.parse(fileMap, "whereclause");
|
||||||
|
Element target = Manager.build(context, scu.getTargetType(structureMap));
|
||||||
|
scu.transform(null, source, structureMap, target);
|
||||||
|
FHIRPathEngine fp = new FHIRPathEngine(context);
|
||||||
|
assertEquals("true", fp.evaluateToString(target, "rest.resource.interaction.where(code='create').exists()"));
|
||||||
|
}
|
||||||
|
|
||||||
private void assertSerializeDeserialize(StructureMap structureMap) {
|
private void assertSerializeDeserialize(StructureMap structureMap) {
|
||||||
Assertions.assertEquals("syntax", structureMap.getName());
|
Assertions.assertEquals("syntax", structureMap.getName());
|
||||||
Assertions.assertEquals("description", structureMap.getDescription());
|
Assertions.assertEquals("description", structureMap.getDescription());
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||||
<artifactId>org.hl7.fhir.core</artifactId>
|
<artifactId>org.hl7.fhir.core</artifactId>
|
||||||
<version>6.3.29-SNAPSHOT</version>
|
<version>6.3.30-SNAPSHOT</version>
|
||||||
<relativePath>../pom.xml</relativePath>
|
<relativePath>../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||||
<artifactId>org.hl7.fhir.core</artifactId>
|
<artifactId>org.hl7.fhir.core</artifactId>
|
||||||
<version>6.3.29-SNAPSHOT</version>
|
<version>6.3.30-SNAPSHOT</version>
|
||||||
<relativePath>../pom.xml</relativePath>
|
<relativePath>../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||||
<artifactId>org.hl7.fhir.core</artifactId>
|
<artifactId>org.hl7.fhir.core</artifactId>
|
||||||
<version>6.3.29-SNAPSHOT</version>
|
<version>6.3.30-SNAPSHOT</version>
|
||||||
<relativePath>../pom.xml</relativePath>
|
<relativePath>../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||||
<artifactId>org.hl7.fhir.core</artifactId>
|
<artifactId>org.hl7.fhir.core</artifactId>
|
||||||
<version>6.3.29-SNAPSHOT</version>
|
<version>6.3.30-SNAPSHOT</version>
|
||||||
<relativePath>../pom.xml</relativePath>
|
<relativePath>../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
|
|
2
pom.xml
2
pom.xml
|
@ -14,7 +14,7 @@
|
||||||
HAPI FHIR
|
HAPI FHIR
|
||||||
-->
|
-->
|
||||||
<artifactId>org.hl7.fhir.core</artifactId>
|
<artifactId>org.hl7.fhir.core</artifactId>
|
||||||
<version>6.3.29-SNAPSHOT</version>
|
<version>6.3.30-SNAPSHOT</version>
|
||||||
<packaging>pom</packaging>
|
<packaging>pom</packaging>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
|
|
Loading…
Reference in New Issue