Summary Table
Categories |
Total Count |
PII |
0 |
URL |
0 |
DNS |
0 |
EKL |
0 |
IP |
0 |
PORT |
0 |
VsID |
0 |
CF |
0 |
AI |
0 |
VPD |
0 |
PL |
0 |
Other |
0 |
File Content
import { Component, OnInit, Input } from '@angular/core';
import { AppState } from '../../models/state';
import { Store } from '@ngrx/store';
import * as patientActions from '../../actions/patient.action';
import { ObservationHash, PatientQueryParams, FilterOps } from '../../models/patientModels';
@Component({
selector: 'app-vital-summary',
templateUrl: './vital-summary.component.html',
styleUrls: ['./vital-summary.component.css']
})
export class VitalSummaryComponent implements OnInit {
_queryParams: PatientQueryParams;
selectedKeys = [];
addVital = '';
@Input() vitalSummary: ObservationHash;
@Input()
set queryParams(params: PatientQueryParams) {
this._queryParams = params;
this.selectedKeys = (params.vitals.filter.name && params.vitals.filter.name.value) ? params.vitals.filter.name.value.split('+') : [];
}
constructor(private _store: Store<AppState>) { }
ngOnInit() {
}
/**
* Updates the vitals parameters to trigger a details refresh.
* If the user clicks an already-selected key, it's deselected, otherwise, it's selected.
* @param key key of the vital type that was clicked
*/
selectRow(key: string) {
const idx = this.selectedKeys.indexOf(key);
const newParams = JSON.parse(JSON.stringify(this._queryParams.vitals));
let newKeys = [...this.selectedKeys];
if ( idx >= 0) {
// only let them deselect if it's the not the last vital selected
if (newKeys.length > 1) {
newKeys = [...newKeys.slice(0, idx), ...newKeys.slice(idx + 1)];
}
} else {
newKeys.push(key);
}
const newKey = newKeys.join('+');
newParams.filter['name'] = { operator: FilterOps.eq, value: newKey };
newParams.page = 1;
this._store.dispatch(new patientActions.SetQueryParameters({element: 'vitals', params: JSON.parse(JSON.stringify(newParams)) }));
}
addSummaryType() {
// they shouldn't be able to trigger this without selecting a type, but check they did anyhow..
if (this.addVital === '' ) { return; }
try {
const newVital = this.addVital.split('|');
if (newVital.length < 3) { return; }
this._store.dispatch(new patientActions.AddVitalSummaryType({key: newVital[0], title: newVital[2], abbr: newVital[1]}));
} catch (ex) {
return;
}
}
keySelected(key) {
if (this.selectedKeys.indexOf(key) >= 0 ) {
return true;
} else {
return false;
}
}
// TODO - ALLOW MULTI_SELECT HERE! THEN ADD CHART
}