Narrative enhancements
This commit is contained in:
parent
ece3fab5f8
commit
4953c5629c
|
@ -0,0 +1,9 @@
|
|||
package ca.uhn.fhir.narrative;
|
||||
|
||||
public class BaseThymeleafNarrativeGenerator {
|
||||
|
||||
public String getPropertyFile() {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
|
@ -38,8 +38,9 @@ import ca.uhn.fhir.model.dstu.valueset.NarrativeStatusEnum;
|
|||
import ca.uhn.fhir.model.primitive.XhtmlDt;
|
||||
import ca.uhn.fhir.parser.DataFormatException;
|
||||
|
||||
public class ThymeleafNarrativeGenerator implements INarrativeGenerator {
|
||||
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(ThymeleafNarrativeGenerator.class);
|
||||
public class DefaultThymeleafNarrativeGenerator extends BaseThymeleafNarrativeGenerator implements INarrativeGenerator {
|
||||
|
||||
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(DefaultThymeleafNarrativeGenerator.class);
|
||||
|
||||
private HashMap<String, String> myDatatypeClassNameToNarrativeTemplate;
|
||||
private TemplateEngine myDatatypeTemplateEngine;
|
||||
|
@ -51,11 +52,11 @@ public class ThymeleafNarrativeGenerator implements INarrativeGenerator {
|
|||
private TemplateEngine myProfileTemplateEngine;
|
||||
private HashMap<String, String> myProfileToNarrativeTemplate;
|
||||
|
||||
public ThymeleafNarrativeGenerator() throws IOException {
|
||||
public DefaultThymeleafNarrativeGenerator() throws IOException {
|
||||
myProfileToNarrativeTemplate = new HashMap<String, String>();
|
||||
myDatatypeClassNameToNarrativeTemplate = new HashMap<String, String>();
|
||||
|
||||
String propFileName = "classpath:ca/uhn/fhir/narrative/narratives.properties";
|
||||
String propFileName = getPropertyFile();
|
||||
loadProperties(propFileName);
|
||||
|
||||
{
|
||||
|
@ -81,6 +82,11 @@ public class ThymeleafNarrativeGenerator implements INarrativeGenerator {
|
|||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPropertyFile() {
|
||||
return "classpath:ca/uhn/fhir/narrative/narratives.properties";
|
||||
}
|
||||
|
||||
@Override
|
||||
public NarrativeDt generateNarrative(String theProfile, IResource theResource) {
|
||||
if (myIgnoreMissingTemplates && !myProfileToNarrativeTemplate.containsKey(theProfile)) {
|
||||
|
@ -174,9 +180,9 @@ public class ThymeleafNarrativeGenerator implements INarrativeGenerator {
|
|||
private InputStream loadResource(String name) {
|
||||
if (name.startsWith("classpath:")) {
|
||||
String cpName = name.substring("classpath:".length());
|
||||
InputStream resource = ThymeleafNarrativeGenerator.class.getResourceAsStream(cpName);
|
||||
InputStream resource = DefaultThymeleafNarrativeGenerator.class.getResourceAsStream(cpName);
|
||||
if (resource == null) {
|
||||
resource = ThymeleafNarrativeGenerator.class.getResourceAsStream("/" + cpName);
|
||||
resource = DefaultThymeleafNarrativeGenerator.class.getResourceAsStream("/" + cpName);
|
||||
if (resource == null) {
|
||||
throw new ConfigurationException("Can not find '" + cpName + "' on classpath");
|
||||
}
|
||||
|
@ -268,7 +274,7 @@ public class ThymeleafNarrativeGenerator implements INarrativeGenerator {
|
|||
|
||||
}
|
||||
|
||||
private final class ProfileResourceResolver implements IResourceResolver {
|
||||
private final class ProfileResourceResolver implements IResourceResolver {
|
||||
@Override
|
||||
public String getName() {
|
||||
return getClass().getCanonicalName();
|
|
@ -8,9 +8,14 @@
|
|||
|
||||
<div>
|
||||
<div class="hapiHeaderText">
|
||||
<!--/*
|
||||
Show the DiagnosticReport's name.text value, or if that isn't populated, show the
|
||||
display value on the first coding, and if that's missing too show a default "Untitled"
|
||||
value
|
||||
*/-->
|
||||
<th:block th:if="${not resource.name.text.empty}" th:text="${resource.name.text.value}"/>
|
||||
<th:block th:if="${resource.name.text.empty} and ${not #lists.isEmpty(resource.name.coding)} and ${not resource.name.coding[0].empty} and ${not resource.name.coding[0].display.empty}" th:text="${resource.name.coding[0].display}"/>
|
||||
<th:block th:if="${resource.name.text.empty} and ${not #lists.isEmpty(resource.name.coding)} and ${not resource.name.coding[0].empty} and ${resource.name.coding[0].display.empty}" th:text="Untitled Diagnostic Report"/>
|
||||
<th:block th:if=" ${resource.name.text.empty} and ${not resource.name.codingFirstRep.display.empty}" th:text="${resource.name.codingFirstRep.display}"/>
|
||||
<th:block th:if= "${resource.name.text.empty} and ${resource.name.codingFirstRep.display.empty}" th:text="Untitled Diagnostic Report"/>
|
||||
<!--/*--> Complete Blood Count <!--*/-->
|
||||
</div>
|
||||
|
||||
|
|
|
@ -22,11 +22,11 @@ import ca.uhn.fhir.parser.DataFormatException;
|
|||
|
||||
public class ThymeleafNarrativeGeneratorTest {
|
||||
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(ThymeleafNarrativeGeneratorTest.class);
|
||||
private ThymeleafNarrativeGenerator gen;
|
||||
private DefaultThymeleafNarrativeGenerator gen;
|
||||
|
||||
@Before
|
||||
public void before() throws IOException {
|
||||
gen = new ThymeleafNarrativeGenerator();
|
||||
gen = new DefaultThymeleafNarrativeGenerator();
|
||||
gen.setIgnoreFailures(false);
|
||||
gen.setIgnoreMissingTemplates(true);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue