Update Validator -version handling, and improve tx server error handling

This commit is contained in:
Grahame Grieve 2022-04-20 11:17:40 +10:00
parent c58516ce44
commit 5fef79c08d
17 changed files with 46 additions and 30 deletions

View File

@ -899,9 +899,13 @@ public abstract class BaseWorkerContext extends I18nBase implements IWorkerConte
txLog.clearLastId();
}
Bundle resp = txClient.validateBatch(batch);
if (resp == null) {
throw new FHIRException(formatMessage(I18nConstants.TX_SERVER_NO_BATCH_RESPONSE));
}
for (int i = 0; i < batch.getEntry().size(); i++) {
CodingValidationRequest t = (CodingValidationRequest) batch.getEntry().get(i).getUserData("source");
BundleEntryComponent r = resp.getEntry().get(i);
if (r.getResource() instanceof Parameters) {
t.setResult(processValidationResult((Parameters) r.getResource()));
if (txCache != null) {

View File

@ -130,7 +130,6 @@ public class ObjectConverter {
ByteArrayOutputStream bo = new ByteArrayOutputStream();
try {
new JsonParser(context).compose(element, bo, OutputStyle.NORMAL, null);
// TextFile.bytesToFile(bo.toByteArray(), "c:\\temp\\json.json");
return new org.hl7.fhir.r5.formats.JsonParser().parse(bo.toByteArray());
} catch (IOException e) {
// won't happen

View File

@ -65,7 +65,7 @@ public class Tester {
// String tgt = normalise(TextFile.fileToString("C:\\work\\org.hl7.fhir\\build\\publish\\"+Utilities.changeFileExt(f, ".json")));
Element e = Manager.parseSingle(context, new FileInputStream("C:\\work\\org.hl7.fhir\\build\\publish\\"+f), FhirFormat.XML);
Manager.compose(context, e, new FileOutputStream("C:\\work\\org.hl7.fhir\\build\\publish\\"+Utilities.changeFileExt(f, ".mm.ttl")), FhirFormat.TURTLE, OutputStyle.PRETTY, null);
Manager.compose(context, e, new FileOutputStream("C:\\temp\\resource.xml"), FhirFormat.XML, OutputStyle.PRETTY, null);
Manager.compose(context, e, new FileOutputStream(Utilities.path("[tmp]", "resource.xml")), FhirFormat.XML, OutputStyle.PRETTY, null);
String src = TextFile.fileToString("C:\\work\\org.hl7.fhir\\build\\publish\\"+Utilities.changeFileExt(f, ".mm.ttl"));
String tgt = TextFile.fileToString("C:\\work\\org.hl7.fhir\\build\\publish\\"+Utilities.changeFileExt(f, ".ttl"));
t++;

View File

@ -64,7 +64,6 @@ import org.xmlpull.v1.XmlPullParserException;
*/
public class LoincToDEConvertor {
// C:\temp\LOINC.xml
public static void main(String[] args) throws FHIRFormatError, IOException, XmlPullParserException, SAXException, ParserConfigurationException {
if (args.length == 0) {
System.out.println("FHIR LOINC to CDE convertor. ");

View File

@ -216,7 +216,7 @@ public class CompareUtilities extends BaseTestingUtilities {
command.add("\"" + diff + "\" \"" + expected + "\" \"" + actual + "\"");
ProcessBuilder builder = new ProcessBuilder(command);
builder.directory(new CSFile("c:\\temp"));
builder.directory(new CSFile(Utilities.path("[tmp]")));
builder.start();
}
@ -300,12 +300,6 @@ public class CompareUtilities extends BaseTestingUtilities {
return null;
}
public static String temp() {
if (new File("c:\\temp").exists())
return "c:\\temp";
return System.getProperty("java.io.tmpdir");
}
public static String checkTextIsSame(String expected, String actual) throws JsonSyntaxException, FileNotFoundException, IOException {
return checkTextIsSame(expected, actual, true);
}

View File

@ -60,6 +60,7 @@ import javax.xml.crypto.dsig.spec.TransformParameterSpec;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import org.hl7.fhir.utilities.Utilities;
import org.hl7.fhir.utilities.xml.XmlGenerator;
import org.w3c.dom.Document;
@ -114,7 +115,7 @@ public class DigitalSignatures {
XMLSignature signature = fac.newXMLSignature(si, ki);
signature.sign(dsc);
OutputStream os = new FileOutputStream("c:\\temp\\java-digsig.xml");
OutputStream os = new FileOutputStream(Utilities.path("[tmp]", "java-digsig.xml"));
new XmlGenerator().generate(doc.getDocumentElement(), os);
}
}

View File

@ -415,13 +415,13 @@ public class MappingSheetParser {
private static final String SFX = "<body></html>";
public static void main(String[] args) throws FileNotFoundException, IOException, FHIRException {
MappingSheetParser parser = new MappingSheetParser();
parser.parse(new FileInputStream("c:\\temp\\v2-pid.csv"), "v2-pid.csv");
parser.parse(new FileInputStream(Utilities.path("[tmp]", "v2-pid.csv")), "v2-pid.csv");
ConceptMap cm = parser.getConceptMap();
StructureMap sm = parser.getStructureMap();
new JsonParser().setOutputStyle(OutputStyle.PRETTY).compose(new FileOutputStream("c:\\temp\\sm.json"), sm);
new JsonParser().setOutputStyle(OutputStyle.PRETTY).compose(new FileOutputStream("c:\\temp\\cm.json"), cm);
TextFile.stringToFile(StructureMapUtilities.render(sm), "c:\\temp\\sm.txt");
TextFile.stringToFile(PFX+parser.genSheet(cm)+SFX, "c:\\temp\\map.html");
new JsonParser().setOutputStyle(OutputStyle.PRETTY).compose(new FileOutputStream(Utilities.path("[tmp]", "sm.json")), sm);
new JsonParser().setOutputStyle(OutputStyle.PRETTY).compose(new FileOutputStream(Utilities.path("[tmp]", "cm.json")), cm);
TextFile.stringToFile(StructureMapUtilities.render(sm), Utilities.path("[tmp]", "sm.txt"));
TextFile.stringToFile(PFX+parser.genSheet(cm)+SFX, Utilities.path("[tmp]", "map.html"));
}
}

View File

@ -13,6 +13,7 @@ import org.hl7.fhir.r5.formats.IParser.OutputStyle;
import org.hl7.fhir.r5.model.StructureDefinition;
import org.hl7.fhir.r5.test.utils.TestingUtilities;
import org.hl7.fhir.r5.utils.FHIRPathEngine;
import org.hl7.fhir.utilities.Utilities;
import org.hl7.fhir.utilities.npm.FilesystemPackageCacheManager;
import org.hl7.fhir.utilities.npm.ToolsVersion;
import org.junit.jupiter.api.Assertions;
@ -136,7 +137,7 @@ public class CDARoundTripTests {
// new FileInputStream("C:\\work\\org.hl7.fhir.us\\ccda-to-fhir-maps\\cda\\IAT2-Discharge_Summary-DCI.xml"),
// FhirFormat.XML);
//
// Manager.compose(context, e, new FileOutputStream("C:\\temp\\ccda.xml"), FhirFormat.XML, OutputStyle.PRETTY, null);
// Manager.compose(context, e, new FileOutputStream(Utilities.path("[tmp]", "ccda.xml"), FhirFormat.XML, OutputStyle.PRETTY, null);
//// Manager.compose(context, e, new FileOutputStream("C:\\work\\org.hl7.fhir.test\\ccda-to-fhir-maps\\testdocuments\\IAT2-Discharge_Summary-DCI.out.json"), FhirFormat.JSON, OutputStyle.PRETTY, null);
//// Manager.compose(context, e, new FileOutputStream("C:\\work\\org.hl7.fhir.test\\ccda-to-fhir-maps\\testdocuments\\IAT2-Discharge_Summary-DCI.out.ttl"), FhirFormat.TURTLE, OutputStyle.PRETTY, null);
// } catch (Exception e) {

View File

@ -7,11 +7,12 @@ import org.hl7.fhir.exceptions.FHIRException;
import org.hl7.fhir.r5.formats.XmlParser;
import org.hl7.fhir.r5.model.StructureDefinition;
import org.hl7.fhir.r5.utils.QuestionnaireBuilder;
import org.hl7.fhir.utilities.Utilities;
public class QuestionnaireBuilderTester {
private static final String TEST_PROFILE_DIR = "C:\\work\\org.hl7.fhir\\build\\publish";
private static final String TEST_DEST = "c:\\temp\\questionnaires\\";
// private static final String TEST_DEST = Utilities.path("[tmp]", "questionnaires\\");
public static void main(String[] args) {
QuestionnaireBuilder b = new QuestionnaireBuilder(null);

View File

@ -10,6 +10,7 @@ import javax.xml.parsers.ParserConfigurationException;
import org.hl7.fhir.exceptions.FHIRException;
import org.hl7.fhir.exceptions.FHIRFormatError;
import org.hl7.fhir.utilities.Utilities;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
@ -135,7 +136,7 @@ public class StructureMapTests {
// Manager.compose(TestingUtilities.context, cda, new FileOutputStream("C:\\work\\org.hl7.fhir\\build\\guides\\ccda2\\mapping\\example\\ccd.out.xml"), FhirFormat.XML, OutputStyle.PRETTY, null);
// Bundle bundle = new Bundle();
// scu.transform(null, cda, maps.get("http://hl7.org/fhir/StructureMap/cda"), bundle);
// new XmlParser().setOutputStyle(OutputStyle.PRETTY).compose(new FileOutputStream("c:\\temp\\bundle.xml"), bundle);
// new XmlParser().setOutputStyle(OutputStyle.PRETTY).compose(new FileOutputStream(Utilities.path("[tmp]", "bundle.xml"), bundle);
// }
//
// @Test
@ -165,7 +166,7 @@ public class StructureMapTests {
//
// List<StructureDefinition> result = scu.analyse(null, maps.get("http://hl7.org/fhir/StructureMap/cda")).getProfiles();
// for (StructureDefinition sd : result)
// new XmlParser().setOutputStyle(OutputStyle.PRETTY).compose(new FileOutputStream("c:\\temp\\res-"+sd.getId()+".xml"), sd);
// new XmlParser().setOutputStyle(OutputStyle.PRETTY).compose(new FileOutputStream(Utilities.path("[tmp]", "res-"+sd.getId()+".xml"), sd);
// }
//
}

View File

@ -154,7 +154,7 @@ public class NDJsonWriter {
public static void main(String[] args) throws IOException {
String dstDir = "C:\\work\\org.hl7.fhir\\build\\publish\\";
NDJsonWriter ndjson = new NDJsonWriter(dstDir + "examples-ndjson.zip", "c:\\temp\\ndjson");
NDJsonWriter ndjson = new NDJsonWriter(dstDir + "examples-ndjson.zip", Utilities.path("[tmp]", "ndjson"));
ndjson.addFilesFiltered(dstDir, ".json", new String[] {".schema.json", ".canonical.json", ".diff.json", "expansions.json", "package.json"});
ndjson.close();
}

View File

@ -69,6 +69,7 @@ public class Utilities {
private static final String UUID_REGEX = "[0-9a-f]{8}\\-[0-9a-f]{4}\\-[0-9a-f]{4}\\-[0-9a-f]{4}\\-[0-9a-f]{12}";
private static final String OID_REGEX = "[0-2](\\.(0|[1-9][0-9]*))+";
static final String C_TEMP_DIR = "c:\\temp";
/**
* Returns the plural form of the word in the string.
@ -595,7 +596,7 @@ public class Utilities {
if (s.length() == 0) {
if ("[tmp]".equals(a)) {
if (hasCTempDir()) {
a = "c:\\temp";
a = Utilities.path("[tmp]");
} else if (ToolGlobalSettings.hasTempPath()) {
a = ToolGlobalSettings.getTempPath();
} else {
@ -643,7 +644,7 @@ public class Utilities {
if (!System.getProperty("os.name").toLowerCase().contains("win")) {
return false;
}
File tmp = new File("c:\\temp");
File tmp = new File(C_TEMP_DIR);
return tmp.exists() && tmp.isDirectory() && tmp.canWrite();
}

View File

@ -55,9 +55,12 @@ public class VersionUtilities {
}
}
public static final String CURRENT_VERSION = "4.6";
public static final String CURRENT_FULL_VERSION = "4.6.0";
public static final String CURRENT_VERSION = "5.0";
public static final String CURRENT_FULL_VERSION = "5.0.0";
public static final String CURRENT_DEFAULT_VERSION = "4.0";
public static final String CURRENT_DEFAULT_FULL_VERSION = "4.0.1";
public static String packageForVersion(String v) {
if (isR2Ver(v)) {
return "hl7.fhir.r2.core";
@ -351,8 +354,14 @@ public class VersionUtilities {
if ("r4".equals(version)) {
return "4.0.1";
}
if ("r4".equals(version)) {
return "4.0.1";
}
if ("r4b".equals(version)) {
return "4.3.0";
}
if ("r5".equals(version)) {
return CURRENT_FULL_VERSION;
return "5.0.0";
}
throw new FHIRException("Unknown version "+version);
}

View File

@ -699,6 +699,7 @@ public class I18nConstants {
public static final String TYPE_SPECIFIC_CHECKS_DT_QTY_MAX_VALUE_WRONG_UCUM = "TYPE_SPECIFIC_CHECKS_DT_QTY_MAX_VALUE_WRONG_UCUM";
public static final String TYPE_SPECIFIC_CHECKS_DT_BASE64_NO_WS_ERROR = "TYPE_SPECIFIC_CHECKS_DT_BASE64_NO_WS_ERROR";
public static final String TYPE_SPECIFIC_CHECKS_DT_BASE64_NO_WS_WARNING = "TYPE_SPECIFIC_CHECKS_DT_BASE64_NO_WS_WARNING";
public static final String TX_SERVER_NO_BATCH_RESPONSE = "TX_SERVER_NO_BATCH_RESPONSE";
}

View File

@ -709,4 +709,4 @@ TYPE_SPECIFIC_CHECKS_DT_BASE64_NO_WS_ERROR = Base64 encoded values are not allow
TYPE_SPECIFIC_CHECKS_DT_BASE64_NO_WS_WARNING = Base64 encoded values SHOULD not contain any whitespace (per RFC 4648). Note that non-validating readers are encouraged to accept whitespace anyway
SD_DERIVATION_KIND_MISMATCH = The structure definition constrains a kind of {0}, but has a different kind ({1})
VALUESET_IMPORT_UNION_INTERSECTION = This value set has a single include with multiple imported value sets. Per issue https://jira.hl7.org/browse/FHIR-25179, there has been confusion in the past whether these value sets are unioned or intersectioned. If this value set is contained in a package published prior to March 31 2022, it will be treated as a union, otherwise it will be treated as an intersection. If want a union, split the value set imports across multiple includes
TX_SERVER_NO_BATCH_RESPONSE = The server return null from a batch validation request

View File

@ -8,6 +8,7 @@ import java.util.Map;
import java.util.Objects;
import org.hl7.fhir.r5.utils.validation.BundleValidationRule;
import org.hl7.fhir.utilities.VersionUtilities;
import org.hl7.fhir.validation.cli.utils.QuestionnaireMode;
import org.hl7.fhir.validation.cli.utils.ValidationLevel;
import org.hl7.fhir.validation.cli.utils.EngineMode;
@ -359,7 +360,11 @@ public class CliContext {
@JsonProperty("sv")
public CliContext setSv(String sv) {
this.sv = sv;
if (sv != null && sv.startsWith("R")) {
this.sv = VersionUtilities.versionFromCode(sv.toLowerCase());
} else {
this.sv = sv;
}
return this;
}

View File

@ -382,8 +382,8 @@ public class ValidationService {
}
}
if (versions.isEmpty()) {
System.out.println(" No Version Info found: Using Default version '" + VersionUtilities.CURRENT_VERSION + "'");
return "current";
System.out.println(" No Version Info found: Using Default version '" + VersionUtilities.CURRENT_DEFAULT_VERSION + "'");
return VersionUtilities.CURRENT_DEFAULT_FULL_VERSION;
}
if (versions.size() == 1) {
System.out.println("-> use version " + versions.version());