CaMa indicators and follow-up list, model governance page
This commit is contained in:
@@ -0,0 +1,93 @@
|
||||
import { Component, computed, inject, input, resource, signal } from '@angular/core';
|
||||
import { FormsModule } from '@angular/forms';
|
||||
import { MatButtonModule } from '@angular/material/button';
|
||||
import { MatFormFieldModule } from '@angular/material/form-field';
|
||||
import { MatInputModule } from '@angular/material/input';
|
||||
import { MatSelectModule } from '@angular/material/select';
|
||||
import { RouterLink } from '@angular/router';
|
||||
import type { Bundle } from 'fhir/r4';
|
||||
import { Fhir } from '../fhir';
|
||||
import { camaRows } from './follow-up';
|
||||
import { name, PRIORITY } from './measures';
|
||||
|
||||
const STATUSES = ['cancer', 'pending_biopsy', 'biopsy_no_result', 'benign_biopsy'];
|
||||
|
||||
/** CaMa's follow-up list at a cut-off: patients whose latest mammogram in the window is
|
||||
* BI-RADS 4 to 6, where their biopsy stands and how soon they should be seen. */
|
||||
@Component({
|
||||
selector: 'app-tab-seguimiento',
|
||||
imports: [
|
||||
FormsModule,
|
||||
MatButtonModule,
|
||||
MatFormFieldModule,
|
||||
MatInputModule,
|
||||
MatSelectModule,
|
||||
RouterLink,
|
||||
],
|
||||
templateUrl: './tab-seguimiento.html',
|
||||
styleUrl: './tab-riesgos.scss',
|
||||
})
|
||||
export class TabSeguimiento {
|
||||
private readonly fhir = inject(Fhir);
|
||||
readonly domain = input.required<string>();
|
||||
|
||||
protected readonly cutoff = signal<string>('');
|
||||
protected readonly window = signal(3);
|
||||
protected readonly status = signal<string>('');
|
||||
protected readonly size = signal(20);
|
||||
private readonly moved = signal<Bundle | undefined>(undefined);
|
||||
|
||||
protected readonly statuses = STATUSES;
|
||||
protected readonly name = name;
|
||||
protected readonly priority = (code: string) => PRIORITY[code] ?? code;
|
||||
|
||||
private readonly first = resource({
|
||||
params: () => ({
|
||||
domain: this.domain(),
|
||||
'follow-up-window': this.window(),
|
||||
'follow-up-cutoff': this.cutoff() || undefined,
|
||||
'follow-up-status': this.status() || undefined,
|
||||
_count: this.size(),
|
||||
}),
|
||||
loader: ({ params: { domain, ...params } }) => {
|
||||
this.moved.set(undefined);
|
||||
return this.fhir.search(domain, 'Patient', {
|
||||
...params,
|
||||
_revinclude: ['DiagnosticReport:subject'],
|
||||
'_include:iterate': 'DiagnosticReport:result',
|
||||
});
|
||||
},
|
||||
});
|
||||
protected readonly loading = signal(false);
|
||||
protected readonly page = computed(() => this.moved() ?? this.first.value());
|
||||
protected readonly applied = computed(() => {
|
||||
const self = this.page()?.link?.find((l) => l.relation === 'self')?.url;
|
||||
return self ? (new URL(self).searchParams.get('follow-up-cutoff') ?? '') : '';
|
||||
});
|
||||
protected readonly offset = computed(() => {
|
||||
const self = this.page()?.link?.find((l) => l.relation === 'self')?.url;
|
||||
return self ? Number(new URL(self).searchParams.get('_offset') ?? 0) : 0;
|
||||
});
|
||||
protected readonly rows = computed(() => {
|
||||
const page = this.page();
|
||||
const cutoff = this.applied();
|
||||
return page && cutoff ? camaRows(page, cutoff) : [];
|
||||
});
|
||||
protected readonly error = computed(() => this.first.error());
|
||||
|
||||
protected has(relation: 'next' | 'previous'): boolean {
|
||||
return !!this.page()?.link?.some((l) => l.relation === relation);
|
||||
}
|
||||
|
||||
protected async go(relation: 'next' | 'previous'): Promise<void> {
|
||||
const page = this.page();
|
||||
const next = page && this.fhir.follow(this.domain(), page, relation);
|
||||
if (!next) return;
|
||||
this.loading.set(true);
|
||||
try {
|
||||
this.moved.set(await next);
|
||||
} finally {
|
||||
this.loading.set(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user