Fix up loading of IG bundles

This commit is contained in:
Grahame Grieve 2023-03-30 23:30:41 +11:00
parent 76c96a53d6
commit 3df8593c48
2 changed files with 12 additions and 11 deletions

View File

@ -4,6 +4,8 @@ import org.hl7.fhir.r5.context.IWorkerContext;
import org.hl7.fhir.r5.model.CanonicalResource;
import org.hl7.fhir.r5.model.ElementDefinition;
import org.hl7.fhir.r5.model.Enumerations.BindingStrength;
import org.hl7.fhir.r5.model.Extension;
import org.hl7.fhir.r5.model.MarkdownType;
import org.hl7.fhir.r5.model.StructureDefinition.TypeDerivationRule;
import org.hl7.fhir.r5.model.StructureDefinition;
@ -15,24 +17,23 @@ public class R5Hacker {
}
}
private static void fixSD(StructureDefinition sd) {
if (sd.getDerivation() == TypeDerivationRule.CONSTRAINT) {
for (ElementDefinition ed : sd.getDifferential().getElement()) {
fix(ed);
}
for (ElementDefinition ed : sd.getSnapshot().getElement()) {
fix(ed);
}
for (ElementDefinition ed : sd.getDifferential().getElement()) {
fix(ed);
}
for (ElementDefinition ed : sd.getSnapshot().getElement()) {
fix(ed);
}
}
private static void fix(ElementDefinition ed) {
if (ed.hasDefinition()) {
ed.setDefinition(ed.getDefinition().replace("http://hl7.org/fhir/5.0.0-snapshot3/", "http://hl7.org/fhir/R5/"));
}
if (ed.hasBinding() && ed.getBinding().hasExtension(ToolingExtensions.EXT_BINDING_DEFINITION)) {
Extension ext = ed.getBinding().getExtensionByUrl(ToolingExtensions.EXT_BINDING_DEFINITION);
ext.setValue(new MarkdownType(ext.getValue().primitiveValue()));
}
}

View File

@ -122,7 +122,7 @@ public class ToolingExtensions {
public static final String EXT_IGP_PAGES = "http://hl7.org/fhir/StructureDefinition/igpublisher-folder-pages";
public static final String EXT_IGP_SPREADSHEET = "http://hl7.org/fhir/StructureDefinition/igpublisher-spreadsheet";
public static final String EXT_IGP_MAPPING_CSV = "http://hl7.org/fhir/StructureDefinition/igpublisher-mapping-csv";
public static final String EXT_IGP_BUNDLE = "http://hl7.org/fhir/StructureDefinition/igpublisher-bundle";
public static final String EXT_IGP_BUNDLE = "http://hl7.org/fhir/tools/StructureDefinition/igpublisher-bundle";
public static final String EXT_IGP_BASE = "http://hl7.org/fhir/StructureDefinition/igpublisher-res-base";
public static final String EXT_IGP_DEFNS = "http://hl7.org/fhir/StructureDefinition/igpublisher-res-defns";
public static final String EXT_IGP_FORMAT = "http://hl7.org/fhir/StructureDefinition/igpublisher-res-format";