update graphql generation - add note about types.graphql & fix typo

This commit is contained in:
Grahame Grieve 2019-06-16 05:59:13 +10:00
parent 422c659bb3
commit 4ff9e0626a
2 changed files with 41 additions and 1 deletions

View File

@ -0,0 +1,39 @@
package org.hl7.fhir.r4.utils;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import org.hl7.fhir.r4.formats.JsonParser;
import org.hl7.fhir.r4.model.DomainResource;
import org.hl7.fhir.r4.model.Resource;
public class NarrativeRemover {
public static void main(String[] args) {
execute(new File(args[0]));
}
private static void execute(File folder) {
for (File f : folder.listFiles()) {
if (f.isDirectory())
execute(f);
else {
System.out.println(f.getAbsolutePath());
try {
Resource r = new JsonParser().parse(new FileInputStream(f));
if (r instanceof DomainResource) {
DomainResource d = (DomainResource) r;
d.setText(null);
new JsonParser().compose(new FileOutputStream(f), d);
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
}
}

View File

@ -96,6 +96,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("# import the types from 'types.graphql'\r\n\r\n");
generateType(writer, sd);
if (operations.contains(FHIROperationType.READ))
generateIdAccess(writer, sd.getName());
@ -382,7 +383,7 @@ public class GraphQLSchemaGenerator {
private void generatePrimitive(BufferedWriter writer, StructureDefinition sd) throws IOException, FHIRException {
String gqlName = getGqlname(sd.getName());
if (gqlName.equals(sd.getName())) {
writer.write("Scalar ");
writer.write("scalar ");
writer.write(sd.getName());
writer.write(" # JSON Format: ");
writer.write(getJsonFormat(sd));