Gg 20201mar r4b 3 (#454)

* fix bug generating htmlized XML with no namespaces

* Add R4B support to FHIRVersions

* Add resource name mapping for DataRequirement

* R4B fixes

* release notes
This commit is contained in:
Grahame Grieve 2021-03-11 01:08:09 +11:00 committed by GitHub
parent dfc59882ca
commit 7c48c0d66a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 34 additions and 8 deletions

View File

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

View File

@ -967,7 +967,7 @@ public class VersionConvertor_40_50 {
if (src == null) return null;
org.hl7.fhir.r5.model.DataRequirement tgt = new org.hl7.fhir.r5.model.DataRequirement();
copyElement(src, tgt);
if (src.hasType()) tgt.setType(org.hl7.fhir.r5.model.Enumerations.FHIRAllTypes.fromCode(src.getType()));
if (src.hasType()) tgt.setType(org.hl7.fhir.r5.model.Enumerations.FHIRAllTypes.fromCode(convertResourceName4to5(src.getType())));
for (org.hl7.fhir.r4.model.CanonicalType t : src.getProfile()) tgt.getProfile().add(convertCanonical(t));
if (src.hasSubject()) tgt.setSubject(convertType(src.getSubject()));
for (org.hl7.fhir.r4.model.StringType t : src.getMustSupport()) tgt.getMustSupport().add(convertString(t));
@ -981,11 +981,12 @@ public class VersionConvertor_40_50 {
return tgt;
}
public static org.hl7.fhir.r4.model.DataRequirement convertDataRequirement(org.hl7.fhir.r5.model.DataRequirement src) throws FHIRException {
if (src == null) return null;
org.hl7.fhir.r4.model.DataRequirement tgt = new org.hl7.fhir.r4.model.DataRequirement();
copyElement(src, tgt);
if (src.hasType()) tgt.setType(src.getType().toCode());
if (src.hasType()) tgt.setType(convertResourceName5to4(src.getType().toCode()));
for (org.hl7.fhir.r5.model.CanonicalType t : src.getProfile()) tgt.getProfile().add(convertCanonical(t));
if (src.hasSubject()) tgt.setSubject(convertType(src.getSubject()));
for (org.hl7.fhir.r5.model.StringType t : src.getMustSupport()) tgt.getMustSupport().add(convertString(t));
@ -999,6 +1000,22 @@ public class VersionConvertor_40_50 {
return tgt;
}
private static String convertResourceName4to5(String name) {
if (name == null) return null;
if (name.equals("MedicationStatement")) {
return "MedicationUsage";
}
return name;
}
private static String convertResourceName5to4(String name) {
if (name == null) return null;
if (name.equals("MedicationUsage")) {
return "MedicationStatement";
}
return name;
}
public static org.hl7.fhir.r5.model.DataRequirement.DataRequirementCodeFilterComponent convertDataRequirementCodeFilterComponent(org.hl7.fhir.r4.model.DataRequirement.DataRequirementCodeFilterComponent src) throws FHIRException {
if (src == null) return null;
org.hl7.fhir.r5.model.DataRequirement.DataRequirementCodeFilterComponent tgt = new org.hl7.fhir.r5.model.DataRequirement.DataRequirementCodeFilterComponent();

View File

@ -6568,7 +6568,7 @@ The primary difference between a medicationusage and a medicationadministration
*/
NULL;
public static final FHIRVersion R4B = FHIRVersion._4_0_1;
public static final FHIRVersion R4B = FHIRVersion._4_1_0;
public static FHIRVersion fromCode(String codeString) throws FHIRException {
if (codeString == null || "".equals(codeString))
@ -6824,6 +6824,10 @@ public String toCode(int len) {
public String toString() {
return toCode();
}
public boolean isR4B() {
return toCode().startsWith("4.1");
}
// end addition
}

View File

@ -67,10 +67,12 @@ public class GraphQLSchemaGenerator {
private static final String INNER_TYPE_NAME = "gql.type.name";
IWorkerContext context;
private ProfileUtilities profileUtilities;
private String version;
public GraphQLSchemaGenerator(IWorkerContext context) {
public GraphQLSchemaGenerator(IWorkerContext context, String version) {
super();
this.context = context;
this.version = version;
profileUtilities = new ProfileUtilities(context, null, null);
}
@ -87,7 +89,7 @@ public class GraphQLSchemaGenerator {
tl.put(sd.getName(), sd);
}
}
writer.write("# FHIR GraphQL Schema. Version "+Constants.VERSION+"\r\n\r\n");
writer.write("# FHIR GraphQL Schema. Version "+version+"\r\n\r\n");
writer.write("# FHIR Defined Primitive types\r\n");
for (String n : sorted(pl.keySet()))
generatePrimitive(writer, pl.get(n));
@ -107,7 +109,7 @@ public class GraphQLSchemaGenerator {
public void generateResource(OutputStream stream, StructureDefinition sd, List<SearchParameter> parameters, EnumSet<FHIROperationType> operations) throws IOException, FHIRException {
BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(stream));
writer.write("# FHIR GraphQL Schema. Version "+Constants.VERSION+"\r\n\r\n");
writer.write("# FHIR GraphQL Schema. Version "+version+"\r\n\r\n");
writer.write("# import the types from 'types.graphql'\r\n\r\n");
generateType(writer, sd);
if (operations.contains(FHIROperationType.READ))

View File

@ -276,6 +276,8 @@ public class NPMPackageGenerator {
return "hl7.fhir.r3.core";
if (v.startsWith("4.0"))
return "hl7.fhir.r4.core";
if (v.startsWith("4.1"))
return "hl7.fhir.r4b.core";
return null;
}

View File

@ -111,7 +111,7 @@ public class TypesUtilities {
res.add(new WildcardInformation("id", TypeClassification.PRIMITIVE));
res.add(new WildcardInformation("instant", TypeClassification.PRIMITIVE));
res.add(new WildcardInformation("integer", TypeClassification.PRIMITIVE));
if (!version.startsWith("4.0")) {
if (!version.startsWith("4.1")) {
res.add(new WildcardInformation("integer64", TypeClassification.PRIMITIVE));
}
res.add(new WildcardInformation("markdown", TypeClassification.PRIMITIVE));

View File

@ -111,7 +111,7 @@ public class XmlGenerator {
}
private void processElement(Element element) throws IOException, FHIRException {
if (!xml.getDefaultNamespace().equals(element.getNamespaceURI()))
if (xml.getDefaultNamespace() == null || !xml.getDefaultNamespace().equals(element.getNamespaceURI()))
xml.setDefaultNamespace(element.getNamespaceURI());
processAttributes(element);