Skip to content

Commit 4be115f

Browse files
authored
Merge pull request #152 from PIH/MEX-662
MEX-662: add provider name to the printed RX
2 parents fc182e5 + 641f54d commit 4be115f

File tree

2 files changed

+35
-7
lines changed

2 files changed

+35
-7
lines changed

configuration/pih/htmlforms/consult.xml

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,8 @@
332332
jq("#patientAllergies").val(allergies);
333333
}
334334
});
335+
336+
335337
});
336338
</script>
337339

@@ -466,10 +468,22 @@
466468

467469
<section id="encounter-location" sectionTag="fieldset" headerTag="legend" headerStyle="title">
468470
<div class="section-container">
469-
<label>
470-
<uimessage code="pihcore.locationRequired"/>
471-
</label>
472-
<encounterLocation default="SessionAttribute:emrContext.sessionLocationId"/>
471+
<div class="two-columns">
472+
<div>
473+
<label>
474+
<uimessage code="pihcore.locationRequired"/>
475+
</label>
476+
<encounterLocation default="SessionAttribute:emrContext.sessionLocationId"/>
477+
</div>
478+
<div>
479+
<label>
480+
<uimessage code="emr.patientDashBoard.provider" />:
481+
</label>
482+
<span id="encounterProvider">
483+
<lookup complexExpression="#if($encounter) #foreach ($encProv in $encounter.activeEncounterProviders) $ui.format($encProv.provider.person) #end #else $ui.format($user.person) #end" />
484+
</span>
485+
</div>
486+
</div>
473487
</div>
474488
</section>
475489

@@ -2401,6 +2415,7 @@
24012415
}
24022416
const consultDate = moment(consultDateYmd);
24032417
const formattedConsultDate = consultDate.locale('es').format('DD MMM YYYY');
2418+
const provider = $('#encounterProvider').text().trim();
24042419

24052420
// Patient Name
24062421
const givenName = jq(".zl-givenName").html().trim();
@@ -2467,7 +2482,7 @@
24672482
</ifMode>
24682483
<ifMode mode="VIEW" include="true">
24692484
const substringToRemove = '[X] ';
2470-
jq(this).find('.inline-timing').children('span.value:first-child').each(function() {
2485+
jq(this).find('.inline-timing input:checkbox:checked').each(function() {
24712486
const label = jq(this).text().replace(substringToRemove, '');
24722487
const timingDose = jq(this).next(".value").text();
24732488
timingDoses.push( {
@@ -2499,7 +2514,7 @@
24992514
});
25002515
});
25012516

2502-
printPrescription(formattedConsultDate, patientName, age, diagnoses, prescriptions, patientAllergies);
2517+
printPrescription(formattedConsultDate, patientName, age, diagnoses, prescriptions, patientAllergies, provider);
25032518
});
25042519
});
25052520
</script>

configuration/pih/scripts/global/ces.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ function setUpPlanSection(
281281
* One is a library that manipulates PDFs. See: https://pdf-lib.js.org/
282282
* The other is a library that supports printing PDFs directly using the generated PDF output. See: https://printjs.crabbly.com/
283283
*/
284-
async function printPrescription(formattedConsultDate, patientName, age, diagnoses, prescriptions, allergies) {
284+
async function printPrescription(formattedConsultDate, patientName, age, diagnoses, prescriptions, allergies, provider) {
285285

286286
// Load in the PDF template
287287
const templateUrl = emr.resourceLink('file', 'configuration/pih/images/recetas-template.pdf');
@@ -320,6 +320,13 @@ async function printPrescription(formattedConsultDate, patientName, age, diagnos
320320
// color: PDFLib.rgb(1.0,0.59608, 0.0),
321321
// })
322322

323+
page.drawText(provider ? provider : '', {
324+
x: 285,
325+
y: 95,
326+
size: pageFontSize,
327+
font: pageFont
328+
});
329+
323330
prescriptions.forEach( p => {
324331
let drugNameLines = splitToLines(p.drugName ?? '', 35);
325332
let instructionLines = splitToLines(p.instructions ?? '', 35);
@@ -337,6 +344,12 @@ async function printPrescription(formattedConsultDate, patientName, age, diagnos
337344
// reset the row position
338345
rowPosition = 420;
339346
doseRowPosition = rowPosition;
347+
page.drawText( provider ? provider : '', {
348+
x: 285,
349+
y: 95,
350+
size: pageFontSize,
351+
font: pageFont
352+
});
340353
}
341354

342355
for ( var i = 0; i < maxlines; i++ ) {

0 commit comments

Comments
 (0)