Compare commits

...

5 Commits

8 changed files with 248 additions and 24 deletions

View File

@ -0,0 +1,28 @@
<template>
<select class="form-select form-select-sm" style="width: auto;" v-model="x_value">
<option v-for="item in options" :value="item.ien">{{item.name}}</option>
</select>
</template>
<script>
export default {
props: {
client: Object,
modelValue: { default: 2 }
},
data() {
return {
options: [],
x_value: this.modelValue
};
},
watch: {
client: {
async handler(value) { if(value) this.options = await value.ORWORDG_REVSTS(); },
immediate: true
},
modelValue(value) { this.x_value = value; },
x_value(value) { this.$emit('update:modelValue', value); }
}
};
</script>

View File

@ -21,6 +21,14 @@
<ViewVitalsLabs :client="client" :dfn="dfn" :date_begin="report_date_begin" :date_end="report_date" />
</div>
</div>
<div class="card mb-3 shadow">
<div class="card-header d-flex justify-content-between align-items-center">
<span>Orders</span>
<OrderFilterPicker :client="client" v-model="orders_filter" />
<DateRangePicker range="6M" direction="-1" v-model:date="orders_date" v-model:date_end="orders_date_begin" />
</div>
<div class="card-body"><ViewOrders :client="client" :dfn="dfn" :filter="orders_filter" :date_begin="orders_date_begin" :date_end="orders_date" /></div>
</div>
</div>
</template>
@ -29,12 +37,14 @@
import DateRangePicker from './DateRangePicker.vue';
import ViewVitalsLabs from './ViewVitalsLabs.vue';
import OrderFilterPicker from './OrderFilterPicker.vue';
import ViewOrders from './ViewOrders.vue';
var now = new Date();
export default {
components: {
DateRangePicker, ViewVitalsLabs
DateRangePicker, ViewVitalsLabs, OrderFilterPicker, ViewOrders
},
props: {
client: Object
@ -44,7 +54,10 @@
dfn: null,
info: null,
report_date: now,
report_date_begin: now
report_date_begin: now,
orders_filter: 2,
orders_date: now,
orders_date_begin: now
};
},
watch: {

View File

@ -6,16 +6,16 @@
</thead>
<tbody v-for="report in reports">
<template v-for="name in report">
<tr v-if="names[name]">
<th>{{name}}</th>
<tr v-if="names[name]" @dblclick="toggle_filter_name(name)">
<th :class="{ filtered: name == filter_name }">{{name}}</th>
<td v-for="(group, idx) in groups" :class="{ first: (idx == 0) || (group.datehdr.datestr != groups[idx - 1].datehdr.datestr), abnormal_ref: abnormal_ref(group.values[name]), abnormal_ref_low: abnormal_ref_low(group.values[name]), abnormal_ref_high: abnormal_ref_high(group.values[name]), abnormal_iqr: abnormal_iqr(group.values[name]), abnormal_iqr_low: abnormal_iqr_low(group.values[name]), abnormal_iqr_high: abnormal_iqr_high(group.values[name]) }" :title="tooltip(group.values[name])">{{group.values[name] ? group.values[name].value : ''}}</td>
</tr>
</template>
</tbody>
<tbody>
<template v-for="name in names">
<tr v-if="!names_excluded[name]">
<th>{{name}}</th>
<tr v-if="!names_excluded[name]" @dblclick="toggle_filter_name(name)">
<th :class="{ filtered: name == filter_name }">{{name}}</th>
<td v-for="(group, idx) in groups" :class="{ first: (idx == 0) || (group.datehdr.datestr != groups[idx - 1].datehdr.datestr), abnormal_ref: abnormal_ref(group.values[name]), abnormal_ref_low: abnormal_ref_low(group.values[name]), abnormal_ref_high: abnormal_ref_high(group.values[name]), abnormal_iqr: abnormal_iqr(group.values[name]), abnormal_iqr_low: abnormal_iqr_low(group.values[name]), abnormal_iqr_high: abnormal_iqr_high(group.values[name]) }" :title="tooltip(group.values[name])">{{group.values[name] ? group.values[name].value : ''}}</td>
</tr>
</template>
@ -37,16 +37,25 @@
table.table-sticky tbody tr {
border-top: 1px dashed #dee2e6;
}
table.table-sticky tbody tr:hover {
border: 1px solid #6c757d;
}
td:nth-of-type(odd) {
background-color: rgba(0, 0, 0, 0.05);
}
table.table-sticky tbody th, table.table-sticky th.name {
cursor: default;
font-weight: bold;
text-align: center;
padding-left: 1rem;
padding-right: 1rem;
}
table.table-sticky th.filtered {
background-color: #6c757d;
color: #fff;
}
table.table-sticky th.date {
cursor: default;
font-size: 80%;
font-weight: normal;
text-align: center;
@ -147,11 +156,14 @@
}
},
data() {
return {};
return {
filter_name: null
};
},
computed: {
resultset_all() {
return this.resultset_calculated.length > 0 ? this.resultset.concat(this.resultset_calculated) : this.resultset;
var res = this.resultset_calculated.length > 0 ? this.resultset.concat(this.resultset_calculated) : this.resultset;
return this.filter_name ? res.filter(x => x.name == this.filter_name) : res;
},
resultset_calculated() {
var self = this, snapshots = [], results = [], history, update, item;
@ -230,6 +242,9 @@
return res.join('\n');
}
},
toggle_filter_name(name) {
this.filter_name = this.filter_name != name ? name : null;
},
abnormal_ref(item) {
return (item) && (item.flag);
},

