From c15bfb1825ffcbc5923a85484bf37e6286d58104 Mon Sep 17 00:00:00 2001 From: charclayt <ukfeature@gmail.com> Date: Thu, 13 Apr 2023 14:40:20 +0100 Subject: [PATCH] Index datatable modification Added new column for 'recommended referral' ML algorithm will recommend referral based on row data and output will be displayed here. Added priority to recommended referral and referral columns Now both columns will always be displayed at the end of the datatable, no matter the screen size. --- src/data.js | 10 +++++++--- src/index.html | 4 ++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/data.js b/src/data.js index a88371f7..edfbe2e5 100644 --- a/src/data.js +++ b/src/data.js @@ -92,15 +92,20 @@ function displayDataTable(data){ "defaultContent": "NULL"}, { "data": "patient_bmi", "defaultContent": "NULL"}, + { "data": "referral_recommended", // Column for ML algorithm -> To display whether a referral is recommended. + "defaultContent": "N/A"}, { "data": "patient_referral", "defaultContent": "NULL"}, - // { data: "user_id" } ], aoColumnDefs: [{ - targets: 17, + targets: 18, mRender: function (data, type, full, meta) { return '<input type="checkbox" class="minimal" onchange="checkReferral(this)" id='+ full.patient_id +''+ (data ? ' checked' : '') +'/>'; } + },{ + responsivePriority: 1, targets: 18 // Adds priority of 1 to referral column -> Will be last displayed due to responsiveness + },{ + responsivePriority: 2, targets: 17 // Adds priority of 2 to recommended referral column }] }).on( 'select', function ( e, dt, type, indexes ) { //if not responsive view launch responsive modal @@ -121,7 +126,6 @@ function checkReferral(data){ let sqlQuery = `UPDATE fid_patients SET patient_referral = ${checked} WHERE patient_id = ${column_id}`; sqlRequest.query(sqlQuery, function(err,data) { if (err) console.log(err); - sql.close(); }); diff --git a/src/index.html b/src/index.html index 4a13ed9a..bca52b14 100644 --- a/src/index.html +++ b/src/index.html @@ -126,6 +126,10 @@ <i class="datatable-sort-icon fas fa-arrow-up" data-mdb-sort="bmi"></i> bmi </th> + <th style="cursor: pointer;" scope="col"> + <i class="datatable-sort-icon fas fa-arrow-up" data-mdb-sort="referral_recommended"></i> + referral recommended + </th> <th style="cursor: pointer;" scope="col"> <i class="datatable-sort-icon fas fa-arrow-up" data-mdb-sort="referral"></i> referral -- GitLab