allow validation message to have count

This commit is contained in:
Grahame Grieve 2024-04-20 23:36:25 +10:00
parent 8cca22aef3
commit 1c797d64d9
3 changed files with 66 additions and 14 deletions

View File

@ -1022,6 +1022,7 @@ public class I18nConstants {
public static final String XSI_TYPE_WRONG = "XSI_TYPE_WRONG";
public static final String XSI_TYPE_UNNECESSARY = "XSI_TYPE_UNNECESSARY";
public static final String TERMINOLOGY_TX_OID_MULTIPLE_MATCHES = "TERMINOLOGY_TX_OID_MULTIPLE_MATCHES";
public static final String TERMINOLOGY_TX_OID_MULTIPLE_MATCHES_CHOSEN = "TERMINOLOGY_TX_OID_MULTIPLE_MATCHES_CHOSEN";
public static final String CDA_UNKNOWN_TEMPLATE = "CDA_UNKNOWN_TEMPLATE";
public static final String CDA_UNKNOWN_TEMPLATE_EXT = "CDA_UNKNOWN_TEMPLATE_EXT";
public static final String UNABLE_TO_DETERMINE_TYPE_CONTEXT_INV = "UNABLE_TO_DETERMINE_TYPE_CONTEXT_INV";

View File

@ -1478,5 +1478,9 @@ public class NpmPackage {
this.warned = warned;
}
public String vid() {
return id()+"#"+version();
}
}

View File

@ -28,16 +28,63 @@ import org.hl7.fhir.utilities.json.parser.JsonParser;
public class PackageHacker {
private static boolean useSecureReferences = false;
public static void main(String[] args) throws FileNotFoundException, IOException {
new PackageHacker().edit("/Users/grahamegrieve/web/hl7.org/fhir/us/vitals/2020Sep/package.tgz");
new PackageHacker().massEdit(new File("/Users/grahamegrieve/web/hl7.org/fhir"));
// new PackageHacker().edit("/Users/grahamegrieve/web/hl7.org/fhir/us/vitals/2020Sep/package.tgz");
}
private void massEdit(File dir) throws IOException {
System.out.println("process "+dir.getAbsolutePath());
for (File f : dir.listFiles()) {
if (f.isDirectory()) {
massEdit(f);
} else if (f.getName().equals("package.tgz")) {
try {
FileInputStream fs = ManagedFileAccess.inStream(f);
NpmPackage pck = NpmPackage.fromPackage(fs);
if ("fhir.core".equals(pck.getNpm().str("type"))) {
System.out.println("!!change "+f.getAbsolutePath());
pck.getNpm().remove("type");
pck.getNpm().set("type", "Core");
FileOutputStream fso = ManagedFileAccess.outStream(f);
try {
pck.save(fso);
} finally {
fso.close();
}
}
} catch (Exception e) {
System.out.println("!!Error: "+e.getMessage());
}
} else if (f.getName().startsWith("hl7.fhir.r") && f.getName().endsWith(".examples.tgz")) {
try {
FileInputStream fs = ManagedFileAccess.inStream(f);
NpmPackage pck = NpmPackage.fromPackage(fs);
if ("fhir.examples".equals(pck.getNpm().str("type"))) {
System.out.println("!!change "+f.getAbsolutePath());
pck.getNpm().remove("type");
pck.getNpm().set("type", "Examples");
FileOutputStream fso = ManagedFileAccess.outStream(f);
try {
pck.save(fso);
} finally {
fso.close();
}
}
} catch (Exception e) {
System.out.println("!!Error: "+e.getMessage());
}
}
}
}
private void edit(String name) throws FileNotFoundException, IOException {
File f = ManagedFileAccess.file(name);
if (!f.exists())
throw new Error("Unable to find "+f.getAbsolutePath());
NpmPackage pck = null;
FileInputStream fs = ManagedFileAccess.inStream(f);
try {
@ -47,7 +94,7 @@ public class PackageHacker {
}
System.out.println("Altering Package "+f.getAbsolutePath());
System.out.println(nice(pck.getNpm()));
change(pck.getNpm());
System.out.println("Revised Package");
@ -68,13 +115,13 @@ public class PackageHacker {
}
private void fixExampleContent(Map<String, byte[]> content) {
// byte[] cnt = content.get("ServiceRequest-SDOHCC-ServiceRequestCompletedFoodPantryApplicationAssistExample.json");
// content.put("ServiceRequest-SDOHCC-ServiceRequestCompletedFoodPantryApplicationAssist.json", cnt);
// content.remove("ServiceRequest-SDOHCC-ServiceRequestCompletedFoodPantryApplicationAssistExample.json");
// byte[] cnt = content.get("ServiceRequest-SDOHCC-ServiceRequestCompletedFoodPantryApplicationAssistExample.json");
// content.put("ServiceRequest-SDOHCC-ServiceRequestCompletedFoodPantryApplicationAssist.json", cnt);
// content.remove("ServiceRequest-SDOHCC-ServiceRequestCompletedFoodPantryApplicationAssistExample.json");
}
private void fixContent(Map<String, byte[]> content) {
// fixVersionInContent(content);
// fixVersionInContent(content);
}
@ -83,7 +130,7 @@ public class PackageHacker {
}
private void change(JsonObject npm) throws FileNotFoundException, IOException {
// fixVersions(npm, ver);
// fixVersions(npm, ver);
npm.remove("notForPublication");
npm.set("name", "hl7.fhir.us.vitals");
}
@ -98,7 +145,7 @@ public class PackageHacker {
}
}
}
}
private void fixVersions(JsonObject npm) {
@ -128,10 +175,10 @@ public class PackageHacker {
private void addContentFrom(String folder, Map<String, byte[]> content) throws FileNotFoundException, IOException {
for (File f : ManagedFileAccess.file(folder).listFiles()) {
if (f.getName().endsWith(".json") && !f.getName().endsWith(".canonical.json")) {
String cnt = TextFile.fileToString(f);
if (cnt.contains("\"resourceType\"")) {
content.put("package/"+f.getName(), TextFile.fileToBytes(f));
}
String cnt = TextFile.fileToString(f);
if (cnt.contains("\"resourceType\"")) {
content.put("package/"+f.getName(), TextFile.fileToBytes(f));
}
}
}
}