104
htdocs/ViewOrders.vue Normal file
View File

@ -0,0 +1,104 @@
<template>
<table v-if="details.length > 0" class="table table-striped">
<template v-for="group in details">
<thead>
<tr>
<th>{{map_groups[group.key].name}}</th>
<th>Practitioner</th>
<th style="text-align: right;">Status</th>
</tr>
</thead>
<tbody>
<tr v-for="item in group.values">
<td><div v-for="line in item.text">{{line}}</div></td>
<td>
<div v-if="item.PrvNam" :title="item.PrvID">{{item.PrvNam}}</div>
<div v-if="item.Nrs">Nurse: {{item.Nrs}}</div>
<div v-if="item.Clk">Clerk: {{item.Clk}}</div>
<div v-if="item.ChartRev">Chart: {{item.ChartRev}}</div>
<div v-if="item.LOC">{{item.LOC.split(':')[0]}}</div>
</td>
<td style="text-align: right;">
<div v-if="item.Sts">{{name_of_status[item.Sts]}}</div>
<div v-if="item.OrdTm">Ordered: {{strptime_vista(item.OrdTm).toLocaleDateString('en-CA')}}</div>
<div v-if="item.StrtTm">Start: {{strptime_vista(item.StrtTm).toLocaleDateString('en-CA')}}</div>
<div v-if="item.StopTm">Stop: {{strptime_vista(item.StopTm).toLocaleDateString('en-CA')}}</div>
</td>
</tr>
</tbody>
</template>
</table>
</template>
<style scoped>
th {
text-transform: lowercase;
}
th::first-letter {
text-transform: uppercase;
}
</style>
<script>
import { groupByArray, strftime_vista, strptime_vista } from './util.mjs';
const name_of_status = {
0: 'Error',
1: 'Discontinued',
2: 'Complete',
3: 'Hold',
4: 'Flagged',
5: 'Pending',
6: 'Active',
7: 'Expired',
8: 'Scheduled',
9: 'Partial results',
10: 'Delayed',
11: 'Unreleased',
12: 'DC/edit',
13: 'Cancelled',
14: 'Lapsed',
15: 'Renewed',
97: '',
98: 'New',
99: 'No status'
};
export default {
props: {
client: Object,
dfn: String,
filter: { default: 2 },
group: { default: 1 },
date_begin: Date,
date_end: Date
},
data() {
return {
orders: [],
details: [],
map_groups: {},
name_of_status
};
},
computed: {
params() {
return { dfn: this.dfn, filter: this.filter, group: this.group, date_begin: strftime_vista(this.date_begin), date_end: strftime_vista(this.date_end) };
}
},
watch: {
async params(value) {
this.orders = await this.client.ORWORR_AGET(value.dfn, value.filter, value.group, value.date_begin, value.date_end);
},
async orders(value) {
this.details = this.orders.length > 0 ? groupByArray(await this.client.ORWORR_GET4LST(0, 0, value.map(x => x.ifn)), x => x.Grp) : [];
}
},
methods: {
strptime_vista
},
async mounted() {
this.map_groups = (await this.client.ORWORDG_ALLTREE()).reduce((acc, x) => (acc[x.ien] = x, acc), {});
}
};
</script>

View File

@ -87,17 +87,31 @@ function lab_parse1default(data) {
results[(x = results[i]).name] = x;
if(x.comment) x.comment = x.comment.join('\n');
}
if((res.accession.startsWith('HE ')) && ((results.hasOwnProperty('SEGS')) || (results.hasOwnProperty('BANDS')))) {
results.push(results['NEUTROPHIL%'] = {
name: 'NEUTROPHIL%', unit: '%', range: '42.2 - 75.2',
value: x = (results.hasOwnProperty('SEGS') ? +results.SEGS.value : 0) + (results.hasOwnProperty('BANDS') ? +results.BANDS.value : 0),
flag: (x < 42.2 ? 'L' : x > 75.2 ? 'H' : undefined)
});
results.push(results['NEUTROPHIL#'] = {
name: 'NEUTROPHIL#', unit: 'K/cmm', range: '1.4 - 6.5',
value: +(x = 0.01*x*results.WBC.value).toFixed(3),
flag: (x < 1.4 ? 'L' : x > 6.5 ? 'H' : undefined)
});
if(res.accession.startsWith('HE ')) {
if((results.hasOwnProperty('SEGS')) || (results.hasOwnProperty('BANDS'))) {
results.push(results['NEUTROPHIL%'] = {
name: 'NEUTROPHIL%', unit: '%', range: '42.2 - 75.2',
value: x = (results.hasOwnProperty('SEGS') ? +results.SEGS.value : 0) + (results.hasOwnProperty('BANDS') ? +results.BANDS.value : 0),
flag: (x < 42.2 ? 'L' : x > 75.2 ? 'H' : undefined)
});
results.push(results['NEUTROPHIL#'] = {
name: 'NEUTROPHIL#', unit: 'K/cmm', range: '1.4 - 6.5',
value: +(x = 0.01*x*results.WBC.value).toFixed(3),
flag: (x < 1.4 ? 'L' : x > 6.5 ? 'H' : undefined)
});
}
if((results.hasOwnProperty('LYMPHS')) || (results.hasOwnProperty('ATYPICAL LYMPHOCYTES'))) {
results.push(results['LYMPHOCYTE%'] = {
name: 'LYMPHOCYTE%', unit: '%', range: '15.0 - 41.0',
value: x = (results.hasOwnProperty('LYMPHS') ? +results.LYMPHS.value : 0) + (results.hasOwnProperty('ATYPICAL LYMPHOCYTES') ? +results['ATYPICAL LYMPHOCYTES'].value : 0),
flag: (x < 15 ? 'L' : x > 41 ? 'H' : undefined)
});
results.push(results['LYMPHOCYTE#'] = {
name: 'LYMPHOCYTE#', unit: 'K/cmm', range: '1.2 - 3.4',
value: +(x = 0.01*x*results.WBC.value).toFixed(3),
flag: (x < 1.2 ? 'L' : x > 3.4 ? 'H' : undefined)
});
}
}
return res;
}
@ -165,3 +179,36 @@ export function measurement_parse(data) {
res.push(...extras);
return res;
}
export function order_parse(data) {
var res = [], item, line;
for(var i = 0; i < data.length; ++i) {
if((line = data[i]).startsWith('~')) {
res.push(item = line.slice(1).split('^'));
item.IFN = item[0];
item.Grp = item[1];
item.OrdTm = item[2];
item.StrtTm = item[3];
item.StopTm = item[4];
item.Sts = item[5];
item.Sig = item[6];
item.Nrs = item[7];
item.Clk = item[8];
item.PrvID = item[9];
item.PrvNam = item[10];
item.Act = item[11];
item.Flagged = item[12];
item.DCType = item[13];
item.ChartRev = item[14];
item.DEA = item[15];
item.DigSig = item[17];
item.LOC = item[18];
item.DCORIGINAL = item[19];
item.IsPendingDCorder = item[20];
item.IsDelayOrder = item[21];
item.text = [];
} else if((item) && (line.startsWith('t'))) item.text.push(line.slice(1));
else console.log('INVALID:', line);
}
return res;
}

View File

