Merge pull request #463 from hapifhir/gg-2021-03-r2b-package-hack
Gg 2021 03 r2b package hack
This commit is contained in:
commit
e69bad679a
|
@ -0,0 +1 @@
|
|||
* minor fixes in code generators for R4B
|
|
@ -210,6 +210,9 @@ public class Enumerations40_50 extends VersionConvertor_40_50 {
|
|||
case _4_0_1:
|
||||
tgt.setValue(org.hl7.fhir.r5.model.Enumerations.FHIRVersion._4_0_1);
|
||||
break;
|
||||
case _4_1_0:
|
||||
tgt.setValue(org.hl7.fhir.r5.model.Enumerations.FHIRVersion._4_1_0);
|
||||
break;
|
||||
default:
|
||||
tgt.setValue(org.hl7.fhir.r5.model.Enumerations.FHIRVersion.NULL);
|
||||
break;
|
||||
|
@ -292,6 +295,9 @@ public class Enumerations40_50 extends VersionConvertor_40_50 {
|
|||
case _4_0_1:
|
||||
tgt.setValue(org.hl7.fhir.r4.model.Enumerations.FHIRVersion._4_0_1);
|
||||
break;
|
||||
case _4_1_0:
|
||||
tgt.setValue(org.hl7.fhir.r4.model.Enumerations.FHIRVersion._4_1_0);
|
||||
break;
|
||||
default:
|
||||
tgt.setValue(org.hl7.fhir.r4.model.Enumerations.FHIRVersion.NULL);
|
||||
break;
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -10032,6 +10032,10 @@ The primary difference between a medication statement and a medication administr
|
|||
* added to help the parsers
|
||||
*/
|
||||
_4_0_1,
|
||||
/**
|
||||
* R4B - manually added
|
||||
*/
|
||||
_4_1_0,
|
||||
NULL;
|
||||
public static FHIRVersion fromCode(String codeString) throws FHIRException {
|
||||
if (codeString == null || "".equals(codeString))
|
||||
|
@ -10082,6 +10086,8 @@ The primary difference between a medication statement and a medication administr
|
|||
return _4_0_0;
|
||||
if ("4.0.1".equals(codeString))
|
||||
return _4_0_1;
|
||||
if ("4.1.0".equals(codeString))
|
||||
return _4_1_0;
|
||||
throw new FHIRException("Unknown FHIRVersion code '"+codeString+"'");
|
||||
}
|
||||
@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 _4_0_0: return "4.0.0";
|
||||
case _4_0_1: return "4.0.1";
|
||||
case _4_1_0: return "4.1.0";
|
||||
case NULL: return null;
|
||||
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 _4_0_0: 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;
|
||||
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 _4_0_0: return "FHIR Release 4 (Normative + STU).";
|
||||
case _4_0_1: return "FHIR Release 4 Technical Correction #1.";
|
||||
case _4_1_0: return "FHIR Release 4B";
|
||||
case NULL: return null;
|
||||
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 _4_0_0: return "4.0.0";
|
||||
case _4_0_1: return "4.0.1";
|
||||
case _4_1_0: return "4.1.0";
|
||||
case NULL: return null;
|
||||
default: return "?";
|
||||
}
|
||||
|
@ -10263,6 +10273,8 @@ The primary difference between a medication statement and a medication administr
|
|||
return FHIRVersion._4_0_0;
|
||||
if ("4.0.1".equals(codeString))
|
||||
return FHIRVersion._4_0_1;
|
||||
if ("4.1.0".equals(codeString))
|
||||
return FHIRVersion._4_1_0;
|
||||
throw new IllegalArgumentException("Unknown FHIRVersion code '"+codeString+"'");
|
||||
}
|
||||
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);
|
||||
if ("4.0.1".equals(codeString))
|
||||
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+"'");
|
||||
}
|
||||
public String toCode(FHIRVersion code) {
|
||||
|
@ -10368,6 +10382,8 @@ The primary difference between a medication statement and a medication administr
|
|||
return "4.0.0";
|
||||
if (code == FHIRVersion._4_0_1)
|
||||
return "4.0.1";
|
||||
if (code == FHIRVersion._4_1_0)
|
||||
return "4.1.0";
|
||||
return "?";
|
||||
}
|
||||
public String toSystem(FHIRVersion code) {
|
||||
|
|
|
@ -4628,7 +4628,7 @@ public class ProfileUtilities extends TranslatingUtilities {
|
|||
erow.getSubRows().add(row);
|
||||
Cell c = gen.new Cell();
|
||||
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();
|
||||
row.getCells().add(c);
|
||||
c.addPiece(gen.new Piece(null, null, null));
|
||||
|
|
|
@ -465,4 +465,5 @@ public class VersionUtilities {
|
|||
return null;
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -64,6 +64,7 @@ public abstract class BasePackageCacheManager implements IPackageCacheManager {
|
|||
protected InputStreamWithSrc loadFromPackageServer(String id, String version) {
|
||||
|
||||
for (String nextPackageServer : getPackageServers()) {
|
||||
if (okToUsePackageServer(nextPackageServer, id)) {
|
||||
PackageClient packageClient = myClientFactory.apply(nextPackageServer);
|
||||
try {
|
||||
if (Utilities.noString(version)) {
|
||||
|
@ -78,12 +79,22 @@ public abstract class BasePackageCacheManager implements IPackageCacheManager {
|
|||
} catch (IOException e) {
|
||||
ourLog.info("Failed to resolve package {}#{} from server: {}", id, version, nextPackageServer);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
@Override
|
||||
|
|
2
pom.xml
2
pom.xml
|
@ -19,7 +19,7 @@
|
|||
|
||||
<properties>
|
||||
<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_platform_launcher_version>1.7.1</junit_platform_launcher_version>
|
||||
<maven_surefire_version>3.0.0-M4</maven_surefire_version>
|
||||
|
|
Loading…
Reference in New Issue