nuVistA/htdocs/RouteRecall.vue

122 lines
4.7 KiB
Vue
Raw Normal View History

2022-09-23 23:59:55 -04:00
<template>
<div>
<div class="card mb-3 shadow">
<div class="card-header">Clinics</div>
<div class="card-body">
<ViewResourceLookup :client="client" v-model:selection="selection" />
</div>
</div>
<div class="card mb-3 shadow">
<div class="card-header d-flex justify-content-between align-items-center">
<span>Recall list ({{patients_lost.length + patients_outstanding.length}})</span>
</div>
<div class="card-body">
<table class="table" style="font-family: monospace;" v-if="patients_lost && patients_lost.length > 0">
<thead>
<tr><th>Lost ({{patients_lost.length}})</th><th>Last appt</th><th>Clinic</th><th>Days</th></tr>
</thead>
<tbody>
<tr v-for="row in patients_lost" :style="{ backgroundColor: strHashHSL(row.Clinic, '90%') }">
<td v-if="production"><router-link :to="'/patient/$' + row.key">{{row.Name}} ${{row.key}}</router-link></td>
2022-09-24 00:42:06 -04:00
<td v-else><router-link :title="strtr_unscramble(row.Name)" :to="'/patient/$' + row.Name.charAt(0) + row.key.slice(-4) + '?name=' + row.Name">{{row.Name}} ${{row.key}}</router-link></td>
2022-09-23 23:59:55 -04:00
<td>{{datefmt(row.TimeLast)}} {{dow[row.TimeLast.getDay()]}}</td>
<td>{{row.Clinic}}</td>
<td>{{Math.round(row.TimeLastDiff/86400000)}}</td>
</tr>
</tbody>
</table>
<table class="table" style="font-family: monospace;" v-if="patients_outstanding && patients_outstanding.length > 0">
<thead>
<tr><th>Outstanding ({{patients_outstanding.length}})</th><th>Next appt</th><th>Clinic</th><th>Days</th></tr>
</thead>
<tbody>
<tr v-for="row in patients_outstanding" :style="{ backgroundColor: strHashHSL(row.Clinic, '90%') }">
<td v-if="production"><router-link :to="'/patient/$' + row.key">{{row.Name}} ${{row.key}}</router-link></td>
2022-09-24 00:42:06 -04:00
<td v-else><router-link :title="strtr_unscramble(row.Name)" :to="'/patient/$' + row.Name.charAt(0) + row.key.slice(-4) + '?name=' + row.Name">{{row.Name}} ${{row.key}}</router-link></td>
2022-09-23 23:59:55 -04:00
<td>{{datefmt(row.TimeNext)}} {{dow[row.TimeNext.getDay()]}}</td>
<td>{{row.Clinic}}</td>
<td>{{Math.round(row.TimeNextDiff/86400000)}}</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</template>
<script>
2022-09-26 18:33:21 -04:00
import { state } from './vistax.mjs';
2022-09-24 00:42:06 -04:00
import { groupByArray, strtr_unscramble, strHashHSL, strftime_vista, debounce } from './util.mjs';
2022-09-23 23:59:55 -04:00
import ViewResourceLookup from './ViewResourceLookup.vue';
function dateonly(date) {
return new Date(date.getFullYear(), date.getMonth(), date.getDate());
}
export default {
components: {
ViewResourceLookup
},
props: {
client: Object
},
data() {
2022-09-26 18:33:21 -04:00
var resources = state.resources;
2022-09-23 23:59:55 -04:00
var today = dateonly(new Date());
return {
selection: resources ? (resources.split(',').filter(x => x) || []) : [],
patients: [],
production: true,
date_begin: new Date(today.getFullYear() - 1, today.getMonth(), today.getDate()),
date_end: new Date(today.getFullYear() + 1, today.getMonth(), today.getDate()),
dow: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat']
};
},
computed: {
patients_lost() {
return this.patients.filter(x => x.TimeLastDiff >= 0).sort((a, b) => b.TimeLastDiff - a.TimeLastDiff);
},
patients_outstanding() {
return this.patients.filter(x => x.TimeNextDiff >= 0).sort((a, b) => b.TimeNextDiff - a.TimeNextDiff);
}
},
watch: {
2022-09-24 00:23:30 -04:00
selection(value) {
this.debounced_selection(value);
}
},
methods: {
strHashHSL,
2022-09-24 00:42:06 -04:00
strtr_unscramble,
2022-09-24 00:23:30 -04:00
datefmt(date) {
return date ? date.toLocaleDateString('en-CA') : '';
}
},
created() {
this.debounced_selection = debounce(async function(value) {
2022-09-26 18:33:21 -04:00
state.resources = value.join(',');
2022-09-23 23:59:55 -04:00
var patients = this.selection.length > 0 ? groupByArray(await this.client.SDEC_CLINLET(this.selection.join('|') + '|', strftime_vista(this.date_begin), strftime_vista(this.date_end)), x => x.HRN) : [], now = new Date(), group, values, appt;
for(var i = patients.length - 1; i >= 0; --i) {
group = patients[i];
group.Name = group.values[0].Name;
group.DOB = group.values[0].DOB;
group.values = values = group.values.map(function(x) { return { Time: new Date(x.ApptDate), Clinic: x.Clinic }; }).sort((a, b) => a.Time - b.Time);
group.TimeLast = (appt = group.values[group.values.length - 1]).Time;
group.TimeLastDiff = now - group.TimeLast;
group.Clinic = appt.Clinic;
if(group.TimeLastDiff < 0) for(var j = 0; j < values.length; ++j) if(values[j].Time - now > 0) {
group.TimeNext = values[j].Time;
group.TimeNextDiff = group.TimeNext - now;
break;
}
}
this.patients = patients.sort((a, b) => a.Time - b.Time);
2022-09-24 00:23:30 -04:00
}, 500);
2022-09-23 23:59:55 -04:00
},
async mounted() {
this.production = (await this.client.serverinfo()).result.production == '1';
}
};
</script>