Skip to content

Commit

Permalink
Merge pull request hapifhir#1736 from hapifhir/2024-09-gg-unknown-cod…
Browse files Browse the repository at this point in the history
…e-systesm

2024 09 gg unknown code systesm
  • Loading branch information
grahamegrieve authored Sep 6, 2024
2 parents 39d747d + 9f9e9df commit 0c457a1
Show file tree
Hide file tree
Showing 9 changed files with 163 additions and 77 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -124,11 +124,9 @@ public OpIssueCode getCode() {
}
public String getMessage() {
return message;
}

}
}


private ValueSet valueset;
private Map<String, ValueSetValidator> inner = new HashMap<>();
private ValidationOptions options;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1491,7 +1491,7 @@ public static boolean startsWithInList(String s, String... list) {
}

public static boolean startsWithInList(String s, Collection<String> list) {
if (s == null) {
if (s == null || list == null) {
return false;
}
for (String l : list) {
Expand Down Expand Up @@ -2304,4 +2304,16 @@ public static boolean isValidHtmlAnchorChar(char c) {
}
}

public static boolean listValueStartsWith(String s, Set<String> list) {
if (s == null || list == null) {
return false;
}
for (String l : list) {
if (l.startsWith(s)) {
return true;
}
}
return false;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,19 @@ public class PackageHacker {

public static void main(String[] args) throws FileNotFoundException, IOException {
// new PackageHacker().massEdit(new File("/Users/grahamegrieve/web/hl7.org/fhir"));
new PackageHacker().edit("/Users/grahamegrieve/web/hl7.org/fhir/6.0.0-ballot1/hl7.fhir.r6.core.tgz");
new PackageHacker().edit("/Users/grahamegrieve/web/hl7.org/fhir/6.0.0-ballot1/hl7.fhir.r6.corexml.tgz");
new PackageHacker().edit("/Users/grahamegrieve/web/hl7.org/fhir/6.0.0-ballot1/hl7.fhir.r6.examples.tgz");
new PackageHacker().edit("/Users/grahamegrieve/web/hl7.org/fhir/6.0.0-ballot1/hl7.fhir.r6.expansions.tgz");
new PackageHacker().edit("/Users/grahamegrieve/web/hl7.org/fhir/6.0.0-ballot1/hl7.fhir.r6.search.tgz");
new PackageHacker().edit("/Users/grahamegrieve/web/hl7.org/fhir/6.0.0-ballot2/hl7.fhir.r6.core.tgz");
new PackageHacker().edit("/Users/grahamegrieve/web/hl7.org/fhir/6.0.0-ballot2/hl7.fhir.r6.corexml.tgz");
new PackageHacker().edit("/Users/grahamegrieve/web/hl7.org/fhir/6.0.0-ballot2/hl7.fhir.r6.examples.tgz");
new PackageHacker().edit("/Users/grahamegrieve/web/hl7.org/fhir/6.0.0-ballot2/hl7.fhir.r6.expansions.tgz");
new PackageHacker().edit("/Users/grahamegrieve/web/hl7.org/fhir/6.0.0-ballot2/hl7.fhir.r6.search.tgz");
// new PackageHacker().edit("/Users/grahamegrieve/web/hl7.org/fhir/6.0.0-ballot1/hl7.fhir.r6.core.tgz");
// new PackageHacker().edit("/Users/grahamegrieve/web/hl7.org/fhir/6.0.0-ballot1/hl7.fhir.r6.corexml.tgz");
// new PackageHacker().edit("/Users/grahamegrieve/web/hl7.org/fhir/6.0.0-ballot1/hl7.fhir.r6.examples.tgz");
// new PackageHacker().edit("/Users/grahamegrieve/web/hl7.org/fhir/6.0.0-ballot1/hl7.fhir.r6.expansions.tgz");
// new PackageHacker().edit("/Users/grahamegrieve/web/hl7.org/fhir/6.0.0-ballot1/hl7.fhir.r6.search.tgz");
// new PackageHacker().edit("/Users/grahamegrieve/web/hl7.org/fhir/6.0.0-ballot2/hl7.fhir.r6.core.tgz");
// new PackageHacker().edit("/Users/grahamegrieve/web/hl7.org/fhir/6.0.0-ballot2/hl7.fhir.r6.corexml.tgz");
// new PackageHacker().edit("/Users/grahamegrieve/web/hl7.org/fhir/6.0.0-ballot2/hl7.fhir.r6.examples.tgz");
// new PackageHacker().edit("/Users/grahamegrieve/web/hl7.org/fhir/6.0.0-ballot2/hl7.fhir.r6.expansions.tgz");
// new PackageHacker().edit("/Users/grahamegrieve/web/hl7.org/fhir/6.0.0-ballot2/hl7.fhir.r6.search.tgz");

// new PackageHacker().edit(args[0]);
// new PackageHacker().edit("/Users/grahamegrieve/web/hl7.org/fhir/us/core/v311/package.tgz", "http://hl7.org/fhir/us/core/STU3.1.1");
new PackageHacker().edit("/Users/grahamegrieve/web/hl7.org/fhir/us/core/v700/package.tgz", "http://hl7.org/fhir/us/core/STU7");
}

// private void massEdit(File dir) throws IOException {
Expand Down Expand Up @@ -91,7 +92,7 @@ public static void main(String[] args) throws FileNotFoundException, IOException
// }
// }

private void edit(String name) throws FileNotFoundException, IOException {
private void edit(String name, String path) throws FileNotFoundException, IOException {
File f = ManagedFileAccess.file(name);
if (!f.exists())
throw new Error("Unable to find "+f.getAbsolutePath());
Expand All @@ -107,23 +108,23 @@ private void edit(String name) throws FileNotFoundException, IOException {
System.out.println("Altering Package "+f.getAbsolutePath());
System.out.println(nice(pck.getNpm()));

if (change(pck.getNpm())) {
if (change(pck.getNpm(), path)) {

System.out.println("Revised Package");
System.out.println("=======================");
System.out.println(nice(pck.getNpm()));
System.out.println("=======================");
// System.out.print("save? y/n: ");
// int r = System.in.read();
// if (r == 'y') {
System.out.print("save? y/n: ");
int r = System.in.read();
if (r == 'y') {
f.renameTo(ManagedFileAccess.file(Utilities.changeFileExt(name, ".tgz.bak")));
FileOutputStream fso = ManagedFileAccess.outStream(f);
try {
pck.save(fso);
} finally {
fso.close();
}
// }
}
}
}

Expand All @@ -142,13 +143,15 @@ private String nice(JsonObject json) {
return JsonParser.compose(json, true);
}

private boolean change(JsonObject npm) throws FileNotFoundException, IOException {
// fixVersions(npm, ver);
if (npm.has("notForPublication")) {
npm.remove("notForPublication");
return true;
}
return false;
private boolean change(JsonObject npm, String path) throws FileNotFoundException, IOException {
npm.remove("url");
npm.add("url", path);
return true;
// if (npm.has("notForPublication")) {
// npm.remove("notForPublication");
// return true;
// }
// return false;
}

private void fixVersionInContent(Map<String, byte[]> content) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ public interface IValidationEngineLoader {
@Getter @Setter private boolean allowDoubleQuotesInFHIRPath;
@Getter @Setter private boolean checkIPSCodes;
@Getter @Setter private BestPracticeWarningLevel bestPracticeLevel;
@Getter @Setter private boolean unknownCodeSystemsCauseErrors;
@Getter @Setter private Locale locale;
@Getter @Setter private List<ImplementationGuide> igs = new ArrayList<>();
@Getter @Setter private List<String> extensionDomains = new ArrayList<>();
Expand Down Expand Up @@ -289,6 +290,7 @@ public ValidationEngine(ValidationEngine other) throws FHIRException, IOExceptio
fhirPathEngine = other.fhirPathEngine;
igLoader = other.igLoader;
jurisdiction = other.jurisdiction;
unknownCodeSystemsCauseErrors = other.unknownCodeSystemsCauseErrors;
}

/**
Expand Down Expand Up @@ -906,6 +908,7 @@ public InstanceValidator getValidator(FhirFormat format) throws FHIRException, I
if (policyAdvisor != null) {
validator.setPolicyAdvisor(policyAdvisor);
}
validator.setUnknownCodeSystemsCauseErrors(unknownCodeSystemsCauseErrors);
return validator;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,9 @@ public class CliContext {
@JsonProperty("bestPracticeLevel")
private BestPracticeWarningLevel bestPracticeLevel = BestPracticeWarningLevel.Warning;

@JsonProperty("unknownCodeSystemsCauseErrors")
private boolean unknownCodeSystemsCauseErrors;

@JsonProperty("baseEngine")
public String getBaseEngine() {
return baseEngine;
Expand Down Expand Up @@ -832,15 +835,16 @@ public boolean equals(Object o) {
Objects.equals(watchMode, that.watchMode) &&
Objects.equals(bestPracticeLevel, that.bestPracticeLevel) &&
Objects.equals(watchScanDelay, that.watchScanDelay) &&
Objects.equals(unknownCodeSystemsCauseErrors, that.unknownCodeSystemsCauseErrors) &&
Objects.equals(watchSettleTime, that.watchSettleTime) ;
}

@Override
public int hashCode() {
return Objects.hash(baseEngine, doNative, extensions, hintAboutNonMustSupport, recursive, doDebug, assumeValidRestReferences, canDoNative, noInternalCaching,
noExtensibleBindingMessages, noInvariants, displayWarnings, wantInvariantsInMessages, map, output, outputSuffix, htmlOutput, txServer, sv, txLog, txCache, mapLog, lang, srcLang, tgtLang, fhirpath, snomedCT,
targetVer, igs, questionnaireMode, level, profiles, sources, inputs, mode, locale, locations, crumbTrails, forPublication, showTimes, allowExampleUrls, outputStyle, jurisdiction, noUnicodeBiDiControlChars, watchMode, watchScanDelay, watchSettleTime, bestPracticeLevel,
htmlInMarkdownCheck, allowDoubleQuotesInFHIRPath, checkIPSCodes);
targetVer, igs, questionnaireMode, level, profiles, sources, inputs, mode, locale, locations, crumbTrails, forPublication, showTimes, allowExampleUrls, outputStyle, jurisdiction, noUnicodeBiDiControlChars,
watchMode, watchScanDelay, watchSettleTime, bestPracticeLevel, unknownCodeSystemsCauseErrors, htmlInMarkdownCheck, allowDoubleQuotesInFHIRPath, checkIPSCodes);
}

@Override
Expand Down Expand Up @@ -899,6 +903,7 @@ public String toString() {
", bestPracticeLevel=" + bestPracticeLevel +
", watchSettleTime=" + watchSettleTime +
", watchScanDelay=" + watchScanDelay +
", unknownCodeSystemsCauseErrors=" + unknownCodeSystemsCauseErrors +
'}';
}

Expand Down Expand Up @@ -956,4 +961,17 @@ public CliContext setBestPracticeLevel(BestPracticeWarningLevel bestPracticeLeve
return this;
}


@JsonProperty("unknownCodeSystemsCauseErrors")
public boolean isUnknownCodeSystemsCauseErrors() {
return unknownCodeSystemsCauseErrors;
}


@JsonProperty("unknownCodeSystemsCauseErrors")
public void setUnknownCodeSystemsCauseErrors(boolean unknownCodeSystemsCauseErrors) {
this.unknownCodeSystemsCauseErrors = unknownCodeSystemsCauseErrors;
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -581,6 +581,7 @@ protected ValidationEngine buildValidationEngine( CliContext cliContext, String
}
validationEngine.getBundleValidationRules().addAll(cliContext.getBundleValidationRules());
validationEngine.setJurisdiction(CodeSystemUtilities.readCoding(cliContext.getJurisdiction()));
validationEngine.setUnknownCodeSystemsCauseErrors(cliContext.isUnknownCodeSystemsCauseErrors());
TerminologyCache.setNoCaching(cliContext.isNoInternalCaching());
validationEngine.prepare(); // generate any missing snapshots
System.out.println(" go (" + timeTracker.milestone() + ")");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,7 @@ public class Params {
public static final String DISABLE_DEFAULT_RESOURCE_FETCHER = "-disable-default-resource-fetcher";
public static final String CHECK_IPS_CODES = "-check-ips-codes";
public static final String BEST_PRACTICE = "-best-practice";


public static final String UNKNOWN_CODESYSTEMS_CAUSE_ERROR = "-unknown-codesystems-cause-errors";

public static final String RUN_TESTS = "-run-tests";

Expand Down Expand Up @@ -320,6 +319,8 @@ else if (args[i].equals(HTML_OUTPUT)) {
cliContext.setCrumbTrails(true);
} else if (args[i].equals(FOR_PUBLICATION)) {
cliContext.setForPublication(true);
} else if (args[i].equals(UNKNOWN_CODESYSTEMS_CAUSE_ERROR)) {
cliContext.setUnknownCodeSystemsCauseErrors(true);
} else if (args[i].equals(VERBOSE)) {
cliContext.setCrumbTrails(true);
} else if (args[i].equals(ALLOW_EXAMPLE_URLS)) {
Expand Down
Loading

0 comments on commit 0c457a1

Please sign in to comment.