Skip to content

Commit

Permalink
Portal EASIPRO bug fixes (#5637)
Browse files Browse the repository at this point in the history
- add My Assessments to menu
- logic to collapse table view to show assessment only
- fix screen render

(cherry picked from commit e0879d1)
  • Loading branch information
sjpadgett committed Jul 26, 2022
1 parent 64af072 commit eb6cc4a
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 37 deletions.
53 changes: 30 additions & 23 deletions portal/get_pro.php
Expand Up @@ -23,30 +23,37 @@
$records = Easipro::assessmentsForPatient($pid);

if (!empty($records)) { ?>
<table class="table table-striped">
<tr>
<th><?php echo xlt('Name'); ?></th>
<th><?php echo xlt('Deadline (CST)'); ?></th>
<th><?php echo xlt('Status'); ?></th>
<th>&nbsp;</th>
</tr>
<?php
foreach ($records as $row) {
echo "<tr>";
echo "<td>" . text($row['form_name']) . "</td>";
echo "<td>" . text($row['deadline']) . "</td>";
echo "<td id='asst_status_" . attr($row['assessment_oid']) . "'>" . text($row['status']) . "</td>";
if ($row['status'] == 'ordered') {
echo "<td id='asst_" . attr($row['assessment_oid']) . "'><button class='btn btn-sm btn-primary' onclick=\"startAssessment(this," . attr_js($row['assessment_oid']) . ")\">" . xlt('Start Assessment') . "</button></td>";
} elseif ($row['status'] == 'in-progress') {
echo "<td>" . xlt('Continue Assessment') . "</td>";
} elseif ($row['status'] == 'completed') {
echo "<td><i class='fa fa-check-circle'></i></td>";
<div class="font-weight-bold m-1" onclick="$('.assessment-row').toggleClass('d-none');" role="button">
<i class="font-weight-bold fa fa-eye mr-1"></i><?php echo xlt("My Assessments") ?>
</div>
<div class="table-responsive">
<table class="table table-sm table-striped">
<thead class="assessment-row">
<tr>
<th><?php echo xlt('Name'); ?></th>
<th><?php echo xlt('Deadline (CST)'); ?></th>
<th><?php echo xlt('Status'); ?></th>
<th>&nbsp;</th>
</tr>
</thead><tbody>
<?php
foreach ($records as $row) {
echo "<tr class='assessment-row' id='hide_assessment_" . attr($row['assessment_oid']) . "'>";
echo "<td>" . text($row['form_name']) . "</td>";
echo "<td>" . text($row['deadline']) . "</td>";
echo "<td id='asst_status_" . attr($row['assessment_oid']) . "'>" . text($row['status']) . "</td>";
if ($row['status'] == 'ordered') {
echo "<td id='asst_" . attr($row['assessment_oid']) . "'><button class='btn btn-sm btn-primary' onclick=\"startAssessment(this," . attr_js($row['assessment_oid']) . ")\">" . xlt('Start Assessment') . "</button></td>";
} elseif ($row['status'] == 'in-progress') {
echo "<td>" . xlt('Continue Assessment') . "</td>";
} elseif ($row['status'] == 'completed') {
echo "<td><i class='fa fa-check-circle'></i></td>";
}
echo "</tr>";
}
echo "</tr>";
}
echo "</table>";
echo "</tbody></table></div>";
} else {
echo xlt("No Assessment to Display.");
}
echo "<div id='Content'></div>" ?>
echo "<div class='form-row mx-2' id='ContentTitle'></div>";
echo "<div class='container-lg' id='Content'></div>" ?>
10 changes: 10 additions & 0 deletions portal/home.php
Expand Up @@ -198,6 +198,16 @@ function buildNav($newcnt, $pid, $result)
}
}

if ($GLOBALS['easipro_enable'] && !empty($GLOBALS['easipro_server']) && !empty($GLOBALS['easipro_name'])) {
$navItems[] = [
'url' => '#procard',
'label' => xl('My Assessments'),
'icon' => 'fas fa-file-medical',
'dataToggle' => 'collapse',
'dataType' => 'cardgroup'
];
}

// Build sub nav items

