Skip to content

Commit 08428f9

Browse files
dotasekjamesagnew
andauthored
Update to org.hl7.fhir.core 6.6.1 (#7149)
* WIP match package changes to org.hl7.fhir.core * Hacky solution * Use core 6.6.1 + adjust method signatures * Fix breaking validation tests * Bump exception codes * Delete outdated tests as per PR comments * More robust asserts (stop caring about message order) * Add comments as per PR comments * spotless * Add test for #6316 * Update error codes * Naming convention * spotless --------- Co-authored-by: James Agnew <[email protected]>
1 parent 440d4c8 commit 08428f9

File tree

22 files changed

+214
-209
lines changed

22 files changed

+214
-209
lines changed

hapi-fhir-base/src/main/java/ca/uhn/fhir/fhirpath/IFhirPathEvaluationContext.java

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,25 @@
2828

2929
public interface IFhirPathEvaluationContext {
3030

31+
/**
32+
* The is an adapter for org.hl7.fhir.utilities.fhirpath.FHIRPathConstantEvaluationMode. At present, it matches
33+
* org.hl7.fhir.core 1-to-1.
34+
* </br>
35+
* Comments are provided here for convenience, but org.hl7.fhir.utilities.fhirpath.FHIRPathConstantEvaluationMode
36+
* should be considered the source of truth.
37+
*
38+
*/
39+
public enum ConstantEvaluationMode {
40+
EXPLICIT, // the FHIRPathEngine has encountered an explicit reference to a constant e.g. %{token} that it does
41+
// not recognise internally
42+
NOVALUE, // the FHIRPathEngine was invoked with no focus provided
43+
IMPLICIT_BEFORE, // The FHIRPath engine is about to evaluate a named property reference, but the Host
44+
// Application is being offered an opportunity to provide it's own value first
45+
IMPLICIT_AFTER // The FHIRPath engine has evaluated a property and found nothing, and perhaps the Host
46+
// Application wants to offer a value (constant fall through). This only happens if
47+
// checkWithHostServicesBeforeHand is true on the FHIRPath engine
48+
}
49+
3150
/**
3251
* Evaluates the <code>resolve()</code> function and returns the target
3352
* of the resolution.
@@ -41,12 +60,13 @@ default IBase resolveReference(@Nonnull IIdType theReference, @Nullable IBase th
4160

4261
/**
4362
*
44-
* @param appContext
45-
* @param name The name of the constant(s) to be resolved
46-
* @param beforeContext
63+
* @param theAppContext
64+
* @param theName The name of the constant(s) to be resolved
65+
* @param theConstantEvaluationMode
4766
* @return
4867
*/
49-
default List<IBase> resolveConstant(Object appContext, String name, boolean beforeContext) {
68+
default List<IBase> resolveConstant(
69+
Object theAppContext, String theName, ConstantEvaluationMode theConstantEvaluationMode) {
5070
return null;
5171
}
5272
}

hapi-fhir-jpaserver-searchparam/src/main/java/ca/uhn/fhir/jpa/searchparam/extractor/SearchParamExtractorR4.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,15 @@
3535
import org.hl7.fhir.r4.fhirpath.ExpressionNode;
3636
import org.hl7.fhir.r4.fhirpath.FHIRPathEngine;
3737
import org.hl7.fhir.r4.fhirpath.FHIRPathUtilityClasses.FunctionDetails;
38+
import org.hl7.fhir.r4.fhirpath.IHostApplicationServices;
3839
import org.hl7.fhir.r4.fhirpath.TypeDetails;
3940
import org.hl7.fhir.r4.hapi.ctx.HapiWorkerContext;
4041
import org.hl7.fhir.r4.model.Base;
4142
import org.hl7.fhir.r4.model.IdType;
4243
import org.hl7.fhir.r4.model.Resource;
4344
import org.hl7.fhir.r4.model.ResourceType;
4445
import org.hl7.fhir.r4.model.ValueSet;
46+
import org.hl7.fhir.utilities.fhirpath.FHIRPathConstantEvaluationMode;
4547

4648
import java.util.Collections;
4749
import java.util.HashMap;
@@ -101,20 +103,20 @@ public void initFhirPath() {
101103
myParsedFhirPathCache = CacheFactory.build(TimeUnit.MINUTES.toMillis(10));
102104
}
103105

104-
private class SearchParamExtractorR4HostServices implements FHIRPathEngine.IEvaluationContext {
106+
private class SearchParamExtractorR4HostServices implements IHostApplicationServices {
105107

106108
private final Map<String, Base> myResourceTypeToStub = Collections.synchronizedMap(new HashMap<>());
107109

108110
@Override
109111
public List<Base> resolveConstant(
110-
FHIRPathEngine engine, Object appContext, String name, boolean beforeContext, boolean explicitConstant)
112+
FHIRPathEngine engine, Object appContext, String name, FHIRPathConstantEvaluationMode mode)
111113
throws PathEngineException {
112114
return Collections.emptyList();
113115
}
114116

115117
@Override
116118
public TypeDetails resolveConstantType(
117-
FHIRPathEngine engine, Object appContext, String name, boolean explicitConstant)
119+
FHIRPathEngine engine, Object appContext, String name, FHIRPathConstantEvaluationMode mode)
118120
throws PathEngineException {
119121
return null;
120122
}

hapi-fhir-jpaserver-searchparam/src/main/java/ca/uhn/fhir/jpa/searchparam/extractor/SearchParamExtractorR4B.java

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,15 @@
3535
import org.hl7.fhir.r4b.fhirpath.ExpressionNode;
3636
import org.hl7.fhir.r4b.fhirpath.FHIRPathEngine;
3737
import org.hl7.fhir.r4b.fhirpath.FHIRPathUtilityClasses.FunctionDetails;
38+
import org.hl7.fhir.r4b.fhirpath.IHostApplicationServices;
3839
import org.hl7.fhir.r4b.fhirpath.TypeDetails;
3940
import org.hl7.fhir.r4b.hapi.ctx.HapiWorkerContext;
4041
import org.hl7.fhir.r4b.model.Base;
4142
import org.hl7.fhir.r4b.model.IdType;
4243
import org.hl7.fhir.r4b.model.Resource;
4344
import org.hl7.fhir.r4b.model.ResourceType;
4445
import org.hl7.fhir.r4b.model.ValueSet;
46+
import org.hl7.fhir.utilities.fhirpath.FHIRPathConstantEvaluationMode;
4547

4648
import java.util.Collections;
4749
import java.util.HashMap;
@@ -101,20 +103,20 @@ public void initFhirPath() {
101103
myParsedFhirPathCache = CacheFactory.build(TimeUnit.MINUTES.toMillis(10));
102104
}
103105

104-
private class SearchParamExtractorR4BHostServices implements FHIRPathEngine.IEvaluationContext {
106+
private class SearchParamExtractorR4BHostServices implements IHostApplicationServices {
105107

106108
private final Map<String, Base> myResourceTypeToStub = Collections.synchronizedMap(new HashMap<>());
107109

108110
@Override
109111
public List<Base> resolveConstant(
110-
FHIRPathEngine engine, Object appContext, String name, boolean beforeContext, boolean explicitConstant)
112+
FHIRPathEngine engine, Object appContext, String name, FHIRPathConstantEvaluationMode mode)
111113
throws PathEngineException {
112114
return Collections.emptyList();
113115
}
114116

115117
@Override
116118
public TypeDetails resolveConstantType(
117-
FHIRPathEngine engine, Object appContext, String name, boolean explicitConstant)
119+
FHIRPathEngine engine, Object appContext, String name, FHIRPathConstantEvaluationMode mode)
118120
throws PathEngineException {
119121
return null;
120122
}
@@ -208,5 +210,10 @@ public boolean conformsToProfile(FHIRPathEngine engine, Object appContext, Base
208210
public ValueSet resolveValueSet(FHIRPathEngine engine, Object appContext, String url) {
209211
return null;
210212
}
213+
214+
@Override
215+
public boolean paramIsType(String name, int index) {
216+
return false;
217+
}
211218
}
212219
}

hapi-fhir-jpaserver-searchparam/src/main/java/ca/uhn/fhir/jpa/searchparam/extractor/SearchParamExtractorR5.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,15 @@
3434
import org.hl7.fhir.r5.fhirpath.ExpressionNode;
3535
import org.hl7.fhir.r5.fhirpath.FHIRPathEngine;
3636
import org.hl7.fhir.r5.fhirpath.FHIRPathUtilityClasses.FunctionDetails;
37+
import org.hl7.fhir.r5.fhirpath.IHostApplicationServices;
3738
import org.hl7.fhir.r5.fhirpath.TypeDetails;
3839
import org.hl7.fhir.r5.hapi.ctx.HapiWorkerContext;
3940
import org.hl7.fhir.r5.model.Base;
4041
import org.hl7.fhir.r5.model.IdType;
4142
import org.hl7.fhir.r5.model.Resource;
4243
import org.hl7.fhir.r5.model.ResourceType;
4344
import org.hl7.fhir.r5.model.ValueSet;
45+
import org.hl7.fhir.utilities.fhirpath.FHIRPathConstantEvaluationMode;
4446

4547
import java.util.Collections;
4648
import java.util.HashMap;
@@ -98,20 +100,20 @@ public IValueExtractor getPathValueExtractor(IBase theResource, String theSingle
98100
};
99101
}
100102

