Merge pull request #1535 from hapifhir/2024-01-gg-fix-fhirpath-messages

2024 01 gg fix fhirpath messages
This commit is contained in:
Grahame Grieve 2024-01-10 07:03:26 +11:00 committed by GitHub
commit 71c67405dc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 28 additions and 7 deletions

View File

@ -1720,7 +1720,7 @@ public class FHIRPathEngine {
return new ArrayList<Base>(Arrays.asList(context.focusResource));
} else if (s.equals("%rootResource")) {
if (context.rootResource == null) {
throw makeException(expr, I18nConstants.FHIRPATH_CANNOT_USE, "%rootResource", "no focus resource");
throw makeException(expr, I18nConstants.FHIRPATH_CANNOT_USE, "%rootResource", "no focus rootResource");
}
return new ArrayList<Base>(Arrays.asList(context.rootResource));
} else if (s.equals("%context")) {
@ -3092,7 +3092,7 @@ public class FHIRPathEngine {
return new TypeDetails(CollectionStatus.SINGLETON, context.resource);
} else if (s.equals("%rootResource")) {
if (context.resource == null) {
throw makeException(expr, I18nConstants.FHIRPATH_CANNOT_USE, "%rootResource", "no focus resource");
throw makeException(expr, I18nConstants.FHIRPATH_CANNOT_USE, "%rootResource", "no focus rootResource");
}
return new TypeDetails(CollectionStatus.SINGLETON, context.resource);
} else if (s.equals("%context")) {

View File

@ -768,6 +768,7 @@ public class PatientRenderer extends ResourceRenderer {
} else {
String n = UUID.randomUUID().toString().toLowerCase()+ext;
TextFile.bytesToFile(att.getData(), new File(Utilities.path(context.getDestDir(), n)));
context.registerFile(n);
td.img(n, "patient photo");
}
return;

View File

@ -188,6 +188,7 @@ public class RenderingContext {
private boolean copyButton;
private ProfileKnowledgeProvider pkp;
private String changeVersion;
private List<String> files = new ArrayList<String>(); // files created as by-products in destDir
private Map<KnownLinkType, String> links = new HashMap<>();
private Map<String, String> namedLinks = new HashMap<>();
@ -726,4 +727,16 @@ public class RenderingContext {
return namedLinks;
}
public void registerFile(String n) {
try {
files.add(Utilities.path(destDir, n));
} catch (IOException e) {
}
}
public List<String> getFiles() {
return files;
}
}

View File

@ -173,6 +173,7 @@ import org.hl7.fhir.r5.utils.validation.IValidationPolicyAdvisor;
import org.hl7.fhir.r5.utils.validation.IValidationProfileUsageTracker;
import org.hl7.fhir.r5.utils.validation.IValidatorResourceFetcher;
import org.hl7.fhir.r5.utils.validation.IValidationPolicyAdvisor.CodedContentValidationAction;
import org.hl7.fhir.r5.utils.validation.IValidationPolicyAdvisor.ElementValidationAction;
import org.hl7.fhir.r5.utils.validation.constants.BestPracticeWarningLevel;
import org.hl7.fhir.r5.utils.validation.constants.BindingKind;
import org.hl7.fhir.r5.utils.validation.constants.CheckDisplayOption;
@ -6222,6 +6223,9 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat
if (debug) {
System.out.println(" check " + localStack.getLiteralPath()+" against "+ei.getDefinition().getId()+" in profile "+profile.getVersionedUrl()+time());
}
EnumSet<ElementValidationAction> actionSet = policyAdvisor == null ? EnumSet.allOf(ElementValidationAction.class) :
policyAdvisor.policyForElement(this, valContext.getAppContext(), profile, ei.getDefinition(), localStack.getLiteralPath());
String localStackLiteralPath = localStack.getLiteralPath();
String eiPath = ei.getPath();
if (!eiPath.equals(localStackLiteralPath)) {
@ -6237,8 +6241,11 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat
// ok = checkInvariants(valContext, errors, profile, typeDefn != null ? typeDefn : checkDefn, ei.getElement(), ei.getElement(), localStack, false) && ok;
// but this isn't correct - when the invariant is on the element, the invariant is in the context of the resource that contains the element.
// changed 18-Jul 2023 - see https://chat.fhir.org/#narrow/stream/179266-fhirpath/topic/FHIRPath.20.25resource.20variable
ok = checkInvariants(valContext, errors, profile, typeDefn != null ? typeDefn : checkDefn, resource, ei.getElement(), localStack, false) && ok;
if (actionSet.contains(ElementValidationAction.Invariants)) {
ok = checkInvariants(valContext, errors, profile, typeDefn != null ? typeDefn : checkDefn, resource, ei.getElement(), localStack, false) && ok;
}
boolean checkBindings = actionSet.contains(ElementValidationAction.Bindings);
ei.getElement().markValidation(profile, checkDefn);
boolean elementValidated = false;
if (type != null) {
@ -6255,15 +6262,15 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat
if (type.equals("Identifier")) {
ok = checkIdentifier(errors, ei.getPath(), ei.getElement(), checkDefn) && ok;
} else if (type.equals("Coding")) {
ok = checkCoding(errors, ei.getPath(), ei.getElement(), profile, checkDefn, inCodeableConcept, checkDisplayInContext, localStack) && ok;
ok = (checkCoding(checkBindings ? errors : new ArrayList<>(), ei.getPath(), ei.getElement(), profile, checkDefn, inCodeableConcept, checkDisplayInContext, localStack) || !checkBindings) && ok;
} else if (type.equals("Quantity")) {
ok = checkQuantity(errors, ei.getPath(), ei.getElement(), profile, checkDefn, localStack) && ok;
} else if (type.equals("Attachment")) {
ok = checkAttachment(errors, ei.getPath(), ei.getElement(), profile, checkDefn, inCodeableConcept, checkDisplayInContext, localStack) && ok;
} else if (type.equals("CodeableConcept")) {
BooleanHolder bh = new BooleanHolder();
checkDisplay = checkCodeableConcept(errors, ei.getPath(), ei.getElement(), profile, checkDefn, localStack, bh);
ok = bh.ok() & ok;
checkDisplay = checkCodeableConcept(checkBindings ? errors : new ArrayList<>(), ei.getPath(), ei.getElement(), profile, checkDefn, localStack, bh);
ok = (bh.ok() || !checkBindings) & ok;
thisIsCodeableConcept = true;
} else if (type.equals("Reference")) {
ok = checkReference(valContext, errors, ei.getPath(), ei.getElement(), profile, checkDefn, actualType, localStack, pct, mode) && ok;