Java Code Examples for ca.uhn.fhir.context.FhirContext#setNarrativeGenerator()

The following examples show how to use ca.uhn.fhir.context.FhirContext#setNarrativeGenerator() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Example99_NarrativeGenerator.java    From fhirstarters with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public static void main(String[] args) {
	
	// Create an encounter with an invalid status and no class
	Patient pat = new Patient();
	pat.addName().setFamily("Simpson").addGiven("Homer").addGiven("Jay");
	pat.addAddress().addLine("342 Evergreen Terrace").addLine("Springfield");
	pat.addIdentifier().setSystem("http://acme.org/mrns").setValue("12345");
	
	// Create a new context and enable the narrative generator
	FhirContext ctx = FhirContext.forDstu2();
	ctx.setNarrativeGenerator(new DefaultThymeleafNarrativeGenerator());
	
	String res = ctx.newJsonParser().setPrettyPrint(true).encodeResourceToString(pat);
	System.out.println(res);
}