|
|
@@ -2,7 +2,7 @@ function gather(
|
|
|
data: App.Health.Index.Data[],
|
|
|
transform: (model: App.Health.Index.Model) => any,
|
|
|
skip = false,
|
|
|
- link = { 血压: [1, 2], }
|
|
|
+ link = { 血压: ['收缩压', '舒张压'], }
|
|
|
) {
|
|
|
const ref = ((link) => {
|
|
|
const ref: Record<string, { id: string; name: string; }> = {};
|
|
|
@@ -15,9 +15,9 @@ function gather(
|
|
|
|
|
|
const cache = new Map<{ id: string; name: string; }, App.Health.Index.Ruler[]>();
|
|
|
for (const item of data) {
|
|
|
- if (skip && item.isAuto) continue;
|
|
|
+ if (skip && item.isAuto === 'Y') continue;
|
|
|
const model = createHealthIndex(item);
|
|
|
- const _ = ref[model.id] ?? { id: model.id, name: model.name };
|
|
|
+ const _ = ref[model.name] ?? { id: model.id, name: model.name };
|
|
|
if (ref[model.id]) model.name = model.name.replace(_.name, '');
|
|
|
if (cache.has(_)) {
|
|
|
cache.get(_)?.push(transform(model))
|
|
|
@@ -32,11 +32,6 @@ export function healthIndex2Ruler(model: App.Health.Index.Model): App.Health.Ind
|
|
|
let { scope, range, precision, values, ...ruler } = model;
|
|
|
const min = range?.[0] ?? Math.floor(scope[0] * 0.5);
|
|
|
const max = range?.[1] ?? Math.floor(scope[1] * 1.5);
|
|
|
- precision = ((diff) => {
|
|
|
- if (diff < 5) return 0.01;
|
|
|
- if (diff < 10) return 0.1;
|
|
|
- else return 1;
|
|
|
- })(max - min)
|
|
|
return {
|
|
|
...ruler, min, max, precision,
|
|
|
markLine: [
|
|
|
@@ -97,7 +92,7 @@ export function createHealthIndex(data: App.Health.Index.Data): App.Health.Index
|
|
|
]
|
|
|
return {
|
|
|
...model, id,
|
|
|
- precision: (+inputPrecision!) || 1,
|
|
|
+ precision: ({ 0: 0.01, 1: 0.1, 2: 2, 3: 1 } as any)[inputPrecision ?? 3],
|
|
|
range, scope,
|
|
|
values: patientQuotaRecordDTOS?.map(item => {
|
|
|
return { value: +item.quotaVal, abnormal: item.abnormal, description: item.abnormalDesc, date: item.time2 }
|
|
|
@@ -107,27 +102,6 @@ export function createHealthIndex(data: App.Health.Index.Data): App.Health.Index
|
|
|
|
|
|
|
|
|
export function transformHealthIndex2Ruler(data: App.Health.Index.Data[]): { id: string, name: string, options: App.Health.Index.Ruler[] }[] {
|
|
|
- // const ref = ((link) => {
|
|
|
- // const ref: Record<string, { id: string; name: string; }> = {};
|
|
|
- // Object.entries(link).forEach(([name, keys]) => {
|
|
|
- // const _ = { id: name, name };
|
|
|
- // keys.forEach(key => { ref[key] = _; })
|
|
|
- // })
|
|
|
- // return ref;
|
|
|
- // })({ 血压: [1, 2], })
|
|
|
- // const cache = new Map<{ id: string; name: string; }, App.Health.Index.Ruler[]>();
|
|
|
- // for (const item of data) {
|
|
|
- // if (item.isAuto) continue;
|
|
|
- // const model = createHealthIndex(item);
|
|
|
- // const _ = ref[model.id] ?? { id: model.id, name: model.name };
|
|
|
- // if (ref[model.id]) model.name = model.name.replace(_.name, '');
|
|
|
- // if (cache.has(_)) {
|
|
|
- // cache.get(_)?.push(healthIndex2Ruler(model))
|
|
|
- // } else {
|
|
|
- // cache.set(_, [healthIndex2Ruler(model)])
|
|
|
- // }
|
|
|
- // }
|
|
|
- // return [...cache].map(gather => ({ ...gather[0], options: gather[1] }))
|
|
|
return gather(data, healthIndex2Ruler, true);
|
|
|
}
|
|
|
|