Print Patient Name on Impress

Hi,

Is there a way to print the patient’s name, Patient ID, Date of Birth and sex on the impress?

Thanks

I presume you mean the COA when you say Impress. You will need to develop a senaite addon and create your own custom COA. This tells you how to go about: GitHub - senaite/senaite.impress: HTML to PDF Rendering Engine for SENAITE

Once you have your own template and view, you can create a method in the view to provide any patient data you require which will be called from inside the template where you can use that data.

1 Like

Hi Mike,
Thanks for your reply. I have tried like that:

I have created a method at …/bika/lims/content/client.py

from Products.Archetypes.public import *
from Products.ATContentTypes.content import schemata
from Products.ATContentTypes.content import folder

class Patient(folder.ATFolder):
    schema = schemata.ATContentTypeSchema.copy() + Schema((
        StringField('patient_id',
            required=True,
            searchable=True,
            widget=StringWidget(
                label='Patient ID',
                description='Enter the patient ID',
            ),
        ),
        StringField('first_name',
            required=True,
            searchable=True,
            widget=StringWidget(
                label='First Name',
                description='Enter the patient\'s first name',
            ),
        ),
        StringField('middle_name',
            searchable=True,
            widget=StringWidget(
                label='Middle Name',
                description='Enter the patient\'s middle name',
            ),
        ),
        StringField('last_name',
            required=True,
            searchable=True,
            widget=StringWidget(
                label='Last Name',
                description='Enter the patient\'s last name',
            ),
        ),
        StringField('sex',
            required=True,
            searchable=True,
            widget=SelectionWidget(
                label='Sex',
                description='Select the patient\'s sex',
                vocabulary=[
                    ('male', 'Male'),
                    ('female', 'Female'),
                    ('other', 'Other'),
                ],
            ),
        ),
        DateField('date_of_birth',
            required=True,
            searchable=True,
            widget=CalendarWidget(
                label='Date of Birth',
                description='Select the patient\'s date of birth',
            ),
        ),
    ))

    def get_full_name(self):
        # Create the full name from first name, middle name, and last name
        parts = [self.getField('first_name').get(self), self.getField('middle_name').get(self), self.getField('last_name').get(self)]
        return " ".join(filter(None, parts))

Then I have modified the COA report template Default.pt to display the patient’s name by adding the following code:

<tr>
    <td>Patient Name:</td>
    <td tal:content="client/first_name"></td>
</tr>

I could not be successful. Can you correct me? Thanks

Were you able to get this to work? If you were able to get this to work, how did you manage to do so?

@mikemets , @ronaldm , Mike and Ronald, any insight or how to help on how to get the patient name on the report?

I have changed only that file as;

~/senaitelims/eggs/cp27mu/senaite.impress-2.4.0-py2.7.egg/senaite/impress/templates/reports/Default.pt


              <!-- Left Table -->
              <table class="table table-sm table-condensed">
               <!-- Patient Name -->

                <tr>
                  <td class="label" i18n:translate="">
                    <div>
                      <strong>Ad Soyad</strong>
                    </div>
                    <div>
                      <small>Name Surname</small>
                    </div>
                  </td>
            <td> <a tal:content="model/PatientFullName/firstname"/></td>

@ngslabex thanks a lot. I was able to get the patient name to print.
Do you know how I can get the patient date of birth and patient sex?
Thanks for the help

        <td> <a tal:content="python:view.to_localized_time(model.DateOfBirth, long_format=0)" /><a> / </a><a tal:condition="python: model.Sex == 'm'" tal:content="python: 'Male'" /><a tal:condition="python: model.Sex == 'f'" tal:content="python: 'Female'" /><a tal:condition="python: model.Sex == ''" tal:content="python: 'Undefined'" /></td>

You can add that code to senaite/impress/templates/reports/Default.pt file. I hope it helps to you.

@ngslabex thanks much, that worked perfectly.
I appreciate the help.

1 Like

thanks @ngslabex this was helpful to me too - just sharing my adapted report template in case it saves anyone else time working this out (NB: I am using senaite.patient)

