Skip to content

Commit

Permalink
GSoC 2018 Project: PDF generator code for Patient Report section (#1165)
Browse files Browse the repository at this point in the history
* PDF generator code for Patient Report section

* Procedure orders PDF generation code

* PDF generation code for clinical instructions, issues, procedure orders added and new code for history

* Added support for other sections and removed Demographics error

* Improved date comparison, removed bugs and added other features
  • Loading branch information
2208Abhinav authored and aethelwulffe committed Jan 22, 2019
1 parent 9e2b609 commit 3f8b1d3
Show file tree
Hide file tree
Showing 17 changed files with 2,066 additions and 1 deletion.
7 changes: 6 additions & 1 deletion interface/patient_file/report/patient_report.php
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,7 @@ function show_date_fun(){
</table>
<br>
<input type="button" class="genreport" value="<?php xl('Generate Report','e'); ?>" />&nbsp;
<input type="button" class="genpdfrep" value="<?php xl('Download PDF','e'); ?>" />
<input type="button" class="genpdfrep" value="<?php xl('Download PDF','e'); ?>" />&nbsp;
<br><br><br>

<span class="bold"><?php xl('Documents','e'); ?></span>:<br>
Expand Down Expand Up @@ -490,6 +490,11 @@ function show_date_fun(){
// check/uncheck all Forms of an encounter
$(".encounter").click(function() { SelectForms($(this)); });

$('.pdf_proto').click(function() {
$('#report_form').attr('action', '../../../modules/pdf_generator/selector.php');
$('#report_form').submit();
});

$(".generateCCR").click(
function() {
if(document.getElementById('show_date').checked == true){
Expand Down
69 changes: 69 additions & 0 deletions modules/pdf_generator/report/billing.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
<?php
/**
* The purpose of this code is to get the patient billing data
* in a formatted manner and store it in a single variable $content_billing.
* The content of this variable will be printed in the PDF if required.
*
*
* LICENSE: This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0
* See the Mozilla Public License for more details.
* If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
*
* @package Librehealth EHR
* @author Abhinav([email protected])
* @link http://librehealth.io
*
* Please help the overall project by sending changes you make to the author and to the LibreEHR community.
*
*/

$content_billing = '<span style="font-size:25px;font-family: Arial, sans-serif;">' . xlt("Billing Information") . ':<br></span>';
if (count($ar['patient_encounter']) > 0) {
$billings = array();
$content_billing .= "<table>";
$content_billing .= '<tr><td width="400"><b>' . xlt("Code") . '</b></td><td><b>' . xlt("Fee") . '</b></td></tr>';
$total = 0.00;
$copays = 0.00;
foreach ($ar['patient_encounter'] as $be) {
$ta = explode(":",$be);
$billing = getPatientBillingEncounter($pid,$ta[1]);
$billings[] = $billing;
foreach ($billing as $b) {
$content_billing .= "<tr>";
$content_billing .= "<td>";
$content_billing .= $b['code_type'] . ": " . $b['code'] . "&nbsp;". $b['modifier'] . "&nbsp;&nbsp;&nbsp;" . $b['code_text'] . "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
$content_billing .= "</td>";
$content_billing .= "<td>";
$content_billing .= oeFormatMoney($b['fee']);
$content_billing .= "</td>";
$content_billing .= "</tr>";
$total += $b['fee'];
if ($b['code_type'] == "COPAY") {
$copays += $b['fee'];
}
}
}
$content_billing .= "<tr><td>&nbsp;</td></tr>";
$content_billing .= "<tr><td><b>" . xlt("Sub") . "-" . xlt("Total") . "</b></td><td>" . oeFormatMoney($total + abs($copays)) . "</td></tr>";
$content_billing .= "<tr><td><b>" . xlt("Pid") . "</b></td><td>" . oeFormatMoney(abs($copays)) . "</td></tr>";
$content_billing .= "<tr><td><b>" . xlt("Total") . "</b></td><td>" . oeFormatMoney($total) . "</td></tr>";
$content_billing .= "</table>";
}
else {
pdfPatientBilling($pid);
}
function pdfPatientBilling($pid) {
global $content_billing;
$res = sqlStatement("SELECT * FROM billing WHERE pid='$pid' ORDER BY date");
while($result = sqlFetchArray($res)) {
$content_billing .= "<span><b>" . oeFormatSDFT(strtotime($result{"date"})) . " : </b></span>";
$content_billing .= "<span>(".$result{"code_type"}.") ";
$content_billing .= $result['code_type'] == 'COPAY' ? oeFormatMoney($result['code']) : $result['code'];
$content_billing .= " - ". wordwrap($result['code_text'], 70, "\n", true)."</span>";
$content_billing .= "<br>";
}
}

$pdf->WriteHTML($content_billing, true, false, false, false, '');

?>
49 changes: 49 additions & 0 deletions modules/pdf_generator/report/clinical_instructions.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?php
/**
* The purpose of this code is to get the patient insurance data
* in a formatted manner and store it in a single variable $content_instructions.
* The content of this variable will be printed in the PDF if required.
*
*
* LICENSE: This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0
* See the Mozilla Public License for more details.
* If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
*
* @package Librehealth EHR
* @author Abhinav([email protected])
* @link http://librehealth.io
*
* Please help the overall project by sending changes you make to the author and to the LibreEHR community.
*
*/

foreach($_POST as $instr_name => $instr_value){
if(substr($instr_name, 0, 21) == "clinical_instructions")
{
pdfClinicalInstructinsData($pid, $instr_value, $_SESSION['authUser']);
}
}
function pdfClinicalInstructinsData($pid, $encounter, $user){
global $content_instructions;

$instructions_query = sqlStatement("SELECT * FROM form_clinical_instructions WHERE pid='$pid' AND encounter='$encounter' AND user='$user'");
while($instructions_data = sqlFetchArray($instructions_query))
{
$content_instructions .= '<span style="font-size:25px;font-family: Arial, sans-serif;">' . xlt("Clinical Instructions") . ':</span>';
$instructions_date = explode(' ', $instructions_data['date']);
$content_instructions .= '<br style="line-height:15px;">(' . $instructions_date[0] . ')<br style="line-height:15px;">';
$content_instructions .= '<table border="0.5">';
$content_instructions .= '<tr><td align="center" style="height:15px;">' . xlt("Instructions") . '</td></tr>';
$content_instructions .= '<tr><td align="center" style="height:15px;">' . $instructions_data['instruction'] . '</td></tr>';
$content_instructions .= "</table><br><br>";
}
}
if($content_instructions)
{
$pdf->Ln(2);
$pdf->Line(10, $pdf->GetY(), $pdf->GetPageWidth()-10, $pdf->GetY());
$pdf->Ln(2);
$pdf->WriteHTML($instructions_content, true, false, false, false, '');
}

?>
30 changes: 30 additions & 0 deletions modules/pdf_generator/report/communications.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php
/**
* The purpose of this code is to get the patient communication data
* in a formatted manner and store it in a single variable $content_comu.
* The content of this variable will be printed in the PDF if required.
*
*
* LICENSE: This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0
* See the Mozilla Public License for more details.
* If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
*
* @package Librehealth EHR
* @author Abhinav([email protected])
* @link http://librehealth.io
*
* Please help the overall project by sending changes you make to the author and to the LibreEHR community.
*
*/

$content_comu .= '<span style="font-size:25px;font-family: Arial, sans-serif;">' . xlt("Patient Communication sent") . ':<br></span>';
$sql="SELECT concat( 'Messsage Type: ', batchcom.msg_type, ', Message Subject: ', batchcom.msg_subject, ', Sent on:', batchcom.msg_date_sent ) AS batchcom_data, batchcom.msg_text, concat( users.fname, users.lname ) AS'user_name' FROM `batchcom` JOIN `users` ON users.id = batchcom.sent_by WHERE batchcom.patient_id='$pid'";

$result = sqlStatement($sql);
while ($row=sqlFetchArray($result)) {
$content_comu .= $row{'batchcom_data'}.", ".xlt("By").": ".$row{'user_name'}."<br>".xlt("Text").":<br> ".$row{'msg_txt'}."<br>";
}

$pdf->WriteHTML($content_comu, true, false, true, false, '');

?>
Loading

0 comments on commit 3f8b1d3

Please sign in to comment.