Merge pull request #463 from hapifhir/gg-2021-03-r2b-package-hack

Gg 2021 03 r2b package hack
This commit is contained in:
Grahame Grieve 2021-03-23 06:28:05 +10:00 committed by GitHub
commit e69bad679a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 100 additions and 15 deletions

View File

@ -0,0 +1 @@
* minor fixes in code generators for R4B

View File

@ -210,6 +210,9 @@ public class Enumerations40_50 extends VersionConvertor_40_50 {
case _4_0_1: case _4_0_1:
tgt.setValue(org.hl7.fhir.r5.model.Enumerations.FHIRVersion._4_0_1); tgt.setValue(org.hl7.fhir.r5.model.Enumerations.FHIRVersion._4_0_1);
break; break;
case _4_1_0:
tgt.setValue(org.hl7.fhir.r5.model.Enumerations.FHIRVersion._4_1_0);
break;
default: default:
tgt.setValue(org.hl7.fhir.r5.model.Enumerations.FHIRVersion.NULL); tgt.setValue(org.hl7.fhir.r5.model.Enumerations.FHIRVersion.NULL);
break; break;
@ -292,6 +295,9 @@ public class Enumerations40_50 extends VersionConvertor_40_50 {
case _4_0_1: case _4_0_1:
tgt.setValue(org.hl7.fhir.r4.model.Enumerations.FHIRVersion._4_0_1); tgt.setValue(org.hl7.fhir.r4.model.Enumerations.FHIRVersion._4_0_1);
break; break;
case _4_1_0:
tgt.setValue(org.hl7.fhir.r4.model.Enumerations.FHIRVersion._4_1_0);
break;
default: default:
tgt.setValue(org.hl7.fhir.r4.model.Enumerations.FHIRVersion.NULL); tgt.setValue(org.hl7.fhir.r4.model.Enumerations.FHIRVersion.NULL);
break; break;

View File

@ -0,0 +1,50 @@
package org.hl7.fhir.convertors.misc;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import org.hl7.fhir.exceptions.FHIRFormatError;
import org.hl7.fhir.utilities.Utilities;
import org.hl7.fhir.utilities.json.JsonTrackingParser;
import org.hl7.fhir.utilities.npm.NpmPackage;
import com.google.gson.JsonObject;
public class CorePackageTools {
public static void main(String[] args) throws FHIRFormatError, FileNotFoundException, IOException {
if ("-xml".equals(args[0])) {
new CorePackageTools().buildXml(args[1], args[2], args[3]);
}
if ("-pack".equals(args[0])) {
new CorePackageTools().buildPackage(args[1], args[2]);
}
}
private void buildPackage(String path, String output) throws IOException {
NpmPackage npm = NpmPackage.fromFolder(path);
npm.loadAllFiles();
npm.save(new FileOutputStream(output));
}
private void buildXml(String json, String xml, String version) throws FHIRFormatError, FileNotFoundException, IOException {
for (File f : new File(Utilities.path(json, "package")).listFiles()) {
if (f.getName().endsWith(".json")) {
JsonObject j = new JsonTrackingParser().parseJson(f);
if (j.has("resourceType")) {
if ("1.4".equals(version)) {
String n = f.getName();
System.out.println(n);
String xn = Utilities.changeFileExt(n, ".xml");
org.hl7.fhir.dstu2016may.model.Resource r = new org.hl7.fhir.dstu2016may.formats.JsonParser().parse(new FileInputStream(f));
new org.hl7.fhir.dstu2016may.formats.XmlParser().setOutputStyle(org.hl7.fhir.dstu2016may.formats.IParser.OutputStyle.NORMAL).compose(new FileOutputStream(Utilities.path(xml, "package", xn)), r);
}
}
}
}
}
}

View File

@ -10032,6 +10032,10 @@ The primary difference between a medication statement and a medication administr
* added to help the parsers * added to help the parsers
*/ */
_4_0_1, _4_0_1,
/**
* R4B - manually added
*/
_4_1_0,
NULL; NULL;
public static FHIRVersion fromCode(String codeString) throws FHIRException { public static FHIRVersion fromCode(String codeString) throws FHIRException {
if (codeString == null || "".equals(codeString)) if (codeString == null || "".equals(codeString))
@ -10082,6 +10086,8 @@ The primary difference between a medication statement and a medication administr
return _4_0_0; return _4_0_0;
if ("4.0.1".equals(codeString)) if ("4.0.1".equals(codeString))
return _4_0_1; return _4_0_1;
if ("4.1.0".equals(codeString))
return _4_1_0;
throw new FHIRException("Unknown FHIRVersion code '"+codeString+"'"); throw new FHIRException("Unknown FHIRVersion code '"+codeString+"'");
} }
@Override @Override
@ -10113,6 +10119,7 @@ The primary difference between a medication statement and a medication administr
case _3_5_0: return "3.5.0"; case _3_5_0: return "3.5.0";
case _4_0_0: return "4.0.0"; case _4_0_0: return "4.0.0";
case _4_0_1: return "4.0.1"; case _4_0_1: return "4.0.1";
case _4_1_0: return "4.1.0";
case NULL: return null; case NULL: return null;
default: return "?"; default: return "?";
} }
@ -10142,6 +10149,7 @@ The primary difference between a medication statement and a medication administr
case _3_5_0: return "http://hl7.org/fhir/FHIR-version"; case _3_5_0: return "http://hl7.org/fhir/FHIR-version";
case _4_0_0: return "http://hl7.org/fhir/FHIR-version"; case _4_0_0: return "http://hl7.org/fhir/FHIR-version";
case _4_0_1: return "http://hl7.org/fhir/FHIR-version"; case _4_0_1: return "http://hl7.org/fhir/FHIR-version";
case _4_1_0: return "http://hl7.org/fhir/FHIR-version";
case NULL: return null; case NULL: return null;
default: return "?"; default: return "?";
} }
@ -10171,6 +10179,7 @@ The primary difference between a medication statement and a medication administr
case _3_5_0: return "R4 Ballot #2."; case _3_5_0: return "R4 Ballot #2.";
case _4_0_0: return "FHIR Release 4 (Normative + STU)."; case _4_0_0: return "FHIR Release 4 (Normative + STU).";
case _4_0_1: return "FHIR Release 4 Technical Correction #1."; case _4_0_1: return "FHIR Release 4 Technical Correction #1.";
case _4_1_0: return "FHIR Release 4B";
case NULL: return null; case NULL: return null;
default: return "?"; default: return "?";
} }
@ -10200,6 +10209,7 @@ The primary difference between a medication statement and a medication administr
case _3_5_0: return "3.5.0"; case _3_5_0: return "3.5.0";
case _4_0_0: return "4.0.0"; case _4_0_0: return "4.0.0";
case _4_0_1: return "4.0.1"; case _4_0_1: return "4.0.1";
case _4_1_0: return "4.1.0";
case NULL: return null; case NULL: return null;
default: return "?"; default: return "?";
} }
@ -10263,6 +10273,8 @@ The primary difference between a medication statement and a medication administr
return FHIRVersion._4_0_0; return FHIRVersion._4_0_0;
if ("4.0.1".equals(codeString)) if ("4.0.1".equals(codeString))
return FHIRVersion._4_0_1; return FHIRVersion._4_0_1;
if ("4.1.0".equals(codeString))
return FHIRVersion._4_1_0;
throw new IllegalArgumentException("Unknown FHIRVersion code '"+codeString+"'"); throw new IllegalArgumentException("Unknown FHIRVersion code '"+codeString+"'");
} }
public Enumeration<FHIRVersion> fromType(Base code) throws FHIRException { public Enumeration<FHIRVersion> fromType(Base code) throws FHIRException {
@ -10319,6 +10331,8 @@ The primary difference between a medication statement and a medication administr
return new Enumeration<FHIRVersion>(this, FHIRVersion._4_0_0); return new Enumeration<FHIRVersion>(this, FHIRVersion._4_0_0);
if ("4.0.1".equals(codeString)) if ("4.0.1".equals(codeString))
return new Enumeration<FHIRVersion>(this, FHIRVersion._4_0_1); return new Enumeration<FHIRVersion>(this, FHIRVersion._4_0_1);
if ("4.1.0".equals(codeString))
return new Enumeration<FHIRVersion>(this, FHIRVersion._4_1_0);
throw new FHIRException("Unknown FHIRVersion code '"+codeString+"'"); throw new FHIRException("Unknown FHIRVersion code '"+codeString+"'");
} }
public String toCode(FHIRVersion code) { public String toCode(FHIRVersion code) {
@ -10368,6 +10382,8 @@ The primary difference between a medication statement and a medication administr
return "4.0.0"; return "4.0.0";
if (code == FHIRVersion._4_0_1) if (code == FHIRVersion._4_0_1)
return "4.0.1"; return "4.0.1";
if (code == FHIRVersion._4_1_0)
return "4.1.0";
return "?"; return "?";
} }
public String toSystem(FHIRVersion code) { public String toSystem(FHIRVersion code) {

View File

@ -4628,7 +4628,7 @@ public class ProfileUtilities extends TranslatingUtilities {
erow.getSubRows().add(row); erow.getSubRows().add(row);
Cell c = gen.new Cell(); Cell c = gen.new Cell();
row.getCells().add(c); row.getCells().add(c);
c.addPiece(gen.new Piece((ed.getBase().getPath().equals(ed.getPath()) ? ref+ed.getPath() : corePath+(VersionUtilities.isThisOrLater("4.1", context.getVersion()) ? "types-definitions.html#"+ed.getBase().getPath() : "element-definitions.html#"+ed.getBase().getPath())), t.getName(), null)); c.addPiece(gen.new Piece((ed.getBase().getPath().equals(ed.getPath()) ? ref+ed.getPath() : corePath+(VersionUtilities.isR5Ver(context.getVersion()) ? "types-definitions.html#"+ed.getBase().getPath() : "element-definitions.html#"+ed.getBase().getPath())), t.getName(), null));
c = gen.new Cell(); c = gen.new Cell();
row.getCells().add(c); row.getCells().add(c);
c.addPiece(gen.new Piece(null, null, null)); c.addPiece(gen.new Piece(null, null, null));

View File

@ -465,4 +465,5 @@ public class VersionUtilities {
return null; return null;
} }
} }

