diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/GraphQLSchemaGenerator.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/GraphQLSchemaGenerator.java index 5b0d1d717..a637231dd 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/GraphQLSchemaGenerator.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/GraphQLSchemaGenerator.java @@ -491,9 +491,8 @@ public class GraphQLSchemaGenerator { private String getJsonFormat(StructureDefinition sd) throws FHIRException { for (ElementDefinition ed : sd.getSnapshot().getElement()) { - throw new Error("What is this code doing?"); -// if (!ed.getType().isEmpty() && ed.getType().get(0).getCodeElement().hasExtension(" http://hl7.org/fhir/StructureDefinition/structuredefinition-json-type")) -// return ed.getType().get(0).getCodeElement().getExtensionString(" http://hl7.org/fhir/StructureDefinition/structuredefinition-json-type"); + if (!ed.getType().isEmpty() && ed.getType().get(0).getCodeElement().hasExtension("http://hl7.org/fhir/StructureDefinition/structuredefinition-json-type")) + return ed.getType().get(0).getCodeElement().getExtensionString(" http://hl7.org/fhir/StructureDefinition/structuredefinition-json-type"); } // all primitives but JSON_NUMBER_TYPES are represented as JSON strings if (JSON_NUMBER_TYPES.contains(sd.getName())) { diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/ToolingExtensions.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/ToolingExtensions.java index 6d21e8277..2a40bd170 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/ToolingExtensions.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/ToolingExtensions.java @@ -125,6 +125,22 @@ public class ToolingExtensions { public static final String EXT_EXPLICIT_TYPE = "http://hl7.org/fhir/StructureDefinition/structuredefinition-explicit-type-name"; public static final String EXT_TIME_FORMAT = "http://hl7.org/fhir/StructureDefinition/elementdefinition-timeformat"; + public static final String EXT_IGP_RESOURCES = "http://hl7.org/fhir/StructureDefinition/igpublisher-folder-resource"; + public static final String EXT_IGP_PAGES = "http://hl7.org/fhir/StructureDefinition/igpublisher-folder-pages"; + public static final String EXT_IGP_SPREADSHEET = "http://hl7.org/fhir/StructureDefinition/igpublisher-spreadsheet"; + public static final String EXT_IGP_MAPPING_CSV = "http://hl7.org/fhir/StructureDefinition/igpublisher-mapping-csv"; + public static final String EXT_IGP_BUNDLE = "http://hl7.org/fhir/StructureDefinition/igpublisher-bundle"; + public static final String EXT_IGP_BASE = "http://hl7.org/fhir/StructureDefinition/igpublisher-res-base"; + public static final String EXT_IGP_DEFNS = "http://hl7.org/fhir/StructureDefinition/igpublisher-res-defns"; + public static final String EXT_IGP_FORMAT = "http://hl7.org/fhir/StructureDefinition/igpublisher-res-format"; + public static final String EXT_IGP_SOURCE = "http://hl7.org/fhir/StructureDefinition/igpublisher-res-source"; + public static final String EXT_IGP_CONTAINED_RESOURCE_INFO = "http://hl7.org/fhir/tools/StructureDefinition/contained-resource-information"; + public static final String EXT_PRIVATE_BASE = "http://hl7.org/fhir/tools/"; + public static final String EXT_BINARY_FORMAT = "http://hl7.org/fhir/StructureDefinition/implementationguide-resource-format"; + public static final String EXT_IGP_RESOURCE_INFO = "http://hl7.org/fhir/tools/StructureDefinition/resource-information"; + public static final String EXT_IGP_LOADVERSION = "http://hl7.org/fhir/StructureDefinition/igpublisher-loadversion"; + public static final String EXT_LIST_PACKAGE = "http://hl7.org/fhir/StructureDefinition/list-packageId"; + // validated // private static final String EXT_OID = "http://hl7.org/fhir/StructureDefinition/valueset-oid"; // public static final String EXT_DEPRECATED = "http://hl7.org/fhir/StructureDefinition/codesystem-deprecated"; diff --git a/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/json/JsonTrackingParser.java b/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/json/JsonTrackingParser.java index b37965b2c..47e5e27a8 100644 --- a/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/json/JsonTrackingParser.java +++ b/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/json/JsonTrackingParser.java @@ -1,5 +1,7 @@ package org.hl7.fhir.utilities.json; +import static org.junit.jupiter.api.DynamicContainer.dynamicContainer; + import java.io.File; /* @@ -375,6 +377,10 @@ public class JsonTrackingParser { return parse(TextFile.bytesToString(stream), null); } + public static JsonArray parseJsonArray(byte[] stream) throws IOException { + return parseArray(TextFile.bytesToString(stream), null); + } + public static JsonObject parseJson(byte[] stream, boolean allowDuplicates) throws IOException { return parse(TextFile.bytesToString(stream), null, allowDuplicates); } @@ -391,17 +397,34 @@ public class JsonTrackingParser { return parse(source, map, false); } + public static JsonArray parseArray(String source, Map map) throws IOException { + return parseArray(source, map, false); + } + + public static JsonObject parse(String source, Map map, boolean allowDuplicates) throws IOException { return parse(source, map, allowDuplicates, false); } + public static JsonArray parseArray(String source, Map map, boolean allowDuplicates) throws IOException { + return parseArray(source, map, allowDuplicates, false); + } + public static JsonObject parse(String source, Map map, boolean allowDuplicates, boolean allowComments) throws IOException { - JsonTrackingParser self = new JsonTrackingParser(); - self.map = map; - self.setErrorOnDuplicates(!allowDuplicates); - self.setAllowComments(allowComments); + JsonTrackingParser self = new JsonTrackingParser(); + self.map = map; + self.setErrorOnDuplicates(!allowDuplicates); + self.setAllowComments(allowComments); return self.parse(Utilities.stripBOM(source)); - } + } + + public static JsonArray parseArray(String source, Map map, boolean allowDuplicates, boolean allowComments) throws IOException { + JsonTrackingParser self = new JsonTrackingParser(); + self.map = map; + self.setErrorOnDuplicates(!allowDuplicates); + self.setAllowComments(allowComments); + return self.parseArray(Utilities.stripBOM(source)); + } private JsonObject parse(String source) throws IOException { lexer = new Lexer(source); @@ -421,6 +444,10 @@ public class JsonTrackingParser { return result; } + private JsonArray parseArray(String source) throws IOException { + return new Gson().fromJson(source, JsonArray.class); + } + private void readObject(JsonObject obj, boolean root) throws IOException { if (map != null) map.put(obj, lexer.location.copy()); @@ -703,5 +730,11 @@ public class JsonTrackingParser { return parseJson(res.getContent()); } + public static JsonArray fetchJsonArray(String source) throws IOException { + SimpleHTTPClient fetcher = new SimpleHTTPClient(); + HTTPResult res = fetcher.get(source+"?nocache=" + System.currentTimeMillis()); + res.checkThrowException(); + return parseJsonArray(res.getContent()); + } } \ No newline at end of file