<tal:report define="model python:view.model;">

  <!-- REPORT CONTROLS -->
  <tal:t replace="structure python:view.render_controls(context, **options)" />

  <!-- REPORT JS -->
  <tal:t replace="structure python:view.render_js(context, **options)" />

  <!-- REPORT CSS -->
  <tal:t replace="structure python:view.render_css(context, **options)" />

  <!-- NEW REPORT HEADER -->
  <!-- Header Table -->
  <div class="row section-header no-gutters">
  <!-- Header Left -->
  <div class="col-2 text-left">
  <img class="logo image-fluid" style="object-fit:contain; height:60px; margin-top:0px; margin-left:15px" src="https://subdomain.domain.tld/site/site_logo.png" alt="Site logo" title="Site logo">
  </img>
  </div>
  <div class="col-10 text-left">
  <!-- Header Right -->
  <h1><strong>The Title of the Laboratory</strong></h1>
  <h1>Analysis Report</h1>
  </div>
  </div>

  <!-- REPORT INFO -->
  <tal:t replace="structure python:view.render_info(context, **options)" />

  <!-- REPORT ALERTS -->
  <tal:t replace="structure python:view.render_alerts(context, **options)" />

  <!-- NEW PATIENT INFO -->
    <div class="row section-summary no-gutters">
  <div class="w-100">
  <h1>Patient Information</h1>
  <table class="table table-sm table-condensed">
  <tr>
  <td class="label" i18n:translate="">
    <div>Patient MRN</div>
  </td>
  <td>
    <a tal:content="model/MedicalRecordNumber/value"/>
  </td>
  </tr>
  <tr>
  <td class="label" i18n:translate="">
    <div>Patient Full Name</div>
  </td>
  <td>
    <a tal:content="model/getPatientFullName"/>
  </td>
  </tr>
  <tr>
  <td class="label" i18n:translate="">
  <div>Age</div>
  </td>
  <td>
  <a tal:content="python: '%d years, %d months' % (model.getAge().years, model.getAge().months)"/>
  </td>
  </tr>
  <tr>
  <td class="label" i18n:translate="">
    <div>Patient Date Of Birth</div>
  </td>
  <td>
    <a tal:content="python: model.getDateOfBirth()[0].strftime('%d/%m/%Y')" />
    <a tal:condition="python: model.getDateOfBirthEstimated()" tal:content="python: '(NB: estimated from age)'"/>
  </td>
  </tr>
  <tr>
  <td class="label" i18n:translate="">
    <div>Patient Sex</div>
  </td>
  <td>
    <a tal:condition="python: model.Sex == 'm'" tal:content="python: 'Male'" />
    <a tal:condition="python: model.Sex == 'f'" tal:content="python: 'Female'" />
    <a tal:condition="python: model.Sex == ''" tal:content="python: 'Unspecified'" />
  </td>
  </tr>
  <tr>
  <td class="label" i18n:translate="">
    <div>Patient Address</div>
  </td>
  <td>
    <a tal:content="model/PatientAddress"/>
  </td>
  </tr>
  </table>
  </div>
  </div>
  
  <!-- REPORT RESULTS -->
  <tal:t replace="structure python:view.render_results(context, **options)" />

  <!-- RESULTS INTERPRETATION -->
  <tal:t replace="structure python:view.render_interpretations(context, **options)" />

  <!-- SAMPLE REMARKS -->
  <tal:t replace="structure python:view.render_remarks(context, **options)" />

  <!-- REPORT SUMMARY -->
  <tal:t replace="structure python:view.render_summary(context, **options)" />
  
  <!-- REPORT ATTACHMENTS -->
  <tal:t replace="structure python:view.render_attachments(context, **options)" />

  <!-- REPORT SIGNATURES -->
  <tal:t replace="structure python:view.render_signatures(context, **options)" />

  <!-- REPORT DISCREETER -->
  <tal:t replace="structure python:view.render_discreeter(context, **options)" />

  <!-- REPORT FOOTER -->
  <tal:t replace="structure python:view.render_footer(context, **options)" />

</tal:report>
1 Like