reorg extensions (clean up)

This commit is contained in:
Grahame Grieve 2022-09-20 04:51:00 -04:00
parent eca93b0a76
commit cfa5d39bdb
3 changed files with 56 additions and 8 deletions

View File

@ -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())) {

View File

@ -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";

View File

@ -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<JsonElement, LocationData> map) throws IOException {
return parseArray(source, map, false);
}
public static JsonObject parse(String source, Map<JsonElement, LocationData> map, boolean allowDuplicates) throws IOException {
return parse(source, map, allowDuplicates, false);
}
public static JsonArray parseArray(String source, Map<JsonElement, LocationData> map, boolean allowDuplicates) throws IOException {
return parseArray(source, map, allowDuplicates, false);
}
public static JsonObject parse(String source, Map<JsonElement, LocationData> 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<JsonElement, LocationData> 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());
}
}