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, Input } from '@angular/core';
import { GridElement } from '../../models/uiModels';
import * as _ from 'lodash';
import { QueryParams, ProgressNote } from '../../models/patientModels';
import { AppState } from '../../models/state';
import { Store } from '@ngrx/store';
import * as patientActions from '../../actions/patient.action';
import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
import { ProgressNoteComponent } from '../progress-note/progress-note.component';
@Component({
selector: 'app-progress-notes',
templateUrl: './progress-notes.component.html',
styleUrls: ['./progress-notes.component.css']
})
export class ProgressNotesComponent {
/**
* local data store for note data, error info, unique note title list and the datatable to display
*/
_progressNotes = {
data: [],
err: '',
dataTable: [],
noteTitles : []
};
/**
* input property for current querystring parameters
*/
@Input()
queryParams: QueryParams;
/**
* input property of progress notes for display. In format {data: ProgessNote[], err: string }
* @description When input array changes, clear the data table & repopulate
*/
@Input()
set progressNotes(progressNotes: {data: ProgressNote[], err: string}) {
this._progressNotes.data = progressNotes.data;
this._progressNotes.err = progressNotes.err;
this._progressNotes.dataTable = [];
if (progressNotes.data) { this.generateDataTable(); }
}
/**
* property defines the data elements, headers & tooltips to display on the grid
*/
dataDef: Array<GridElement> = [
{ header: 'Local Title', key: 'localTitle', tooltip: 'Local Title name assigned to the progress note' },
{ header: 'Date/Time Entered', key: 'entryDate', tooltip: 'Date/Time of Note', format: 'date'},
{ header: 'Author', key: 'author', tooltip: 'Author of note or Dictating Provider' },
{ header: 'Status', key: 'status', tooltip: 'State of note (i.e. Unsigned, Completed, Amended, etc.)' },
{ header: 'Hospital Location', key: 'hospitalLocation', tooltip: 'This is the location (WARD or CLINIC) associated with the document' },
{ header: 'Facility',
key: 'facility.stationNumber',
tooltip: 'Station number of facility where progress note record was entered.',
dataTooltipKey: 'facility.siteName'
}
];
queryBuilderDef: Array<GridElement> = [
{ header: 'Standard Title', key: 'standardTitle'}
];
constructor(private _store: Store<AppState>, private modalService: NgbModal) {
// QueryBuilderDef should contain all the columns from the grid definition
this.queryBuilderDef = [...this.dataDef, ...this.queryBuilderDef];
}
/**
* used by template to display dataDef's header text for a field. in the case of
* standard title, it's set here statically.
* @param itm - Field name to get the display text for
*/
displayText(itm: string) {
if (itm === 'standardTitle') { return 'Standard Title'; }
return _.find(this.dataDef, (elem) => elem.key === itm ).header;
}
/**
* creates local dataTable array from the progress note data, applying local filters and
* sorting it.
*/
generateDataTable() {
this._progressNotes.dataTable = [];
// push the data into the data table
this._progressNotes.data.forEach((itm, idx) => {
this._progressNotes.dataTable.push({
localTitle: itm.localTitle,
entryDate: itm.entryDate,
author: itm.author,
status: itm.status,
hospitalLocation: itm.hospitalLocation,
'facility.stationNumber': itm.facility.stationNumber,
'facility.siteName': itm.facility.siteName,
standardTitle: itm.standardTitle,
dataIndex: idx
});
});
// pull out unique standard titles for filter..
this._progressNotes.noteTitles = _.sortedUniq(this._progressNotes.data.map((itm) => itm.standardTitle).sort());
}
/**
* Method for displaying detailed Progress Note record in a modal popup
* @param dataTableRecord the Progress Note to display
*/
viewDetail(dataTableRecord: any) {
const progressNoteModal = this.modalService.open(ProgressNoteComponent, {size: 'lg', windowClass: 'record-popup'});
progressNoteModal.componentInstance.data = {...this._progressNotes.data[dataTableRecord.dataIndex]};
}
/**
* Paging events bubble up from grid component. updating the store here triggers a requery
* @param action string in [prev, next, number]
*/
changePage(action: any) {
const newParams = JSON.parse(JSON.stringify(this.queryParams));
switch (action) {
case 'next':
newParams.page++;
break;
case 'prev':
if (newParams.page > 1) { newParams.page--; }
break;
default:
if (Number.isInteger(action)) { newParams.page = action; }
}
this._store.dispatch(new patientActions.SetQueryParameters({element: 'progressNotes', params: JSON.parse(JSON.stringify(newParams)) }));
}
sync(params: QueryParams) {
const newParams = JSON.parse(JSON.stringify(this.queryParams));
newParams.filter = JSON.parse(JSON.stringify(params.filter));
newParams.sort = JSON.parse(JSON.stringify(params.sort));
newParams.size = params.size;
newParams.page = 1;
this._store.dispatch(new patientActions.SetQueryParameters({element: 'progressNotes', params: JSON.parse(JSON.stringify(newParams)) }));
}
resetAndSync() {
this._store.dispatch(new patientActions.ResetQueryParameters({element: 'progressNotes'}));
}
}