Skip to content

Commit

Permalink
feat(medical): patient checkin report complete
Browse files Browse the repository at this point in the history
This commit finalizes and completes the patient checkin report.  The
report shows patient checkins over time, with a nice header to give
information about both the enterprise and the patient in question.

Closes #522.
  • Loading branch information
Jonathan Niles committed Aug 4, 2016
1 parent 21efcae commit f1d629c
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 21 deletions.
1 change: 0 additions & 1 deletion server/config/interceptors.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ exports.handler = function handler(error, req, res, next) {

// check if it is a database error and format the proper description if so.
if (error.sqlState) {
console.log('error:', error);
error = new BadRequest(map[error.code]);
}

Expand Down
53 changes: 35 additions & 18 deletions server/controllers/medical/reports/checkins.handlebars
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,34 @@
<title>{{translate "PATIENT_RECORDS.CHECK_IN.TITLE"}}</title>
<link href="{{absolutePath}}/css/bhima-bootstrap.css" rel="stylesheet">
<link href="{{absolutePath}}/vendor/components-font-awesome/css/font-awesome.css" rel="stylesheet">
<meta charset="utf-8" />
<meta charset="utf-8" />
<style>
.table-report{
.table-report {
font-size: 0.8em;
}
.table-report tr td,
.table-report tr th {
padding : 1px;
.table-report > thead > th {
font-size: 1.2em;
}
.table-report > tbody > tr > td,
.table-report > tbody > tr > th,
.table-report > thead > tr > th {
padding : 2px;
}
.table-report {
margin-bottom : 0;
}
.table-report > tbody > tr > td,
.table-report > tbody > tr > th {
border: 1px solid #ddd;
}
.table-report > thead > tr > th {
border-bottom : 1px solid #000;
}
</style>
</head>
Expand Down Expand Up @@ -53,8 +72,7 @@

<!-- Report Metadata -->
<div class="col-xs-6 text-right">
<div><strong>{{translate "PATIENT_RECORDS.CHECK_IN.REPORT_TITLE"}}</strong></div>
<div><i class="fa fa-hospital-o"></i> {{metadata.enterprise.name}}</div>
<div><strong><i class="fa fa-hospital-o"></i> {{metadata.enterprise.name}}</strong></div>
<div>{{metadata.enterprise.location}}</div>
<div><i class="fa fa-calendar"></i> {{translate "REPORT.PRODUCED_ON"}} {{timestamp metadata.timestamp}}</div>
<div><i class="fa fa-user"></i> {{translate "REPORT.PRODUCED_BY"}} {{metadata.user.username}}</div>
Expand All @@ -67,7 +85,7 @@
</section>

<section>
<table class="table table-bordered table-condensed table-report">
<table class="table table-condensed table-report">
<thead>
<tr class="text-capitalize">
<th class="text-center"><i class="fa fa-bookmark-o"></i></th>
Expand All @@ -81,9 +99,9 @@
<!-- initial patient registration -->
<tr>
<th class="text-center">{{patient.year}}</th>
<td>{{date patient.registration_date}}</td>
<td>{{translate "FORM.LABELS.DATE_REGISTRATION"}}</td>
<td>{{patient.displayName}}</td>
<td class="text-center">{{date patient.registration_date}}</td>
<td class="text-center">{{translate "FORM.LABELS.DATE_REGISTRATION"}}</td>
<td class="text-center">{{patient.displayName}}</td>
</tr>

<!-- print a row for each checkin -->
Expand All @@ -92,15 +110,15 @@
{{#if @first}}
<tr>
<th rowspan="{{records.length}}" class="text-center">{{year}}</th>
<td>{{timestamp this.start_date}}</td>
<td>{{translate "PATIENT_RECORDS.CHECK_IN.TITLE"}}</td>
<td>{{this.displayName}}</td>
<td class="text-center">{{date this.start_date}}</td>
<td class="text-center">{{translate "PATIENT_RECORDS.CHECK_IN.TITLE"}}</td>
<td class="text-center">{{this.displayName}}</td>
</tr>
{{else}}
<tr>
<td>{{timestamp this.start_date}}</td>
<td>{{translate "PATIENT_RECORDS.CHECK_IN.TITLE"}}</td>
<td>{{this.displayName}}</td>
<td class="text-center">{{date this.start_date}}</td>
<td class="text-center">{{translate "PATIENT_RECORDS.CHECK_IN.TITLE"}}</td>
<td class="text-center">{{this.displayName}}</td>
</tr>
{{/if}}
{{/each}}
Expand All @@ -112,6 +130,5 @@
</tr>
{{/each}}
</table>
<p class="text-right">{{translate "FORM.LABELS.TOTAL"}} {{total}}</p>
</section>
</body>
8 changes: 6 additions & 2 deletions server/lib/template.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
const exphbs = require('express-handlebars');
const numeral = require('numeral');

// this is very cheeky
const moment = require('moment');

const formatDollar = '$0,0.00';
Expand All @@ -35,7 +34,8 @@ const hbs = exphbs.create({
age : age,
uppercase : uppercase,
lowercase : lowercase,
sum : sum
sum : sum,
add : add
}
});

Expand Down Expand Up @@ -93,6 +93,10 @@ function lowercase(value) {
return String(value).toLowerCase();
}

function add(a, b) {
return a + b;
}

/**
* @function sum
* @desc This function is responsible to calculate the sum of an array given
Expand Down

0 comments on commit f1d629c

Please sign in to comment.