Skip to content

Commit

Permalink
Merge pull request #804 from HL7/2023-11-gg-subscription-topic
Browse files Browse the repository at this point in the history
2023 11 gg subscription topic
  • Loading branch information
grahamegrieve authored Nov 7, 2023
2 parents 6b76011 + b94f953 commit 62ce77c
Show file tree
Hide file tree
Showing 13 changed files with 225 additions and 29 deletions.
30 changes: 13 additions & 17 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
* TxClient: Remove "profile" from tx operations
* Validator: Validate contextInvariant in extension definitions
* Validator: Fix Typo in TI WG name
* Validator: Handle unknown constants properly in FHIRPath
* Validator: Fix handling of type ancestors at the root of FHIRPath expressions
* Validator: CDA templates with no extension value use urn:oid: not urn:hl7ii:
* Validator: Allow URL as a type of string in FHIRPath type checking
* Validator: Fix semver validation
* Validator: Fix problem resolving context in CDA invariants
* Validator: Fix for FHIRPath constant handling
* Renderer: SQL in FHIR Implementation of ViewDefinitions available as beta
* Renderer: Fixes to Search Parameter rendering of multiples per FHIR-I decision
* Renderer: Fix broken links in extension references done by [[[]]]
* Renderer: Fix broken links in code system rendering of parents
* Renderer: Support using names in [[[markdown]]] when rendering
* Renderer: Fix [[[ and ]]] in markdown processing, and allow names
* Test Cases: Add CDA to test IGs
* General: Corrected spelling of 'supercedes' to 'supersedes' in IG…
* Snapshot Generation: Support suppress examples when generating snapshots
* Validator: Validate Vital signs Profiles when validating observations
* Validator: Hack around problem with vs-1 constraint in R4
* Validator: Check for retired status when multiple OID matches exist
* Validator: Fix for validating extensions on R5 resources in R4 (R4 special case)
* Validator: Minor fixes for standalone ViewDefinition validator
* Renderer: Revised Capability Statement rendering (Thanks Vassil Peytchev)
* Renderer: Fix bug rendering primitive types with an extension that provides a value alternative
* Renderer: Add clickable links for references when rendering json and xml instances in IG publisher
* Renderer: Fix bug generating profile spreadsheets
* Cross-Version: Handle SubscriptionTopic in cross-version analysis
* Internal QA: track memory during IG tests
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,9 @@ public class IGKnowledgeProvider implements ProfileKnowledgeProvider, ParserBase
private Set<String> summaryRows = new HashSet<>();
private String altCanonical;
private XVerExtensionManager xver;
private List<FetchedFile> files;

