diff --git a/org.hl7.fhir.publisher.core/src/main/java/org/hl7/fhir/igtools/openehr/ArchetypeImporter.java b/org.hl7.fhir.publisher.core/src/main/java/org/hl7/fhir/igtools/openehr/ArchetypeImporter.java index 4ec8b780b..d5b252e23 100644 --- a/org.hl7.fhir.publisher.core/src/main/java/org/hl7/fhir/igtools/openehr/ArchetypeImporter.java +++ b/org.hl7.fhir.publisher.core/src/main/java/org/hl7/fhir/igtools/openehr/ArchetypeImporter.java @@ -79,9 +79,12 @@ public static class ProcessedArchetype { private StructureDefinition sd; private Bundle bnd; private String source; - protected ProcessedArchetype(String source, Archetype archetype, Bundle bnd, StructureDefinition sd) { + private String sourceName; + + protected ProcessedArchetype(String source,String sourceName, Archetype archetype, Bundle bnd, StructureDefinition sd) { super(); this.source = source; + this.sourceName = sourceName; this.archetype = archetype; this.sd = sd; this.bnd = bnd; @@ -89,6 +92,9 @@ protected ProcessedArchetype(String source, Archetype archetype, Bundle bnd, St public String getSource() { return source; } + public String getSourceName() { + return sourceName; + } public Archetype getArchetype() { return archetype; } @@ -216,7 +222,7 @@ public ProcessedArchetype importArchetype(InputStream stream, String name) throw List defns = sd.getDifferential().getElement(); processDefinition(defns, null, defn, baseType, null, baseType, defn.getNodeId()); - return new ProcessedArchetype(new String(cnt), archetype, bnd, sd); + return new ProcessedArchetype(new String(cnt), name, archetype, bnd, sd); } private Archetype load20(InputStream stream) throws ADLParseException, IOException { diff --git a/org.hl7.fhir.publisher.core/src/main/java/org/hl7/fhir/igtools/publisher/IGPack2NpmConvertor.java b/org.hl7.fhir.publisher.core/src/main/java/org/hl7/fhir/igtools/publisher/IGPack2NpmConvertor.java index 5b4b807d9..91732f336 100644 --- a/org.hl7.fhir.publisher.core/src/main/java/org/hl7/fhir/igtools/publisher/IGPack2NpmConvertor.java +++ b/org.hl7.fhir.publisher.core/src/main/java/org/hl7/fhir/igtools/publisher/IGPack2NpmConvertor.java @@ -216,9 +216,7 @@ private void processValidatorPack(File f) throws IOException { String destFile = dest != null ? dest : Utilities.path(Utilities.getDirectoryForFile(f.getAbsolutePath()), "package.tgz"); String url = Utilities.noString(website) ? canonical : website; NPMPackageGenerator npm = new NPMPackageGenerator(destFile, canonical, url, PackageType.IG, ig, new Date(), false); - ByteArrayOutputStream bs = new ByteArrayOutputStream(); - new JsonParser().setOutputStyle(OutputStyle.NORMAL).compose(bs, ig); - npm.addFile(Category.OTHER, "ig-r4.jsonX", bs.toByteArray()); + npm.addFile(Category.RESOURCE, "ImplementationGuide-"+ig.getId()+".json", compose(ig, version)); diff --git a/org.hl7.fhir.publisher.core/src/main/java/org/hl7/fhir/igtools/publisher/Publisher.java b/org.hl7.fhir.publisher.core/src/main/java/org/hl7/fhir/igtools/publisher/Publisher.java index 226b05a28..c4f41a28c 100644 --- a/org.hl7.fhir.publisher.core/src/main/java/org/hl7/fhir/igtools/publisher/Publisher.java +++ b/org.hl7.fhir.publisher.core/src/main/java/org/hl7/fhir/igtools/publisher/Publisher.java @@ -5697,9 +5697,10 @@ private boolean loadBundle(String name, boolean needToBuild, FetchedFile igf, St } private boolean loadArchetype(FetchedFile f, String cause) throws Exception { - ProcessedArchetype pa = new ArchetypeImporter(context, igpkp.getCanonical()).importArchetype(f.getSource(), f.getName()); + ProcessedArchetype pa = new ArchetypeImporter(context, igpkp.getCanonical()).importArchetype(f.getSource(), new File(f.getStatedPath()).getName()); Bundle bnd = pa.getBnd(); - pa.getSd().setUserData(UserDataNames.archetype, pa.getSource()); + pa.getSd().setUserData(UserDataNames.archetypeSource, pa.getSource()); + pa.getSd().setUserData(UserDataNames.archetypeName, pa.getSourceName()); f.setBundle(new FetchedResource(f.getName()+" (bundle)")); f.setBundleType(FetchedBundleType.NATIVE); @@ -8415,11 +8416,7 @@ private void updateImplementationGuide() throws Exception { } r.setResource(publishedIg); r.setElement(convertToElement(r, publishedIg)); - - ByteArrayOutputStream bs = new ByteArrayOutputStream(); - new org.hl7.fhir.r4.formats.JsonParser().compose(bs, VersionConvertorFactory_40_50.convertResource(publishedIg)); - npm.addFile(Category.OTHER, "ig-r4.jsonX", bs.toByteArray()); - + for (ImplementationGuideDefinitionResourceComponent res : publishedIg.getDefinition().getResource()) { FetchedResource rt = null; for (FetchedFile tf : fileList) { @@ -12411,7 +12408,10 @@ private byte[] saveNativeResourceOutputs(FetchedFile f, FetchedResource r) throw Element eNN = element; jp.compose(element, bsj, OutputStyle.NORMAL, igpkp.getCanonical()); if (!r.isCustomResource()) { - npm.addFile(isExample(f,r ) ? Category.EXAMPLE : Category.RESOURCE, element.fhirType()+"-"+r.getId()+".json", bsj.toByteArray()); + npm.addFile(isExample(f,r ) ? Category.EXAMPLE : Category.RESOURCE, element.fhirType()+"-"+r.getId()+".json", bsj.toByteArray()); + if (r.getResource() != null && r.getResource().hasUserData(UserDataNames.archetypeSource)) { + npm.addFile(Category.ADL, r.getResource().getUserString(UserDataNames.archetypeName), r.getResource().getUserString(UserDataNames.archetypeSource).getBytes(StandardCharsets.UTF_8)); + } } else if ("StructureDefinition".equals(r.fhirType())) { npm.addFile(Category.RESOURCE, element.fhirType()+"-"+r.getId()+".json", bsj.toByteArray()); StructureDefinition sdt = (StructureDefinition) r.getResource().copy(); @@ -13248,7 +13248,7 @@ private void generateOutputsStructureDefinition(FetchedFile f, FetchedResource r fragment("StructureDefinition-"+prefixForContainer+sd.getId()+"-eview"+langSfx, sdr.eview(igpkp.getDefinitionsName(r), otherFilesRun, tabbedSnapshots, StructureDefinitionRendererMode.SUMMARY, false), f.getOutputNames(), r, vars, null, start, "eview", "StructureDefinition"); fragment("StructureDefinition-"+prefixForContainer+sd.getId()+"-eview-all"+langSfx, sdr.eview(igpkp.getDefinitionsName(r), otherFilesRun, tabbedSnapshots, StructureDefinitionRendererMode.SUMMARY, true), f.getOutputNames(), r, vars, null, start, "eview", "StructureDefinition"); } - if (igpkp.wantGen(r, "adl") && sd.hasUserData(UserDataNames.archetype)) { + if (igpkp.wantGen(r, "adl") && sd.hasUserData(UserDataNames.archetypeSource)) { long start = System.currentTimeMillis(); fragment("StructureDefinition-"+prefixForContainer+sd.getId()+"-adl"+langSfx, sdr.adl(), f.getOutputNames(), r, vars, null, start, "adl", "StructureDefinition"); } diff --git a/org.hl7.fhir.publisher.core/src/main/java/org/hl7/fhir/igtools/publisher/R4ToR4BAnalyser.java b/org.hl7.fhir.publisher.core/src/main/java/org/hl7/fhir/igtools/publisher/R4ToR4BAnalyser.java index 565567f32..73a7eaac4 100644 --- a/org.hl7.fhir.publisher.core/src/main/java/org/hl7/fhir/igtools/publisher/R4ToR4BAnalyser.java +++ b/org.hl7.fhir.publisher.core/src/main/java/org/hl7/fhir/igtools/publisher/R4ToR4BAnalyser.java @@ -467,8 +467,6 @@ private void processFileSame(NPMPackageGenerator gen, String folder, String file // System.out.println("** Exclude "+res.fhirType()+"/"+res.getId()+" from same version"); } } - } else if (filename.equals("ig-r4.json") || filename.equals("ig-r4.jsonX")) { - gen.addFile(folder, filename, updateIGR4(content, ver, pver)); } else if (filename.equals("spec.internals")) { gen.addFile(folder, filename, updateSpecInternals(content, ver, pver)); } else { diff --git a/org.hl7.fhir.publisher.core/src/main/java/org/hl7/fhir/igtools/renderers/StructureDefinitionRenderer.java b/org.hl7.fhir.publisher.core/src/main/java/org/hl7/fhir/igtools/renderers/StructureDefinitionRenderer.java index 044dd05f5..6b2bc332d 100644 --- a/org.hl7.fhir.publisher.core/src/main/java/org/hl7/fhir/igtools/renderers/StructureDefinitionRenderer.java +++ b/org.hl7.fhir.publisher.core/src/main/java/org/hl7/fhir/igtools/renderers/StructureDefinitionRenderer.java @@ -2569,6 +2569,6 @@ public String experimentalWarning() { } public String adl() { - return "
"+Utilities.escapeXml(sd.getUserString(UserDataNames.archetype))+"
"; + return "
"+Utilities.escapeXml(sd.getUserString(UserDataNames.archetypeSource))+"
"; } }