# How to print an encounter details? - OpenMRS 2x and RefApp 2x

**URL:** <https://talk.openmrs.org/t/how-to-print-an-encounter-details-openmrs-2x-and-refapp-2x/10616>\
**Category:** Implementing\
**Created:** [March 18, 2017, 9:01pm UTC](https://talk.openmrs.org/t/how-to-print-an-encounter-details-openmrs-2x-and-refapp-2x/10616 "2017-03-18T21:01:51Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![hpardess](https://talk.openmrs.org/letter_avatar/hpardess/32/5_5575768a8748004e209b776fc1b2916d.png) [@hpardess](https://talk.openmrs.org/u/hpardess)\
**Post date:** [March 18, 2017, 9:01pm UTC](https://talk.openmrs.org/t/how-to-print-an-encounter-details-openmrs-2x-and-refapp-2x/10616/1 "2017-03-18T21:01:51Z")

</div>

Hi,

How can I print the Transfer, Discharge, Lab Test or vitals encounters of a patient patient in any visit (either past or active visit). The scenario is: when a patient is transferred from one ward to another, the provider will record the transfer encounter and also print a transfer slip for that patient to show it in destination ward. Also when a patient is discharged, the patient will get a discharge slip to show it in exit counter to close his file.

 ![](https://talk.openmrs.org/uploads/default/original/2X/9/99714e6bb417ae8c375f4f1f8058af7c86a032b5.jpg)

@dkayiwa: thank you for help in extending [XReports 1.9](https://talk.openmrs.org/t/best-approach-for-having-patient-id-card-in-openmrs-2x-and-refapp-2x/10304/41) functionality to be able add any report to patient dashboard. Could you please extend the json to handle the printing of encounters based on type.

In report json (Extension field), if we define the encounter type then for each encounter in all visits of a patient the print icon should appear as shown in attached image. by clicking on print icon, patient-id and encounter-id should be passed to report as parameter.

Regards, Hameedullah Pardess

---

<div class="post-metadata">

**Author:** ![dkayiwa](https://talk.openmrs.org/user_avatar/talk.openmrs.org/dkayiwa/32/179_2.png) [@dkayiwa](https://talk.openmrs.org/u/dkayiwa)\
**Post date:** [March 19, 2017, 11:59am UTC](https://talk.openmrs.org/t/how-to-print-an-encounter-details-openmrs-2x-and-refapp-2x/10616/2 "2017-03-19T11:59:33Z")

</div>

Can you create a ticket for this?

---

<div class="post-metadata">

**Author:** ![hpardess](https://talk.openmrs.org/letter_avatar/hpardess/32/5_5575768a8748004e209b776fc1b2916d.png) [@hpardess](https://talk.openmrs.org/u/hpardess)\
**Post date:** [March 19, 2017, 5:25pm UTC](https://talk.openmrs.org/t/how-to-print-an-encounter-details-openmrs-2x-and-refapp-2x/10616/3 "2017-03-19T17:25:58Z")

</div>

While creating issue, I could not find the XReports in projects list.

---

<div class="post-metadata">

**Author:** ![hpardess](https://talk.openmrs.org/letter_avatar/hpardess/32/5_5575768a8748004e209b776fc1b2916d.png) [@hpardess](https://talk.openmrs.org/u/hpardess)\
**Post date:** [March 19, 2017, 5:33pm UTC](https://talk.openmrs.org/t/how-to-print-an-encounter-details-openmrs-2x-and-refapp-2x/10616/4 "2017-03-19T17:33:03Z")

</div>

To generate a report, i want to select patient id and visit. How can i pass the visit id as parameter to a report?

---

<div class="post-metadata">

**Author:** ![dkayiwa](https://talk.openmrs.org/user_avatar/talk.openmrs.org/dkayiwa/32/179_2.png) [@dkayiwa](https://talk.openmrs.org/u/dkayiwa)\
**Post date:** [March 19, 2017, 8:17pm UTC](https://talk.openmrs.org/t/how-to-print-an-encounter-details-openmrs-2x-and-refapp-2x/10616/5 "2017-03-19T20:17:14Z")

</div>

Which kind of report are you thinking of where you would like to first select a visit id?

---

<div class="post-metadata">

**Author:** ![hpardess](https://talk.openmrs.org/letter_avatar/hpardess/32/5_5575768a8748004e209b776fc1b2916d.png) [@hpardess](https://talk.openmrs.org/u/hpardess)\
**Post date:** [March 22, 2017, 11:18am UTC](https://talk.openmrs.org/t/how-to-print-an-encounter-details-openmrs-2x-and-refapp-2x/10616/6 "2017-03-22T11:18:17Z")

</div>

I would like to print all the encounters of a specific visit of a patient. In this scenario i need to have visit id and join it will all relevant encounters.

---

<div class="post-metadata">

**Author:** ![dkayiwa](https://talk.openmrs.org/user_avatar/talk.openmrs.org/dkayiwa/32/179_2.png) [@dkayiwa](https://talk.openmrs.org/u/dkayiwa)\
**Post date:** [March 22, 2017, 12:04pm UTC](https://talk.openmrs.org/t/how-to-print-an-encounter-details-openmrs-2x-and-refapp-2x/10616/7 "2017-03-22T12:04:35Z")

</div>

Do you have a mockup of how such a report would look like?

---

<div class="post-metadata">

**Author:** ![hpardess](https://talk.openmrs.org/letter_avatar/hpardess/32/5_5575768a8748004e209b776fc1b2916d.png) [@hpardess](https://talk.openmrs.org/u/hpardess)\
**Post date:** [March 22, 2017, 10:37pm UTC](https://talk.openmrs.org/t/how-to-print-an-encounter-details-openmrs-2x-and-refapp-2x/10616/8 "2017-03-22T22:37:18Z")

</div>

My main purpose is to be able list types of encounters in XReport JSON (in Extension value) and a print button should appear for those encounters. When I click on print button then encounterID and PatientID should be send as parameter to the report.

---

<div class="post-metadata">

**Author:** ![dkayiwa](https://talk.openmrs.org/user_avatar/talk.openmrs.org/dkayiwa/32/179_2.png) [@dkayiwa](https://talk.openmrs.org/u/dkayiwa)\
**Post date:** [March 23, 2017, 9:09am UTC](https://talk.openmrs.org/t/how-to-print-an-encounter-details-openmrs-2x-and-refapp-2x/10616/9 "2017-03-23T09:09:40Z")

</div>

Without a mockup, i cant really be sure of what is in your mind. 😄

---

<div class="post-metadata">

**Author:** ![hpardess](https://talk.openmrs.org/letter_avatar/hpardess/32/5_5575768a8748004e209b776fc1b2916d.png) [@hpardess](https://talk.openmrs.org/u/hpardess)\
**Post date:** [March 23, 2017, 8:41pm UTC](https://talk.openmrs.org/t/how-to-print-an-encounter-details-openmrs-2x-and-refapp-2x/10616/10 "2017-03-23T20:41:17Z")

</div>

I want to print Visit Note and Transfer encounters separately. when a patient visits a doctor then end of the visit i should take print out of his visit note and attach it to his physical file. or when patient is transferred to another ward, I should take print out of his transfer encounter and give him to show in another ward to be admitted.

Even if a patient ask for his Visit Note of his old visit then we should be able to print it for patient. Here are the screenshots:

 ![](https://talk.openmrs.org/uploads/default/original/2X/4/4397d6a4c42c2980505073e5168109fe14d6d748.jpg) ![](https://talk.openmrs.org/uploads/default/original/2X/a/ae0cbcece61d64243677dc4c6d9a89018a10ded8.jpg) ![](https://talk.openmrs.org/uploads/default/original/2X/d/d8e02f4ff36ca74261e19f801a1c55b59c3e3e16.jpg)

---

<div class="post-metadata">

**Author:** ![hpardess](https://talk.openmrs.org/letter_avatar/hpardess/32/5_5575768a8748004e209b776fc1b2916d.png) [@hpardess](https://talk.openmrs.org/u/hpardess)\
**Post date:** [March 25, 2017, 6:40pm UTC](https://talk.openmrs.org/t/how-to-print-an-encounter-details-openmrs-2x-and-refapp-2x/10616/11 "2017-03-25T18:40:46Z")

</div>

Ticket is created for this. here is the link [https://issues.openmrs.org/browse/XREP-2](https://issues.openmrs.org/browse/XREP-2)

---

<div class="post-metadata">

**Author:** ![hpardess](https://talk.openmrs.org/letter_avatar/hpardess/32/5_5575768a8748004e209b776fc1b2916d.png) [@hpardess](https://talk.openmrs.org/u/hpardess)\
**Post date:** [March 26, 2017, 1:18pm UTC](https://talk.openmrs.org/t/how-to-print-an-encounter-details-openmrs-2x-and-refapp-2x/10616/12 "2017-03-26T13:18:30Z")

</div>

I am thinking for an alternative way to have print button for the encounter. As much I learned, I should customize all forms such as discharge, vitals, clinical note. Then add print button inside each form like following screenshot,

 ![](https://talk.openmrs.org/uploads/default/original/2X/d/daa4f1229c66f864df5ed0d8e6cde0d51796cdeb.PNG)

`<a target="_blank" href="" style="float: right">Print</a>`

I will set the href value as report URL but this href should be created dynamically `http://qa-refapp.openmrs.org/xreports/runReports.page?patientId={{patient.patientId}}&reportId=5$encounterId={{encounter.id}}`

how can i set the encounterId, patientId and visitId ?

---

<div class="post-metadata">

**Author:** ![hpardess](https://talk.openmrs.org/letter_avatar/hpardess/32/5_5575768a8748004e209b776fc1b2916d.png) [@hpardess](https://talk.openmrs.org/u/hpardess)\
**Post date:** [April 4, 2017, 7:33pm UTC](https://talk.openmrs.org/t/how-to-print-an-encounter-details-openmrs-2x-and-refapp-2x/10616/13 "2017-04-04T19:33:10Z")

</div>

This is what I was asking for

 ![](https://talk.openmrs.org/uploads/default/original/2X/9/9ed8a64b3da4cb075f8aaadeb3357c6bcbcda711.PNG)Currently, I have hard-coded the xreport URL for each encounter type in Coreapps Module.

In future, we can set this report URL in Form Management for each form. Also we should be able to set the print right based on encounter type.

---

<div class="post-metadata">

**Author:** ![hpardess](https://talk.openmrs.org/letter_avatar/hpardess/32/5_5575768a8748004e209b776fc1b2916d.png) [@hpardess](https://talk.openmrs.org/u/hpardess)\
**Post date:** [April 6, 2017, 10:30am UTC](https://talk.openmrs.org/t/how-to-print-an-encounter-details-openmrs-2x-and-refapp-2x/10616/14 "2017-04-06T10:30:42Z")

</div>

@dkayiwa: I have designed reports that need two parameters 1. Encounter ID 2. Patient ID In your old post, you have mentioned that parameters should be passed as in URL Query string. I am also doing same but the report is not printed.

> /openmrs/xreports/reportRunner.page?reportId=3&groupId=3&patientId=7&encounterId=3

> [@Best approach for having Patient ID card in OpenMRS 2x and RefApp 2x](https://talk.openmrs.org/t/best-approach-for-having-patient-id-card-in-openmrs-2x-and-refapp-2x/10304/26):
>
> Go to the settings page as here: [http://qa-refapp.openmrs.org/openmrs/admin/maintenance/settings.list?show=Xreports](http://qa-refapp.openmrs.org/openmrs/admin/maintenance/settings.list?show=Xreports) and set the value of the reportId for “Patient Summary Report Id” You can copy the reportId value from the url for the manage reports page as here: [http://qa-refapp.openmrs.org/openmrs/xreports/report.page?reportId=5&groupId=&](http://qa-refapp.openmrs.org/openmrs/xreports/report.page?reportId=5&groupId=&) I have also just uploaded the module to modulus. This time i was able to login.

but I try to print the report from Home\>XReports\>Run Reports and entered encounterId and patientId, the report is printed correctly. but the patientId and encouterId are not listed in URL Query string.

> /openmrs/xreports/reportRunner.page?reportId=3&groupId=3

---

<div class="post-metadata">

**Author:** ![hpardess](https://talk.openmrs.org/letter_avatar/hpardess/32/5_5575768a8748004e209b776fc1b2916d.png) [@hpardess](https://talk.openmrs.org/u/hpardess)\
**Post date:** [April 6, 2017, 8:44pm UTC](https://talk.openmrs.org/t/how-to-print-an-encounter-details-openmrs-2x-and-refapp-2x/10616/15 "2017-04-06T20:44:05Z")

</div>

@dkayiwa:I have extended the RefApp and I display the print button for each encounter with specific report URL.

 ![](https://talk.openmrs.org/uploads/default/original/2X/5/55a5a00fa2c5ef015c6b155c5e354e0117f14f66.PNG)

But the report printed empty while i press the print button. Although i have all the required parameters in URL

 ![](https://talk.openmrs.org/uploads/default/original/2X/f/f7546fbba99e56d7de7aee729c719f04828e0c10.PNG)

---

<div class="post-metadata">

**Author:** ![dkayiwa](https://talk.openmrs.org/user_avatar/talk.openmrs.org/dkayiwa/32/179_2.png) [@dkayiwa](https://talk.openmrs.org/u/dkayiwa)\
**Post date:** [April 6, 2017, 8:52pm UTC](https://talk.openmrs.org/t/how-to-print-an-encounter-details-openmrs-2x-and-refapp-2x/10616/16 "2017-04-06T20:52:44Z")

</div>

Does this report have a reporting module dataset behind it?

---

<div class="post-metadata">

**Author:** ![hpardess](https://talk.openmrs.org/letter_avatar/hpardess/32/5_5575768a8748004e209b776fc1b2916d.png) [@hpardess](https://talk.openmrs.org/u/hpardess)\
**Post date:** [April 6, 2017, 9:06pm UTC](https://talk.openmrs.org/t/how-to-print-an-encounter-details-openmrs-2x-and-refapp-2x/10616/17 "2017-04-06T21:06:58Z")

</div>

Yeah i have. Here is the screen shots when i run it from Home\>XReports\>Run Reports

 ![](https://talk.openmrs.org/uploads/default/original/2X/7/7d663a8e964e52eec98094546269c0159ce40d42.PNG) ![](https://talk.openmrs.org/uploads/default/original/2X/a/a1d943ebf5fd909360f937606fe80909a37c8882.PNG)

---

<div class="post-metadata">

**Author:** ![hpardess](https://talk.openmrs.org/letter_avatar/hpardess/32/5_5575768a8748004e209b776fc1b2916d.png) [@hpardess](https://talk.openmrs.org/u/hpardess)\
**Post date:** [April 8, 2017, 12:47pm UTC](https://talk.openmrs.org/t/how-to-print-an-encounter-details-openmrs-2x-and-refapp-2x/10616/18 "2017-04-08T12:47:34Z")

</div>

The patientId in XReports is hard-coded. Are we going to do same for all parameters?

> <https://github.com/dkayiwa/openmrs-module-xreports/blob/63f9526cf98e914ac5c4273b4d73d745d42070f4/omod/src/main/java/org/openmrs/module/xreports/page/controller/ReportRunnerPageController.java#L90>

---

<div class="post-metadata">

**Author:** ![hpardess](https://talk.openmrs.org/letter_avatar/hpardess/32/5_5575768a8748004e209b776fc1b2916d.png) [@hpardess](https://talk.openmrs.org/u/hpardess)\
**Post date:** [April 8, 2017, 1:07pm UTC](https://talk.openmrs.org/t/how-to-print-an-encounter-details-openmrs-2x-and-refapp-2x/10616/19 "2017-04-08T13:07:56Z")

</div>

@dkayiwa: I feel this is the right controller that would handle the request for a report with paramenters

> <https://github.com/dkayiwa/openmrs-module-xreports/blob/master/omod/src/main/java/org/openmrs/module/xreports/web/controller/FillParameterFormController.java#L209-L282>

but I is called only on submit action and then redirect the page to show the report.

Better option will be to create different controller which will get parameters in URL Query string and send those parameters to onSubmit() controller to avoid duplication of code.

---

<div class="post-metadata">

**Author:** ![dkayiwa](https://talk.openmrs.org/user_avatar/talk.openmrs.org/dkayiwa/32/179_2.png) [@dkayiwa](https://talk.openmrs.org/u/dkayiwa)\
**Post date:** [April 8, 2017, 6:39pm UTC](https://talk.openmrs.org/t/how-to-print-an-encounter-details-openmrs-2x-and-refapp-2x/10616/20 "2017-04-08T18:39:01Z")

</div>

Are you able to reproduce this at? [qa-refapp.openmrs.org](http://qa-refapp.openmrs.org)

[Next page](https://talk.openmrs.org/t/how-to-print-an-encounter-details-openmrs-2x-and-refapp-2x/10616.md?page=2)
