Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

3764 WIP Fix for #3764 #3896

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

dotasek
Copy link
Contributor

@dotasek dotasek commented Aug 9, 2022

WORK IN PROGRESS

This is the bare minimum of code required for our test case to pass, and to allow a review of the solution itself.

@@ -94,7 +94,7 @@ public static void main(String[] args) throws Exception {

ValidationSupportChain validationSupportChain = new ValidationSupportChain();
validationSupportChain.addValidationSupport((ca.uhn.fhir.context.support.IValidationSupport) new DefaultProfileValidationSupport(ctx));
validationSupportChain.addValidationSupport((ca.uhn.fhir.context.support.IValidationSupport) new PrePopulatedValidationSupport(ctx, structureDefinitions, valueSets, codeSystems));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Recommend leaving the old constructor in place (the one without the final parameter) but also creating the new constructor, and having the old one just chain to the new one. That way we don't break any existing users' code.

import static ca.uhn.fhir.util.ClasspathUtil.loadResource;
import static org.junit.jupiter.api.Assertions.assertEquals;

public class ParserWithValidationR4Test {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A couple of comments on this test:

  • The naming for this class and the test method don't seem to align with what's actually being tested. Maybe XverValidationR4Test?
  • We should include a negative test as well - E.g. same resource being validated but instead of "valueUri" : "https://r2.smarthealthit.org" it ias "valueInteger": 123 and presumably we'd get a validation error because the value is of the wrong datatype?
  • It'd be nice to include an example on this page that shows how to validate with xver refs. I think the code snippet would basically by the same logic as this test.

@@ -258,7 +258,8 @@ public List<StructureDefinition> getStructures() {

@Override
public void cacheResource(Resource res) {
throw new UnsupportedOperationException(Msg.code(660));
//FIXME Should we implement anything here?
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jamesagnew I removed the UnsupportedOperationException here because this chunk of code in the core library was triggering it:

https://github.com/hapifhir/org.hl7.fhir.core/blob/327d73aae550b2bbca146558749b542e99d67b35/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/BaseValidator.java#L1062

I don't like removing this exception. I think the appropriate thing to do would be to have IWorkerContext include a new method like implementsCacheResource, which is set to false in our implementation, which would prevent cacheResource from being called.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dotasek definitely no concerns with making that method a no-op.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants