Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/HL7/fhir-ig-publisher
Browse files Browse the repository at this point in the history
  • Loading branch information
lmckenzi committed Aug 1, 2023
2 parents fc652e4 + 68fba84 commit b15500a
Show file tree
Hide file tree
Showing 14 changed files with 423 additions and 196 deletions.
76 changes: 76 additions & 0 deletions documentation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# IG Publisher User Documentation

## Introduction

This is the documentation for the IG Publisher.

## IG Requirements

Supported Implementation Guides that the IG publisher can publish are always contained in directories that
contain a file named ```ig.ini``` with the following content:

```ini
[IG]
ig = {path}
template = {template-id}
```
Other entries are allowed, but not used by the IG-Publisher. ig - the path to the ImplementationGuide resource
that defines.

You can either run the Publisher with a default directory of the folder that contains the ig.ini, or use the ```-ig``` parameter.

See [Location?](todo) for documentation about the content of the IG to be built.

## Command Line Parameters

Run mode:
* ```-help``` - produce the command line help
* ```-go-publish`` - publication mode, see below`
* ```-gui``` - run the GUI (not really supported)

Command line build mode parameters
* ```-ig``` {folder} - the folder that contains the IG
* ```-prompt``` - ask which ig to run (default to last)
* ```-source``` - run with standard template. this is publishing lite (just a set of conformance resource, IG publisher autobuilds an IG) ?supported
* ```-fhir-settings``` - see next section
* ```-debug``` - turn on debugging (extra logging, can be verbose)
* ```-proxy``` - proxy to use if it must be set manually (host:port)
* ```-tx``` - alternative tx server to tx.fhir.org (but still most be the same software, see [running your own copy of tx.fhir.org](https://confluence.hl7.org/display/FHIR/Running+your+own+copy+of+tx.fhir.org))
* ```-no-network``` - turn of all network access - any attempt to use the network will generate an error (offline build mode)
* ```-no-sushi``` - don't run sushi before build IG (if it's there to be run)
* ```-generation-off``` - turn narrative generation off completely to make for faster local run time
* ```-no-narrative``` - comma list of resources (type/id) to not generate narrative for (e.g. faster run)
* ```-validation-off``` - turn validation off completely to make for faster local run time
* ```-no-validate``` - comma list of resources (type/id) to not validate (e.g. faster run)
* ```-resetTx``` - clear the local terminology cache before running
* ```-resetTxErrors``` - remove any errors from the local cache but leave other content there
* ```-auto-ig-build``` - used by the ci-build (see below) to switch on some ci-build integration features
* ```-simplifier``` - used by simplifier when running the IG publisher internally (under development)
* ```-jekyll``` - path to Jekyll (but use config, see below)
* ```-cacheVersion``` - ?not supported anymore?
* ```-spec``` - path to old spec file (deprecated and not supported)
* ```-publish``` - ?not supported anymore?

## Configuration File

## Go Publish

(todo)

## CI-build integration

See https://github.com/FHIR/auto-ig-builder#quick-start-guide

## UI mode

This exists but isn't well documented.

## Shell Integration

### Windows

To do

### OSX

To do
2 changes: 1 addition & 1 deletion master-branch-pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ steps:
inputs:
mavenPomFile: '$(System.DefaultWorkingDirectory)/pom.xml'
goals: deploy
options: '--settings $(System.DefaultWorkingDirectory)/settings.xml -DdeployToSonatype -e'
options: '--settings $(System.DefaultWorkingDirectory)/settings.xml -Dmaven.test.skip -DdeployToSonatype -e'
publishJUnitResults: false

# Deploy the SNAPSHOT artifact to GitHub packages.
Expand Down
2 changes: 1 addition & 1 deletion org.hl7.fhir.publisher.cli/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>org.hl7.fhir.publisher</artifactId>
<groupId>org.hl7.fhir.publisher</groupId>
<version>1.3.24-SNAPSHOT</version>
<version>1.3.26-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
Expand Down
2 changes: 1 addition & 1 deletion org.hl7.fhir.publisher.core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>org.hl7.fhir.publisher</groupId>
<artifactId>org.hl7.fhir.publisher</artifactId>
<version>1.3.24-SNAPSHOT</version>
<version>1.3.26-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
package org.hl7.fhir.igtools.publisher;

/*
Copyright (c) 2011+, HL7, Inc.
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of HL7 nor the names of its contributors may be used to
endorse or promote products derived from this software without specific
prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/



import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

import org.hl7.fhir.r5.context.IWorkerContext;
import org.hl7.fhir.r5.model.CodeSystem;
import org.hl7.fhir.r5.model.CodeSystem.ConceptDefinitionComponent;
import org.hl7.fhir.r5.utils.XVerExtensionManager;
import org.hl7.fhir.utilities.validation.ValidationMessage;
import org.hl7.fhir.utilities.validation.ValidationMessage.IssueType;
import org.hl7.fhir.validation.BaseValidator;

/**
* This is defunct, I think? All this checking happens in the main code system validator?
*
* @author grahamegrieve
*
*/
public class CodeSystemValidator extends BaseValidator {

public CodeSystemValidator(IWorkerContext context, XVerExtensionManager xverManager) {
super(context, xverManager, false);
}

public List<ValidationMessage> validate(CodeSystem cs, boolean forBuild) {
List<ValidationMessage> errors = new ArrayList<ValidationMessage>();

// this is an invariant on CodeSystem, but the invariant is wrong in R3, and doesn't work
checkCodesUnique(cs, errors);
return errors;
}

private void checkCodesUnique(CodeSystem cs, List<ValidationMessage> errors) {
Set<String> codes = new HashSet<String>();
checkCodes(codes, cs.getConcept(), "CodeSystem.where(id = '"+cs.getId()+"')", errors);
}

private void checkCodes(Set<String> codes, List<ConceptDefinitionComponent> list, String path, List<ValidationMessage> errors) {
for (ConceptDefinitionComponent cc : list) {
String npath = path+".concept.where(code = '"+cc.getCode()+"')";
if (codes.contains(cc.getCode())) {
rule(errors, NO_RULE_DATE, IssueType.BUSINESSRULE, npath, false, "Duplicate Code "+cc.getCode());
}
codes.add(cc.getCode());
checkCodes(codes, cc.getConcept(), npath, errors);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -677,7 +677,7 @@ private boolean checkResolveLink(String filename, Location loc, String path, Str
}

if (!resolved) {
if (rref.startsWith("http://") || rref.startsWith("https://") || rref.startsWith("ftp://") || rref.startsWith("tel:")) {
if (rref.startsWith("http://") || rref.startsWith("https://") || rref.startsWith("ftp://") || rref.startsWith("tel:") || rref.startsWith("urn:")) {
resolved = true;
if (specs != null) {
for (SpecMapManager spec : specs) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
* #L%
*/

import java.awt.EventQueue;
import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
Expand Down Expand Up @@ -63,7 +62,6 @@
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;

import javax.swing.UIManager;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
Expand All @@ -76,7 +74,7 @@
import org.apache.commons.lang3.NotImplementedException;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.SystemUtils;
import org.apache.xmlbeans.XmlOptionCharEscapeMap;

import org.checkerframework.checker.nullness.qual.NonNull;
import org.hl7.fhir.convertors.advisors.impl.BaseAdvisor_10_50;
import org.hl7.fhir.convertors.factory.VersionConvertorFactory_10_50;
Expand All @@ -85,7 +83,7 @@
import org.hl7.fhir.convertors.factory.VersionConvertorFactory_30_50;
import org.hl7.fhir.convertors.factory.VersionConvertorFactory_40_50;
import org.hl7.fhir.convertors.factory.VersionConvertorFactory_43_50;
import org.hl7.fhir.convertors.misc.DicomPackageBuilder;

import org.hl7.fhir.convertors.misc.NpmPackageVersionConverter;
import org.hl7.fhir.convertors.txClient.TerminologyClientFactory;
import org.hl7.fhir.exceptions.DefinitionException;
Expand Down Expand Up @@ -268,9 +266,7 @@
import org.hl7.fhir.utilities.ZipGenerator;
import org.hl7.fhir.utilities.i18n.I18nConstants;
import org.hl7.fhir.utilities.i18n.JsonLangFileProducer;
import org.hl7.fhir.utilities.i18n.JsonLangFileProducer.JsonLangProducerSession;
import org.hl7.fhir.utilities.i18n.LanguageFileProducer.LanguageProducerLanguageSession;
import org.hl7.fhir.utilities.i18n.LanguageFileProducer.LanguageProducerSession;

import org.hl7.fhir.utilities.i18n.LanguageFileProducer.TranslationUnit;
import org.hl7.fhir.utilities.i18n.PoGetTextProducer;
import org.hl7.fhir.utilities.i18n.XLIFFProducer;
Expand Down Expand Up @@ -304,7 +300,6 @@
import org.hl7.fhir.utilities.xml.XMLUtil;
import org.hl7.fhir.utilities.xml.XmlEscaper;
import org.hl7.fhir.validation.ValidatorUtils;
import org.hl7.fhir.validation.codesystem.CodeSystemValidator;
import org.hl7.fhir.validation.instance.InstanceValidator;
import org.hl7.fhir.validation.instance.utils.ValidatorHostContext;
import org.hl7.fhir.validation.profile.ProfileValidator;
Expand Down Expand Up @@ -925,9 +920,13 @@ private void packageTemplate() throws IOException {
Utilities.createDirectory(outputDir);
long startTime = System.nanoTime();
JsonObject qaJson = new JsonObject();
StringBuilder txt = new StringBuilder();
qaJson.add("url", templateInfo.asString("canonical"));
txt.append("url = "+templateInfo.asString("canonical")+"\r\n");
qaJson.add("package-id", templateInfo.asString("name"));
txt.append("package-id = "+templateInfo.asString("name")+"\r\n");
qaJson.add("ig-ver", templateInfo.asString("version"));
txt.append("ig-ver = "+templateInfo.asString("version")+"\r\n");
qaJson.add("date", new SimpleDateFormat("EEE, dd MMM, yyyy HH:mm:ss Z", new Locale("en", "US")).format(execTime.getTime()));
qaJson.add("version", Constants.VERSION);
qaJson.add("tool", Constants.VERSION+" ("+ToolsVersion.TOOLS_VERSION+")");
Expand All @@ -949,10 +948,12 @@ private void packageTemplate() throws IOException {
} catch (Exception e) {
e.printStackTrace();
qaJson.add("exception", e.getMessage());
txt.append("exception = "+e.getMessage()+"\r\n");
}
long endTime = System.nanoTime();
String json = org.hl7.fhir.utilities.json.parser.JsonParser.compose(qaJson, true);
TextFile.stringToFile(json, Utilities.path(outputDir, "qa.json"), false);
TextFile.stringToFile(txt.toString(), Utilities.path(outputDir, "qa.txt"), false);

Utilities.createDirectory(tempDir);
ZipGenerator zip = new ZipGenerator(Utilities.path(tempDir, "full-ig.zip"));
Expand Down Expand Up @@ -1003,6 +1004,16 @@ private void processTxLog(String path) throws FileNotFoundException, IOException
PrintStream f = new PrintStream(new FileOutputStream(path));
String title = "Terminology Server Log";
f.println("<html><head><title>"+title+"</title></head><body><h2>"+title+"</h2><pre>");
for (String s : tx.split("\\r?\\n|\\r")) {
if (s.startsWith("---") && s.endsWith("---")) {
f.println("</pre><hr/>");
String id = s.replace("-", "").trim();
f.println("<a name=\"l"+id+"\"> </a><h3>"+id+"</h3>");
f.println("<pre>");
} else {
f.println(s);
}
}
f.print(tx);
f.println("</pre></head></html>");
f.close();
Expand Down Expand Up @@ -11123,17 +11134,7 @@ public String getConfigFile() {
}

private static void runGUI() throws InterruptedException, InvocationTargetException {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
GraphicalPublisher window = new GraphicalPublisher();
window.frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
GraphicalPublisher.launchUI();
}

public void setTxServer(String s) {
Expand Down Expand Up @@ -11280,14 +11281,14 @@ public static void main(String[] args) throws Exception {
NpmPackage npm = pcm.loadPackage(p);
System.out.println("OK: "+npm.name()+"#"+npm.version()+" for FHIR version(s) "+npm.fhirVersionList()+" with canonical "+npm.canonical());
}
} else if (hasNamedParam(args, "-dicom-gen")) {
DicomPackageBuilder pgen = new DicomPackageBuilder();
pgen.setSource(getNamedParam(args, "src"));
pgen.setDest(getNamedParam(args, "dst"));
if (hasNamedParam(args, "-pattern")) {
pgen.setPattern(getNamedParam(args, "-pattern"));
}
pgen.execute();
// } else if (hasNamedParam(args, "-dicom-gen")) {
// DicomPackageBuilder pgen = new DicomPackageBuilder();
// pgen.setSource(getNamedParam(args, "src"));
// pgen.setDest(getNamedParam(args, "dst"));
// if (hasNamedParam(args, "-pattern")) {
// pgen.setPattern(getNamedParam(args, "-pattern"));
// }
// pgen.execute();
} else if (hasNamedParam(args, "-help") || hasNamedParam(args, "-?") || hasNamedParam(args, "/?") || hasNamedParam(args, "?") || args.length == 0) {
System.out.println("");
System.out.println("To use this publisher to publish a FHIR Implementation Guide, run ");
Expand Down Expand Up @@ -11331,16 +11332,16 @@ public static void main(String[] args) throws Exception {
System.out.println("or you can configure the proxy using -Dhttp.proxyHost=<ip> -Dhttp.proxyPort=<port> -Dhttps.proxyHost=<ip> -Dhttps.proxyPort=<port>");
System.out.println("");
System.out.println("For additional information, see https://confluence.hl7.org/display/FHIR/IG+Publisher+Documentation");
} else if (hasNamedParam(args, "-convert")) {
// convert a igpack.zip to a package.tgz
IGPack2NpmConvertor conv = new IGPack2NpmConvertor();
conv.setSource(getNamedParam(args, "-source"));
conv.setDest(getNamedParam(args, "-dest"));
conv.setPackageId(getNamedParam(args, "-npm-name"));
conv.setVersionIg(getNamedParam(args, "-version"));
conv.setLicense(getNamedParam(args, "-license"));
conv.setWebsite(getNamedParam(args, "-website"));
conv.execute();
// } else if (hasNamedParam(args, "-convert")) {
// // convert a igpack.zip to a package.tgz
// IGPack2NpmConvertor conv = new IGPack2NpmConvertor();
// conv.setSource(getNamedParam(args, "-source"));
// conv.setDest(getNamedParam(args, "-dest"));
// conv.setPackageId(getNamedParam(args, "-npm-name"));
// conv.setVersionIg(getNamedParam(args, "-version"));
// conv.setLicense(getNamedParam(args, "-license"));
// conv.setWebsite(getNamedParam(args, "-website"));
// conv.execute();
} else if (hasNamedParam(args, "-delete-current")) {
if (!args[0].equals("-delete-current")) {
throw new Error("-delete-current must have the format -delete-current {root}/{realm}/{code} -history {history} (first argument is not -delete-current)");
Expand Down Expand Up @@ -11508,7 +11509,7 @@ public static void main(String[] args) throws Exception {
self.setSourceDir(getNamedParam(args, "-source"));
self.setDestDir(getNamedParam(args, "-destination"));
self.specifiedVersion = getNamedParam(args, "-version");
} else if(!hasNamedParam(args, "-ig") && args.length == 1 && new File(args[0]).exists()) {
} else if (!hasNamedParam(args, "-ig") && args.length == 1 && new File(args[0]).exists()) {
self.setConfigFile(determineActualIG(args[0], IGBuildMode.MANUAL));
} else if (hasNamedParam(args, "-prompt")) {
IniFile ini = new IniFile("publisher.ini");
Expand Down
Loading

0 comments on commit b15500a

Please sign in to comment.