public IGKnowledgeProvider(IWorkerContext context, String pathToSpec, String canonical, JsonObject igs, List<ValidationMessage> errors, boolean noXhtml, Template template, List<String> listedURLExemptions, String altCanonical) throws Exception {
public IGKnowledgeProvider(IWorkerContext context, String pathToSpec, String canonical, JsonObject igs, List<ValidationMessage> errors, boolean noXhtml, Template template, List<String> listedURLExemptions, String altCanonical, List<FetchedFile> files) throws Exception {
super();
this.context = context;
this.pathToSpec = pathToSpec;
Expand All @@ -90,6 +91,7 @@ public IGKnowledgeProvider(IWorkerContext context, String pathToSpec, String can
this.template = template;
this.listedURLExemptions = listedURLExemptions;
this.altCanonical = altCanonical;
this.files = files;
if (igs != null) {
loadPaths(igs);
}
Expand Down Expand Up @@ -760,5 +762,30 @@ public Set<String> summaryRows() {
return summaryRows ;
}

@Override
public String resolveReference(String ref) {
if (ref == null) {
return null;
}
Resource res = context.fetchResource(Resource.class, ref);
if (res != null && res.hasWebPath()) {
return res.getWebPath();
}
if (ref.startsWith(canonical)) {
ref = Utilities.getRelativeUrlPath(canonical, ref);
}
String[] p = ref.split("/");
if (p.length == 2 && files != null) {
for (FetchedFile f : files) {
for (FetchedResource r : f.getResources()) {
if (p[0].equals(r.fhirType()) && p[1].equals(r.getId())) {
return getLinkFor(r, true);
}
}
}
}
return null;
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -3016,7 +3016,7 @@ else if (vsCache == null) {
checkTSVersion(vsCache, context.connectToTSServer(TerminologyClientFactory.makeClient("Tx-Server", webTxServer.getAddress(), "fhir/publisher", FhirPublication.fromCode(version)), txLog));

loadPubPack();
igpkp = new IGKnowledgeProvider(context, checkAppendSlash(specPath), determineCanonical(sourceIg.getUrl(), "ImplementationGuide.url"), template.config(), errors, VersionUtilities.isR2Ver(version), template, listedURLExemptions, altCanonical);
igpkp = new IGKnowledgeProvider(context, checkAppendSlash(specPath), determineCanonical(sourceIg.getUrl(), "ImplementationGuide.url"), template.config(), errors, VersionUtilities.isR2Ver(version), template, listedURLExemptions, altCanonical, fileList);
if (autoLoad) {
igpkp.setAutoPath(true);
}
Expand Down Expand Up @@ -3522,7 +3522,7 @@ else if (mode == IGBuildMode.AUTOBUILD)

loadPubPack();

igpkp = new IGKnowledgeProvider(context, checkAppendSlash(specPath), cb.asString(), configuration, errors, VersionUtilities.isR2Ver(version), null, listedURLExemptions, altCanonical);
igpkp = new IGKnowledgeProvider(context, checkAppendSlash(specPath), cb.asString(), configuration, errors, VersionUtilities.isR2Ver(version), null, listedURLExemptions, altCanonical, fileList);
igpkp.loadSpecPaths(specMaps.get(0));
fetcher.setPkp(igpkp);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
import java.util.Map;
import java.util.Map.Entry;

import org.hl7.fhir.convertors.factory.VersionConvertorFactory_40_50;
import org.hl7.fhir.convertors.factory.VersionConvertorFactory_43_50;
import org.hl7.fhir.exceptions.FHIRException;
import org.hl7.fhir.igtools.publisher.loaders.PublisherLoader;
import org.hl7.fhir.r4b.model.Bundle;
Expand Down Expand Up @@ -80,7 +82,7 @@ public String present() {
private static final List<String> R4BOnlyTypes = Collections.unmodifiableList(
Arrays.asList(new String[] {"CodeableReference", "RatioRange", "NutritionProduct",
"AdministrableProductDefinition", "ClinicalUseDefinition", "PackagedProductDefinition", "ManufacturedItemDefinition", "RegulatedAuthorization",
"MedicinalProductDefinition", "Ingredient", "SubstanceDefinition", "Citation", "EvidenceReport", "SubscriptionStatus", "SubscriptionTopic"}));
"MedicinalProductDefinition", "Ingredient", "SubstanceDefinition", "Citation", "EvidenceReport", "SubscriptionStatus"/*, "SubscriptionTopic"*/}));

private static final List<String> R4OnlyTypes = Collections.unmodifiableList(
Arrays.asList(new String[] {"MedicinalProduct", "MedicinalProductIngredient", "SubstanceSpecification", "MedicinalProductAuthorization",
Expand Down Expand Up @@ -269,17 +271,40 @@ public boolean canBeR4B() {

public String generate(String pid, boolean inline) {
if (VersionUtilities.isR4Ver(context.getVersion())) {
return gen(pid, "R4", "R4B", r4BOK, r4Problems, r4BProblems, r4Exemptions, r4BExemptions, inline);
return gen(pid, "R4", "R4B", r4OK, r4BOK, r4Problems, r4BProblems, r4Exemptions, r4BExemptions, inline);
} else if (VersionUtilities.isR4BVer(context.getVersion())) {
return gen(pid, "R4B", "R4", r4OK, r4BProblems, r4Problems, r4BExemptions, r4Exemptions, inline);
return gen(pid, "R4B", "R4", r4BOK, r4OK, r4BProblems, r4Problems, r4BExemptions, r4Exemptions, inline);
} else {
return "";
}
}

private String gen(String pid, String src, String dst, boolean dstOk, List<String> srcProblems, List<String> dstProblems, Map<String, ResPointer> srcExempt, Map<String, ResPointer> dstExempt, boolean inline) {
private String gen(String pid, String src, String dst, boolean srcOk, boolean dstOk, List<String> srcProblems, List<String> dstProblems, Map<String, ResPointer> srcExempt, Map<String, ResPointer> dstExempt, boolean inline) {
StringBuilder b = new StringBuilder();
if (dstOk) {
if (!srcOk) {
if (!inline) {
b.append("<p>");
}
b.append("Something went wrong with the cross-version analysis because: \r\n");
if (!inline) {
b.append("</p>\r\n");
b.append("<ul>\r\n");
}
boolean first = true;
for (String s : srcProblems) {
if (!inline) {
b.append("<li>");
}
if (first) first = false; else if (inline) b.append(", ");
b.append(s);
if (!inline) {
b.append("</li>\r\n");
}
}
if (!inline) {
b.append("</ul>\r\n");
}
} else if (dstOk) {
if (!inline) {
b.append("<p>");
}
Expand Down Expand Up @@ -503,6 +528,11 @@ private void processFileOther(NPMPackageGenerator gen, String folder, String fil
if (Utilities.existsInList(folder, "package", "example")) {
if (!Utilities.existsInList(filename, "package.json", ".index.json", ".index.db")) {
org.hl7.fhir.r4b.model.Resource res = new org.hl7.fhir.r4b.formats.JsonParser().parse(content);
if (VersionUtilities.isR4Ver(context.getVersion()) && "Basic".equals(res.fhirType())) {
org.hl7.fhir.r4.model.Resource r4 = new org.hl7.fhir.r4.formats.JsonParser().parse(content);
org.hl7.fhir.r5.model.Resource r5 = VersionConvertorFactory_40_50.convertResource(r4);
res = VersionConvertorFactory_43_50.convertResource(r5);
}
boolean exempt = (exemptions.containsKey(res.fhirType()+"/"+res.getId()) ||
((res instanceof org.hl7.fhir.r4b.model.CanonicalResource) && exemptions.containsKey(((org.hl7.fhir.r4b.model.CanonicalResource) res).getUrl())));
if (!exempt) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ public int getUseCount() {
}

public boolean matches(String msg) {
return matchesInner(msg) || matchesInner(msg.replace(" (this may not be a problem, but you should check that it's not intended to match a slice)", ""));
}

private boolean matchesInner(String msg) {
switch (compType) {
case 0: return msg.equals(messageComp);
case 1: return msg.startsWith(messageComp);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ public void startChecks(ImplementationGuide ig) {
vi.context.setLocale(context.getLocale());
vi.context.setLogger(context.getLogger());
vi.context.loadFromPackageAndDependencies(current, new PublisherLoader(current, SpecMapManager.fromPackage(current), current.getWebLocation(), null).makeLoader(), pcm);
vi.pkp = new IGKnowledgeProvider(vi.context, current.getWebLocation(), current.canonical(), null, null, false, null, null, null);
vi.pkp = new IGKnowledgeProvider(vi.context, current.getWebLocation(), current.canonical(), null, null, false, null, null, null, null);
} catch (Exception e) {
vi.errMsg = "Unable to find load package "+pid+"#"+vi.version+" ("+e.getMessage()+" on file "+filename+")";
e.printStackTrace();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ public void startChecks(ImplementationGuide ig) {
vi.context.setLocale(context.getLocale());
vi.context.setLogger(context.getLogger());
vi.context.loadFromPackageAndDependencies(current, new PublisherLoader(current, SpecMapManager.fromPackage(current), current.getWebLocation(), null).makeLoader(), pcm);
vi.pkp = new IGKnowledgeProvider(vi.context, current.getWebLocation(), current.canonical(), null, null, false, null, null, null);
vi.pkp = new IGKnowledgeProvider(vi.context, current.getWebLocation(), current.canonical(), null, null, false, null, null, null, null);
} catch (Exception e) {
vi.errMsg = "Unable to find load package "+pid+"#"+vi.version+" ("+e.getMessage()+" on file "+filename+")";
e.printStackTrace();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,5 +215,10 @@ public void anchor(String name) {
b.append("<a name=\""+name+"\"></a>");
}

@Override
public void externalLink(String ref) {
b.append("<a href=\""+Utilities.escapeXml(ref)+"\" style=\"color: Maroon\">&#x1F517;</a> ");
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -785,4 +785,18 @@ public void decorate(ElementDecoration decoration) throws IOException {
@Override
public void setSchemaLocation(String s, String s1) throws IOException {
}


@Override
public void externalLink(String ref) throws IOException {
if (pendingClose) {
b.append("&gt;");
writeDecorations();
writePendingComment();
pendingClose = false;
}
b.append("<a href=\""+Utilities.escapeXml(ref)+"\" style=\"color: Maroon\">&#x1F517;</a> ");
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ private void testIg(String id, String path) throws Exception {
String version = readVersion();
File statsFile = determineStatsFile();
long time = System.currentTimeMillis();
long startingMem = getCurrentmem();

System.out.println("=======================================================================================");
String p = (path == null ? Utilities.path(FhirSettings.getTestIgsPath(), id) : Utilities.path(FhirSettings.getTestIgsPath(), id, path));
Expand Down Expand Up @@ -84,7 +85,7 @@ private void testIg(String id, String path) throws Exception {
si.set("warnings", cWarn);
si.set("hints", cHint);
si.set("time", System.currentTimeMillis() - time);
si.set("memory", pub.getMaxMemory());
si.set("memory", pub.getMaxMemory() - startingMem);
JsonParser.compose(stats, statsFile, true);

Map<String, Map<String, String>> statsMap = new HashMap<>();
Expand Down Expand Up @@ -134,6 +135,15 @@ private void testIg(String id, String path) throws Exception {
dumpMem(id);
}

private long getCurrentmem() {

Runtime runtime = Runtime.getRuntime();
long totalMemory = runtime.totalMemory();
long freeMemory = runtime.freeMemory();
long usedMemory = totalMemory - freeMemory;
return usedMemory;
}

private void dumpMem(String id) throws IOException {
File f = new File(Utilities.path("[tmp]", "memory-dump-"+id+".hprof"));
f.delete();
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<version>1.5.2-SNAPSHOT</version> <!-- See the note above -->

<properties>
<core_version>6.2.1</core_version>
<core_version>6.2.2-SNAPSHOT</core_version>
<maven_surefire_version>3.0.0-M5</maven_surefire_version>
<apache_poi_version>5.2.1</apache_poi_version>
<okhttp.version>4.11.0</okhttp.version>
Expand Down
1 change: 1 addition & 0 deletions test-statistics.csv
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
1.4.17,45405,1152,90,,333893,713,576428,510291,688062,20062,77921,292184,255657,49109,182535
1.5.0,48649,1349,129,128937,254417,1494,385606,446970,760444,42358,73453,185270,225642,59841,200877
1.5.1,47973,1120,75,108608,331701,595,566979,500812,702868,32185,76394,300885,258990,49734,191994
1.5.2,65891,1056,80,109119,545761,594,892711,392719,675203,32335,113522,538889,389926,51564,207463
109 changes: 109 additions & 0 deletions test-statistics.json
Original file line number Diff line number Diff line change
Expand Up @@ -407,5 +407,114 @@
"time" : 702868,
"memory" : 5103103688
}
},
"1.5.2" : {
"sync-date" : "2023-10-28",
"date" : "2023-11-07",
"hl7.fhir.template.ig" : {
"errors" : 0,
"warnings" : 0,
"hints" : 0,
"time" : 594,
"memory" : 9868864
},
"hl7.cda.uv.core" : {
"errors" : 0,
"warnings" : 1,
"hints" : 2,
"time" : 109119,
"memory" : 4793043584
},
"hl7.fhir.us.ecr" : {
"errors" : 6,
"warnings" : 27,
"hints" : 0,
"time" : 392719,
"memory" : 8445073096
},
"hl7.fhir.uv.ipa" : {
"errors" : 25,
"warnings" : 8,
"hints" : 32,
"time" : 113522,
"memory" : 1874596080
},
"hl7.fhir.uv.ips" : {
"errors" : 0,
"warnings" : 31,
"hints" : 17,
"time" : 538889,
"memory" : 2607124480
},
"ihe.mhd.fhir" : {
"errors" : 0,
"warnings" : 21,
"hints" : 21,
"time" : 207463,
"memory" : 2264503184
},
"hl7.fhir.uv.sdc" : {
"errors" : 125,
"warnings" : 38,
"hints" : 153,
"time" : 389926,
"memory" : 2254545928
},
"hl7.fhir.uv.tools" : {
"errors" : 68,
"warnings" : 4,
"hints" : 3,
"time" : 51564,
"memory" : 1694438320
},
"hl7.base.template.ig" : {
"errors" : 0,
"warnings" : 0,
"hints" : 0,
"time" : 80,
"memory" : 8390664
},
"hl7.fhir.uv.howto" : {
"errors" : 1,
"warnings" : 0,
"hints" : 0,
"time" : 32335,
"memory" : 1050476360
},
"fhir.base.template.ig" : {
"errors" : 0,
"warnings" : 0,
"hints" : 0,
"time" : 1056,
"memory" : 92963024
},
"hl7.fhir.au.base" : {
"errors" : 10,
"warnings" : 187,
"hints" : 78,
"time" : 545761,
"memory" : 4179752904
},
"example.fhir.uv.myig" : {
"errors" : 18,
"warnings" : 11,
"hints" : 7,
"time" : 65891,
"memory" : 1492180160
},
"hl7.fhir.us.core" : {
"errors" : 8,
"warnings" : 7,
"hints" : 211,
"time" : 892711,
"memory" : 9977895608
},
"hl7.fhir.uv.extensions" : {
"errors" : 126,
"warnings" : 92,
"hints" : 211,
"time" : 675203,
"memory" : 7181111928
}
}
}

0 comments on commit 62ce77c

Please sign in to comment.