Fix broken build
This commit is contained in:
parent
3433ecfd14
commit
00a8f8c759
|
@ -108,7 +108,7 @@ public class JpaServerDemo extends RestfulServer {
|
||||||
* This server tries to dynamically generate narratives
|
* This server tries to dynamically generate narratives
|
||||||
*/
|
*/
|
||||||
FhirContext ctx = getFhirContext();
|
FhirContext ctx = getFhirContext();
|
||||||
ctx.setNarrativeGenerator(new DefaultThymeleafNarrativeGenerator(getFhirContext()));
|
ctx.setNarrativeGenerator(new DefaultThymeleafNarrativeGenerator());
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Default to JSON and pretty printing
|
* Default to JSON and pretty printing
|
||||||
|
|
|
@ -108,7 +108,7 @@ public class JpaServerDemoDstu2 extends RestfulServer {
|
||||||
* This server tries to dynamically generate narratives
|
* This server tries to dynamically generate narratives
|
||||||
*/
|
*/
|
||||||
FhirContext ctx = getFhirContext();
|
FhirContext ctx = getFhirContext();
|
||||||
ctx.setNarrativeGenerator(new DefaultThymeleafNarrativeGenerator(getFhirContext()));
|
ctx.setNarrativeGenerator(new DefaultThymeleafNarrativeGenerator());
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Default to JSON and pretty printing
|
* Default to JSON and pretty printing
|
||||||
|
|
|
@ -75,7 +75,7 @@ public class JpaServerDemo extends RestfulServer {
|
||||||
* This server tries to dynamically generate narratives
|
* This server tries to dynamically generate narratives
|
||||||
*/
|
*/
|
||||||
FhirContext ctx = getFhirContext();
|
FhirContext ctx = getFhirContext();
|
||||||
ctx.setNarrativeGenerator(new DefaultThymeleafNarrativeGenerator(getFhirContext()));
|
ctx.setNarrativeGenerator(new DefaultThymeleafNarrativeGenerator());
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Default to JSON and pretty printing
|
* Default to JSON and pretty printing
|
||||||
|
|
|
@ -1,16 +1,15 @@
|
||||||
package example;
|
package example;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
import ca.uhn.fhir.context.FhirContext;
|
import ca.uhn.fhir.context.FhirContext;
|
||||||
import ca.uhn.fhir.model.dstu2.resource.Patient;
|
import ca.uhn.fhir.model.dstu2.resource.Patient;
|
||||||
import ca.uhn.fhir.model.dstu2.valueset.NarrativeStatusEnum;
|
import ca.uhn.fhir.model.dstu2.valueset.NarrativeStatusEnum;
|
||||||
import ca.uhn.fhir.narrative.DefaultThymeleafNarrativeGenerator;
|
import ca.uhn.fhir.narrative.DefaultThymeleafNarrativeGenerator;
|
||||||
import ca.uhn.fhir.parser.DataFormatException;
|
import ca.uhn.fhir.parser.DataFormatException;
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
public class Narrative {
|
public class Narrative {
|
||||||
|
|
||||||
public static void main(String[] args) throws DataFormatException, IOException {
|
public static void main(String[] args) throws DataFormatException {
|
||||||
|
|
||||||
//START SNIPPET: example1
|
//START SNIPPET: example1
|
||||||
Patient patient = new Patient();
|
Patient patient = new Patient();
|
||||||
|
@ -21,7 +20,7 @@ patient.addAddress().addLine("742 Evergreen Terrace").setCity("Springfield").set
|
||||||
FhirContext ctx = FhirContext.forDstu2();
|
FhirContext ctx = FhirContext.forDstu2();
|
||||||
|
|
||||||
// Use the narrative generator
|
// Use the narrative generator
|
||||||
ctx.setNarrativeGenerator(new DefaultThymeleafNarrativeGenerator(ctx));
|
ctx.setNarrativeGenerator(new DefaultThymeleafNarrativeGenerator());
|
||||||
|
|
||||||
// Encode the output, including the narrative
|
// Encode the output, including the narrative
|
||||||
String output = ctx.newJsonParser().setPrettyPrint(true).encodeResourceToString(patient);
|
String output = ctx.newJsonParser().setPrettyPrint(true).encodeResourceToString(patient);
|
||||||
|
|
|
@ -1,18 +1,17 @@
|
||||||
package example;
|
package example;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
import ca.uhn.fhir.context.FhirContext;
|
import ca.uhn.fhir.context.FhirContext;
|
||||||
import ca.uhn.fhir.narrative.CustomThymeleafNarrativeGenerator;
|
import ca.uhn.fhir.narrative.CustomThymeleafNarrativeGenerator;
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
public class NarrativeGenerator {
|
public class NarrativeGenerator {
|
||||||
|
|
||||||
public void testGenerator() throws IOException {
|
public void testGenerator() {
|
||||||
|
|
||||||
//START SNIPPET: gen
|
//START SNIPPET: gen
|
||||||
FhirContext ctx = FhirContext.forDstu2();
|
FhirContext ctx = FhirContext.forDstu2();
|
||||||
String propFile = "classpath:/com/foo/customnarrative.properties";
|
String propFile = "classpath:/com/foo/customnarrative.properties";
|
||||||
CustomThymeleafNarrativeGenerator gen = new CustomThymeleafNarrativeGenerator(ctx, propFile);
|
CustomThymeleafNarrativeGenerator gen = new CustomThymeleafNarrativeGenerator(propFile);
|
||||||
|
|
||||||
ctx.setNarrativeGenerator(gen);
|
ctx.setNarrativeGenerator(gen);
|
||||||
//END SNIPPET: gen
|
//END SNIPPET: gen
|
||||||
|
|
|
@ -36,7 +36,7 @@ public abstract class BaseThymeleafNarrativeGenerator extends ThymeleafNarrative
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*/
|
*/
|
||||||
public BaseThymeleafNarrativeGenerator() {
|
protected BaseThymeleafNarrativeGenerator() {
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,7 +58,7 @@ public abstract class BaseThymeleafNarrativeGenerator extends ThymeleafNarrative
|
||||||
|
|
||||||
List<String> propFileName = getPropertyFile();
|
List<String> propFileName = getPropertyFile();
|
||||||
try {
|
try {
|
||||||
NarrativeTemplateManifest manifest = NarrativeTemplateManifest.forManifestFileLocation(propFileName);
|
NarrativeTemplateManifest manifest = NarrativeTemplateManifest.forManifestFileContents(propFileName);
|
||||||
setManifest(manifest);
|
setManifest(manifest);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new InternalErrorException(e);
|
throw new InternalErrorException(e);
|
||||||
|
|
|
@ -23,7 +23,6 @@ package ca.uhn.fhir.narrative;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import ca.uhn.fhir.context.FhirContext;
|
|
||||||
import org.apache.commons.lang3.Validate;
|
import org.apache.commons.lang3.Validate;
|
||||||
|
|
||||||
public class CustomThymeleafNarrativeGenerator extends BaseThymeleafNarrativeGenerator {
|
public class CustomThymeleafNarrativeGenerator extends BaseThymeleafNarrativeGenerator {
|
||||||
|
|
|
@ -92,22 +92,6 @@ public class NarrativeTemplateManifest implements INarrativeTemplateManifest {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static NarrativeTemplateManifest forManifestFileLocation(FhirContext theFhirContext, String... thePropertyFilePaths) throws IOException {
|
|
||||||
return forManifestFileLocation(Arrays.asList(thePropertyFilePaths));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static NarrativeTemplateManifest forManifestFileLocation(Collection<String> thePropertyFilePaths) throws IOException {
|
|
||||||
ourLog.debug("Loading narrative properties file(s): {}", thePropertyFilePaths);
|
|
||||||
|
|
||||||
List<String> manifestFileContents = new ArrayList<>(thePropertyFilePaths.size());
|
|
||||||
for (String next : thePropertyFilePaths) {
|
|
||||||
String resource = loadResource(next);
|
|
||||||
manifestFileContents.add(resource);
|
|
||||||
}
|
|
||||||
|
|
||||||
return forManifestFileContents(manifestFileContents);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static NarrativeTemplateManifest forManifestFileContents(String... theResources) throws IOException {
|
public static NarrativeTemplateManifest forManifestFileContents(String... theResources) throws IOException {
|
||||||
return forManifestFileContents(Arrays.asList(theResources));
|
return forManifestFileContents(Arrays.asList(theResources));
|
||||||
}
|
}
|
||||||
|
|
|
@ -125,7 +125,7 @@ public class JpaServerDemo extends RestfulServer {
|
||||||
* This server tries to dynamically generate narratives
|
* This server tries to dynamically generate narratives
|
||||||
*/
|
*/
|
||||||
FhirContext ctx = getFhirContext();
|
FhirContext ctx = getFhirContext();
|
||||||
ctx.setNarrativeGenerator(new DefaultThymeleafNarrativeGenerator(getFhirContext()));
|
ctx.setNarrativeGenerator(new DefaultThymeleafNarrativeGenerator());
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Default to XML and pretty printing
|
* Default to XML and pretty printing
|
||||||
|
|
|
@ -74,9 +74,9 @@ public abstract class BaseResourceProviderDstu2Test extends BaseJpaDstu2Test {
|
||||||
|
|
||||||
ourRestServer.setResourceProviders((List)myResourceProviders);
|
ourRestServer.setResourceProviders((List)myResourceProviders);
|
||||||
|
|
||||||
ourRestServer.getFhirContext().setNarrativeGenerator(new DefaultThymeleafNarrativeGenerator(myFhirCtx));
|
ourRestServer.getFhirContext().setNarrativeGenerator(new DefaultThymeleafNarrativeGenerator());
|
||||||
|
|
||||||
ourRestServer.setPlainProviders(mySystemProvider);
|
ourRestServer.registerProvider(mySystemProvider);
|
||||||
|
|
||||||
JpaConformanceProviderDstu2 confProvider = new JpaConformanceProviderDstu2(ourRestServer, mySystemDao, myDaoConfig);
|
JpaConformanceProviderDstu2 confProvider = new JpaConformanceProviderDstu2(ourRestServer, mySystemDao, myDaoConfig);
|
||||||
confProvider.setImplementationDescription("THIS IS THE DESC");
|
confProvider.setImplementationDescription("THIS IS THE DESC");
|
||||||
|
|
|
@ -92,10 +92,10 @@ public abstract class BaseResourceProviderDstu3Test extends BaseJpaDstu3Test {
|
||||||
|
|
||||||
ourRestServer.setResourceProviders((List) myResourceProviders);
|
ourRestServer.setResourceProviders((List) myResourceProviders);
|
||||||
|
|
||||||
ourRestServer.getFhirContext().setNarrativeGenerator(new DefaultThymeleafNarrativeGenerator(myFhirCtx));
|
ourRestServer.getFhirContext().setNarrativeGenerator(new DefaultThymeleafNarrativeGenerator());
|
||||||
|
|
||||||
myTerminologyUploaderProvider = myAppCtx.getBean(TerminologyUploaderProviderDstu3.class);
|
myTerminologyUploaderProvider = myAppCtx.getBean(TerminologyUploaderProviderDstu3.class);
|
||||||
ourRestServer.setPlainProviders(mySystemProvider, myTerminologyUploaderProvider);
|
ourRestServer.registerProviders(mySystemProvider, myTerminologyUploaderProvider);
|
||||||
|
|
||||||
SubscriptionTriggeringProvider subscriptionTriggeringProvider = myAppCtx.getBean(SubscriptionTriggeringProvider.class);
|
SubscriptionTriggeringProvider subscriptionTriggeringProvider = myAppCtx.getBean(SubscriptionTriggeringProvider.class);
|
||||||
ourRestServer.registerProvider(subscriptionTriggeringProvider);
|
ourRestServer.registerProvider(subscriptionTriggeringProvider);
|
||||||
|
|
|
@ -99,12 +99,12 @@ public abstract class BaseResourceProviderR4Test extends BaseJpaR4Test {
|
||||||
|
|
||||||
ourRestServer.setResourceProviders((List) myResourceProviders);
|
ourRestServer.setResourceProviders((List) myResourceProviders);
|
||||||
|
|
||||||
ourRestServer.getFhirContext().setNarrativeGenerator(new DefaultThymeleafNarrativeGenerator(myFhirCtx));
|
ourRestServer.getFhirContext().setNarrativeGenerator(new DefaultThymeleafNarrativeGenerator());
|
||||||
|
|
||||||
myTerminologyUploaderProvider = myAppCtx.getBean(TerminologyUploaderProviderR4.class);
|
myTerminologyUploaderProvider = myAppCtx.getBean(TerminologyUploaderProviderR4.class);
|
||||||
ourGraphQLProvider = myAppCtx.getBean("myGraphQLProvider");
|
ourGraphQLProvider = myAppCtx.getBean("myGraphQLProvider");
|
||||||
|
|
||||||
ourRestServer.setPlainProviders(mySystemProvider, myTerminologyUploaderProvider, ourGraphQLProvider);
|
ourRestServer.registerProviders(mySystemProvider, myTerminologyUploaderProvider, ourGraphQLProvider);
|
||||||
|
|
||||||
JpaConformanceProviderR4 confProvider = new JpaConformanceProviderR4(ourRestServer, mySystemDao, myDaoConfig);
|
JpaConformanceProviderR4 confProvider = new JpaConformanceProviderR4(ourRestServer, mySystemDao, myDaoConfig);
|
||||||
confProvider.setImplementationDescription("THIS IS THE DESC");
|
confProvider.setImplementationDescription("THIS IS THE DESC");
|
||||||
|
|
|
@ -109,7 +109,7 @@ public class JpaServerDemo extends RestfulServer {
|
||||||
* This server tries to dynamically generate narratives
|
* This server tries to dynamically generate narratives
|
||||||
*/
|
*/
|
||||||
FhirContext ctx = getFhirContext();
|
FhirContext ctx = getFhirContext();
|
||||||
ctx.setNarrativeGenerator(new DefaultThymeleafNarrativeGenerator(getFhirContext()));
|
ctx.setNarrativeGenerator(new DefaultThymeleafNarrativeGenerator());
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Default to JSON and pretty printing
|
* Default to JSON and pretty printing
|
||||||
|
|
|
@ -108,7 +108,7 @@ public class JpaServerDemoDstu2 extends RestfulServer {
|
||||||
* This server tries to dynamically generate narratives
|
* This server tries to dynamically generate narratives
|
||||||
*/
|
*/
|
||||||
FhirContext ctx = getFhirContext();
|
FhirContext ctx = getFhirContext();
|
||||||
ctx.setNarrativeGenerator(new DefaultThymeleafNarrativeGenerator(getFhirContext()));
|
ctx.setNarrativeGenerator(new DefaultThymeleafNarrativeGenerator());
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Default to JSON and pretty printing
|
* Default to JSON and pretty printing
|
||||||
|
|
|
@ -159,7 +159,7 @@ public class TestRestfulServer extends RestfulServer {
|
||||||
* This server tries to dynamically generate narratives
|
* This server tries to dynamically generate narratives
|
||||||
*/
|
*/
|
||||||
FhirContext ctx = getFhirContext();
|
FhirContext ctx = getFhirContext();
|
||||||
ctx.setNarrativeGenerator(new DefaultThymeleafNarrativeGenerator(getFhirContext()));
|
ctx.setNarrativeGenerator(new DefaultThymeleafNarrativeGenerator());
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The resource and system providers (which actually implement the various FHIR
|
* The resource and system providers (which actually implement the various FHIR
|
||||||
|
@ -171,7 +171,7 @@ public class TestRestfulServer extends RestfulServer {
|
||||||
}
|
}
|
||||||
setResourceProviders(beans);
|
setResourceProviders(beans);
|
||||||
|
|
||||||
setPlainProviders(plainProviders);
|
registerProviders(plainProviders);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Enable CORS
|
* Enable CORS
|
||||||
|
|
|
@ -1020,7 +1020,7 @@ public class JsonParserDstu2_1Test {
|
||||||
Patient p = new Patient();
|
Patient p = new Patient();
|
||||||
p.addName().addFamily("Smith").addGiven("John");
|
p.addName().addFamily("Smith").addGiven("John");
|
||||||
|
|
||||||
ourCtx.setNarrativeGenerator(new DefaultThymeleafNarrativeGenerator(ourCtx));
|
ourCtx.setNarrativeGenerator(new DefaultThymeleafNarrativeGenerator());
|
||||||
|
|
||||||
String output = ourCtx.newJsonParser().encodeResourceToString(p);
|
String output = ourCtx.newJsonParser().encodeResourceToString(p);
|
||||||
ourLog.info(output);
|
ourLog.info(output);
|
||||||
|
|
|
@ -1695,7 +1695,7 @@ public class XmlParserDstu2_1Test {
|
||||||
Patient p = new Patient();
|
Patient p = new Patient();
|
||||||
p.addName().addFamily("Smith").addGiven("John");
|
p.addName().addFamily("Smith").addGiven("John");
|
||||||
|
|
||||||
ourCtx.setNarrativeGenerator(new DefaultThymeleafNarrativeGenerator(ourCtx));
|
ourCtx.setNarrativeGenerator(new DefaultThymeleafNarrativeGenerator());
|
||||||
|
|
||||||
String output = ourCtx.newXmlParser().encodeResourceToString(p);
|
String output = ourCtx.newXmlParser().encodeResourceToString(p);
|
||||||
ourLog.info(output);
|
ourLog.info(output);
|
||||||
|
|
|
@ -26,7 +26,7 @@ public class CustomThymeleafNarrativeGeneratorDstu2Test {
|
||||||
public void testGenerator() {
|
public void testGenerator() {
|
||||||
|
|
||||||
// CustomThymeleafNarrativeGenerator gen = new CustomThymeleafNarrativeGenerator("file:src/test/resources/narrative/customnarrative.properties");
|
// CustomThymeleafNarrativeGenerator gen = new CustomThymeleafNarrativeGenerator("file:src/test/resources/narrative/customnarrative.properties");
|
||||||
CustomThymeleafNarrativeGenerator gen = new CustomThymeleafNarrativeGenerator(ourCtx,"classpath:narrative/customnarrative_dstu2.properties");
|
CustomThymeleafNarrativeGenerator gen = new CustomThymeleafNarrativeGenerator("classpath:narrative/customnarrative_dstu2.properties");
|
||||||
ourCtx.setNarrativeGenerator(gen);
|
ourCtx.setNarrativeGenerator(gen);
|
||||||
|
|
||||||
Practitioner p = new Practitioner();
|
Practitioner p = new Practitioner();
|
||||||
|
@ -35,7 +35,7 @@ public class CustomThymeleafNarrativeGeneratorDstu2Test {
|
||||||
p.addAddress().addLine("line1").addLine("line2");
|
p.addAddress().addLine("line1").addLine("line2");
|
||||||
p.getName().addFamily("fam1").addGiven("given");
|
p.getName().addFamily("fam1").addGiven("given");
|
||||||
|
|
||||||
gen.populateResourceNarrative(p);
|
gen.populateResourceNarrative(ourCtx, p);
|
||||||
|
|
||||||
String actual = p.getText().getDiv().getValueAsString();
|
String actual = p.getText().getDiv().getValueAsString();
|
||||||
ourLog.info(actual);
|
ourLog.info(actual);
|
||||||
|
|
|
@ -1,32 +1,12 @@
|
||||||
package ca.uhn.fhir.narrative;
|
package ca.uhn.fhir.narrative;
|
||||||
|
|
||||||
import static org.hamcrest.Matchers.containsString;
|
|
||||||
import static org.hamcrest.Matchers.not;
|
|
||||||
import static org.junit.Assert.assertEquals;
|
|
||||||
import static org.junit.Assert.assertThat;
|
|
||||||
import static org.junit.Assert.assertTrue;
|
|
||||||
|
|
||||||
import java.util.Date;
|
|
||||||
|
|
||||||
import org.hamcrest.core.StringContains;
|
|
||||||
import org.junit.AfterClass;
|
|
||||||
import org.junit.Before;
|
|
||||||
import org.junit.Ignore;
|
|
||||||
import org.junit.Test;
|
|
||||||
|
|
||||||
import ca.uhn.fhir.context.FhirContext;
|
import ca.uhn.fhir.context.FhirContext;
|
||||||
import ca.uhn.fhir.model.api.TemporalPrecisionEnum;
|
import ca.uhn.fhir.model.api.TemporalPrecisionEnum;
|
||||||
import ca.uhn.fhir.model.dstu2.composite.CodeableConceptDt;
|
import ca.uhn.fhir.model.dstu2.composite.CodeableConceptDt;
|
||||||
import ca.uhn.fhir.model.dstu2.composite.QuantityDt;
|
import ca.uhn.fhir.model.dstu2.composite.QuantityDt;
|
||||||
import ca.uhn.fhir.model.dstu2.composite.ResourceReferenceDt;
|
import ca.uhn.fhir.model.dstu2.composite.ResourceReferenceDt;
|
||||||
import ca.uhn.fhir.model.dstu2.composite.SimpleQuantityDt;
|
import ca.uhn.fhir.model.dstu2.composite.SimpleQuantityDt;
|
||||||
import ca.uhn.fhir.model.dstu2.resource.DiagnosticReport;
|
import ca.uhn.fhir.model.dstu2.resource.*;
|
||||||
import ca.uhn.fhir.model.dstu2.resource.Medication;
|
|
||||||
import ca.uhn.fhir.model.dstu2.resource.MedicationOrder;
|
|
||||||
import ca.uhn.fhir.model.dstu2.resource.Observation;
|
|
||||||
import ca.uhn.fhir.model.dstu2.resource.OperationOutcome;
|
|
||||||
import ca.uhn.fhir.model.dstu2.resource.Parameters;
|
|
||||||
import ca.uhn.fhir.model.dstu2.resource.Patient;
|
|
||||||
import ca.uhn.fhir.model.dstu2.valueset.DiagnosticReportStatusEnum;
|
import ca.uhn.fhir.model.dstu2.valueset.DiagnosticReportStatusEnum;
|
||||||
import ca.uhn.fhir.model.dstu2.valueset.MedicationOrderStatusEnum;
|
import ca.uhn.fhir.model.dstu2.valueset.MedicationOrderStatusEnum;
|
||||||
import ca.uhn.fhir.model.dstu2.valueset.ObservationStatusEnum;
|
import ca.uhn.fhir.model.dstu2.valueset.ObservationStatusEnum;
|
||||||
|
@ -34,6 +14,18 @@ import ca.uhn.fhir.model.primitive.DateTimeDt;
|
||||||
import ca.uhn.fhir.model.primitive.StringDt;
|
import ca.uhn.fhir.model.primitive.StringDt;
|
||||||
import ca.uhn.fhir.parser.DataFormatException;
|
import ca.uhn.fhir.parser.DataFormatException;
|
||||||
import ca.uhn.fhir.util.TestUtil;
|
import ca.uhn.fhir.util.TestUtil;
|
||||||
|
import org.hamcrest.core.StringContains;
|
||||||
|
import org.junit.AfterClass;
|
||||||
|
import org.junit.Before;
|
||||||
|
import org.junit.Ignore;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
import static org.hamcrest.Matchers.containsString;
|
||||||
|
import static org.hamcrest.Matchers.not;
|
||||||
|
import static org.junit.Assert.assertThat;
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
public class DefaultThymeleafNarrativeGeneratorDstu2Test {
|
public class DefaultThymeleafNarrativeGeneratorDstu2Test {
|
||||||
private static FhirContext ourCtx = FhirContext.forDstu2();
|
private static FhirContext ourCtx = FhirContext.forDstu2();
|
||||||
|
@ -48,7 +40,7 @@ public class DefaultThymeleafNarrativeGeneratorDstu2Test {
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void before() {
|
public void before() {
|
||||||
myGen = new DefaultThymeleafNarrativeGenerator(ourCtx);
|
myGen = new DefaultThymeleafNarrativeGenerator();
|
||||||
myGen.setUseHapiServerConformanceNarrative(true);
|
myGen.setUseHapiServerConformanceNarrative(true);
|
||||||
|
|
||||||
ourCtx.setNarrativeGenerator(myGen);
|
ourCtx.setNarrativeGenerator(myGen);
|
||||||
|
@ -65,7 +57,7 @@ public class DefaultThymeleafNarrativeGeneratorDstu2Test {
|
||||||
|
|
||||||
value.setBirthDate(new Date(), TemporalPrecisionEnum.DAY);
|
value.setBirthDate(new Date(), TemporalPrecisionEnum.DAY);
|
||||||
|
|
||||||
myGen.populateResourceNarrative(value);
|
myGen.populateResourceNarrative(ourCtx, value);
|
||||||
String output = value.getText().getDiv().getValueAsString();
|
String output = value.getText().getDiv().getValueAsString();
|
||||||
ourLog.info(output);
|
ourLog.info(output);
|
||||||
assertThat(output, StringContains.containsString("<div class=\"hapiHeaderText\">joe john <b>BLOW </b></div>"));
|
assertThat(output, StringContains.containsString("<div class=\"hapiHeaderText\">joe john <b>BLOW </b></div>"));
|
||||||
|
@ -77,7 +69,7 @@ public class DefaultThymeleafNarrativeGeneratorDstu2Test {
|
||||||
Parameters value = new Parameters();
|
Parameters value = new Parameters();
|
||||||
value.setId("123");
|
value.setId("123");
|
||||||
|
|
||||||
myGen.populateResourceNarrative(value);
|
myGen.populateResourceNarrative(ourCtx, value);
|
||||||
String output = value.getText().getDiv().getValueAsString();
|
String output = value.getText().getDiv().getValueAsString();
|
||||||
ourLog.info(output);
|
ourLog.info(output);
|
||||||
assertThat(output, not(containsString("narrative")));
|
assertThat(output, not(containsString("narrative")));
|
||||||
|
@ -99,7 +91,7 @@ public class DefaultThymeleafNarrativeGeneratorDstu2Test {
|
||||||
|
|
||||||
OperationOutcome oo = ourCtx.newXmlParser().parseResource(OperationOutcome.class, parse);
|
OperationOutcome oo = ourCtx.newXmlParser().parseResource(OperationOutcome.class, parse);
|
||||||
|
|
||||||
myGen.populateResourceNarrative(oo);
|
myGen.populateResourceNarrative(ourCtx, oo);
|
||||||
String output = oo.getText().getDiv().getValueAsString();
|
String output = oo.getText().getDiv().getValueAsString();
|
||||||
|
|
||||||
ourLog.info(output);
|
ourLog.info(output);
|
||||||
|
@ -137,7 +129,7 @@ public class DefaultThymeleafNarrativeGeneratorDstu2Test {
|
||||||
value.addResult().setResource(obs);
|
value.addResult().setResource(obs);
|
||||||
}
|
}
|
||||||
|
|
||||||
myGen.populateResourceNarrative(value);
|
myGen.populateResourceNarrative(ourCtx, value);
|
||||||
String output = value.getText().getDiv().getValueAsString();
|
String output = value.getText().getDiv().getValueAsString();
|
||||||
|
|
||||||
ourLog.info(output);
|
ourLog.info(output);
|
||||||
|
@ -162,11 +154,11 @@ public class DefaultThymeleafNarrativeGeneratorDstu2Test {
|
||||||
mp.setStatus(MedicationOrderStatusEnum.ACTIVE);
|
mp.setStatus(MedicationOrderStatusEnum.ACTIVE);
|
||||||
mp.setDateWritten(new DateTimeDt("2014-09-01"));
|
mp.setDateWritten(new DateTimeDt("2014-09-01"));
|
||||||
|
|
||||||
myGen.populateResourceNarrative(mp);
|
myGen.populateResourceNarrative(ourCtx, mp);
|
||||||
String output = mp.getText().getDiv().getValueAsString();
|
String output = mp.getText().getDiv().getValueAsString();
|
||||||
|
|
||||||
assertTrue("Expected medication name of ciprofloaxin within narrative: " + output, output.indexOf("ciprofloaxin") > -1);
|
assertTrue("Expected medication name of ciprofloaxin within narrative: " + output, output.contains("ciprofloaxin"));
|
||||||
assertTrue("Expected string status of ACTIVE within narrative: " + output, output.indexOf("ACTIVE") > -1);
|
assertTrue("Expected string status of ACTIVE within narrative: " + output, output.contains("ACTIVE"));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -175,7 +167,7 @@ public class DefaultThymeleafNarrativeGeneratorDstu2Test {
|
||||||
Medication med = new Medication();
|
Medication med = new Medication();
|
||||||
med.getCode().setText("ciproflaxin");
|
med.getCode().setText("ciproflaxin");
|
||||||
|
|
||||||
myGen.populateResourceNarrative(med);
|
myGen.populateResourceNarrative(ourCtx, med);
|
||||||
String output = med.getText().getDiv().getValueAsString();
|
String output = med.getText().getDiv().getValueAsString();
|
||||||
assertThat(output, containsString("ciproflaxin"));
|
assertThat(output, containsString("ciproflaxin"));
|
||||||
|
|
||||||
|
|
|
@ -71,7 +71,7 @@ public class BundleTypeInResponseTest {
|
||||||
|
|
||||||
ServletHandler proxyHandler = new ServletHandler();
|
ServletHandler proxyHandler = new ServletHandler();
|
||||||
RestfulServer servlet = new RestfulServer(ourCtx);
|
RestfulServer servlet = new RestfulServer(ourCtx);
|
||||||
servlet.getFhirContext().setNarrativeGenerator(new DefaultThymeleafNarrativeGenerator(ourCtx));
|
servlet.getFhirContext().setNarrativeGenerator(new DefaultThymeleafNarrativeGenerator());
|
||||||
|
|
||||||
servlet.setResourceProviders(patientProvider);
|
servlet.setResourceProviders(patientProvider);
|
||||||
ServletHolder servletHolder = new ServletHolder(servlet);
|
ServletHolder servletHolder = new ServletHolder(servlet);
|
||||||
|
|
|
@ -58,13 +58,13 @@ public class ThymeleafNarrativeGeneratorTest {
|
||||||
ref.setReference("DiagnosticReport/1").setResource(dr1);
|
ref.setReference("DiagnosticReport/1").setResource(dr1);
|
||||||
sect.getEntry().add(ref);
|
sect.getEntry().add(ref);
|
||||||
|
|
||||||
NarrativeTemplateManifest manifest = NarrativeTemplateManifest.forManifestFileLocation(myCtx, "classpath:narrative2/narratives.properties");
|
NarrativeTemplateManifest manifest = NarrativeTemplateManifest.forManifestFileContents("classpath:narrative2/narratives.properties");
|
||||||
ThymeleafNarrativeGenerator gen = new ThymeleafNarrativeGenerator(myCtx);
|
ThymeleafNarrativeGenerator gen = new ThymeleafNarrativeGenerator();
|
||||||
gen.setManifest(manifest);
|
gen.setManifest(manifest);
|
||||||
|
|
||||||
gen.populateResourceNarrative(composition);
|
gen.populateResourceNarrative(myCtx, composition);
|
||||||
|
|
||||||
// Firt narrative should be empty
|
// First narrative should be empty
|
||||||
String narrative = composition.getSection().get(0).getText().getDiv().getValueAsString();
|
String narrative = composition.getSection().get(0).getText().getDiv().getValueAsString();
|
||||||
assertThat(narrative, Matchers.emptyOrNullString());
|
assertThat(narrative, Matchers.emptyOrNullString());
|
||||||
|
|
||||||
|
@ -78,7 +78,7 @@ public class ThymeleafNarrativeGeneratorTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testTemplateCount() throws IOException {
|
public void testTemplateCount() throws IOException {
|
||||||
NarrativeTemplateManifest manifest = NarrativeTemplateManifest.forManifestFileLocation(myCtx, "classpath:narrative2/narratives.properties");
|
NarrativeTemplateManifest manifest = NarrativeTemplateManifest.forManifestFileContents("classpath:narrative2/narratives.properties");
|
||||||
assertEquals(4, manifest.getNamedTemplateCount());
|
assertEquals(4, manifest.getNamedTemplateCount());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -48,7 +48,7 @@ public class ExampleRestfulServlet extends RestfulServer {
|
||||||
* but can be useful as it causes HAPI to generate narratives for
|
* but can be useful as it causes HAPI to generate narratives for
|
||||||
* resources which don't otherwise have one.
|
* resources which don't otherwise have one.
|
||||||
*/
|
*/
|
||||||
INarrativeGenerator narrativeGen = new DefaultThymeleafNarrativeGenerator(getFhirContext());
|
INarrativeGenerator narrativeGen = new DefaultThymeleafNarrativeGenerator();
|
||||||
getFhirContext().setNarrativeGenerator(narrativeGen);
|
getFhirContext().setNarrativeGenerator(narrativeGen);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Reference in New Issue