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