View File

@ -64,26 +64,37 @@ public abstract class BasePackageCacheManager implements IPackageCacheManager {
protected InputStreamWithSrc loadFromPackageServer(String id, String version) { protected InputStreamWithSrc loadFromPackageServer(String id, String version) {
for (String nextPackageServer : getPackageServers()) { for (String nextPackageServer : getPackageServers()) {
PackageClient packageClient = myClientFactory.apply(nextPackageServer); if (okToUsePackageServer(nextPackageServer, id)) {
try { PackageClient packageClient = myClientFactory.apply(nextPackageServer);
if (Utilities.noString(version)) { try {
version = packageClient.getLatestVersion(id); if (Utilities.noString(version)) {
version = packageClient.getLatestVersion(id);
}
if (version.endsWith(".x")) {
version = packageClient.getLatestVersion(id, version);
}
InputStream stream = packageClient.fetch(id, version);
String url = packageClient.url(id, version);
return new InputStreamWithSrc(stream, url, version);
} catch (IOException e) {
ourLog.info("Failed to resolve package {}#{} from server: {}", id, version, nextPackageServer);
} }
if (version.endsWith(".x")) {
version = packageClient.getLatestVersion(id, version);
}
InputStream stream = packageClient.fetch(id, version);
String url = packageClient.url(id, version);
return new InputStreamWithSrc(stream, url, version);
} catch (IOException e) {
ourLog.info("Failed to resolve package {}#{} from server: {}", id, version, nextPackageServer);
} }
} }
return null; return null;
} }
// hack - we have a hacked 1.4.0 out there. Only packages2.fhir.org has it.
// this is not a long term thing, but it's not clear how to release patches for
// 1.4.0
private boolean okToUsePackageServer(String server, String id) {
if ("http://packages.fhir.org".equals(server) && "hl7.fhir.r2b.core".equals(id)) {
return false;
}
return true;
}
public abstract NpmPackage loadPackageFromCacheOnly(String id, @Nullable String version) throws IOException; public abstract NpmPackage loadPackageFromCacheOnly(String id, @Nullable String version) throws IOException;
@Override @Override

View File

@ -19,7 +19,7 @@
<properties> <properties>
<hapi_fhir_version>5.1.0</hapi_fhir_version> <hapi_fhir_version>5.1.0</hapi_fhir_version>
<validator_test_case_version>1.1.57</validator_test_case_version> <validator_test_case_version>1.1.58-SNAPSHOT</validator_test_case_version>
<junit_jupiter_version>5.7.1</junit_jupiter_version> <junit_jupiter_version>5.7.1</junit_jupiter_version>
<junit_platform_launcher_version>1.7.1</junit_platform_launcher_version> <junit_platform_launcher_version>1.7.1</junit_platform_launcher_version>
<maven_surefire_version>3.0.0-M4</maven_surefire_version> <maven_surefire_version>3.0.0-M4</maven_surefire_version>