Wiki Spaces

Documentation
Projects
Resources

Get Help from Others

Q&A: Ask OpenMRS
Discussion: OpenMRS Talk
Real-Time: IRC Chat | Slack

Projects

Page tree
Skip to end of metadata
Go to start of metadata

OpenMRS FHIR module support for adding custom narratives which can define through Thymeleaf HTML based syntax[1]

Configuring FHIR Module to support custom narratives

We have define two Settings (formerly Global Properties from 1.8 downwards) within the module to enable custom narratives. Once they have cconfigured. servelet container need  to be restarted. 

Settings (formerly Global Properties from 1.8 downwards)Detailss

fhir.isCustomerNarrativesEnabled 

To enable custom narratives, this value need to be set to true. By default custom narratives generation is disabled in the server.

fhir.customNarrativePropertiesPath

Once custom narratives enabled, the path of the narratives property file should be specified in here.
Sample Setting (formerly Global Property from 1.8 downwards) configuration screenshot

Sample custom narratives property file(narratives.properties) content
Patient.class=ca.uhn.fhir.model.dstu2.resource.Patient
patient.narrative=file:/home/harsha/development/applications/Patient.html

 

Sample Patient narrative generator file defined using Thymeleaf HTML based syntax
<!--/* 
This top section is not exported as a part of the Narrative,
it is only present so that this template can be viewed in 
a browser. 
-->
<html>
        <head>
                <link rel="stylesheet" type="text/css" href="narrative.css"/>
        </head>
        <body>
<!--*/-->
 <div>
        <div class="hapiHeaderText" th:if="${not resource.nameFirstRep.empty}" th:narrative="${resource.nameFirstRep}"/>
        <table class="hapiPropertyTable">
		<tbody>
			<tr th:if="${not resource.identifierFirstRep.empty}">
                       <td>Identifier</td>
                       <td th:narrative="${resource.identifierFirstRep}"></td>
            </tr>
            <tr th:if="${not resource.addressFirstRep.empty}">
                      <td>Address</td>
                      <td th:narrative="${resource.addressFirstRep}"></td>
             </tr>
			 <tr th:if="${not resource.birthDateElement.empty}">
                       <td>Date of birth</td>
					   <td><span th:text="${#dates.format(resource.birthDateElement.value,'dd MMMM yyyy')}"></span></td>
			  </tr>
		</tbody>
		</table>
</div>

<!--/*-->
        </body>
</html>
<!--*/-->


Sample response of Patient resource request
<?xml version="1.0" encoding="UTF-8"?>
<Patient xmlns="http://hl7.org/fhir">
   <id value="8b0d0f75-887b-11e4-81b7-f01faf67ac41" />
   <text>
      <status value="generated" />
      <div xmlns="http://www.w3.org/1999/xhtml">
         <div class="hapiHeaderText">
            Mr. John
            <b>PATIENT</b>
            Mr.
         </div>
         <table class="hapiPropertyTable">
            <tbody>
               <tr>
                  <td>Identifier</td>
                  <td>OpenMRS Identification Number</td>
               </tr>
               <tr>
                  <td>Address</td>
                  <td>
                     <span>555 Johnson Rd.</span>
                     <br />
                     <span>Apt. 555</span>
                     <br />
                     <span>Indianapolis</span>
                     <span>IN</span>
                     <span>USA</span>
                  </td>
               </tr>
               <tr>
                  <td>Date of birth</td>
                  <td>
                     <span>01 January 1975</span>
                  </td>
               </tr>
            </tbody>
         </table>
      </div>
   </text>
   <identifier>
      <use value="usual" />
      <label value="OpenMRS Identification Number" />
      <system value="urn:uuid:8d793bee-c2cc-11de-8d13-0010c6dffd0f" />
      <value value="100-8" />
   </identifier>
   <identifier>
      <use value="secondary" />
      <label value="Old Identification Number" />
      <system value="urn:uuid:8d79403a-c2cc-11de-8d13-0010c6dffd0f" />
      <value value="100" />
   </identifier>
   <name>
      <use value="usual" />
      <family value="Patient" />
      <given value="John" />
      <prefix value="Mr." />
      <suffix value="Mr." />
   </name>
   <name>
      <use value="old" />
      <family value="harsha" />
      <given value="kumara" />
   </name>
   <name>
      <use value="old" />
      <family value="bob" />
      <given value="alice" />
   </name>
   <name>
      <use value="old" />
      <family value="lisa" />
      <given value="maria" />
   </name>
   <gender value="male" />
   <birthDate value="1975-01-01" />
   <deceasedBoolean value="false" />
   <address>
      <use value="home" />
      <line value="555 Johnson Rd." />
      <line value="Apt. 555" />
      <city value="Indianapolis" />
      <state value="IN" />
      <postalCode value="46202" />
      <country value="USA" />
   </address>
   <address>
      <use value="old" />
      <line value="476/B" />
      <line value="Kahanthota road, Arangala" />
      <city value="COLOMBO" />
      <state value="NA" />
      <postalCode value="10" />
      <country value="SL" />
   </address>
   <active value="true" />
</Patient>



(1) - http://jamesagnew.github.io/hapi-fhir/doc_narrative.html

  • No labels