Skip to content

Commit

Permalink
custom resource workaround for sushi
Browse files Browse the repository at this point in the history
  • Loading branch information
grahamegrieve committed Nov 18, 2024
1 parent 683912a commit b89e5b1
Showing 1 changed file with 19 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5041,6 +5041,25 @@ private String loadCustomResource(String filename) throws FileNotFoundException,
def.setUserData(UserDataNames.loader_custom_resource, "true");
def.setWebPath("placeholder.html"); // we'll figure it out later
context.cacheResource(def);

// work around for a sushi limitation
for (ImplementationGuideDefinitionResourceComponent res : publishedIg.getDefinition().getResource()) {
if (res.getReference().getReference().startsWith("Binary/")) {
if (res.getProfile().size() == 1 && def.getUrl().equals(res.getProfile().get(0).primitiveValue())) {
String id = res.getReference().getReference().substring(res.getReference().getReference().indexOf("/")+1);
File of = new File(Utilities.path(Utilities.getDirectoryForFile(this.getConfigFile()), "fsh-generated", "resources", "Binary-"+id+".json"));
File nf = new File(Utilities.path(Utilities.getDirectoryForFile(this.getConfigFile()), "fsh-generated", "resources", def.getType()+"-"+id+".json"));
if (of.exists()) {
of.renameTo(nf);
JsonObject j = org.hl7.fhir.utilities.json.parser.JsonParser.parseObject(nf);
j.set("resourceType", def.getType());
org.hl7.fhir.utilities.json.parser.JsonParser.compose(j, nf, true);
}
res.getReference().setReference(def.getType()+res.getReference().getReference().substring(res.getReference().getReference().indexOf("/")));
}
}
}

return "loaded";
}

Expand Down

0 comments on commit b89e5b1

Please sign in to comment.