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 { NgbModal } from '@ng-bootstrap/ng-bootstrap';
import { PatientQueryParams } from '../../models/queryParams';
import { PatientPrimaryCareModalComponent } from '../patient-primary-care-modal/patient-primary-care-modal.component';
import { CwadComponent } from '../cwad/cwad.component';
import { Patient } from '../../models/patientModels';
import * as _ from 'lodash';
import { AppointmentsComponent } from '../appointments/appointments.component';
@Component({
selector: 'app-demographics',
templateUrl: './demographics.component.html',
styleUrls: ['./demographics.component.css']
})
export class DemographicsComponent implements OnInit {
patient = {
data: null,
params: null
};
@Input()
set selectedPatient(selectedPatient: {data: Patient, params: PatientQueryParams }) {
this.patient.data = selectedPatient.data;
this.patient.params = selectedPatient.params;
}
constructor(private modalService: NgbModal) { }
ngOnInit() {
}
/**
* Method for displaying detailed patient primary care information in a modal popup
* @param primaryCareRecord the patient primary care record to display
*/
viewPrimaryCareDetails(patientData: any) {
const primaryCareModal = this.modalService.open(PatientPrimaryCareModalComponent, {size: 'lg', windowClass: 'record-popup'});
primaryCareModal.componentInstance.patient = patientData.data;
}
/**
* Method for displaying cwad component in a modal
*/
viewCWADModal() {
const CWADModal = this.modalService.open(CwadComponent, {size: 'lg', windowClass: 'record-popup'});
CWADModal.componentInstance.allergyParams = this.patient.params.allergies;
CWADModal.componentInstance.data = {allergies: this.patient.data.allergies.data, cwad: this.patient.data.cwad.data} ;
}
/**
* Method for displaying patient appointments component in a modal
*/
viewAppointmentsModal() {
const ApptModal = this.modalService.open(AppointmentsComponent, {size: 'lg', windowClass: 'record-popup'});
}
/**
* Calculates the age of the patient using the Date of Birth
*/
calculateAge() {
const dt = new Date(this.patient.data.identity.dob);
const dtOfDeath = new Date(this.patient.data.identity.dateOfDeath);
if (this.patient.data.identity.dob && dt.toString() !== 'Invalid Date' ) {
const endDtTime = (this.patient.data.identity.dateOfDeath && dtOfDeath.toString() !== 'Invalid Date')
? dtOfDeath.getTime() : Date.now();
const timeDiff = Math.abs(endDtTime - dt.getTime());
return Math.floor((timeDiff / (1000 * 3600 * 24)) / 365.25);
} else {
return '';
}
}
/**
* Calculates the BSA of the patient
*/
calculateBsa() {
if (!this.patient.data.vitalSummary) { return '_____'; }
if (!this.patient.data.vitalSummary['height'] || !this.patient.data.vitalSummary['height'].data
|| !this.patient.data.vitalSummary['height'].data.metric) {
return '_____';
}
if (!this.patient.data.vitalSummary['weight'] || !this.patient.data.vitalSummary['weight'].data
|| !this.patient.data.vitalSummary['weight'].data.metric) {
return '_____';
}
const patientHtMeters = Number(this.patient.data.vitalSummary['height'].data.metric.value) * 0.01;
const patientWtKgs = Number(this.patient.data.vitalSummary['weight'].data.metric.value);
return (0.20247 * Math.pow(patientHtMeters, 0.725) * Math.pow(patientWtKgs, 0.425)).toFixed(2);
}
/**
* Calculates the BMI of the patient
*/
calculateBmi() {
if (!this.patient.data.vitalSummary) { return '_____'; }
if (!this.patient.data.vitalSummary['height'] || !this.patient.data.vitalSummary['height'].data
|| !this.patient.data.vitalSummary['height'].data.metric) {
return '_____';
}
if (!this.patient.data.vitalSummary['weight'] || !this.patient.data.vitalSummary['weight'].data
|| !this.patient.data.vitalSummary['weight'].data.metric) {
return '_____';
}
const patientHtMeters = Number(this.patient.data.vitalSummary['height'].data.metric.value) * 0.01;
const patientWtKgs = Number(this.patient.data.vitalSummary['weight'].data.metric.value);
return (patientWtKgs / (patientHtMeters * patientHtMeters)).toFixed(2);
}
/**
* Calculates the creatine clearance value of the patient
*/
calculateCrCl() {
const age = this.calculateAge();
if (age === '' ) { return '<Not Found>'; }
if (!this.patient.data.vitalSummary || !this.patient.data.labSummary) { return '<Not Found>'; }
if (!this.patient.data.vitalSummary['height'] || !this.patient.data.vitalSummary['height'].data
|| !this.patient.data.vitalSummary['height'].data.metric) {
return '<Not Found>';
}
if (!this.patient.data.vitalSummary['weight'] || !this.patient.data.vitalSummary['weight'].data
|| !this.patient.data.vitalSummary['weight'].data.metric) {
return '<Not Found>';
}
if (!this.patient.data.labSummary['creatinine'] || !this.patient.data.labSummary['creatinine'].data
|| !this.patient.data.labSummary['creatinine'].data.metric) {
return '<Not Found>';
}
const patientHtInches = Number(this.patient.data.vitalSummary['height'].data.metric.value) * 0.39370;
const patientWtKgs = Number(this.patient.data.vitalSummary['weight'].data.metric.value);
const creatinine = Number(this.patient.data.labSummary['creatinine'].data.metric.value);
let idealBodyWt, multiplier = 1;
if (this.patient.data.identity.gender === 'Male') {
idealBodyWt = 50 + 2.3 * (patientHtInches - 60);
} else {
idealBodyWt = 45 + 2.3 * (patientHtInches - 60);
multiplier = 0.85;
}
let adjustedBodyWt = patientWtKgs;
if (patientHtInches > 60) {
if ((patientWtKgs / idealBodyWt) > 1.3) {
adjustedBodyWt = (0.3 * (patientWtKgs - idealBodyWt)) + idealBodyWt;
} else {
adjustedBodyWt = (idealBodyWt < patientWtKgs) ? idealBodyWt : patientWtKgs;
}
}
const crcl = ((140 - age) * (adjustedBodyWt) / (creatinine * 72));
return (multiplier * crcl).toFixed(2) + ' (est.)';
}
/**
* Returns the value of Combat Veteran Status based on End date
*/
getCombatVetStatus() {
if (!this.patient.data.details || !this.patient.data.details.data
|| !this.patient.data.details.data.eligibility) { return ''; }
if (!this.patient.data.details.data.eligibility.combatVetEndDate) { return 'Not Eligible'; }
const dt = new Date(this.patient.data.details.data.eligibility.combatVetEndDate);
const today = new Date();
today.setHours(0, 0, 0, 0);
if (dt.toString() !== 'Invalid Date') {
if (dt > today) {
return 'Eligible';
}
}
return 'Not Eligible';
}
/**
* Returns whether or not any of the Conflict Locations are service indicated
* or any of the Environmental Exposures are exposure indicated
*/
getIndicated(data: any): boolean {
if (!data) { return false; }
if (_.find(data, function(itm) { return itm.serviceIndicated || itm.exposureIndicated; })) {
return true;
} else {
return false;
}
}
/**
* Returns string C, W, A, D from cwad data
*/
getPostings(): string {
if (!this.patient.data || !this.patient.data.cwad || !this.patient.data.cwad.data) { return ''; }
const ord = ['C', 'W', 'A', 'D'];
return _.uniq(_.map(this.patient.data.cwad.data, 'docType')).sort((itm1, itm2) => ord.indexOf(itm1) - ord.indexOf(itm2)).join(' ');
}
/**
* Truncates text by a number of letters and adds ellipse {...} if greater
* then the limit to be displayed. if completeWords = true then words wont
* be cut.
*/
truncate(value: string, limit = 30, completeWords = false, ellipsis = '…') {
const lastindex = limit;
if (!value || value === '' ) { return ''; }
if (value.length < limit) {
return `${value.substr(0, limit)}`;
}
if (completeWords) {
limit = value.substr(0, limit).lastIndexOf(' ');
}
return `${value.substr(0, limit)}${ellipsis}`;
}
}