This commit is contained in:
Jiang Yio 2022-09-24 00:23:30 -04:00
parent 9687d9638e
commit 7f42be2e64
2 changed files with 23 additions and 15 deletions

View File

@ -46,7 +46,7 @@
<script>
import cookie from './cookie.mjs';
import { groupByArray, strHashHSL, strftime_vista } from './util.mjs';
import { groupByArray, strHashHSL, strftime_vista, debounce } from './util.mjs';
import ViewResourceLookup from './ViewResourceLookup.vue';
@ -91,7 +91,21 @@
}
},
watch: {
async selection(value) {
selection(value) {
this.debounced_selection(value);
}
},
methods: {
strHashHSL,
unscramble(name) {
return name.length > 0 ? (name.charAt(0) + strtr(name.substring(1), 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'LKJIHGFEDCBAZYXWVUTSRQPONM')) : name;
},
datefmt(date) {
return date ? date.toLocaleDateString('en-CA') : '';
}
},
created() {
this.debounced_selection = debounce(async function(value) {
cookie.set('vista.resources', value.join(','), 7);
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) {
@ -109,16 +123,7 @@
}
}
this.patients = patients.sort((a, b) => a.Time - b.Time);
}
},
methods: {
strHashHSL,
unscramble(name) {
return name.length > 0 ? (name.charAt(0) + strtr(name.substring(1), 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'LKJIHGFEDCBAZYXWVUTSRQPONM')) : name;
},
datefmt(date) {
return date ? date.toLocaleDateString('en-CA') : '';
}
}, 500);
},
async mounted() {
this.production = (await this.client.serverinfo()).result.production == '1';

View File

@ -18,7 +18,7 @@
<script>
import cookie from './cookie.mjs';
import { uniq, strHashHSL } from './util.mjs';
import { uniq, strHashHSL, debounce } from './util.mjs';
import Autocomplete from './Autocomplete.vue';
@ -66,8 +66,8 @@
}
},
watch: {
async params(value) {
this.appointments = value.selection.length > 0 ? (await this.client.SDEC_CLINLET(value.selection.join('|') + '|', datefm(value.date_begin), datefm(value.date_end))).sort((a, b) => (new Date(a.ApptDate)) - (new Date(b.ApptDate))) : [];
params(value) {
this.debounced_params(value);
}
},
methods: {
@ -80,6 +80,9 @@
cookie.set('vista.practitioner', JSON.stringify(this.practitioner), 1);
}
},
created() {
this.debounced_params = debounce(async function(value) { this.appointments = value.selection.length > 0 ? (await this.client.SDEC_CLINLET(value.selection.join('|') + '|', datefm(value.date_begin), datefm(value.date_end))).sort((a, b) => (new Date(a.ApptDate)) - (new Date(b.ApptDate))) : []; }, 500);
},
async mounted() {
var practitioner = cookie.get('vista.practitioner');
if(practitioner) this.practitioner = JSON.parse(practitioner);