2022-09-22 07:10:08 -04:00
|
|
|
<template>
|
2023-04-29 18:24:19 -04:00
|
|
|
<template v-if="age !== undefined">
|
|
|
|
<div v-if="age == Infinity" class="alert alert-danger">❌ update error</div>
|
|
|
|
<div v-else-if="age >= 90000" class="alert alert-warning">⚠ last updated <template v-if="age < 3600000">{{ts.toLocaleString()}}</template><template v-else>{{ts.toLocaleString()}}</template></div>
|
|
|
|
</template>
|
2023-05-29 18:27:52 -04:00
|
|
|
<div v-if="tag_list.length > 0">
|
|
|
|
<span v-if="filter_array.length > 0" class="tag badge bg-danger" @click="filter = {}">🗑{{filter_array.length}}</span><span v-else class="tag badge">🏷</span>
|
|
|
|
<span v-for="key in tag_list" class="tag badge" :style="{ color: filter[key] ? null : 'rgba(var(--bs-dark-rgb), var(--bs-text-opacity))', backgroundColor: filter[key] ? strHashHSL(key, '50%') : null }" @click="filter[key] ? delete filter[key] : filter[key] = true">{{key.toUpperCase()}}</span>
|
|
|
|
</div>
|
2023-05-03 23:18:54 -04:00
|
|
|
<datalist :id="'datalist-' + uid"><option v-for="item in practitioner_list" :value="item" /></datalist>
|
2022-09-22 07:10:08 -04:00
|
|
|
<table class="table" style="font-family: monospace;" v-if="appointments && appointments.length > 0">
|
|
|
|
<thead>
|
2023-04-25 18:21:32 -04:00
|
|
|
<tr><th style="width: 7rem;">Time</th><th>Clinic</th><th>Patient</th><th>Note</th><th style="width: 16rem;">Assignee</th></tr>
|
2022-09-24 00:12:36 -04:00
|
|
|
</thead>
|
2023-04-25 18:21:32 -04:00
|
|
|
<tbody class="striped">
|
2023-05-29 18:27:52 -04:00
|
|
|
<tr v-for="row in appointments" v-show="(filter_array.length < 1) || (filter_conj(tag_map[row.APPOINTMENTID]))" :class="{ voided: (row.CANCELLED != '0') || (row.NOSHOW != '0') }" :style="{ backgroundColor: strHashHSL(row.RESOURCENAME, '90%') }">
|
2023-04-25 18:21:32 -04:00
|
|
|
<td v-if="row.CANCELLED != '0'" title="Cancelled"><div><span class="emoji">❌</span> {{row.START_TIME.match(/\d\d:\d\d/)[0]}}</div><div class="date">{{row.START_TIME.match(/\w{3} \d+, \d{4}/)[0]}}</div></td>
|
|
|
|
<td v-else-if="row.NOSHOW != '0'" title="No show"><div><span class="emoji">❓</span> {{row.START_TIME.match(/\d\d:\d\d/)[0]}}</div><div class="date">{{row.START_TIME.match(/\w{3} \d+, \d{4}/)[0]}}</div></td>
|
|
|
|
<td v-else-if="row.CHECKOUT" :title="'Checked out ' + row.CHECKOUT"><div><span class="emoji">✅</span> {{row.START_TIME.match(/\d\d:\d\d/)[0]}}</div><div class="date">{{row.START_TIME.match(/\w{3} \d+, \d{4}/)[0]}}</div></td>
|
|
|
|
<td v-else-if="row.CHECKIN" :title="'Checked in ' + row.CHECKIN"><div><span class="emoji">✔</span> {{row.START_TIME.match(/\d\d:\d\d/)[0]}}</div><div class="date">{{row.START_TIME.match(/\w{3} \d+, \d{4}/)[0]}}</div></td>
|
|
|
|
<td v-else title="Scheduled"><div><span class="emoji">⌛</span> {{row.START_TIME.match(/\d\d:\d\d/)[0]}}</div><div class="date">{{row.START_TIME.match(/\w{3} \d+, \d{4}/)[0]}}</div></td>
|
|
|
|
<td>{{row.RESOURCENAME}}</td>
|
2023-05-29 18:25:32 -04:00
|
|
|
<td><router-link :to="'/patient/' + row.PATIENTID">{{row.PATIENTNAME}} <span :title="row.HRN">{{row.HRN.slice(-4)}}</span></router-link> <span v-if="row.SENSITIVE != '0'" class="emoji">⚠</span></td>
|
2023-05-29 18:27:52 -04:00
|
|
|
<td>{{row.NOTE}}<span v-for="(value, key) in tag_map[row.APPOINTMENTID]" class="tag badge" :style="{ backgroundColor: strHashHSL(key, '50%') }" @click="filter[key] = true">{{value}}</span></td>
|
2023-05-03 23:18:54 -04:00
|
|
|
<td><input class="form-control" :list="'datalist-' + uid" :value="practitioner[row.PATIENTNAME]" @input="e => practitioner[row.PATIENTNAME] = e.target.value" /></td>
|
2022-09-22 07:10:08 -04:00
|
|
|
</tr>
|
|
|
|
</tbody>
|
2023-05-05 01:51:22 -04:00
|
|
|
<caption style="text-align: center;">{{appointments.length || 'no'}} appointment{{appointments.length != 1 ? 's' : ''}} <template v-if="date_begin.toLocaleDateString('sv-SE') == date_end.toLocaleDateString('sv-SE')">on {{date_begin.toLocaleDateString('sv-SE')}}</template><template v-else>from {{date_begin.toLocaleDateString('sv-SE')}} to {{date_end.toLocaleDateString('sv-SE')}}</template></caption>
|
2022-09-22 07:10:08 -04:00
|
|
|
</table>
|
|
|
|
</template>
|
|
|
|
|
2023-04-25 18:21:32 -04:00
|
|
|
<style scoped>
|
|
|
|
.striped {
|
|
|
|
background-image: repeating-linear-gradient(
|
|
|
|
-45deg,
|
|
|
|
rgba(255, 255, 255, 0.1),
|
|
|
|
rgba(255, 255, 255, 0.1) 10px,
|
|
|
|
rgba(0, 0, 0, 0.1) 10px,
|
|
|
|
rgba(0, 0, 0, 0.1) 20px
|
|
|
|
);
|
|
|
|
}
|
|
|
|
.voided {
|
|
|
|
opacity: 0.8;
|
|
|
|
}
|
|
|
|
.date {
|
|
|
|
font-size: 80%;
|
|
|
|
}
|
|
|
|
.emoji {
|
|
|
|
font-family:
|
|
|
|
"Twemoji Mozilla",
|
|
|
|
"Apple Color Emoji",
|
|
|
|
"Segoe UI Emoji",
|
|
|
|
"Segoe UI Symbol",
|
|
|
|
"Noto Color Emoji",
|
|
|
|
"EmojiOne Color",
|
|
|
|
"Android Emoji",
|
|
|
|
sans-serif;
|
|
|
|
}
|
2023-05-01 04:13:20 -04:00
|
|
|
.badge.tag {
|
|
|
|
cursor: pointer;
|
|
|
|
margin-right: 0.35em;
|
|
|
|
}
|
2023-04-25 18:21:32 -04:00
|
|
|
</style>
|
|
|
|
|
2022-09-22 07:10:08 -04:00
|
|
|
<script>
|
2023-04-25 18:21:32 -04:00
|
|
|
import { uniq, strHashHSL, strfdate_vista, debounce } from './util.mjs';
|
2022-09-22 07:10:08 -04:00
|
|
|
|
2023-05-03 01:44:21 -04:00
|
|
|
function clearTimeouts(timers) {
|
|
|
|
if(timers.length > 1) console.warn('Clearing multiple timeouts', timers.slice());
|
|
|
|
for(var i = 0; i < timers.length; ++i) window.clearTimeout(timers[i]);
|
|
|
|
timers.length = 0;
|
|
|
|
}
|
|
|
|
|
2022-09-22 07:10:08 -04:00
|
|
|
export default {
|
|
|
|
props: {
|
|
|
|
client: Object,
|
|
|
|
selection: {
|
|
|
|
type: Array,
|
|
|
|
default: []
|
|
|
|
},
|
2022-09-24 00:42:06 -04:00
|
|
|
date_begin: Date,
|
|
|
|
date_end: Date
|
2022-09-22 07:10:08 -04:00
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
2023-05-03 23:18:54 -04:00
|
|
|
uid: Math.random()*0x7fffffff|0,
|
2022-09-22 07:10:08 -04:00
|
|
|
appointments: [],
|
2023-05-03 01:44:21 -04:00
|
|
|
timers: [],
|
2023-04-25 18:21:32 -04:00
|
|
|
ts: null,
|
2023-05-01 04:13:20 -04:00
|
|
|
age: undefined,
|
|
|
|
filter: {}
|
2022-09-22 07:10:08 -04:00
|
|
|
};
|
|
|
|
},
|
|
|
|
computed: {
|
2023-05-29 18:27:52 -04:00
|
|
|
tag_map() {
|
|
|
|
var res0 = {}, practitioner = this.practitioner;
|
|
|
|
if(this.appointments) this.appointments.forEach(function(row) {
|
|
|
|
var res1 = res0[row.APPOINTMENTID] = {}, re, matches;
|
|
|
|
if((row.RESOURCENAME) && (matches = row.RESOURCENAME.replace(/\W+/g, '-').replace(/^-+|-+$/g, ''))) res1[matches.toLowerCase()] = matches;
|
|
|
|
if(row.WALKIN != '0') res1['walkin'] = 'WALKIN';
|
|
|
|
if((row.CANCELLED != '0') || (row.NOSHOW != '0')) res1['inactive'] = 'INACTIVE';
|
|
|
|
else res1['active'] = 'ACTIVE';
|
|
|
|
if(row.NOTE) {
|
|
|
|
re = /#([0-9a-z][\w-]*)/gi;
|
|
|
|
while(matches = re.exec(row.NOTE)) res1[matches[1].toLowerCase()] = matches[1];
|
|
|
|
re = /Dr[\.\s]*\b([a-z][\w-]*)/gi;
|
|
|
|
while(matches = re.exec(row.NOTE)) res1[matches[1].toLowerCase()] = matches[1];
|
|
|
|
}
|
|
|
|
if((matches = practitioner[row.PATIENTNAME]) && (matches = matches.replace(/\W+/g, '-').replace(/^-+|-+$/g, ''))) res1[matches.toLowerCase()] = matches.toUpperCase();
|
|
|
|
});
|
|
|
|
return res0;
|
|
|
|
},
|
|
|
|
tag_list() {
|
|
|
|
var res = {}, tag_map = this.tag_map;
|
|
|
|
if(tag_map) for(var k in tag_map) if(tag_map.hasOwnProperty(k)) Object.assign(res, tag_map[k]);
|
|
|
|
return Object.keys(res).sort();
|
|
|
|
},
|
2023-05-01 04:13:20 -04:00
|
|
|
filter_array() {
|
|
|
|
return Object.keys(this.filter).sort();
|
|
|
|
},
|
2022-10-01 07:05:12 -04:00
|
|
|
practitioner() {
|
|
|
|
return this.client.remotestate.practitioner || (this.client.remotestate.practitioner = {});
|
|
|
|
},
|
2022-09-22 07:10:08 -04:00
|
|
|
practitioner_list() {
|
2023-04-24 21:30:14 -04:00
|
|
|
return this.practitioner ? uniq(Object.values(this.practitioner).filter(x => x)).sort() : [];
|
2022-09-22 07:10:08 -04:00
|
|
|
}
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
strHashHSL,
|
2023-05-01 04:13:20 -04:00
|
|
|
filter_conj(tags) {
|
|
|
|
var filter_array = this.filter_array;
|
|
|
|
for(var i = this.filter_array.length - 1; i >= 0; --i) if(!tags[this.filter_array[i]]) return false;
|
|
|
|
return true;
|
|
|
|
},
|
2023-04-25 18:21:32 -04:00
|
|
|
async update() {
|
2023-05-03 01:44:21 -04:00
|
|
|
clearTimeouts(this.timers);
|
2023-04-25 18:21:32 -04:00
|
|
|
try {
|
|
|
|
this.appointments = (await this.client.SDEC_CRSCHED(this.selection.join('|') + '|', strfdate_vista(this.date_begin), strfdate_vista(this.date_end) + '@2359')).sort((a, b) => (new Date(a.START_TIME)) - (new Date(b.START_TIME)));
|
2023-04-29 18:24:19 -04:00
|
|
|
var now = new Date();
|
|
|
|
this.ts = this.appointments._ts ? new Date(1000*this.appointments._ts) : now;
|
|
|
|
this.age = now - this.ts;
|
2023-05-03 01:44:21 -04:00
|
|
|
this.timers.push(window.setTimeout(this.update, Math.max(60000 - this.age, 10000)));
|
2023-04-25 18:21:32 -04:00
|
|
|
} catch(ex) {
|
2023-04-29 18:24:19 -04:00
|
|
|
this.age = this.ts ? (new Date()) - this.ts : Infinity;
|
2023-04-25 18:21:32 -04:00
|
|
|
console.warn(ex);
|
2023-05-03 01:44:21 -04:00
|
|
|
this.timers.push(window.setTimeout(this.update, 30000));
|
2023-04-25 18:21:32 -04:00
|
|
|
}
|
|
|
|
}
|
2022-09-22 07:10:08 -04:00
|
|
|
},
|
2023-04-25 18:21:32 -04:00
|
|
|
mounted() {
|
|
|
|
this.$watch(
|
|
|
|
() => (this.client, this.selection, this.date_begin, this.date_end, {}),
|
|
|
|
debounce(async () => {
|
2023-05-01 17:20:40 -04:00
|
|
|
this.filter = {};
|
2023-04-25 18:21:32 -04:00
|
|
|
this.update();
|
|
|
|
}, 500)
|
|
|
|
);
|
2022-09-24 00:23:30 -04:00
|
|
|
},
|
2023-04-25 18:21:32 -04:00
|
|
|
unmounted() {
|
2023-05-03 01:44:21 -04:00
|
|
|
clearTimeouts(this.timers);
|
2022-09-22 07:10:08 -04:00
|
|
|
}
|
|
|
|
};
|
|
|
|
</script>
|