101-
private class SearchParamExtractorR5HostServices implements FHIRPathEngine.IEvaluationContext {
103+
private class SearchParamExtractorR5HostServices implements IHostApplicationServices {
102104

103105
private final Map<String, Base> myResourceTypeToStub = Collections.synchronizedMap(new HashMap<>());
104106

105107
@Override
106108
public List<Base> resolveConstant(
107-
FHIRPathEngine engine, Object appContext, String name, boolean beforeContext, boolean explicitConstant)
109+
FHIRPathEngine engine, Object appContext, String name, FHIRPathConstantEvaluationMode mode)
108110
throws PathEngineException {
109111
return Collections.emptyList();
110112
}
111113

112114
@Override
113115
public TypeDetails resolveConstantType(
114-
FHIRPathEngine engine, Object appContext, String name, boolean explicitConstant)
116+
FHIRPathEngine engine, Object appContext, String name, FHIRPathConstantEvaluationMode mode)
115117
throws PathEngineException {
116118
return null;
117119
}

hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/topic/SubscriptionTriggerMatcher.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,10 +133,13 @@ private InMemoryMatchResult evaluateFhirPathCriteria(String theFhirPathCriteria)
133133
fhirPathEngine.setEvaluationContext(new IFhirPathEvaluationContext() {
134134

135135
@Override
136-
public List<IBase> resolveConstant(Object appContext, String name, boolean beforeContext) {
137-
if ("current".equalsIgnoreCase(name)) return List.of(myResource);
136+
public List<IBase> resolveConstant(
137+
Object theAppContext,
138+
String theName,
139+
IFhirPathEvaluationContext.ConstantEvaluationMode theConstantEvaluationMode) {
140+
if ("current".equalsIgnoreCase(theName)) return List.of(myResource);
138141

139-
if ("previous".equalsIgnoreCase(name)) {
142+
if ("previous".equalsIgnoreCase(theName)) {
140143
Optional previousResource = myPreviousVersionReader.readPreviousVersion(myResource);
141144
if (previousResource.isPresent()) return List.of((IBase) previousResource.get());
142145
}

hapi-fhir-storage/src/main/java/ca/uhn/fhir/jpa/graphql/GraphQLProvider.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
import jakarta.annotation.Nullable;
4343
import org.apache.commons.lang3.ObjectUtils;
4444
import org.apache.commons.lang3.Validate;
45+
import org.hl7.fhir.dstu3.support.utils.GraphQLEngine;
4546
import org.hl7.fhir.instance.model.api.IBaseResource;
4647
import org.hl7.fhir.instance.model.api.IIdType;
4748
import org.hl7.fhir.utilities.graphql.IGraphQLEngine;
@@ -90,7 +91,7 @@ public GraphQLProvider(
9091
validationSupport, new DefaultProfileValidationSupport(theFhirContext));
9192
org.hl7.fhir.dstu3.hapi.ctx.HapiWorkerContext workerContext =
9293
new org.hl7.fhir.dstu3.hapi.ctx.HapiWorkerContext(theFhirContext, validationSupport);
93-
myEngineFactory = () -> new org.hl7.fhir.dstu3.utils.GraphQLEngine(workerContext);
94+
myEngineFactory = () -> new GraphQLEngine(workerContext);
9495
break;
9596
}
9697
case R4: {

hapi-fhir-structures-dstu3/src/main/java/org/hl7/fhir/dstu3/hapi/ctx/HapiWorkerContext.java

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,6 @@
2727
import org.hl7.fhir.dstu3.model.ValueSet;
2828
import org.hl7.fhir.dstu3.model.ValueSet.ConceptSetComponent;
2929
import org.hl7.fhir.dstu3.model.ValueSet.ValueSetExpansionComponent;
30-
import org.hl7.fhir.dstu3.terminologies.ValueSetExpander;
31-
import org.hl7.fhir.dstu3.utils.INarrativeGenerator;
32-
import org.hl7.fhir.dstu3.utils.validation.IResourceValidator;
3330
import org.hl7.fhir.exceptions.FHIRException;
3431
import org.hl7.fhir.utilities.FhirPublication;
3532
import org.hl7.fhir.utilities.i18n.I18nBase;
@@ -143,7 +140,7 @@ public List<ConceptMap> findMapsForSource(String theUrl) {
143140
}
144141

145142
@Override
146-
public ValueSetExpander.ValueSetExpansionOutcome expandVS(ValueSet source, boolean cacheOk, boolean heiarchical) {
143+
public IWorkerContext.ValueSetExpansionOutcome expandVS(ValueSet source, boolean cacheOk, boolean heiarchical) {
147144
throw new UnsupportedOperationException(Msg.code(614));
148145
}
149146

@@ -162,16 +159,6 @@ public void setExpansionProfile(ExpansionProfile theExpProfile) {
162159
myExpansionProfile = theExpProfile;
163160
}
164161

165-
@Override
166-
public INarrativeGenerator getNarrativeGenerator(String thePrefix, String theBasePath) {
167-
throw new UnsupportedOperationException(Msg.code(616));
168-
}
169-
170-
@Override
171-
public IResourceValidator newValidator() throws FHIRException {
172-
throw new UnsupportedOperationException(Msg.code(617));
173-
}
174-
175162
@Override
176163
public IParser getParser(ParserType theType) {
177164
throw new UnsupportedOperationException(Msg.code(618));

hapi-fhir-structures-dstu3/src/main/java/org/hl7/fhir/dstu3/hapi/fluentpath/FhirPathDstu3.java

Lines changed: 41 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,16 @@
1010
import org.hl7.fhir.dstu3.fhirpath.ExpressionNode;
1111
import org.hl7.fhir.dstu3.fhirpath.FHIRPathEngine;
1212
import org.hl7.fhir.dstu3.fhirpath.FHIRPathUtilityClasses.FunctionDetails;
13+
import org.hl7.fhir.dstu3.fhirpath.IHostApplicationServices;
1314
import org.hl7.fhir.dstu3.fhirpath.TypeDetails;
1415
import org.hl7.fhir.dstu3.hapi.ctx.HapiWorkerContext;
1516
import org.hl7.fhir.dstu3.model.Base;
1617
import org.hl7.fhir.dstu3.model.IdType;
18+
import org.hl7.fhir.dstu3.model.ValueSet;
1719
import org.hl7.fhir.exceptions.FHIRException;
1820
import org.hl7.fhir.exceptions.PathEngineException;
1921
import org.hl7.fhir.instance.model.api.IBase;
22+
import org.hl7.fhir.utilities.fhirpath.FHIRPathConstantEvaluationMode;
2023

2124
import java.util.List;
2225
import java.util.Optional;
@@ -87,15 +90,19 @@ public IParsedExpression parse(String theExpression) {
8790

8891
@Override
8992
public void setEvaluationContext(@Nonnull IFhirPathEvaluationContext theEvaluationContext) {
90-
myEngine.setHostServices(new FHIRPathEngine.IEvaluationContext() {
93+
myEngine.setHostServices(new IHostApplicationServices() {
9194

9295
@Override
93-
public Base resolveConstant(Object appContext, String name) throws PathEngineException {
96+
public List<Base> resolveConstant(
97+
FHIRPathEngine engine, Object appContext, String name, FHIRPathConstantEvaluationMode mode)
98+
throws PathEngineException {
9499
return null;
95100
}
96101

97102
@Override
98-
public TypeDetails resolveConstantType(Object appContext, String name) throws PathEngineException {
103+
public TypeDetails resolveConstantType(
104+
FHIRPathEngine engine, Object appContext, String name, FHIRPathConstantEvaluationMode mode)
105+
throws PathEngineException {
99106
return null;
100107
}
101108

@@ -105,25 +112,52 @@ public boolean log(String argument, List<Base> focus) {
105112
}
106113

107114
@Override
108-
public FunctionDetails resolveFunction(String functionName) {
115+
public FunctionDetails resolveFunction(FHIRPathEngine engine, String functionName) {
109116
return null;
110117
}
111118

112119
@Override
113-
public TypeDetails checkFunction(Object appContext, String functionName, List<TypeDetails> parameters)
120+
public TypeDetails checkFunction(
121+
FHIRPathEngine engine,
122+
Object appContext,
123+
String functionName,
124+
TypeDetails focus,
125+
List<TypeDetails> parameters)
114126
throws PathEngineException {
115127
return null;
116128
}
117129

118130
@Override
119-
public List<Base> executeFunction(Object appContext, String functionName, List<List<Base>> parameters) {
131+
public List<Base> executeFunction(
132+
FHIRPathEngine engine,
133+
Object appContext,
134+
List<Base> focus,
135+
String functionName,
136+
List<List<Base>> parameters) {
120137
return null;
121138
}
122139

123140
@Override
124-
public Base resolveReference(Object appContext, String theUrl) throws FHIRException {
141+
public Base resolveReference(FHIRPathEngine engine, Object appContext, String theUrl, Base refContext)
142+
throws FHIRException {
125143
return (Base) theEvaluationContext.resolveReference(new IdType(theUrl), null);
126144
}
145+
146+
@Override
147+
public boolean conformsToProfile(FHIRPathEngine engine, Object appContext, Base item, String url)
148+
throws FHIRException {
149+
return false;
150+
}
151+
152+
@Override
153+
public ValueSet resolveValueSet(FHIRPathEngine engine, Object appContext, String url) {
154+
return null;
155+
}
156+
157+
@Override
158+
public boolean paramIsType(String name, int index) {
159+
return false;
160+
}
127161
});
128162
}
129163

hapi-fhir-structures-r4/src/main/java/org/hl7/fhir/r4/hapi/fluentpath/FhirPathR4.java

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,13 @@
1313
import org.hl7.fhir.r4.fhirpath.ExpressionNode;
1414
import org.hl7.fhir.r4.fhirpath.FHIRPathEngine;
1515
import org.hl7.fhir.r4.fhirpath.FHIRPathUtilityClasses.FunctionDetails;
16+
import org.hl7.fhir.r4.fhirpath.IHostApplicationServices;
1617
import org.hl7.fhir.r4.fhirpath.TypeDetails;
1718
import org.hl7.fhir.r4.hapi.ctx.HapiWorkerContext;
1819
import org.hl7.fhir.r4.model.Base;
1920
import org.hl7.fhir.r4.model.IdType;
2021
import org.hl7.fhir.r4.model.ValueSet;
22+
import org.hl7.fhir.utilities.fhirpath.FHIRPathConstantEvaluationMode;
2123

2224
import java.util.List;
2325
import java.util.Optional;
@@ -91,22 +93,18 @@ public IParsedExpression parse(String theExpression) {
9193

9294
@Override
9395
public void setEvaluationContext(@Nonnull IFhirPathEvaluationContext theEvaluationContext) {
94-
myEngine.setHostServices(new FHIRPathEngine.IEvaluationContext() {
96+
myEngine.setHostServices(new IHostApplicationServices() {
9597

9698
@Override
9799
public List<Base> resolveConstant(
98-
FHIRPathEngine engine,
99-
Object appContext,
100-
String name,
101-
boolean beforeContext,
102-
boolean explicitConstant)
100+
FHIRPathEngine engine, Object appContext, String name, FHIRPathConstantEvaluationMode mode)
103101
throws PathEngineException {
104102
return null;
105103
}
106104

107105
@Override
108106
public TypeDetails resolveConstantType(
109-
FHIRPathEngine engine, Object appContext, String name, boolean explicitConstant)
107+
FHIRPathEngine engine, Object appContext, String name, FHIRPathConstantEvaluationMode mode)
110108
throws PathEngineException {
111109
return null;
112110
}

0 commit comments

Comments
 (0)