Skip to content

Commit

Permalink
Fix missing patient Id in demograhics widget (openemr#5803)
Browse files Browse the repository at this point in the history
* Fix missing patient Id in demograhics widget

* - change to allow up to 3 id photos
- remove file name uuid from rendering

* - fix event selector for persisting widget toggle states
  • Loading branch information
sjpadgett authored Oct 3, 2022
1 parent 262b066 commit c98ed42
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 12 deletions.
26 changes: 14 additions & 12 deletions interface/patient_file/summary/demographics.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,22 +140,25 @@ function pic_array($pid, $picture_directory)
return ($pics);
}

// Get the document ID of the first document in a specific catg.
function get_document_by_catg($pid, $doc_catg)
// Get the document ID's in a specific catg.
// this is only used in one place, here for id photos
function get_document_by_catg($pid, $doc_catg, $limit = 1)
{
$result = array();
$results = null;

if ($pid and $doc_catg) {
$result = sqlQuery("SELECT d.id, d.date, d.url
$query = sqlStatement("SELECT d.id, d.date, d.url
FROM documents AS d, categories_to_documents AS cd, categories AS c
WHERE d.foreign_id = ?
AND cd.document_id = d.id
AND c.id = cd.category_id
AND c.name LIKE ?
ORDER BY d.date DESC LIMIT 1", array($pid, $doc_catg));
ORDER BY d.date DESC LIMIT ?", array($pid, $doc_catg, $limit));
}

return ($result['id'] ?? false);
while ($result = sqlFetchArray($query)) {
$results[] = $result['id'];
}
return ($results ?? false);
}

function portalAuthorized($pid)
Expand Down Expand Up @@ -235,8 +238,7 @@ function image_widget($doc_id, $doc_catg)
" <img src = '$web_root" .
"/controller.php?document&retrieve&patient_id=" . attr_url($pid) . "&document_id=" . attr_url($doc_id) . "&as_file=false'" .
" $image_width alt='" . attr($doc_catg) . ":" . attr($image_file) . "'> </a> </td> <td class='align-middle'>" .
text($doc_catg) . '<br />&nbsp;' . text($image_file) .
"</td>";
text($doc_catg) . "</td>";
} else {
$to_url = "<td> <a href='" . $web_root . "/controller.php?document&retrieve" .
"&patient_id=" . attr_url($pid) . "&document_id=" . attr_url($doc_id) . "'" .
Expand Down Expand Up @@ -777,7 +779,7 @@ function openReminderPopup() {

// Update the User's visibility setting when the card header is clicked
function cardTitleButtonClickListener() {
const buttons = document.querySelectorAll(".card-title button[data-toggle='collapse']");
const buttons = document.querySelectorAll(".card-title a[data-toggle='collapse']");
buttons.forEach((b) => {
b.addEventListener("click", (e) => {
updateUserVisibilitySetting(e);
Expand Down Expand Up @@ -948,7 +950,7 @@ function setMyPatient() {
// Get the document ID of the patient ID card if access to it is wanted here.
$idcard_doc_id = false;
if ($GLOBALS['patient_id_category_name']) {
$idcard_doc_id = get_document_by_catg($pid, $GLOBALS['patient_id_category_name']);
$idcard_doc_id = get_document_by_catg($pid, $GLOBALS['patient_id_category_name'], 3);
}
?>
<div class="main mb-5">
Expand Down Expand Up @@ -1359,7 +1361,7 @@ function setMyPatient() {
'card_text_color' => $card->getTextColorClass(),
'forceAlwaysOpen' => !$card->canCollapse(),
'btnLabel' => $btnLabel,
'btnLink' => 'test',
'btnLink' => "javascript:$('#patient_portal').collapse('toggle')",
];

echo $t->render($card->getTemplateFile(), array_merge($card->getTemplateVariables(), $viewArgs));
Expand Down
7 changes: 7 additions & 0 deletions templates/patient/card/photo.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,12 @@
{{ imageWidget(p, patientPhotoCategoryName)}}
{% endfor %}

{% endif %}
{% if idCardDocID %}

{% for p in idCardDocID %}
{{ imageWidget(p, patientIDCategoryID)}}
{% endfor %}

{% endif %}
{% endblock %}

0 comments on commit c98ed42

Please sign in to comment.