@ -2,7 +2,7 @@ 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';
import { lab_parse, lab_reparse_results, measurement_parse, order_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');
@ -67,12 +67,24 @@ export function caretseparated1(fn, columns=null) {
}
}
export function sliced(fn, start, end) {
return async function(...args) {
return (await fn(...args)).slice(start, end);
}
}
export function labreportparsed(fn) {
return async function(...args) {
return lab_parse(await fn(...args));
}
}
export function orderparsed(fn) {
return async function(...args) {
return order_parse(await fn(...args));
}
}
export function tabulated(fn, mapping) {
return async function(...args) {
var res = (await fn(...args)).map(function(row) { return row.slice(); }), nrow = res.length;
@ -141,6 +153,11 @@ export function Client(cid, secret) {
this.ORWLRR_INTERIM = memoized(labreportparsed(unwrapped(logged((...args) => this.callctx(['OR CPRS GUI CHART'], 'ORWLRR_INTERIM', ...args), 'ORWLRR_INTERIM'))));
this.ORWLRR_INTERIM_RESULTS = memoized(async (...args) => lab_reparse_results(await this.ORWLRR_INTERIM(...args)));
this.ORWORDG_ALLTREE = memoized(caretseparated(unwrapped(logged(() => this.callctx(['OR CPRS GUI CHART'], 'ORWORDG_ALLTREE'), 'ORWORDG_ALLTREE')), ['ien', 'name', 'parent', 'has_children']));
this.ORWORDG_REVSTS = memoized(caretseparated(unwrapped(logged(() => this.callctx(['OR CPRS GUI CHART'], 'ORWORDG_REVSTS'), 'ORWORDG_REVSTS')), ['ien', 'name', 'parent', 'has_children']));
this.ORWORR_AGET = memoized(caretseparated(sliced(unwrapped(logged((...args) => this.callctx(['OR CPRS GUI CHART'], 'ORWORR_AGET', ...args), 'ORWORR_AGET')), 1), ['ifn', 'dgrp', 'time']));
this.ORWORR_GET4LST = memoized(orderparsed(unwrapped(logged((...args) => this.callctx(['OR CPRS GUI CHART'], 'ORWORR_GET4LST', ...args), 'ORWORR_GET4LST'))));
return this;
}
Client._registry = {};

View File

@ -31,7 +31,7 @@ class CacheProxyRPC(util.CacheProxy):
if volatile is None:
volatile = util.Store().memo
self._cache(('__call__', 'close', 'authenticate', 'keepalive', 'XWB_CREATE_CONTEXT', 'XWB_IM_HERE'), None)
self._cache(('SDEC_RESOURCE', 'ORWLRR_ALLTESTS_ALL'), persistent, prefix=prefix, ttl=float('inf'))
self._cache(('SDEC_RESOURCE', 'ORWLRR_ALLTESTS_ALL', 'ORWORDG_ALLTREE', 'ORWORDG_REVSTS'), persistent, prefix=prefix, ttl=float('inf'))
self._cache(('XWB_GET_BROKER_INFO', 'XUS_INTRO_MSG'), volatile, prefix=prefix, ttl=float('inf'))
self._cache(None, volatile, prefix=prefix, ttl=float('-inf'))
def _cache_persistent(self, persistent=None, prefix=''):

6
rpc.py
View File

@ -32,7 +32,7 @@ def l_pack(value: Any, envelope: int=3, wrapped: bool=True, basictype=b'0', enco
bare = b't'.join(l_pack(k, envelope=envelope, wrapped=False, encoding=encoding) + l_pack(v, envelope=envelope, wrapped=False, encoding=encoding) for k, v in value.items())
return (b'2' + bare + b'f') if wrapped else bare
elif not isinstance(value, str) and hasattr(value, '__iter__'):
bare = b't'.join(l_pack(k, envelope=envelope, wrapped=False, encoding=encoding) + l_pack(v, envelope=envelope, wrapped=False, encoding=encoding) for k, v in enumerate(value))
bare = b't'.join(l_pack(k, envelope=envelope, wrapped=False, encoding=encoding) + l_pack(v, envelope=envelope, wrapped=False, encoding=encoding) for k, v in enumerate(value, start=1))
return (b'2' + bare + b'f') if wrapped else bare
elif isinstance(value, MReference):
return l_pack(str(value), envelope=envelope, basictype=b'1', encoding=encoding)
@ -45,9 +45,9 @@ def l_pack(value: Any, envelope: int=3, wrapped: bool=True, basictype=b'0', enco
def l_pack_maxlen(value: Any, encoding: str='latin-1'):
if isinstance(value, dict):
return max(max(l_pack_maxlen(k, encoding=encoding) for k in value.keys()), max(l_pack_maxlen(v, encoding=encoding) for v in value.values()))
return max(max(l_pack_maxlen(k, encoding=encoding) for k in value.keys()), max(l_pack_maxlen(v, encoding=encoding) for v in value.values())) if len(value) > 0 else 0
elif not isinstance(value, str) and hasattr(value, '__iter__'):
return max(len(str(max(0, len(value) - 1))), max(l_pack_maxlen(v, encoding=encoding) for v in value))
return max(len(str(len(value))), max(l_pack_maxlen(v, encoding=encoding) for v in value)) if len(value) > 0 else 0
else:
return len(str(value).encode(encoding))