Added oneCode command line option to validate; allowing one coding entry to validate CodeableConcept.

This commit is contained in:
Stuart McGrigor 2024-07-03 19:49:33 +12:00
parent 7835064044
commit 49d64c1633
2 changed files with 8 additions and 2 deletions

View File

@ -87,6 +87,8 @@ public class ValidateCommand extends BaseCommand {
"igpack",
true,
"If specified, provides the filename of an IGPack file to include in validation");
addOptionalOption(
retVal, null, "oneCode", false, "Validate allowing one coding to satisfy CodeableConcept binding");
addOptionalOption(retVal, "x", "xsd", false, "Validate using Schemas");
addOptionalOption(retVal, "s", "sch", false, "Validate using Schematrons");
addOptionalOption(retVal, "e", "encoding", "encoding", "File encoding (default is UTF-8)");
@ -168,7 +170,6 @@ public class ValidateCommand extends BaseCommand {
val.registerValidatorModule(instanceValidator);
validationSupportChain =
ValidationSupportChainCreator.getValidationSupportChainR4(ctx, theCommandLine);
validationSupportChain.oneCodingIsSufficient = true;
instanceValidator.setValidationSupport(validationSupportChain);
break;
}
@ -177,6 +178,10 @@ public class ValidateCommand extends BaseCommand {
Msg.code(1620) + "Profile validation (-p) is not supported for this FHIR version");
}
// Do we allow CodeableConcepts to be satisfied by only one coding?
// Useful when we are using additionalBindings.
validationSupportChain.oneCodingIsSufficient = theCommandLine.hasOption("oneCode");
// If they want to do profile validation - there might be a whole IG to load...
if (theCommandLine.hasOption("igpack")) {
String igPack = theCommandLine.getOptionValue("igpack");

View File

@ -23,6 +23,7 @@ import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.context.support.DefaultProfileValidationSupport;
import ca.uhn.fhir.i18n.Msg;
import org.apache.commons.cli.CommandLine;
import org.hl7.fhir.common.hapi.validation.support.CommonCodeSystemsTerminologyService;
import org.hl7.fhir.common.hapi.validation.support.InMemoryTerminologyServerValidationSupport;
import org.hl7.fhir.common.hapi.validation.support.LocalFileValidationSupport;
import org.hl7.fhir.common.hapi.validation.support.SnapshotGeneratingValidationSupport;
@ -52,7 +53,7 @@ public class ValidationSupportChainCreator {
if (commandLine.hasOption("r")) {
chain.addValidationSupport(new LoadingValidationSupportDstu3());
}
chain.addValidationSupport(new CommonCodeSystemsTerminologyService(ctx));
return chain;
}