Skip to content

Commit

Permalink
fixed small bug in mention search
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnLevander committed Aug 5, 2022
1 parent faf3d2a commit 33a092b
Showing 1 changed file with 40 additions and 27 deletions.
67 changes: 40 additions & 27 deletions client/src/views/Patient/Patient.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ function Patient() {
// Highlight the selected circle in both overview and main areas
$('#main_' + reportId).addClass(css);
$('#overview_' + reportId).addClass(css);
$("#occ_radio").prop('checked', true);
const e = new Event("change");
const element = document.querySelector('input[type=radio][name="sort_order"]');
element.dispatchEvent(e);
}

function highlightTextMentions(textMentions, reportText) {
Expand Down Expand Up @@ -133,6 +137,10 @@ function Patient() {
highlightedReportText += textFragments[j];
}

const e = new Event("change");
const element = document.querySelector('input[type=radio][name="sort_order"]');
element.dispatchEvent(e);

return highlightedReportText;
}

Expand Down Expand Up @@ -410,6 +418,7 @@ function Patient() {

// Also highlight the selected report circle in timeline
highlightSelectedTimelineReport(reportId)

});

// Click the report mentioned term to show it in the report text
Expand All @@ -427,7 +436,6 @@ function Patient() {

// Reset button event
$(document).on("click", "#reset", function () {

// Remove highlighted fact
$('.fact').removeClass('highlighted_fact');

Expand Down Expand Up @@ -456,44 +464,49 @@ function Patient() {

function sortMentions(method) {
// Declaring Variables
debugger;
let geek_list, i, run, li, stop;
// Taking content of list as input
geek_list = document.getElementById("mentions");

run = true;
if (geek_list !== null && geek_list !== undefined) {

while (run) {
run = false;
li = geek_list.getElementsByTagName("li");
run = true;

// Loop traversing through all the list items
for (i = 0; i < (li.length - 1); i++) {
stop = false;
if (method === "alphabetically") {
if (li[i].textContent.toLowerCase() >
li[i + 1].textContent.toLowerCase()) {
stop = true;
break;
}
} else if (method === "occurrence") {
if (parseInt(li[i].getAttribute("data-begin")) >
(parseInt(li[i + 1].getAttribute("data-begin")))) {
stop = true;
break;
while (run) {
run = false;
li = geek_list.getElementsByTagName("li");

// Loop traversing through all the list items
for (i = 0; i < (li.length - 1); i++) {
stop = false;
if (method === "alphabetically") {
if (li[i].textContent.toLowerCase() >
li[i + 1].textContent.toLowerCase()) {
stop = true;
break;
}
} else if (method === "occurrence") {
if (parseInt(li[i].getAttribute("data-begin")) >
(parseInt(li[i + 1].getAttribute("data-begin")))) {
stop = true;
break;
}
}
}
}

/* If the current item is smaller than
the next item then adding it after
it using insertBefore() method */
if (stop) {
li[i].parentNode.insertBefore(
li[i + 1], li[i]);
/* If the current item is smaller than
the next item then adding it after
it using insertBefore() method */
if (stop) {
li[i].parentNode.insertBefore(
li[i + 1], li[i]);

run = true;
run = true;
}
}
}

}

$('input[type=radio][name="sort_order"]').change(function () {
Expand Down

0 comments on commit 33a092b

Please sign in to comment.