Compare commits
No commits in common. "4c270d5e3883e0f6acdead1e4ddb552aa1a0e62e" and "6c7050b0f4d53e8de658d4f26e27f825f003da25" have entirely different histories.
4c270d5e38
...
6c7050b0f4
@ -3,14 +3,12 @@
|
||||
<Navbar v-model:server="server" :user="user" />
|
||||
<div class="container">
|
||||
<Login :secret="secret" v-model:client="client" v-model:server="server" v-model:user="user" />
|
||||
<router-view v-if="user" :client="client"></router-view>
|
||||
<router-view v-if="user"></router-view>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { watchEffect } from 'vue';
|
||||
|
||||
import Navbar from './Navbar.vue';
|
||||
import Login from './Login.vue';
|
||||
import RouteSchedule from './RouteSchedule.vue';
|
||||
@ -40,17 +38,15 @@
|
||||
if(this.heartbeat) window.clearInterval(this.heartbeat);
|
||||
else {
|
||||
[
|
||||
{ path: '/', component: RouteSchedule },
|
||||
{ path: '/patient', component: RoutePatientLookup },
|
||||
{ path: '/patient/:id', component: RoutePatientDetail },
|
||||
{ path: '/recall', component: RouteRecall },
|
||||
{ path: '/', component: RouteSchedule, props: { client: this.client } },
|
||||
{ path: '/patient', component: RoutePatientLookup, props: { client: this.client } },
|
||||
{ path: '/patient/:id', component: RoutePatientDetail, props: { client: this.client } },
|
||||
{ path: '/recall', component: RouteRecall, props: { client: this.client } },
|
||||
].forEach(route => this.$root.$router.addRoute(route));
|
||||
await this.$root.$router.replace(this.$route);
|
||||
}
|
||||
if(value) {
|
||||
this.heartbeat = await value.heartbeat();
|
||||
var stop = watchEffect(() => { if(!value.connected.value) { stop(); this.client = this.server = this.user = null; } });
|
||||
}
|
||||
if(value) this.heartbeat = await value.heartbeat();
|
||||
if(oldvalue) this.$router.go(); // refresh if changed
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -1,7 +1,7 @@
|
||||
<template>
|
||||
<div class="accordion mb-3 shadow">
|
||||
<div class="accordion-item">
|
||||
<h2 class="accordion-header"><button class="accordion-button" :class="{ testing: (x_server) && (x_server.production) && (x_server.production != '1') }" type="button" @click="() => show = !show"><template v-if="user">{{user[2]}}<template v-if="server"> @ {{server.domain}}</template></template><template v-else>Login</template></button></h2>
|
||||
<h2 class="accordion-header"><button class="accordion-button" :class="{ testing: (x_server) && (x_server.production != '1') }" type="button" @click="() => show = !show"><template v-if="user">{{user[2]}}<template v-if="server"> @ {{server.domain}}</template></template><template v-else>Login</template></button></h2>
|
||||
<div class="accordion-collapse collapse" :class="{ show }">
|
||||
<div class="accordion-body">
|
||||
<div class="card">
|
||||
@ -44,6 +44,7 @@
|
||||
</style>
|
||||
|
||||
<script>
|
||||
import cookie from './cookie.mjs';
|
||||
import vistax from './vistax.mjs';
|
||||
|
||||
export default {
|
||||
@ -73,6 +74,7 @@
|
||||
data() {
|
||||
return {
|
||||
show: false,
|
||||
host: cookie.get('host'),
|
||||
x_client: this.client,
|
||||
x_server: this.server,
|
||||
x_user: this.user,
|
||||
@ -81,33 +83,25 @@
|
||||
verifycode: null
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
host: {
|
||||
get() {
|
||||
return vistax.state.host;
|
||||
},
|
||||
set(value) {
|
||||
vistax.state.host = value;
|
||||
}
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
host: {
|
||||
handler(value) {
|
||||
this.connect();
|
||||
}, immediate: true
|
||||
host(value) {
|
||||
cookie.set('host', value);
|
||||
this.logout();
|
||||
},
|
||||
client(value) { this.x_client = value; },
|
||||
x_client(value) { this.$emit('update:client', value); if(!value) this.connect(); },
|
||||
x_client(value) { this.$emit('update:client', value); },
|
||||
server(value) { this.x_server = value; },
|
||||
x_server(value) { this.$emit('update:server', value); },
|
||||
user(value) { this.x_user = value; },
|
||||
x_user(value) { this.$emit('update:user', value); }
|
||||
},
|
||||
async mounted() {
|
||||
this.connect();
|
||||
},
|
||||
methods: {
|
||||
async connect() {
|
||||
this.logout();
|
||||
this.x_client = await (this.host ? vistax.Client.fromCookie(this.secret, this.host) : vistax.Client.fromCookie(this.secret));
|
||||
if(this.x_client) return this.x_client;
|
||||
this.x_client = await vistax.Client.fromCookie(this.secret);
|
||||
this.banner = await this.x_client.XUS_INTRO_MSG();
|
||||
if((await this.x_client.userinfo()).result) try {
|
||||
var user = await this.x_client.XUS_GET_USER_INFO();
|
||||
@ -120,19 +114,19 @@
|
||||
this.$emit('update:server', this.x_server = (await this.x_client.serverinfo()).result);
|
||||
console.log('Backend secret', this.secret);
|
||||
console.log(this.banner);
|
||||
return this.x_client;
|
||||
},
|
||||
async login(evt) {
|
||||
if(this.x_client) {
|
||||
var res = await ((this.accesscode && this.verifycode) ? this.x_client.authenticate(this.accesscode + ';' + this.verifycode) : this.x_client.authenticate());
|
||||
if(!!res.result[0]) {
|
||||
var user = await this.x_client.XUS_GET_USER_INFO();
|
||||
this.x_user = user[0] ? user : null
|
||||
} else this.x_user = null;
|
||||
this.$emit('update:user', this.x_user);
|
||||
this.show = !this.x_user;
|
||||
this.$emit('update:server', this.x_server = (await this.x_client.serverinfo()).result);
|
||||
console.log('Authenticate', res);
|
||||
}
|
||||
if(!this.x_client) await this.connect();
|
||||
var res = await ((this.accesscode && this.verifycode) ? this.x_client.authenticate(this.accesscode + ';' + this.verifycode) : this.x_client.authenticate());
|
||||
if(!!res.result[0]) {
|
||||
var user = await this.x_client.XUS_GET_USER_INFO();
|
||||
this.x_user = user[0] ? user : null
|
||||
} else this.x_user = null;
|
||||
this.$emit('update:user', this.x_user);
|
||||
this.show = !this.x_user;
|
||||
this.$emit('update:server', this.x_server = (await this.x_client.serverinfo()).result);
|
||||
console.log('Authenticate', res);
|
||||
},
|
||||
async logout(evt) {
|
||||
if(this.x_client) {
|
||||
@ -141,8 +135,6 @@
|
||||
this.$emit('update:server', this.x_server = null);
|
||||
this.$emit('update:user', this.x_user = null);
|
||||
}
|
||||
this.banner = null;
|
||||
this.show = true;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -65,7 +65,7 @@
|
||||
var name = this.$route.query.name.toUpperCase();
|
||||
var patient = await this.client.ORWPT_LAST5(id);
|
||||
for(var i = 0; i < patient.length; ++i) if(name == patient[i].name) {
|
||||
this.$router.replace('/patient/' + patient[i].dfn);
|
||||
this.$router.replace('/patient/' + patient[0].dfn);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -45,7 +45,7 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { state } from './vistax.mjs';
|
||||
import cookie from './cookie.mjs';
|
||||
import { groupByArray, strtr_unscramble, strHashHSL, strftime_vista, debounce } from './util.mjs';
|
||||
|
||||
import ViewResourceLookup from './ViewResourceLookup.vue';
|
||||
@ -62,7 +62,7 @@
|
||||
client: Object
|
||||
},
|
||||
data() {
|
||||
var resources = state.resources;
|
||||
var resources = cookie.get('vista.resources');
|
||||
var today = dateonly(new Date());
|
||||
return {
|
||||
selection: resources ? (resources.split(',').filter(x => x) || []) : [],
|
||||
@ -95,7 +95,7 @@
|
||||
},
|
||||
created() {
|
||||
this.debounced_selection = debounce(async function(value) {
|
||||
state.resources = value.join(',');
|
||||
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) {
|
||||
group = patients[i];
|
||||
|
@ -19,7 +19,7 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { state } from './vistax.mjs';
|
||||
import cookie from './cookie.mjs';
|
||||
|
||||
import ViewResourceLookup from './ViewResourceLookup.vue';
|
||||
import DateRangePicker from './DateRangePicker.vue';
|
||||
@ -37,7 +37,7 @@
|
||||
client: Object
|
||||
},
|
||||
data() {
|
||||
var resources = state.resources;
|
||||
var resources = cookie.get('vista.resources');
|
||||
return {
|
||||
selection: resources ? (resources.split(',').filter(x => x) || []) : [],
|
||||
date: dateonly(new Date()),
|
||||
@ -46,7 +46,7 @@
|
||||
},
|
||||
watch: {
|
||||
selection(value, oldvalue) {
|
||||
state.resources = value.join(',');
|
||||
cookie.set('vista.resources', value.join(','), 7);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -1,31 +1,29 @@
|
||||
<template>
|
||||
<div>
|
||||
<div class="input-group">
|
||||
<span class="input-group-text">🔎</span>
|
||||
<input class="form-control" v-model="query_raw" @focus="collapsed = false" />
|
||||
</div>
|
||||
<div :class="{ collapsed }" style="max-height: 30em; overflow-y: auto;">
|
||||
<table class="table table-striped" style="font-family: monospace;" v-if="resultset_raw && resultset_raw.length > 0">
|
||||
<thead>
|
||||
<tr><th></th><th>ID</th><th>Name</th><th>Type</th><th>User</th></tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<template v-for="row in resultset_filtered">
|
||||
<tr :class="{ 'table-active': row.selected }" v-if="row.INACTIVE != 'YES'">
|
||||
<td><input type="checkbox" v-model="row.selected" /></td>
|
||||
<td>{{row.RESOURCEID}}</td>
|
||||
<td>{{row.RESOURCE_NAME}}</td>
|
||||
<td>{{row.RESOURCETYPE}}</td>
|
||||
<td>{{row.USERNAME}}</td>
|
||||
</tr>
|
||||
</template>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div style="font-family: monospace;" v-if="resultset_selected.length">
|
||||
<span class="badge bg-primary" style="cursor: default; margin-right: 0.35em;" v-on:click="reset">CLEAR {{resultset_selected.length}}</span>
|
||||
<span class="badge bg-secondary" style="cursor: default; margin-right: 0.35em;" v-for="row in resultset_selected" v-on:click="row.selected = false;">❌ {{row.RESOURCEID}} {{row.RESOURCE_NAME}}</span>
|
||||
</div>
|
||||
<div class="input-group">
|
||||
<span class="input-group-text">🔎</span>
|
||||
<input class="form-control" v-model="query_raw" @focus="collapsed = false" @blur="collapsed = true" />
|
||||
</div>
|
||||
<div :class="{ collapsed }" style="max-height: 30em; overflow-y: auto;">
|
||||
<table class="table table-striped" style="font-family: monospace;" v-if="resultset_raw && resultset_raw.length > 0">
|
||||
<thead>
|
||||
<tr><th></th><th>ID</th><th>Name</th><th>Type</th><th>User</th></tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<template v-for="row in resultset_filtered">
|
||||
<tr :class="{ 'table-active': row.selected }" v-if="row.INACTIVE != 'YES'">
|
||||
<td><input type="checkbox" v-model="row.selected" /></td>
|
||||
<td>{{row.RESOURCEID}}</td>
|
||||
<td>{{row.RESOURCE_NAME}}</td>
|
||||
<td>{{row.RESOURCETYPE}}</td>
|
||||
<td>{{row.USERNAME}}</td>
|
||||
</tr>
|
||||
</template>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div style="font-family: monospace;" v-if="resultset_selected.length">
|
||||
<span class="badge bg-primary" style="cursor: default; margin-right: 0.35em;" v-on:click="reset">CLEAR {{resultset_selected.length}}</span>
|
||||
<span class="badge bg-secondary" style="cursor: default; margin-right: 0.35em;" v-for="row in resultset_selected" v-on:click="row.selected = false;">❌ {{row.RESOURCEID}} {{row.RESOURCE_NAME}}</span>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@ -93,7 +91,6 @@
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
collapse(evt) { if(!this.$el.contains(evt.target)) this.collapsed = true; },
|
||||
reset(evt) {
|
||||
var selection = this.resultset_selected.slice();
|
||||
for(var i = selection.length - 1; i >= 0; --i) selection[i].selected = false;
|
||||
@ -106,10 +103,6 @@
|
||||
var rs = (await this.client.SDEC_RESOURCE()).slice();
|
||||
update_selection(rs, this.selection);
|
||||
this.resultset_raw = rs;
|
||||
document.addEventListener('click', this.collapse);
|
||||
},
|
||||
destroyed() {
|
||||
document.removeEventListener('click', this.collapse);
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
@ -17,7 +17,7 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { state } from './vistax.mjs';
|
||||
import cookie from './cookie.mjs';
|
||||
import { uniq, strtr_unscramble, strHashHSL, strfdate_vista, debounce } from './util.mjs';
|
||||
|
||||
import Autocomplete from './Autocomplete.vue';
|
||||
@ -60,15 +60,15 @@
|
||||
strtr_unscramble,
|
||||
set_practitioner(patient, practitioner) {
|
||||
this.practitioner[patient] = practitioner;
|
||||
state.practitioner = this.practitioner;
|
||||
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('|') + '|', strfdate_vista(value.date_begin), strfdate_vista(value.date_end))).sort((a, b) => (new Date(a.ApptDate)) - (new Date(b.ApptDate))) : []; }, 500);
|
||||
},
|
||||
async mounted() {
|
||||
var practitioner = state.practitioner;
|
||||
if(practitioner) this.practitioner = practitioner;
|
||||
var practitioner = cookie.get('vista.practitioner');
|
||||
if(practitioner) this.practitioner = JSON.parse(practitioner);
|
||||
this.production = (await this.client.serverinfo()).result.production == '1';
|
||||
}
|
||||
};
|
||||
|
@ -33,8 +33,7 @@
|
||||
{ name: 'Electrolytes', value: ['SODIUM', 'CHLORIDE', 'CO2', 'CALCIUM', 'IONIZED CALCIUM (LABCORP)', 'POTASSIUM', 'MAGNESIUM', 'PO4', 'ANION GAP', 'OSMOBLD'], selected: false },
|
||||
{ name: 'Coagulation', value: ['PT', 'INR', 'PTT'], selected: false },
|
||||
{ name: 'Vitamins', value: ['FERRITIN', 'IRON', 'TIBC', 'B 12', 'FOLATE', 'VITAMIN D TOTAL 25-OH'], selected: false },
|
||||
{ name: 'Thyroid', value: ['TSH', 'T4 (THYROXINE)'], selected: false },
|
||||
{ name: 'Myeloma', value: ['PROTEIN,TOT SER (LC)', 'ALBUMIN [for SPEP](LC)', 'ALPHA-1 GLOBULIN S (LC)', 'ALPHA-2 GLOBULIN S (LC)', 'BETA GLOBULIN S (LC)', 'GAMMA GLOBULIN S (LC)', 'GLOBULIN,TOTAL S (LC)', 'A/G RATIO S (LC)', 'M-SPIKE S (LC)', 'IMMUNOFIXATION SERUM (LC)', 'FREE KAPPA LT CHAIN, S (LC)', 'FREE LAMBDA LT CHAIN, S (LC)', 'KAPPA/LAMBDA RATIO, S (LC)', 'KLRATIO', 'IMMUNOGLOBULIN G,QN (LC)', 'IMMUNOGLOBULIN A,QN (LC)', 'IMMUNOGLOBULIN M,QN (LC)', 'IGG', 'IGA', 'IGM', 'ALBUMIN [for RAND UR](LC)', 'ALPHA-1 GLOB RAND UR(LC)', 'ALPHA-2 GLOB RAND UR(LC)', 'BETA GLOB RAND UR(LC)', 'GAMMA GLOB RAND UR(LC)', 'M-SPIKE% RAND UR(LC)', 'PROTEIN,TOT UR(LC)', 'FKLCUR', 'FLLCUR', 'KAPPA/LAMBDA RATIO, UR (LC)', 'PROTEIN,24H CALC(LC)', 'ALBUMIN [for 24UPEP](LC)', 'ALPHA-1 GLOBULIN 24H(LC)', 'ALPHA-2 GLOBULIN 24H(LC)', 'BETA GLOBULIN 24H(LC)', 'GAMMA GLOBULIN 24H(LC)', 'M-SPIKE mg/24hr(LC)', 'FR KAPPA LTCH', 'FR LAMBDA LTCH'], selected: false }
|
||||
{ name: 'Thyroid', value: ['TSH', 'T4 (THYROXINE)'], selected: false }
|
||||
];
|
||||
reports.reduce((acc, x) => acc[x] = x, reports);
|
||||
|
||||
@ -61,10 +60,9 @@
|
||||
|
||||
function labs_normalize(rs) {
|
||||
return rs.map(function(x) {
|
||||
var specimen = x.specimen;
|
||||
return {
|
||||
time: x.time_collected,
|
||||
name: (specimen == 'BLOOD') || (specimen == 'SERUM') || (specimen == 'PLASMA') ? x.name : (specimen == 'RANDOM URINE') ? x.name + ':UR' : specimen ? x.name + ':' + specimen.charAt(0) : x.name,
|
||||
name: x.name,
|
||||
unit: x.unit,
|
||||
range: x.range,
|
||||
value: x.value,
|
||||
|
@ -52,15 +52,13 @@ function lab_parse1default(data) {
|
||||
if(x.comment) x.comment.push(line.substring(12));
|
||||
else x.comment = [line.substring(12)];
|
||||
} else console.log('DANGLING:', line);
|
||||
} else if(m = line.match(/^\b(?<name>.*?)\s{2,}(?<value>.*?)(?: (?<flag>L\*|L|H\*|H))?\s+(?:(?<unit>.{10}) (?<range>.*?)(?: \[(?<site>\d+)\])?)?$/)) {
|
||||
} else if((line.startsWith('COVID-19 SCR (CEPHEID-RAPID)')) && (m = line.substring(28).match(/^(?<value>.*?)(?: (?<flag>L\*|L|H\*|H))?\s+(?:(?<unit>.{10}) (?<range>.{16}) \[(?<site>\d+)\])?$/))) {
|
||||
if((m.groups.range) && (m.groups.range.startsWith('Ref: '))) m.groups.range = m.groups.range.substring(5);
|
||||
results.push(x = m.groups);
|
||||
if((x.value === '') && (m = x.name.match(/^(?<name>.*?)(?<value>(?:[\d\.]+|positive|negative|reactive|not detected|collected - specimen in lab|test not performed))\s*$/i))) {
|
||||
x.name = m.groups.name;
|
||||
x.value = m.groups.value;
|
||||
}
|
||||
for(var k in x) if(x[k]) x[k] = x[k] ? x[k].replace(/^\s+|\s+$/g, '') : undefined;
|
||||
} else if(m = line.match(/^\b(?<name>.*?) (?<value>(?:[\d\.]+|positive|negative|reactive|not detected|collected - specimen in lab|test not performed))\s*$/i)) {
|
||||
x.name = 'COVID-19 SCR (CEPHEID-RAPID)';
|
||||
} else if(m = line.match(/^\b(?<name>.*?)\s{2,}(?<value>.*?)(?: (?<flag>L\*|L|H\*|H))?\s+(?:(?<unit>.{10}) (?<range>.{16}) \[(?<site>\d+)\])?$/)) {
|
||||
if((m.groups.range) && (m.groups.range.startsWith('Ref: '))) m.groups.range = m.groups.range.substring(5);
|
||||
results.push(x = m.groups);
|
||||
for(var k in x) if(x[k]) x[k] = x[k] ? x[k].replace(/^\s+|\s+$/g, '') : undefined;
|
||||
} else if(line.startsWith(' [')) {
|
||||
@ -74,13 +72,6 @@ function lab_parse1default(data) {
|
||||
x.site = line.split('[')[1].split(']')[0];
|
||||
} else x.range = line.replace(/^\s+|\s+$/g, '');
|
||||
} else console.log('DANGLING:', line);
|
||||
} else if(m = line.match(/^\s{40}\b(?:(?<unit>.{10}) (?<range>.*?)(?: \[(?<site>\d+)\])?)?$/)) {
|
||||
if(results.length > 0) {
|
||||
x = results[results.length - 1];
|
||||
if(m.groups.unit) x.unit = m.groups.unit.replace(/^\s+|\s+$/g, '');
|
||||
if(m.groups.range) x.range = m.groups.range.replace(/^\s+|\s+$/g, '');
|
||||
if(m.groups.site) x.site = m.groups.site.replace(/^\s+|\s+$/g, '');
|
||||
} else console.log('DANGLING:', line, m.groups);
|
||||
} else console.log('INVALID:', line);
|
||||
}
|
||||
for(var i = results.length - 1; i >= 0; --i) {
|
||||
|
@ -1,16 +1,8 @@
|
||||
import { reactive, watch } from 'vue';
|
||||
|
||||
import vista from './vista.mjs';
|
||||
import cookie from './cookie.mjs';
|
||||
import { lab_parse, lab_reparse_results, measurement_parse } from './reportparser.mjs';
|
||||
|
||||
export const state = reactive(cookie.get('state') ? JSON.parse(cookie.get('state')) : {});
|
||||
if((!state.secret) && (cookie.get('secret'))) state.resources = cookie.get('secret');
|
||||
if((!state.cid) && (cookie.get('cid'))) state.resources = cookie.get('cid');
|
||||
if((!state.host) && (cookie.get('host'))) state.resources = cookie.get('host');
|
||||
if((!state.resources) && (cookie.get('vista.resources'))) state.resources = cookie.get('vista.resources');
|
||||
if((!state.practitioner) && (cookie.get('vista.practitioner'))) state.practitioner = JSON.parse(cookie.get('vista.practitioner'));
|
||||
watch(state, value => cookie.set('state', JSON.stringify(value), 45), { immediate: true, deep: true });
|
||||
const COOKIE_TIME = 45;
|
||||
|
||||
function RPCError(type, ...args) {
|
||||
this.name = type;
|
||||
@ -84,24 +76,13 @@ export function Client(cid, secret) {
|
||||
|
||||
this.secret = secret;
|
||||
this.cid = cid;
|
||||
this.connected = reactive({ value: true });
|
||||
|
||||
this.close = function() {
|
||||
console.log('CLOSE', cid);
|
||||
if(heartbeat) window.clearInterval(heartbeat);
|
||||
this.connected.value = false;
|
||||
return vista.close(cid);
|
||||
};
|
||||
this.call = async function(method, ...params) {
|
||||
var res = await vista.call(cid, method, ...params);
|
||||
if((res.error) && (res.error.type == 'ConnectionResetError')) this.close();
|
||||
return res;
|
||||
};
|
||||
this.callctx = async function(context, method, ...params) {
|
||||
var res = vista.callctx(cid, context, method, ...params);
|
||||
if((res.error) && (res.error.type == 'ConnectionResetError')) this.close();
|
||||
return res;
|
||||
};
|
||||
this.call = (method, ...params) => vista.call(cid, method, ...params);
|
||||
this.callctx = (context, method, ...params) => vista.callctx(cid, context, method, ...params);
|
||||
this.heartbeat = async function(interval=null) {
|
||||
if(!interval) interval = 0.45*1000*(await this.XWB_GET_BROKER_INFO())[0];
|
||||
if(heartbeat) window.clearInterval(heartbeat);
|
||||
@ -112,27 +93,27 @@ export function Client(cid, secret) {
|
||||
this.userinfo = () => vista.userinfo(cid);
|
||||
this.authenticate = (avcode=null) => vista.authenticate(cid, avcode);
|
||||
|
||||
this.XWB_IM_HERE = unwrapped(logged(() => this.call('XWB_IM_HERE'), 'XWB_IM_HERE'));
|
||||
this.XWB_IM_HERE = unwrapped(logged(() => vista.call(cid, 'XWB_IM_HERE'), 'XWB_IM_HERE'));
|
||||
|
||||
this.XUS_INTRO_MSG = memoized(unwrapped(logged(() => this.callctx(['XUCOMMAND'], 'XUS_INTRO_MSG'), 'XUS_INTRO_MSG')));
|
||||
this.XWB_GET_BROKER_INFO = memoized(unwrapped(logged(() => this.callctx(['XUCOMMAND'], 'XWB_GET_BROKER_INFO'), 'XWB_GET_BROKER_INFO')));
|
||||
this.XUS_GET_USER_INFO = memoized(unwrapped(logged(() => this.call('XUS_GET_USER_INFO'), 'XUS_GET_USER_INFO')));
|
||||
this.XUS_INTRO_MSG = memoized(unwrapped(logged(() => vista.callctx(cid, ['XUCOMMAND'], 'XUS_INTRO_MSG'), 'XUS_INTRO_MSG')));
|
||||
this.XWB_GET_BROKER_INFO = memoized(unwrapped(logged(() => vista.callctx(cid, ['XUCOMMAND'], 'XWB_GET_BROKER_INFO'), 'XWB_GET_BROKER_INFO')));
|
||||
this.XUS_GET_USER_INFO = memoized(unwrapped(logged(() => vista.call(cid, 'XUS_GET_USER_INFO'), 'XUS_GET_USER_INFO')));
|
||||
|
||||
this.SDEC_RESOURCE = memoized(unwrapped(logged(() => this.callctx(['SDECRPC'], 'SDEC_RESOURCE'), 'SDEC_RESOURCE')));
|
||||
this.SDEC_CLINLET = memoized(unwrapped(logged((...args) => this.callctx(['SDECRPC'], 'SDEC_CLINLET', ...args), 'SDEC_CLINLET')));
|
||||
this.SDEC_RESOURCE = memoized(unwrapped(logged(() => vista.callctx(cid, ['SDECRPC'], 'SDEC_RESOURCE'), 'SDEC_RESOURCE')));
|
||||
this.SDEC_CLINLET = memoized(unwrapped(logged((...args) => vista.callctx(cid, ['SDECRPC'], 'SDEC_CLINLET', ...args), 'SDEC_CLINLET')));
|
||||
|
||||
this.ORWPT_FULLSSN = memoized(caretseparated(unwrapped(logged((...args) => this.callctx(['OR CPRS GUI CHART'], 'ORWPT_FULLSSN', ...args), 'ORWPT_FULLSSN')), ['dfn', 'name', 'date', 'pid']));
|
||||
this.ORWPT_LAST5 = memoized(caretseparated(unwrapped(logged((...args) => this.callctx(['OR CPRS GUI CHART'], 'ORWPT_LAST5', ...args), 'ORWPT_LAST5')), ['dfn', 'name', 'date', 'pid']));
|
||||
this.ORWPT_ID_INFO = memoized(caretseparated1(unwrapped(logged((...args) => this.callctx(['OR CPRS GUI CHART'], 'ORWPT_ID_INFO', ...args), 'ORWPT_ID_INFO')), ['pid', 'dob', 'sex', 'vet', 'sc_percentage', 'ward', 'room_bed', 'name']));
|
||||
this.ORWPT16_LOOKUP = memoized(caretseparated(unwrapped(logged((...args) => this.callctx(['OR CPRS GUI CHART'], 'ORWPT16_LOOKUP', ...args), 'ORWPT16_LOOKUP')), ['dfn', 'name', 'pid']));
|
||||
this.ORWPT16_ID_INFO = memoized(caretseparated1(unwrapped(logged((...args) => this.callctx(['OR CPRS GUI CHART'], 'ORWPT16_ID_INFO', ...args), 'ORWPT16_ID_INFO')), ['pid', 'dob', 'age', 'sex', 'sc_percentage', 'type', 'ward', 'room_bed', 'name']));
|
||||
this.ORWPT_FULLSSN = memoized(caretseparated(unwrapped(logged((...args) => vista.callctx(cid, ['OR CPRS GUI CHART'], 'ORWPT_FULLSSN', ...args), 'ORWPT_FULLSSN')), ['dfn', 'name', 'date', 'pid']));
|
||||
this.ORWPT_LAST5 = memoized(caretseparated(unwrapped(logged((...args) => vista.callctx(cid, ['OR CPRS GUI CHART'], 'ORWPT_LAST5', ...args), 'ORWPT_LAST5')), ['dfn', 'name', 'date', 'pid']));
|
||||
this.ORWPT_ID_INFO = memoized(caretseparated1(unwrapped(logged((...args) => vista.callctx(cid, ['OR CPRS GUI CHART'], 'ORWPT_ID_INFO', ...args), 'ORWPT_ID_INFO')), ['pid', 'dob', 'sex', 'vet', 'sc_percentage', 'ward', 'room_bed', 'name']));
|
||||
this.ORWPT16_LOOKUP = memoized(caretseparated(unwrapped(logged((...args) => vista.callctx(cid, ['OR CPRS GUI CHART'], 'ORWPT16_LOOKUP', ...args), 'ORWPT16_LOOKUP')), ['dfn', 'name', 'pid']));
|
||||
this.ORWPT16_ID_INFO = memoized(caretseparated1(unwrapped(logged((...args) => vista.callctx(cid, ['OR CPRS GUI CHART'], 'ORWPT16_ID_INFO', ...args), 'ORWPT16_ID_INFO')), ['pid', 'dob', 'age', 'sex', 'sc_percentage', 'type', 'ward', 'room_bed', 'name']));
|
||||
|
||||
this.ORQQVI_VITALS = memoized(caretseparated(unwrapped(logged((...args) => this.callctx(['OR CPRS GUI CHART'], 'ORQQVI_VITALS', ...args), 'ORQQVI_VITALS')), ['measurement_ien', 'type', 'value', 'datetime', 'value_american', 'value_metric']));
|
||||
this.ORQQVI_VITALS_FOR_DATE_RANGE = memoized(caretseparated(unwrapped(logged((...args) => this.callctx(['OR CPRS GUI CHART'], 'ORQQVI_VITALS_FOR_DATE_RANGE', ...args), 'ORQQVI_VITALS_FOR_DATE_RANGE')), ['measurement_ien', 'type', 'value', 'datetime']));
|
||||
this.ORQQVI_VITALS = memoized(caretseparated(unwrapped(logged((...args) => vista.callctx(cid, ['OR CPRS GUI CHART'], 'ORQQVI_VITALS', ...args), 'ORQQVI_VITALS')), ['measurement_ien', 'type', 'value', 'datetime', 'value_american', 'value_metric']));
|
||||
this.ORQQVI_VITALS_FOR_DATE_RANGE = memoized(caretseparated(unwrapped(logged((...args) => vista.callctx(cid, ['OR CPRS GUI CHART'], 'ORQQVI_VITALS_FOR_DATE_RANGE', ...args), 'ORQQVI_VITALS_FOR_DATE_RANGE')), ['measurement_ien', 'type', 'value', 'datetime']));
|
||||
|
||||
this.GMV_EXTRACT_REC = memoized(async (dfn, oredt, orsdt) => measurement_parse(await unwrapped(logged((...args0) => this.callctx(['OR CPRS GUI CHART'], 'GMV_EXTRACT_REC', args0.join('^')), 'GMV_EXTRACT_REC'))(dfn, oredt, '', orsdt)));
|
||||
this.GMV_EXTRACT_REC = memoized(async (dfn, oredt, orsdt) => measurement_parse(await unwrapped(logged((...args0) => vista.callctx(cid, ['OR CPRS GUI CHART'], 'GMV_EXTRACT_REC', args0.join('^')), 'GMV_EXTRACT_REC'))(dfn, oredt, '', orsdt)));
|
||||
|
||||
this.ORWLRR_INTERIM = memoized(labreportparsed(unwrapped(logged((...args) => this.callctx(['OR CPRS GUI CHART'], 'ORWLRR_INTERIM', ...args), 'ORWLRR_INTERIM'))));
|
||||
this.ORWLRR_INTERIM = memoized(labreportparsed(unwrapped(logged((...args) => vista.callctx(cid, ['OR CPRS GUI CHART'], 'ORWLRR_INTERIM', ...args), 'ORWLRR_INTERIM'))));
|
||||
this.ORWLRR_INTERIM_RESULTS = memoized(async (...args) => lab_reparse_results(await this.ORWLRR_INTERIM(...args)));
|
||||
|
||||
return this;
|
||||
@ -150,57 +131,57 @@ Client.fromScratch = async function(secret, host='vista.northport.med.va.gov', p
|
||||
};
|
||||
|
||||
Client.fromCookie = async function(secret, defaulthost='vista.northport.med.va.gov:19209') {
|
||||
if(!secret) secret = state.secret;
|
||||
if(!secret) secret = cookie.get('secret');
|
||||
if(secret) {
|
||||
var host = state.host;
|
||||
var host = cookie.get('host');
|
||||
host = (host || defaulthost).split(':');
|
||||
if(secret != state.secret) {
|
||||
if(secret != cookie.get('secret')) {
|
||||
console.log('Using new secret', secret);
|
||||
var client = await Client.fromScratch(secret, host[0], host[1]);
|
||||
if(client) {
|
||||
state.host = host.join(':');
|
||||
state.secret = secret;
|
||||
state.cid = client.cid;
|
||||
cookie.set('host', host.join(':'), COOKIE_TIME);
|
||||
cookie.set('secret', secret);
|
||||
cookie.set('cid', client.cid);
|
||||
console.log('Established connection', client.cid);
|
||||
return client;
|
||||
} else {
|
||||
delete state.secret;
|
||||
delete state.cid;
|
||||
cookie.reset('secret');
|
||||
cookie.reset('cid');
|
||||
console.log('Failed to connect');
|
||||
return null;
|
||||
}
|
||||
} else if(!state.cid) {
|
||||
} else if(!cookie.get('cid')) {
|
||||
console.log('Using saved secret', secret);
|
||||
var client = await Client.fromScratch(secret, host[0], host[1]);
|
||||
if(client) {
|
||||
state.host = host.join(':');
|
||||
state.secret = secret;
|
||||
state.cid = client.cid;
|
||||
cookie.set('host', host.join(':'), COOKIE_TIME);
|
||||
cookie.set('secret', secret);
|
||||
cookie.set('cid', client.cid);
|
||||
console.log('Established connection', client.cid);
|
||||
return client;
|
||||
} else {
|
||||
delete state.secret;
|
||||
delete state.cid;
|
||||
cookie.reset('secret');
|
||||
cookie.reset('cid');
|
||||
console.log('Failed connection');
|
||||
return null;
|
||||
}
|
||||
} else {
|
||||
console.log('Using saved secret and connection', secret);
|
||||
var cid = state.cid;
|
||||
var cid = cookie.get('cid');
|
||||
var client = Client.fromID(cid, secret);
|
||||
if((await vista.call(cid, 'XWB_IM_HERE')).result == '1') {
|
||||
var server = await client.serverinfo();
|
||||
if((host[0] == server.result.host) && (host[1] == server.result.port)) {
|
||||
state.host = host.join(':');
|
||||
cookie.set('host', host.join(':'), COOKIE_TIME);
|
||||
return client;
|
||||
} else console.log('Rejecting previous connection to different server', server);
|
||||
}
|
||||
delete state.cid;
|
||||
cookie.reset('cid');
|
||||
return await Client.fromCookie(secret, host.join(':'));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
export default window.vistax = {
|
||||
state, RPCError, Client, connect: Client.fromCookie
|
||||
RPCError, Client, connect: Client.fromCookie
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user