commit
96538ba249
|
@ -385,7 +385,7 @@ public abstract class BaseWorkerContext extends I18nBase implements IWorkerConte
|
|||
if ((packageInfo == null || !packageInfo.isExamplesPackage()) || !map.containsKey(r.getId())) {
|
||||
map.put(r.getId(), new ResourceProxy(r));
|
||||
} else {
|
||||
System.out.println("Ingore "+r.fhirType()+"/"+r.getId()+" from package "+packageInfo.toString());
|
||||
System.out.println("Ignore "+r.fhirType()+"/"+r.getId()+" from package "+packageInfo.toString());
|
||||
}
|
||||
|
||||
if (r instanceof CodeSystem || r instanceof NamingSystem) {
|
||||
|
|
|
@ -390,7 +390,7 @@ public abstract class BaseWorkerContext extends I18nBase implements IWorkerConte
|
|||
if ((packageInfo == null || !packageInfo.isExamplesPackage()) || !map.containsKey(r.getId())) {
|
||||
map.put(r.getId(), new ResourceProxy(r));
|
||||
} else {
|
||||
System.out.println("Ingore "+r.fhirType()+"/"+r.getId()+" from package "+packageInfo.toString());
|
||||
System.out.println("Ignore "+r.fhirType()+"/"+r.getId()+" from package "+packageInfo.toString());
|
||||
}
|
||||
|
||||
if (r instanceof CodeSystem || r instanceof NamingSystem) {
|
||||
|
|
|
@ -498,7 +498,7 @@ public class FilesystemPackageCacheManager extends BasePackageCacheManager imple
|
|||
|
||||
// nup, don't have it locally (or it's expired)
|
||||
FilesystemPackageCacheManager.InputStreamWithSrc source;
|
||||
if ("current".equals(version) || version.startsWith("current$")) {
|
||||
if ("current".equals(version) || (version!= null && version.startsWith("current$"))) {
|
||||
// special case - fetch from ci-build server
|
||||
source = loadFromCIBuild(id, version.startsWith("current$") ? version.substring(8) : null);
|
||||
} else {
|
||||
|
|
|
@ -426,6 +426,11 @@ public class ValidationEngine implements IValidatorResourceFetcher, IValidationP
|
|||
return transform(cnt.focus, cnt.cntType, map);
|
||||
}
|
||||
|
||||
public StructureMap compile(String mapUri) throws FHIRException, IOException {
|
||||
StructureMap map = context.getTransform(mapUri);
|
||||
return map;
|
||||
}
|
||||
|
||||
public org.hl7.fhir.r5.elementmodel.Element transform(byte[] source, FhirFormat cntType, String mapUri) throws FHIRException, IOException {
|
||||
List<Base> outputs = new ArrayList<>();
|
||||
StructureMapUtilities scu = new StructureMapUtilities(context, new TransformSupportServices(outputs, mapLog, context));
|
||||
|
@ -642,7 +647,7 @@ public class ValidationEngine implements IValidatorResourceFetcher, IValidationP
|
|||
else
|
||||
throw new FHIRException("Unsupported format for " + fn);
|
||||
} else
|
||||
throw new FHIRException("Encounted unsupported configured version " + version + " loading " + fn);
|
||||
throw new FHIRException("Encountered unsupported configured version " + version + " loading " + fn);
|
||||
|
||||
s.close();
|
||||
}
|
||||
|
|
|
@ -241,6 +241,9 @@ public class ValidatorCli {
|
|||
case TRANSFORM:
|
||||
validationService.transform(cliContext, validator);
|
||||
break;
|
||||
case COMPILE:
|
||||
validationService.compile(cliContext, validator);
|
||||
break;
|
||||
case NARRATIVE:
|
||||
validationService.generateNarrative(cliContext, validator);
|
||||
break;
|
||||
|
|
|
@ -253,6 +253,36 @@ public class ValidationService {
|
|||
}
|
||||
}
|
||||
|
||||
public void compile(CliContext cliContext, ValidationEngine validator) throws Exception {
|
||||
if (cliContext.getSources().size() > 0)
|
||||
throw new Exception("Cannot specify sources when compling transform (found " + cliContext.getSources() + ")");
|
||||
if (cliContext.getMap() == null)
|
||||
throw new Exception("Must provide a map when compiling a transform");
|
||||
if (cliContext.getOutput() == null)
|
||||
throw new Exception("Must provide an output name when compiling a transform");
|
||||
try {
|
||||
List<StructureDefinition> structures = validator.getContext().allStructures();
|
||||
for (StructureDefinition sd : structures) {
|
||||
if (!sd.hasSnapshot()) {
|
||||
if (sd.getKind() != null && sd.getKind() == StructureDefinitionKind.LOGICAL) {
|
||||
validator.getContext().generateSnapshot(sd, true);
|
||||
} else {
|
||||
validator.getContext().generateSnapshot(sd, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
validator.setMapLog(cliContext.getMapLog());
|
||||
StructureMap map = validator.compile(cliContext.getMap());
|
||||
if (map == null)
|
||||
throw new Exception("Unable to locate map " + cliContext.getMap());
|
||||
validator.handleOutput(map, cliContext.getOutput(), validator.getVersion());
|
||||
System.out.println(" ...success");
|
||||
} catch (Exception e) {
|
||||
System.out.println(" ...Failure: " + e.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void transformVersion(CliContext cliContext, ValidationEngine validator) throws Exception {
|
||||
if (cliContext.getSources().size() > 1) {
|
||||
throw new Exception("Can only have one source when converting versions (found " + cliContext.getSources() + ")");
|
||||
|
|
|
@ -2,6 +2,7 @@ package org.hl7.fhir.validation.cli.utils;
|
|||
|
||||
public enum EngineMode {
|
||||
VALIDATION,
|
||||
COMPILE,
|
||||
TRANSFORM,
|
||||
NARRATIVE,
|
||||
SNAPSHOT,
|
||||
|
|
|
@ -31,6 +31,7 @@ public class Params {
|
|||
public static final String TO_VERSION = "-to-version";
|
||||
public static final String DO_NATIVE = "-do-native";
|
||||
public static final String NO_NATIVE = "-no-native";
|
||||
public static final String COMPILE = "-compile";
|
||||
public static final String TRANSFORM = "-transform";
|
||||
public static final String NARRATIVE = "-narrative";
|
||||
public static final String SNAPSHOT = "-snapshot";
|
||||
|
@ -192,6 +193,9 @@ public class Params {
|
|||
} else if (args[i].equals(TRANSFORM)) {
|
||||
cliContext.setMap(args[++i]);
|
||||
cliContext.setMode(EngineMode.TRANSFORM);
|
||||
} else if (args[i].equals(COMPILE)) {
|
||||
cliContext.setMap(args[++i]);
|
||||
cliContext.setMode(EngineMode.COMPILE);
|
||||
} else if (args[i].equals(NARRATIVE)) {
|
||||
cliContext.setMode(EngineMode.NARRATIVE);
|
||||
} else if (args[i].equals(SPREADSHEET)) {
|
||||
|
|
Loading…
Reference in New Issue