Hack for wrong URLs in subscriptions backport

This commit is contained in:
Grahame Grieve 2023-10-20 16:25:09 +11:00
parent 87b756e0c7
commit 12cdccf3bb
3 changed files with 22 additions and 2 deletions

View File

@ -123,7 +123,7 @@ public class R4BToR5Loader extends BaseLoaderR5 implements IContextResourceLoade
if (killPrimitives) { if (killPrimitives) {
throw new FHIRException("Cannot kill primitives when using deferred loading"); throw new FHIRException("Cannot kill primitives when using deferred loading");
} }
if (r5 instanceof StructureDefinition && VersionUtilities.isR4BVer(version)) { if (r5 instanceof StructureDefinition) {
r5 = new StructureDefinitionHacker(version).fixSD((StructureDefinition) r5); r5 = new StructureDefinitionHacker(version).fixSD((StructureDefinition) r5);
} }
if (patchUrls) { if (patchUrls) {

View File

@ -123,7 +123,7 @@ public class R4ToR5Loader extends BaseLoaderR5 implements IContextResourceLoader
if (killPrimitives) { if (killPrimitives) {
throw new FHIRException("Cannot kill primitives when using deferred loading"); throw new FHIRException("Cannot kill primitives when using deferred loading");
} }
if (r5 instanceof StructureDefinition && VersionUtilities.isR4Ver(version)) { if (r5 instanceof StructureDefinition) {
r5 = new StructureDefinitionHacker(version).fixSD((StructureDefinition) r5); r5 = new StructureDefinitionHacker(version).fixSD((StructureDefinition) r5);
} }
if (patchUrls) { if (patchUrls) {

View File

@ -49,9 +49,29 @@ public class StructureDefinitionHacker {
} }
} }
} }
if (sd.getUrl().startsWith("http://hl7.org/fhir/uv/subscriptions-backport")) {
for (ElementDefinition ed : sd.getDifferential().getElement()) {
fixMarkdownR4BURLs(ed);
}
for (ElementDefinition ed : sd.getSnapshot().getElement()) {
fixMarkdownR4BURLs(ed);
}
}
return sd; return sd;
} }
private void fixMarkdownR4BURLs(ElementDefinition ed) {
if (ed.hasDefinition()) {
ed.setDefinition(ed.getDefinition().replace("http://hl7.org/fhir/R4B/", "http://hl7.org/fhir/R4/"));
}
if (ed.hasComment()) {
ed.setComment(ed.getComment().replace("http://hl7.org/fhir/R4B/", "http://hl7.org/fhir/R4/"));
}
if (ed.hasRequirements()) {
ed.setRequirements(ed.getRequirements().replace("http://hl7.org/fhir/R4B/", "http://hl7.org/fhir/R4/"));
}
}
private void fixDocSecURL(ElementDefinition ed) { private void fixDocSecURL(ElementDefinition ed) {
for (TypeRefComponent tr : ed.getType()) { for (TypeRefComponent tr : ed.getType()) {
for (CanonicalType c : tr.getProfile()) { for (CanonicalType c : tr.getProfile()) {