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,
AfterViewInit,
OnChanges,
Input,
OnDestroy
} from '@angular/core';
import { Subscription } from 'rxjs/Subscription';
import { EwvViewerService } from '../../ewv-viewer/ewv-viewer.service';
import { PatientInfo } from '../../ewv-viewer/ewv-viewer.model';
@Component({
selector: 'app-patient-info',
templateUrl: './patient-info.component.html',
styleUrls: ['../../../ewv/ewv-viewer/ewv-viewer.component.scss']
})
export class PatientInfoComponent
implements OnDestroy, OnChanges, AfterViewInit {
@Input() data: PatientInfo;
@Input() accordionId;
isSplitView: boolean; // This
isSplitSubscription = new Subscription(); // This
collapseState = true;
patientInfoMsg = 'No Patient Information Found';
collapseStateSubscription: Subscription = new Subscription();
constructor(private ewvViewerService: EwvViewerService) {}
ngAfterViewInit() {
this.collapseStateSubscription = this.ewvViewerService
.getCollapseState()
.subscribe(state => {
this.collapseState = state;
});
}
ngOnChanges() {
this.populateData(); // This?
if (this.data) {
for (const element of Object.keys(this.data)) {
this.data[element] = this.data[element]
? this.data[element]
: '\u2013\u2013\u2013';
}
}
}
populateData() {
this.isSplitSubscription = this.ewvViewerService.isSplitView.subscribe(
// This
data => (this.isSplitView = data)
);
}
getFirstName() {
let firstName = '';
if (this.data && this.data && this.data.firstName) {
firstName = this.data.firstName;
}
return firstName;
}
getLastName() {
let lastName = '';
if (this.data && this.data && this.data.lastName) {
lastName = this.data.lastName;
}
return lastName;
}
getAddressOne() {
let addressOne = '';
if (this.data && this.data && this.data.addressLineOne) {
addressOne = this.data.addressLineOne;
}
return addressOne;
}
getAddressTwo() {
let addressTwo = '';
if (this.data && this.data && this.data.addressLineTwo) {
addressTwo = this.data.addressLineTwo;
}
return addressTwo;
}
getCity() {
let city = '';
if (this.data && this.data && this.data.city) {
city = this.data.city;
}
return city;
}
getState() {
let state = '';
if (this.data && this.data && this.data.state) {
state = this.data.state;
}
return state;
}
getZipCode() {
let zipCode = '';
if (this.data && this.data && this.data.postalCode) {
zipCode = this.data.postalCode;
}
return zipCode;
}
getCountry() {
let country = '';
if (this.data && this.data && this.data.country) {
country = this.data.country;
}
return country;
}
ngOnDestroy() {
this.collapseStateSubscription.unsubscribe();
this.isSplitSubscription.unsubscribe(); // This
}
getCopyAddressTextValue() {
let copyAddressTextValue = '';
copyAddressTextValue =
this.getFirstName() + ' ' + this.getLastName() + '\r';
if (this.getAddressOne()) {
copyAddressTextValue += this.getAddressOne() + '\r';
}
if (this.getAddressTwo()) {
copyAddressTextValue += this.getAddressTwo() + '\r';
}
copyAddressTextValue +=
this.getCity() + ', ' + this.getState() + ' ' + this.getZipCode() + '\r';
if (this.getCountry()) {
copyAddressTextValue += this.getCountry();
}
return copyAddressTextValue;
}
// Idea of code below came from the https://hackernoon.com/copying-text-to-clipboard-with-javascript-df4d4988697f web page.
copyPatientInformationAddressToClipboard() {
const el = document.createElement('textarea');
el.value = this.getCopyAddressTextValue();
el.setAttribute('readonly', '');
el.style.position = 'absolute';
el.style.left = '-9999px';
document.body.appendChild(el);
el.select();
document.execCommand('copy');
document.body.removeChild(el);
}
}