if (!empty($GLOBALS['allow_portal_chat'])) {
Expand Down
30 changes: 16 additions & 14 deletions templates/portal/home.html.twig
Expand Up @@ -32,7 +32,7 @@
webroot_url = webRoot,
tab_mode = true,
isPortal = 1;
function restoreSession() {
return true;
}
Expand Down Expand Up @@ -162,6 +162,11 @@
});
{% endif %}
{% if isEasyPro %}
$("#pro").load("./get_pro.php", {}, function () {
});
{% endif %}
$(".generateDoc_download").click(function () {
$("#doc_form").submit();
});
Expand Down Expand Up @@ -278,10 +283,6 @@
}
{% if isEasyPro %}
$("#pro").load("./get_pro.php", {}, function () {
});
function writeResult(score, stdErr, assessmentOID) {
$.ajax({
url: '../library/ajax/easipro_util.php',
Expand Down Expand Up @@ -312,6 +313,7 @@
success: function (data) {
if (data.DateFinished != '') {
document.getElementById("Content").innerHTML = jsText({{ 'You have finished the assessment.' | xlj }}) + "<br /> " + jsText({{ 'Thank you' | xlj }});
$('.assessment-row').toggleClass('d-none');
document.getElementById("asst_" + assessmentOID).innerHTML = "<i class='fa fa-check-circle'></i>";
document.getElementById("asst_status_" + assessmentOID).innerHTML = "completed";
$.ajax({
Expand All @@ -333,16 +335,16 @@
var screen = "";
for (var j = 0; j < data.Items[0].Elements.length; j++) {
if (typeof (data.Items[0].Elements[j].Map) == 'undefined') {
screen = `<div style="height: 30px>${data.Items[0].Elements[j].Description}</div>`
screen = screen + `<label class="font-weight-bolder mx-1">${data.Items[0].Elements[j].Description}</label>`
} else {
for (var k = 0; k < data.Items[0].Elements[j].Map.length; k++) {
screen = `<div style="height: 50px"><input type="button" class="btn-submit" id="${data.Items[0].Elements[j].Map[k].Value}" name="${data.Items[0].Elements[j].Map[k].ItemResponseOID}" value="${data.Items[0].Elements[j].Map[k].Description}" onclick=selectResponse(this,${assessmentOID}) /></div>`;
screen = screen + `<div class="form-row"><input type="button" class='form-control' id="${data.Items[0].Elements[j].Map[k].Value}" name="${data.Items[0].Elements[j].Map[k].ItemResponseOID}" value="${data.Items[0].Elements[j].Map[k].Description}" onclick="selectResponse(this,'${assessmentOID}')" /></div>`;
}
}
}
document.getElementById("Content").innerHTML = screen;
},
error: function (jqXHR, textStatus, errorThrown) { // document.write(jqXHR.responseText + ':' + textStatus + ':' + errorThrown);
error: function (jqXHR, textStatus, errorThrown) {
alert("An error occurred");
}
});
Expand All @@ -362,24 +364,24 @@
dataType: "json",
success: function (data) {
var screen = "";
let title = $("#" + "hide_assessment_" + assessmentOID).closest('tr').children('td:first').text();
document.getElementById("ContentTitle").innerHTML = "<h5>" + jsText(title) + "</h5>";
$('.assessment-row').toggleClass('d-none');
for (var j = 0; j < data.Items[0].Elements.length; j++) {
if (typeof (data.Items[0].Elements[j].Map) == 'undefined') {
screen = `<div style="height: 30px">${data.Items[0].Elements[j].Description}</div>`;
screen = screen + `<label class="font-weight-bolder mx-1">${data.Items[0].Elements[j].Description}</label>`;
} else {
for (var k = 0; k < data.Items[0].Elements[j].Map.length; k++) {
screen = `<div style="height: 50px"><input type="button" class='btn-submit' id="${data.Items[0].Elements[j].Map[k].Value}" name="${data.Items[0].Elements[j].Map[k].ItemResponseOID}" value="${data.Items[0].Elements[j].Map[k].Description}" onclick=selectResponse(this, ${assessmentOID})/></div>`;
screen = screen + `<div class="form-row"><input type="button" class='form-control' id="${data.Items[0].Elements[j].Map[k].Value}" name="${data.Items[0].Elements[j].Map[k].ItemResponseOID}" value="${data.Items[0].Elements[j].Map[k].Description}" onclick="selectResponse(this, '${assessmentOID}')" /></div>`;
}
}
}
document.getElementById("Content").innerHTML = screen;
param.innerHTML = jsText({{ 'Start Assessment' | xlj }});
param.innerHTML = jsText({{ 'Assessment Started' | xlj }});
},
error: function (jqXHR, textStatus, errorThrown) {
param.innerHTML = jsText({{ 'Start Assessment' | xlj }});
// document.write(jqXHR.responseText);
alert("An error occurred");
}
});
Expand Down

0 comments on commit eb6cc4a

Please sign in to comment.