This commit is contained in:
Grahame Grieve 2024-06-06 19:40:33 +10:00
commit 0250f3ce34
4 changed files with 174 additions and 148 deletions

View File

@ -473,10 +473,12 @@ public class ValidationService {
if (sessionId != null) { if (sessionId != null) {
System.out.println("No such cached session exists for session id " + sessionId + ", re-instantiating validator."); System.out.println("No such cached session exists for session id " + sessionId + ", re-instantiating validator.");
} }
System.out.println("Building new validator engine from CliContext");
ValidationEngine validator = buildValidationEngine(cliContext, definitions, tt); ValidationEngine validator = buildValidationEngine(cliContext, definitions, tt);
sessionId = sessionCache.cacheSession(validator); sessionId = sessionCache.cacheSession(validator);
System.out.println("Cached new session. Cache size = " + sessionCache.getSessionIds().size());
} else { } else {
System.out.println("Cached session exists for session id " + sessionId + ", returning stored validator session id."); System.out.println("Cached session exists for session id " + sessionId + ", returning stored validator session id. Cache size = " + sessionCache.getSessionIds().size());
} }
return sessionId; return sessionId;
} }

View File

@ -1029,7 +1029,7 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat
validateResource(new ValidationContext(appContext, element), errors, element, element, defn, resourceIdRule, stack.resetIds(), null, new ValidationMode(ValidationReason.Validation, ProfileSource.ConfigProfile), false, false); validateResource(new ValidationContext(appContext, element), errors, element, element, defn, resourceIdRule, stack.resetIds(), null, new ValidationMode(ValidationReason.Validation, ProfileSource.ConfigProfile), false, false);
} }
} }
if (hintAboutNonMustSupport) { if (hintAboutNonMustSupport && !profiles.isEmpty()) {
checkElementUsage(errors, element, stack); checkElementUsage(errors, element, stack);
} }
codingObserver.finish(errors, stack); codingObserver.finish(errors, stack);
@ -1042,10 +1042,19 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat
private void checkElementUsage(List<ValidationMessage> errors, Element element, NodeStack stack) { private void checkElementUsage(List<ValidationMessage> errors, Element element, NodeStack stack) {
if (element.getPath()==null
|| (element.getName().equals("id") && !element.getPath().substring(0, element.getPath().length()-3).contains("."))
|| (element.getName().equals("text") && !element.getPath().substring(0, element.getPath().length()-5).contains(".")))
return;
String hasFixed = element.getUserString("hasFixed");
if (element.getPath().contains(".") && (hasFixed== null || !hasFixed.equals("Y"))) {
String elementUsage = element.getUserString("elementSupported"); String elementUsage = element.getUserString("elementSupported");
hint(errors, NO_RULE_DATE, IssueType.INFORMATIONAL, element.line(), element.col(), stack.getLiteralPath(), elementUsage == null || elementUsage.equals("Y"), I18nConstants.MUSTSUPPORT_VAL_MUSTSUPPORT, element.getName(), element.getProperty().getStructure().getVersionedUrl()); hint(errors, NO_RULE_DATE, IssueType.INFORMATIONAL, element.line(), element.col(), stack.getLiteralPath(), elementUsage != null && (elementUsage.equals("Y") || elementUsage.equals("NA")), I18nConstants.MUSTSUPPORT_VAL_MUSTSUPPORT, element.getName(), element.getProperty().getStructure().getVersionedUrl());
if (elementUsage==null || !elementUsage.equals("Y"))
return;
}
if (element.hasChildren()) { if (element.hasChildren() && (hasFixed== null || !hasFixed.equals("Y"))) {
String prevName = ""; String prevName = "";
int elementCount = 0; int elementCount = 0;
for (Element ce : element.getChildren()) { for (Element ce : element.getChildren()) {
@ -6745,13 +6754,16 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat
} }
profile.setUserData("usesMustSupport", usesMustSupport); profile.setUserData("usesMustSupport", usesMustSupport);
} }
if (usesMustSupport.equals("Y")) {
String elementSupported = ei.getElement().getUserString("elementSupported"); String elementSupported = ei.getElement().getUserString("elementSupported");
if (elementSupported == null || ei.definition.getMustSupport()) String fixedValue = ei.getElement().getUserString("hasFixed");
if ((elementSupported == null || !elementSupported.equals("Y")) && ei.definition.getMustSupport()) {
if (ei.definition.getMustSupport()) { if (ei.definition.getMustSupport()) {
ei.getElement().setUserData("elementSupported", "Y"); ei.getElement().setUserData("elementSupported", "Y");
} }
} } else if (elementSupported == null && !usesMustSupport.equals("Y"))
ei.getElement().setUserData("elementSupported", "NA");
if (fixedValue==null && (ei.definition.hasFixed() || ei.definition.hasPattern()))
ei.getElement().setUserData("hasFixed", "Y");
} }
public boolean checkCardinalities(List<ValidationMessage> errors, StructureDefinition profile, Element element, NodeStack stack, public boolean checkCardinalities(List<ValidationMessage> errors, StructureDefinition profile, Element element, NodeStack stack,

View File

@ -128,7 +128,9 @@ public class ProfileValidator extends BaseValidator {
throw new Error("Diff Element is null - this is not an expected thing"); throw new Error("Diff Element is null - this is not an expected thing");
ElementDefinition snapElement = snapshotElements.get(diffElement.getId()); ElementDefinition snapElement = snapshotElements.get(diffElement.getId());
if (snapElement!=null) { // Happens with profiles in the main build - should be able to fix once snapshot generation is fixed - Lloyd if (snapElement!=null) { // Happens with profiles in the main build - should be able to fix once snapshot generation is fixed - Lloyd
warning(errors, NO_RULE_DATE, IssueType.BUSINESSRULE, diffElement.getId(), !checkMustSupport || snapElement.hasMustSupport(), "Elements included in the differential should declare mustSupport"); // We don't care about mustSupport for the root element, if the element is just declaring slicing, if there's a pattern or fixed value, or if the element is being prohibited.
boolean noMustSupport = !checkMustSupport || !snapElement.getPath().contains(".") || snapElement.hasSlicing() || snapElement.hasPattern() || snapElement.hasFixed() || snapElement.getMax().equals("0") || snapElement.hasMustSupport();
warning(errors, NO_RULE_DATE, IssueType.BUSINESSRULE, diffElement.getId(), noMustSupport, "Elements included in the differential that aren't prohibited and don't have fixed values or patterns should declare mustSupport: " + snapElement.getPath());
if (checkAggregation) { if (checkAggregation) {
for (TypeRefComponent type : snapElement.getType()) { for (TypeRefComponent type : snapElement.getType()) {
if ("http://hl7.org/fhir/Reference".equals(type.getWorkingCode()) || "http://hl7.org/fhir/canonical".equals(type.getWorkingCode())) { if ("http://hl7.org/fhir/Reference".equals(type.getWorkingCode()) || "http://hl7.org/fhir/canonical".equals(type.getWorkingCode())) {

10
pom.xml
View File

@ -741,6 +741,16 @@
</execution> </execution>
</executions> </executions>
</plugin> </plugin>
<plugin>
<artifactId>maven-javadoc-plugin</artifactId>
<executions>
<execution>
<id>attach-javadocs</id>
<phase>deploy</phase>
<goals><goal>jar</goal></goals>
</execution>
</executions>
</plugin>
</plugins> </plugins>
</build> </build>
</profile> </profile>