[text] patient-collection.component.ts

Viewer

copydownloadembedprintName: patient-collection.component.ts
  1. import { Component, OnInit, OnDestroy, HostListener, enableProdMode, ViewChild } from "@angular/core";
  2. import { Router, ActivatedRoute } from "@angular/router";
  3. import { LoginService } from "src/app/login/services/login.service";
  4. import { LogoutService } from "src/app/login/services/logout.service";
  5. import { Patient } from "src/app/shared/model/patient";
  6. import { SessionStorageService } from "src/app/shared/services/session-storage.service";
  7. import { AppConstants } from "src/app/shared/constants/app-constants";
  8. import { DatePipe } from "@angular/common";
  9. import { PatientCollectionService } from "./services/patient-collection.service";
  10. import { NotificationService } from "src/app/shared/services/notification.service";
  11. import { DeviceDetectorService } from "ngx-device-detector";
  12. import { UserService } from "src/app/shared/services/user.service";
  13. import { User } from "src/app/shared/model/user";
  14. import { SharePointService } from "../sharepoint/services/sharePoint.service";
  15. import { DxTextBoxComponent, DxPopupComponent, DxSelectBoxComponent, DxDateBoxComponent, DxScrollViewComponent } from "devextreme-angular";
  16. import { VDASService } from "./services/vdas.service";
  17. import { Doctor } from "src/app/shared/model/doctor";
  18. import { DoctorService } from "./services/doctor.service";
  19. import { OrganisationService } from "./services/organisation.service";
  20. import { ValidationService } from "src/app/shared/services/validation.service";
  21. import { TimeSlot } from "src/app/shared/model/timeslot";
  22. import { SchedulerService } from "../scheduler/services/scheduler.service";
  23. import { ResidenceService } from "./services/residence.service";
  24. import { EndpointConfigService } from "src/app/shared/services/endpoint-config.service";
  25. import { LoadingIndicatorService } from "src/app/shared/services/loading-indicator.service";
  26. import validationEngine from 'devextreme/ui/validation_engine';
  27.  
  28. enableProdMode();
  29.  
  30. @Component({
  31.   selector: 'app-patient-collection',
  32.   templateUrl: './patient-collection.component.html',
  33.   styleUrls: ['./patient-collection.component.css']
  34. })
  35. export class PatientCollectionComponent implements OnInit, OnDestroy {
  36.  
  37.   @ViewChild('lastnameInput', { static: false }) lastnameInput: DxTextBoxComponent;
  38.   @ViewChild('secondAppointmentInput', { static: false }) secondAppointmentInput: DxDateBoxComponent;
  39.   @ViewChild('appointmentInput', { static: false }) appointmentInput: DxDateBoxComponent;
  40.   @ViewChild('authorityAssignedIdInput', { static: false }) authorityAssignedIdInput: DxTextBoxComponent;
  41.   @ViewChild('driveInAssignedIdInput', { static: false }) driveInAssignedIdInput: DxTextBoxComponent;
  42.   @ViewChild('birthdateInput', { static: false }) birthdateInput: DxDateBoxComponent;
  43.   @ViewChild('ssnInput', { static: false }) ssnInput: DxTextBoxComponent;
  44.   @ViewChild('vdasPopup', { static: false }) vdasPopup: DxPopupComponent;
  45.   @ViewChild('driveInSelectBox', { static: false }) driveInSelectBox: DxSelectBoxComponent;
  46.   @ViewChild('authoritySelectBox', { static: false }) authoritySelectBox: DxSelectBoxComponent;
  47.   @ViewChild('scrollView', { static: false }) scrollView: DxScrollViewComponent;
  48.   @ViewChild('statusInput', { static: false }) statusInput: DxSelectBoxComponent;
  49.   @ViewChild('laborInput', { static: false }) laborInput: DxSelectBoxComponent;
  50.   @ViewChild('svtCodeInput', { static: false }) svtCodeInput: DxSelectBoxComponent;
  51.   @ViewChild('contactDateInput', { static: false }) contactDateInput: DxDateBoxComponent;
  52.   user: User = JSON.parse(this.sessionStorageService.get(AppConstants.USER));
  53.  
  54.   collectPatient: boolean = true;
  55.   collectPatientForRetest: boolean = false;
  56.   origin: string = '';
  57.   ssn: string = '';
  58.   lastname: string = '';
  59.   birthdate: string = '';
  60.   pageTitle: string = '';
  61.   tabIndex: number = 0;
  62.   patient: Patient;
  63.   canEdit: boolean = false;
  64.   callCenterCanEdit: boolean = false;
  65.   canEditAppointmentHealth: boolean = false;
  66.   maxDate = new Date();
  67.   sexEntries = [
  68.     { name: 'Unknown', text: 'keine Angabe' },
  69.     { name: 'Male', text: "männlich" },
  70.     { name: 'Female', text: "weiblich" },
  71.     { name: 'Diverse', text: 'divers' }
  72.   ];
  73.   areaEntries = JSON.parse(this.sessionStorageService.get(AppConstants.AREAS));
  74.   priorityEntries = JSON.parse(this.sessionStorageService.get(AppConstants.PRIORITIES));
  75.   driveInEntries = JSON.parse(this.sessionStorageService.get(AppConstants.DRIVE_INS));
  76.   authorityEntries = JSON.parse(this.sessionStorageService.get(AppConstants.AUTHORITIES));
  77.   countryCodeEntries = JSON.parse(this.sessionStorageService.get(AppConstants.COUNTRY_CODES));
  78.   statusEntries = JSON.parse(this.sessionStorageService.get(AppConstants.PHONE_STATI));
  79.   setStatusEntries = JSON.parse(this.sessionStorageService.get(AppConstants.SET_STATI));
  80.   laborEntries = JSON.parse(this.sessionStorageService.get(AppConstants.LABORS));
  81.   socialInsuranceCarriers = JSON.parse(this.sessionStorageService.get(AppConstants.SOCIAL_INSURANCE_CARRIERS));
  82.   appointmentEntries: TimeSlot[] = [];
  83.   secAppointmentEntries: TimeSlot[] = [];
  84.  
  85.   pickerType = 'calendar';
  86.   isDesktop: boolean = false;
  87.   isMobile: boolean = false;
  88.   isTablet: boolean = false;
  89.  
  90.   vdasPopupVisible = false;
  91.   vdasPatient: Patient;
  92.  
  93.   doctors: Doctor[];
  94.   organisations;
  95.   residences;
  96.   isVDASLoading = false;
  97.  
  98.   schedulePopupVisible: boolean = false;
  99.   type: string;
  100.  
  101.   status: string;
  102.  
  103.   daysInFuture: number;
  104.   daysToContactDate: number;
  105.  
  106.   constructor(private router: Router,
  107.     private route: ActivatedRoute,
  108.     private loginService: LoginService,
  109.     private logoutService: LogoutService,
  110.     private userService: UserService,
  111.     private patientCollectionService: PatientCollectionService,
  112.     private vdasService: VDASService,
  113.     private doctorService: DoctorService,
  114.     private organisationService: OrganisationService,
  115.     private residenceService: ResidenceService,
  116.     private sharePointService: SharePointService,
  117.     private schedulerService: SchedulerService,
  118.     private validationService: ValidationService,
  119.     private endpointConfigService: EndpointConfigService,
  120.     private loadingIndicatorService: LoadingIndicatorService,
  121.     private notificationService: NotificationService,
  122.     private sessionStorageService: SessionStorageService,
  123.     private deviceDetector: DeviceDetectorService,
  124.     private datePipe: DatePipe) { }
  125.  
  126.   @HostListener('window:unload', ['$event'])
  127.   unload(evt) {
  128.     if (this.patient.id && this.patient.id.length > 0)
  129.       this.patientCollectionService.deletePersonLock(this.patient.id).subscribe();
  130.   }
  131.  
  132.   @HostListener('window:resize', ['$event'])
  133.   onResize(event) {
  134.     window.dispatchEvent(new Event('patientCollectionResize'));
  135.   }
  136.  
  137.   ngOnInit() {
  138.     if (this.loginService.isLoggedIn()) {
  139.       this.origin = this.route.snapshot.queryParamMap.get('origin');
  140.       this.ssn = this.route.snapshot.queryParamMap.get('ssn');
  141.       this.lastname = this.route.snapshot.queryParamMap.get('lastname');
  142.       this.birthdate = this.route.snapshot.queryParamMap.get('birthdate');
  143.       this.tabIndex = this.sessionStorageService.get(AppConstants.SELECTED_TAB) && this.sessionStorageService.get(AppConstants.SELECTED_TAB).length > 0 ? Number(this.sessionStorageService.get(AppConstants.SELECTED_TAB)) : 0;
  144.       this.collectPatient = Boolean(JSON.parse(this.route.snapshot.queryParamMap.get('collectPatient')));
  145.       this.collectPatientForRetest = Boolean(JSON.parse(this.route.snapshot.queryParamMap.get('collectPatientForRetest')));
  146.       if (this.collectPatient) {
  147.         this.pageTitle = 'Drive-In Klientenerfassung';
  148.       } else {
  149.         this.pageTitle = 'Drive-In Klient ändern';
  150.       }
  151.  
  152.       if (!this.collectPatient) {
  153.         this.patient = this.route.snapshot.data.person.body.data.personDetails;
  154.         this.setPatient();
  155.       } else {
  156.         if (!this.collectPatientForRetest) {
  157.           this.patient = new Patient();
  158.           this.patient.priority = "Other";
  159.           this.patient.gesundTestung = false;
  160.           this.patient.gesundTestungEinfach = false;
  161.           this.patient.isDriveInPossible = false;
  162.           this.patient.dataTransferAccepted = false;
  163.           this.patient.nationality = 'AT';
  164.           this.patient.vip = false;
  165.           this.patient.phone = '+43';
  166.           this.patient.contactPerson1OneAppointment = false;
  167.           this.patient.contactPerson1TwoAppointments = false;
  168.           this.patient.notification = true;
  169.           this.patient.appointmentRecording = false;
  170.           // this.patient.familyDoctor = new Doctor();
  171.         }
  172.         else {
  173.           this.patient = this.route.snapshot.data.person.body.data.personDetails;
  174.  
  175.           this.patient.status = null;
  176.           this.patient.authorityId = null;
  177.           this.patient.isDriveInPossible = false;
  178.           this.patient.gesundTestung = false;
  179.           this.patient.gesundTestungEinfach = false;
  180.           this.patient.priority = "Other";
  181.           this.patient.organisationText = null;
  182.           this.patient.authorityAssignedId = null;
  183.           this.patient.driveInAssignedId = null;
  184.           this.patient.appointment = null;
  185.           this.patient.secondAppointment = null;
  186.           this.patient.driveInId = null;
  187.           this.patient.secondDriveInId = null;
  188.           this.patient.laboratoryId = null;
  189.           this.patient.contactDate = null;
  190.           this.patient.countryOfResidence = null;
  191.           this.patient.contactPerson1OneAppointment = false;
  192.           this.patient.contactPerson1TwoAppointments = false;
  193.           this.patient.notification = true;
  194.           this.patient.appointmentRecording = false;
  195.         }
  196.       }
  197.     } else {
  198.       this.logoutService.logout();
  199.     }
  200.  
  201.     setTimeout(() => {
  202.       window.dispatchEvent(new Event('patientCollectionResize'));
  203.     });
  204.  
  205.     this.isDesktop = this.deviceDetector.isDesktop();
  206.     this.isMobile = this.deviceDetector.isMobile();
  207.     this.isTablet = this.deviceDetector.isTablet();
  208.  
  209.     this.setCanEditFields();
  210.  
  211.     if (this.canEdit && this.deviceDetector.isDesktop()) {
  212.       setTimeout(() => {
  213.         if (this.lastnameInput && this.lastnameInput.instance) {
  214.           this.lastnameInput.instance.focus();
  215.         }
  216.       }, 500);
  217.     }
  218.  
  219.     if (this.deviceDetector.isMobile()) {
  220.       $('#patientCollection').css('width', '95%');
  221.       $('#patientCollection').css('margin-left', '2.5%');
  222.       $('#patientCollection').css('margin-right', '2.5%');
  223.     }
  224.     setTimeout(() => {
  225.       this.setVdasStyle();
  226.     });
  227.  
  228.     if (this.deviceDetector.isDesktop()) {
  229.       this.pickerType = 'calendar';
  230.     } else {
  231.       this.pickerType = 'native';
  232.     }
  233.  
  234.     setTimeout(() => {
  235.       if (!this.authoritySelectBox.disabled && this.patient.priority && this.patient.priority === 'PrivateTesting') {
  236.         this.laborInput.disabled = false;
  237.       } else {
  238.         this.laborInput.disabled = true;
  239.       }
  240.  
  241.       if (!this.authoritySelectBox.disabled && this.patient.priority && (this.patient.priority === 'ContactPerson1WithNotification' || this.patient.priority === 'ContactPerson1')) {
  242.         this.contactDateInput.disabled = false;
  243.       } else {
  244.         this.contactDateInput.disabled = true;
  245.       }
  246.  
  247.       if (this.patient.driveInId && !this.patient.secondDriveInId && (this.patient.gesundTestung || this.patient.contactDate)) {
  248.         this.patient.secondDriveInId = this.patient.driveInId;
  249.       }
  250.     });
  251.     this.priorityComparison = this.priorityComparison.bind(this);
  252.     this.statusComparison = this.statusComparison.bind(this);
  253.     this.contactDateComparison = this.contactDateComparison.bind(this);
  254.     this.contactSecondAppointmentComparison = this.contactSecondAppointmentComparison.bind(this);
  255.     this.phoneComparison = this.phoneComparison.bind(this);
  256.  
  257.     if (this.ssn && this.ssn.length > 0) {
  258.       this.patient.ssn = this.ssn;
  259.       this.vdas('');
  260.     }
  261.     if (this.lastname && this.lastname.length > 0)
  262.       this.patient.lastname = this.lastname;
  263.     if (this.birthdate && this.birthdate.length > 0)
  264.       this.patient.birthdate = JSON.parse(this.birthdate);
  265.  
  266.     this.daysToContactDate = this.endpointConfigService.getDaysToContactDateWhereTestRequired();
  267.     this.daysInFuture = this.endpointConfigService.getLoadAppointmentsDaysInFuture();
  268.     this.queryTimeSlots();
  269.   }
  270.  
  271.   ngOnDestroy() {
  272.     if (this.patient.id && this.patient.id.length > 0) {
  273.       this.patientCollectionService.deletePersonLock(this.patient.id).subscribe(response => {
  274.         if (response && response.body && response.body.errors && response.body.errors.length > 0) {
  275.           this.notificationService.notifyError('Klient konnte nicht freigegeben werden: ' + response.body.errors[0].message);
  276.         }
  277.       }, error => {
  278.         this.notificationService.notifyError('Klient konnte nicht freigegeben werden: ' + error.message);
  279.       });
  280.     }
  281.   }
  282.  
  283.   onShowing(e) {
  284.     if (this.vdasPopup && this.vdasPopup.instance) {
  285.       if (!this.isMobile && !this.isTablet) {
  286.         this.vdasPopup.width = '50%';
  287.         this.vdasPopup.height = '50%';
  288.       } else {
  289.         this.vdasPopup.width = '80%';
  290.         this.vdasPopup.height = '80%';
  291.       }
  292.     }
  293.   }
  294.  
  295.   onShown(e) {
  296.     if (this.vdasPopup && this.vdasPopup.instance) {
  297.       this.vdasPopup.instance.repaint();
  298.     }
  299.   }
  300.  
  301.   setCanEditFields() {
  302.     if (this.origin === 'worklist' && this.patient &&
  303.       (this.patient.status === AppConstants.STATUS_ACCEPTED ||
  304.         this.patient.status === AppConstants.STATUS_RETEST ||
  305.         this.patient.status === AppConstants.STATUS_SEEN ||
  306.         this.patient.status === AppConstants.STATUS_SAMPLED_ACCEPTED ||
  307.         !this.patient.status)) {
  308.       this.canEdit = true;
  309.  
  310.       if (this.tabIndex === 0)
  311.         this.callCenterCanEdit = true;
  312.  
  313.       if (this.tabIndex === 0 && this.patient.gesundTestung)
  314.         this.canEditAppointmentHealth = true;
  315.     } else if (this.origin === 'sharepoint' && this.patient &&
  316.       (this.patient.status === AppConstants.STATUS_CREATED ||
  317.         this.patient.status === AppConstants.STATUS_AUTHORITY ||
  318.         this.patient.status === AppConstants.STATUS_ACCEPTED ||
  319.         this.patient.status === AppConstants.STATUS_RETEST ||
  320.         this.patient.status === AppConstants.STATUS_RECALL_1_NEGATIVE ||
  321.         this.patient.status === AppConstants.STATUS_RECALL_2_NEGATIVE ||
  322.         this.patient.status === AppConstants.STATUS_RECALL_3_NEGATIVE ||
  323.         !this.patient.status)) {
  324.       this.canEdit = true;
  325.  
  326.       if (this.patient.status && (this.tabIndex === 1 || this.tabIndex === 2))
  327.         this.callCenterCanEdit = true;
  328.  
  329.       if (this.patient.status && (this.tabIndex === 1 || this.tabIndex === 2) && this.patient.gesundTestung) {
  330.         this.canEditAppointmentHealth = true;
  331.       }
  332.  
  333.       if (this.tabIndex === 0 && this.patient.appointmentRecording) {
  334.         this.callCenterCanEdit = true;
  335.       }
  336.     }
  337.  
  338.     if (this.origin === 'worklist' && this.tabIndex === 4) {
  339.       this.canEdit = false;
  340.       this.callCenterCanEdit = false;
  341.       this.canEditAppointmentHealth = false;
  342.     }
  343.   }
  344.  
  345.   setPatient() {
  346.     if (this.patient) {
  347.       if (this.patient.gesundTestung === null || this.patient.gesundTestung === undefined) {
  348.         this.patient.gesundTestung = false;
  349.       }
  350.       if (this.patient.gesundTestungEinfach === null || this.patient.gesundTestungEinfach === undefined) {
  351.         this.patient.gesundTestungEinfach = false;
  352.       }
  353.       if (this.patient.isDriveInPossible === null || this.patient.isDriveInPossible === undefined) {
  354.         this.patient.isDriveInPossible = false;
  355.       }
  356.       if (this.patient.dataTransferAccepted === null || this.patient.dataTransferAccepted === undefined) {
  357.         this.patient.dataTransferAccepted = false;
  358.       }
  359.       if (this.patient.vip === null || this.patient.vip === undefined) {
  360.         this.patient.vip = false;
  361.       }
  362.       if (this.patient.contactPerson1OneAppointment === null || this.patient.contactPerson1OneAppointment === undefined) {
  363.         this.patient.contactPerson1OneAppointment = false;
  364.       }
  365.       if (this.patient.contactPerson1TwoAppointments === null || this.patient.contactPerson1TwoAppointments === undefined) {
  366.         this.patient.contactPerson1TwoAppointments = false;
  367.       }
  368.       if (this.patient.notification === null || this.patient.notification === undefined) {
  369.         this.patient.notification = false;
  370.       }
  371.       this.patient.appointmentRecording = false;
  372.       this.status = this.patient.status;
  373.     }
  374.   }
  375.  
  376.   setVdasStyle() {
  377.     if (this.patient && this.patient.isVDASQueryAccepted)
  378.       $('.vdasStyle').css('background-color', '#4cae4c');
  379.     else
  380.       $('.vdasStyle').css('background-color', '#b1000a');
  381.   }
  382.  
  383.   getPatient() {
  384.     if (this.patient.isVDASQueryAccepted === null || this.patient.isVDASQueryAccepted === undefined)
  385.       this.patient.isVDASQueryAccepted = false;
  386.     return this.patient;
  387.   }
  388.  
  389.   back(e) {
  390.     let result = confirm("Eingegebene Daten gehen möglicherweise verloren.");
  391.     if (result)
  392.       this.userService.navigatePatientBack(this.origin);
  393.   }
  394.  
  395.   submit(e) {
  396.     this.authoritySelectBox.isValid = true;
  397.     this.driveInSelectBox.isValid = true;
  398.     if (this.validationService.validate(e, this.patient, this.authorityAssignedIdInput, this.secondAppointmentInput, this.driveInAssignedIdInput, this.appointmentInput, this.birthdateInput, this.ssnInput) &&
  399.       (this.origin === 'sharepoint' ? true : (this.patient.authorityId && this.patient.driveInId))) {
  400.       this.loadingIndicatorService.showIndicator();
  401.       let status = AppConstants.STATUS_CREATED;
  402.       if (this.origin === 'worklist' || (this.origin === 'sharepoint' && this.patient.appointmentRecording)) {
  403.         status = AppConstants.STATUS_ACCEPTED;
  404.       }
  405.       this.patientCollectionService.collectPatient(this.getPatient(), status).subscribe(response => {
  406.         if (response && response.body && response.body.errors && response.body.errors.length > 0) {
  407.           this.notificationService.notifyInfo('Klient konnte nicht angelegt werden: ' + response.body.errors[0].message, 5000);
  408.         } else {
  409.           this.notificationService.notifyInfo('Klient wurde erfolgreich angelegt', 5000);
  410.           this.userService.navigatePatientBack(this.origin);
  411.         }
  412.         this.loadingIndicatorService.hideIndicator();
  413.       }, error => {
  414.         this.loadingIndicatorService.hideIndicator();
  415.         this.notificationService.notifyInfo('Klient konnte nicht angelegt werden: ' + error.message, 5000);
  416.       });
  417.     } else {
  418.       if (this.origin === 'worklist') {
  419.         if (!this.patient.authorityId)
  420.           this.authoritySelectBox.isValid = false;
  421.         if (!this.patient.driveInId)
  422.           this.driveInSelectBox.isValid = false;
  423.       }
  424.       this.notificationService.notifyInfo('Bitte überprüfen Sie Ihre Eingaben', 2500);
  425.     }
  426.   }
  427.  
  428.   change(e) {
  429.     if ((this.statusInput && this.statusInput.instance && this.status !== AppConstants.STATUS_ACCEPTED && validationEngine.validateGroup().isValid) || this.validationService.validate(e, this.patient, this.authorityAssignedIdInput, this.secondAppointmentInput, this.driveInAssignedIdInput, this.appointmentInput, this.birthdateInput, this.ssnInput)) {
  430.       this.loadingIndicatorService.showIndicator();
  431.       let patient: Patient = this.getPatient();
  432.       if (this.origin === 'sharepoint' && this.patient.appointmentRecording) {
  433.         patient.status = AppConstants.STATUS_ACCEPTED;
  434.       }
  435.       this.patientCollectionService.changePatient(patient).subscribe(response => {
  436.         if (response && response.body && response.body.errors && response.body.errors.length > 0) {
  437.           this.notificationService.notifyInfo('Klient konnte nicht geändert werden: ' + response.body.errors[0].message, 5000);
  438.         } else {
  439.           if (this.statusInput && this.statusInput.instance) {
  440.             this.authorize(e, this.patient, 'false');
  441.           }
  442.           this.notificationService.notifyInfo('Klient wurde erfolgreich geändert', 5000);
  443.           this.userService.navigatePatientBack(this.origin);
  444.         }
  445.         this.loadingIndicatorService.hideIndicator();
  446.       }, error => {
  447.         this.loadingIndicatorService.hideIndicator();
  448.         this.notificationService.notifyInfo('Klient konnte nicht geändert werden: ' + error.message, 5000);
  449.       });
  450.     } else {
  451.       this.notificationService.notifyInfo('Bitte überprüfen Sie Ihre Eingaben', 2500);
  452.     }
  453.   }
  454.  
  455.   sendToAuthority(e) {
  456.     this.authoritySelectBox.isValid = true;
  457.     this.patientCollectionService.changePatient(this.getPatient()).subscribe(response => {
  458.       if (this.patient.authorityId && validationEngine.validateGroup().isValid) {
  459.         let status = null;
  460.         if (this.origin === 'sharepoint' && this.patient.appointmentRecording) {
  461.           status = AppConstants.STATUS_ACCEPTED;
  462.         }
  463.         this.sharePointService.sendToAuthority(this.patient.id, status).subscribe(response => {
  464.           if (response && response.body && response.body.errors && response.body.errors.length > 0) {
  465.             this.notificationService.notifyInfo('Klient konnte nicht an Behörde übermittelt werden: ' + response.body.errors[0].message, 5000);
  466.           } else {
  467.             this.userService.navigatePatientBack(this.origin);
  468.           }
  469.         }, error => {
  470.           this.notificationService.notifyInfo('Klient konnte nicht an Behörde übermittelt werden: ' + error.message, 5000);
  471.         });
  472.       } else {
  473.         this.notificationService.notifyInfo('Klient konnte nicht an Behörde übermittelt werden', 5000);
  474.         if (!this.patient.authorityId)
  475.           this.authoritySelectBox.isValid = false;
  476.       }
  477.     });
  478.   }
  479.  
  480.   authorize(e, data, isAuthorized: string) {
  481.     this.sharePointService.authorize(data.id, data.status, this.status).subscribe(response => {
  482.       if (response && response.body && response.body.errors && response.body.errors.length > 0) {
  483.         this.notificationService.notifyInfo('Klient konnte nicht bewilligt / abgelehnt werden: ' + response.body.errors[0].message, 5000);
  484.       } else {
  485.         this.userService.navigatePatientBack(this.origin);
  486.       }
  487.     }, error => {
  488.       this.notificationService.notifyInfo('Klient konnte nicht bewilligt / abgelehnt werden: ' + error.message, 5000);
  489.     });
  490.   }
  491.  
  492.   getBarcode(e) {
  493.     if (this.deviceDetector.isDesktop() && this.patient && this.patient.currentSample && this.patient.currentSample.id) {
  494.       window.open('./label/forSampleId/' + this.patient.currentSample.id, '_blank');
  495.     }
  496.   }
  497.  
  498.   vdas(e) {
  499.     if (this.patient.ssn) {
  500.       this.isVDASLoading = true;
  501.       this.vdasService.vdas(this.patient.ssn, this.patient.firstname, this.patient.lastname, this.patient.birthdate).subscribe(response => {
  502.         this.isVDASLoading = false;
  503.         if (response && response.body && response.body.errors && response.body.errors.length > 0) {
  504.           this.notificationService.notifyInfo('VDAS-Abfrage konnte nicht durchgeführt werden: ' + response.body.errors[0].extensions.errorMessage, 5000);
  505.         } else {
  506.           if (response && response.body && response.body.data && response.body.data.vdasQuery) {
  507.             this.vdasPatient = response.body.data.vdasQuery;
  508.           if (this.vdasPatient && this.vdasPatient.insurance && this.vdasPatient.insurance.length === 1) this.vdasPatient.svtCode = this.vdasPatient.insurance[0].svtCode;
  509.             this.vdasPopupVisible = true;
  510.           } else {
  511.             this.vdasPopupVisible = false;
  512.             this.notificationService.notifyInfo('VDAS-Abfrage liefert kein korrektes Ergebnis', 5000);
  513.           }
  514.         }
  515.       }, error => {
  516.         this.isVDASLoading = false;
  517.         this.notificationService.notifyInfo('VDAS-Abfrage konnte nicht durchgeführt werden: ' + error.message, 5000);
  518.       });
  519.     } else {
  520.       this.notificationService.notifyInfo('Bitte geben Sie für eine VDAS-Abfrage eine gültige Sozialversicherungsnummer ein', 5000);
  521.     }
  522.   }
  523.  
  524.   takeAddress(e) {
  525.     this.patient.secondaryAddressStreet = this.patient.addressStreet;
  526.     this.patient.secondaryAddressZip = this.patient.addressZip;
  527.     this.patient.secondaryAddressCity = this.patient.addressCity;
  528.   }
  529.  
  530.   getAuthorityButtonStyle(status, type) {
  531.     if (status && status === AppConstants.STATUS_ACCEPTED && type === AppConstants.STATUS_ACCEPTED)
  532.       return 'authorityButtonAccepted';
  533.     else if (status && status === AppConstants.STATUS_REJECTED && type === AppConstants.STATUS_REJECTED)
  534.       return 'authorityButtonRejected';
  535.     else
  536.       return '';
  537.   }
  538.  
  539.   cancel() {
  540.     this.vdasPopupVisible = false;
  541.     this.vdasPatient = new Patient();
  542.     this.setVdasStyle();
  543.     this.svtCodeInput.isValid = true;
  544.   }
  545.  
  546.   assign() {
  547.     if (this.vdasPatient && this.vdasPatient.lastname) {
  548.       this.patient.lastname = this.vdasPatient.lastname;
  549.     }
  550.     if (this.vdasPatient && this.vdasPatient.firstname) {
  551.       this.patient.firstname = this.vdasPatient.firstname
  552.     }
  553.     if (this.vdasPatient && this.vdasPatient.birthdate) {
  554.       this.patient.birthdate = this.vdasPatient.birthdate;
  555.     }
  556.     if (this.vdasPatient && this.vdasPatient.sex) {
  557.       this.patient.sex = this.vdasPatient.sex;
  558.     }
  559.     if (this.vdasPatient && this.vdasPatient.svtCode) {
  560.       this.patient.svtCode = this.vdasPatient.svtCode;
  561.     } else {
  562.       if (this.vdasPatient.insurance && this.vdasPatient.insurance.length > 0) {
  563.         this.svtCodeInput.isValid = false;
  564.         return;
  565.       }
  566.     }
  567.  
  568.     if (this.vdasPatient && this.vdasPatient.patientZPI[0].patientAddress.streetName) {
  569.       this.patient.addressStreet = this.vdasPatient.patientZPI[0].patientAddress.streetName;
  570.     }
  571.     if (this.vdasPatient && this.vdasPatient.patientZPI[0].patientAddress.postalCode) {
  572.       this.patient.addressZip = this.vdasPatient.patientZPI[0].patientAddress.postalCode;
  573.     }
  574.     if (this.vdasPatient && this.vdasPatient.patientZPI[0].patientAddress.city) {
  575.       this.patient.addressCity = this.vdasPatient.patientZPI[0].patientAddress.city;
  576.     }
  577.  
  578.     this.patient.isVDASQueryAccepted = true;
  579.     this.cancel();
  580.   }
  581.  
  582.   clearDoctors() {
  583.     //this.doctors = [];
  584.   }
  585.  
  586.   clearOrganisations() {
  587.     //this.organisations = [];
  588.   }
  589.  
  590.   onDoctorChanged(e) {
  591.     this.doctorService.searchDoctor(e.value).subscribe(response => {
  592.       if (response && response.body && response.body.data && response.body.data.searchDoctor) {
  593.         this.doctors = response.body.data.searchDoctor;
  594.       }
  595.     });
  596.   }
  597.  
  598.   onOrganisationChanged(e) {
  599.     this.organisationService.searchOrganisation(e.value).subscribe(response => {
  600.       if (response && response.body && response.body.data && response.body.data.searchOrganisation) {
  601.         this.organisations = response.body.data.searchOrganisation;
  602.       }
  603.     });
  604.   }
  605.  
  606.   onResidenceChanged(e) {
  607.     this.residenceService.searchResidences(e.value).subscribe(response => {
  608.       if (response && response.body && response.body.data && response.body.data.searchCountryResisdence) {
  609.         this.residences = response.body.data.searchCountryResisdence;
  610.       }
  611.     });
  612.   }
  613.  
  614.   onDoctorClick(e) {
  615.     if (e && e.itemData && e.itemData.hvUid)
  616.       this.patient.familyDoctorHvUid = e.itemData.hvUid;
  617.     if (e && e.itemData && e.itemData.fullname)
  618.       this.patient.familyDoctor = e.itemData.fullname;
  619.     if (e && e.itemData && e.itemData.city)
  620.       this.patient.familyDoctor += ' (' + e.itemData.city + ')';
  621.   }
  622.  
  623.   onOrganisationClick(e) {
  624.     if (e && e.itemData && e.itemData.text) {
  625.       this.patient.organisationText = e.itemData.text;
  626.     }
  627.   }
  628.  
  629.   onResidenceClick(e) {
  630.     if (e && e.itemData && e.itemData.text) {
  631.       this.patient.countryOfResidence = e.itemData.text;
  632.     }
  633.   }
  634.  
  635.   onGesundTestungChanged(e) {
  636.     if ((this.patient.status && (this.tabIndex === 1 || this.tabIndex === 2)) || (this.origin === 'worklist' && this.tabIndex === 0) || (this.patient.appointmentRecording && this.tabIndex === 0)) {
  637.       if (e && e.value) {
  638.         this.canEditAppointmentHealth = true;
  639.       } else if (e && !e.value) {
  640.         this.canEditAppointmentHealth = false;
  641.         this.patient.secondAppointment = null;
  642.         this.patient.secondDriveInId = null;
  643.       }
  644.     }
  645.  
  646.     if (e && e.value) {
  647.       this.patient.gesundTestungEinfach = false;
  648.       if (this.patient.driveInId && !this.patient.secondDriveInId && (this.patient.gesundTestung || this.patient.contactDate)) {
  649.         this.patient.secondDriveInId = this.patient.driveInId;
  650.       }
  651.     }
  652.   }
  653.  
  654.   onGesundTestungEinfachChanged(e) {
  655.     if (e && e.value) {
  656.       this.patient.gesundTestung = false;
  657.     }
  658.   }
  659.  
  660.  
  661.   onContactPersonTwoAppointmentsChanged(e) {
  662.     if (e && e.value) {
  663.       this.patient.contactPerson1OneAppointment = false;
  664.       if (this.patient.driveInId && !this.patient.secondDriveInId && this.patient.contactPerson1TwoAppointments) {
  665.         this.patient.secondDriveInId = this.patient.driveInId;
  666.       }
  667.     }
  668.  
  669.     if (e && !e.value) {
  670.       this.patient.secondDriveInId = null;
  671.       this.patient.secondAppointment = null;
  672.     }
  673.  
  674.     if (!this.patient.contactPerson1OneAppointment && !this.patient.contactPerson1TwoAppointments)
  675.       this.patient.contactPerson1OneAppointment = true;
  676.   }
  677.  
  678.   onContactPersonOneAppointmentChanged(e) {
  679.     if (e && e.value) {
  680.       this.patient.contactPerson1TwoAppointments = false;
  681.       this.patient.secondDriveInId = null;
  682.       this.patient.secondAppointment = null;
  683.     }
  684.  
  685.     setTimeout(() => {
  686.       if (!this.patient.contactPerson1OneAppointment && !this.patient.contactPerson1TwoAppointments)
  687.         this.patient.contactPerson1OneAppointment = true;
  688.     });
  689.   }
  690.  
  691.   onAppointmentRecordingChanged(e) {
  692.     if (e && e.value) {
  693.       this.callCenterCanEdit = true;
  694.     }
  695.  
  696.     if (e && !e.value) {
  697.       this.patient.authorityAssignedId = null;
  698.       this.patient.driveInAssignedId = null;
  699.       this.patient.driveInId = null;
  700.       this.patient.appointment = null;
  701.       this.patient.secondDriveInId = null;
  702.       this.patient.secondAppointment = null;
  703.       this.callCenterCanEdit = false;
  704.     }
  705.   }
  706.  
  707.   onFocusIn(e) {
  708.     setTimeout(() => {
  709.       this.scrollView.instance.scrollToElement(e.element);
  710.     }, 250);
  711.   }
  712.  
  713.   onBirthdateOpened(e) {
  714.     if (!this.isDesktop)
  715.       this.notificationService.notifyInfo('Hinweis: Durch einen Klick auf das Jahr kann dieses schneller ausgewählt werden', 3000);
  716.   }
  717.  
  718.   onCall(e, phone) {
  719.     if (phone && phone.length > 0)
  720.       return true
  721.     else
  722.       return false;
  723.   }
  724.  
  725.   cancelPatient(e) {
  726.     let confirmResult = confirm('Wollen Sie den Klienten wirklich stornieren?');
  727.     if (confirmResult) {
  728.       if (this.patient && this.patient.id && this.patient.status) {
  729.         this.cancelPatientRaw(this.patient.id, this.patient.status);
  730.       } else {
  731.         if (this.patient.lastname && this.patient.birthdate && this.patient.ssn) {
  732.           this.patientCollectionService.collectPatient(this.getPatient(), AppConstants.STATUS_CREATED).subscribe(response => {
  733.             if (response && response.body && response.body.data && response.body.data.createPerson && response.body.data.createPerson.id) {
  734.               this.cancelPatientRaw(response.body.data.createPerson.id, AppConstants.STATUS_CREATED);
  735.             } else {
  736.               this.notificationService.notifyError('Klient konnte nicht storniert werden');
  737.             }
  738.           }, error => {
  739.             this.notificationService.notifyError('Klient konnte nicht storniert werden: ' + error.message);
  740.           });
  741.         } else {
  742.           this.validationService.validate(e, this.patient, this.authorityAssignedIdInput, this.secondAppointmentInput, this.driveInAssignedIdInput, this.appointmentInput, this.birthdateInput, this.ssnInput);
  743.           this.notificationService.notifyError('Klient konnte nicht storniert werden');
  744.         }
  745.       }
  746.     }
  747.   }
  748.  
  749.   cancelPatientRaw(personId: string, fromStatus: string) {
  750.     this.patientCollectionService.cancelPatient(personId, fromStatus).subscribe(response => {
  751.       if (response && response.body && response.body.errors && response.body.errors.length > 0) {
  752.         this.notificationService.notifyError('Klient konnte nicht storniert werden: ' + response.body.errors[0].message);
  753.       } else {
  754.         this.userService.navigatePatientBack(this.origin);
  755.       }
  756.     }, error => {
  757.       this.notificationService.notifyError('Klient konnte nicht storniert werden: ' + error.message);
  758.     });
  759.   }
  760.  
  761.   showSchedulerApp(e) {
  762.     this.type = AppConstants.SCHEDULE_TYPE_APP;
  763.     this.schedulePopupVisible = true;
  764.   }
  765.  
  766.   showSchedulerSecApp(e) {
  767.     this.type = AppConstants.SCHEDULE_TYPE_SEC_APP;
  768.     this.schedulePopupVisible = true;
  769.   }
  770.  
  771.   closeScheduler(e) {
  772.     this.schedulePopupVisible = false;
  773.   }
  774.  
  775.   scheduleAppointment(e) {
  776.     if (e && e.type && e.date) {
  777.       if (e.type === AppConstants.SCHEDULE_TYPE_APP) {
  778.         this.patient.appointment = e.date;
  779.         this.patient.driveInId = e.driveInId;
  780.       } else if (e.type === AppConstants.SCHEDULE_TYPE_SEC_APP) {
  781.         this.patient.secondAppointment = e.date;
  782.         this.patient.secondDriveInId = e.driveInId;
  783.       }
  784.  
  785.       this.status = AppConstants.STATUS_ACCEPTED;
  786.  
  787.       if (e.date && !this.appointmentEntries.find(timeSlot => timeSlot.startDate === e.date)) {
  788.         this.appointmentEntries.push(new TimeSlot('Frei', e.date, 0));
  789.         this.appointmentEntries.sort((a, b) => a.startDate.localeCompare(b.startDate));
  790.       }
  791.       if (e.date && !this.secAppointmentEntries.find(timeSlot => timeSlot.startDate === e.date)) {
  792.         this.secAppointmentEntries.push(new TimeSlot('Frei', e.date, 0));
  793.         this.secAppointmentEntries.sort((a, b) => a.startDate.localeCompare(b.startDate));
  794.       }
  795.     }
  796.   }
  797.  
  798.   cancelSecondAppointmentGesundTestung(e) {
  799.     let confirmResult = confirm('Wollen Sie den Termin (Gesundtestung) wirklich stornieren?');
  800.     if (confirmResult)
  801.       this.patient.gesundTestungEinfach = true;
  802.   }
  803.  
  804.   cancelSecondAppointmentContact(e) {
  805.     let confirmResult = confirm('Wollen Sie den 2. Termin wirklich stornieren?');
  806.     if (confirmResult)
  807.       this.patient.contactPerson1OneAppointment = true;
  808.   }
  809.  
  810.   createDriveInId(e) {
  811.     this.patientCollectionService.createDriveInId().subscribe(response => {
  812.       if (response && response.body && response.body.data && response.body.data.nextDriveInId) {
  813.         this.patient.driveInAssignedId = response.body.data.nextDriveInId;
  814.       } else {
  815.         this.notificationService.notifyError('DriveIn-ID konnte nicht generiert werden');
  816.       }
  817.     }, error => {
  818.       this.notificationService.notifyError('DriveIn-ID konnte nicht generiert werden: ' + error.message);
  819.     });
  820.   }
  821.  
  822.   onStatusChanged(e) {
  823.     if (e && e.previousValue === AppConstants.STATUS_ACCEPTED) {
  824.       this.patient.appointment = null;
  825.       this.patient.secondAppointment = null;
  826.       this.patient.gesundTestung = false;
  827.       this.patient.gesundTestungEinfach = false;
  828.     }
  829.     setTimeout(() => {
  830.       if (e.value === null) {
  831.         this.status = e.previousValue;
  832.       }
  833.     });
  834.   }
  835.  
  836.   onAuthorityChanged(e) {
  837.     setTimeout(() => {
  838.       if (e.value === null) {
  839.         this.patient.authorityId = e.previousValue;
  840.       }
  841.     });
  842.   }
  843.  
  844.   onDriveInChanged(e) {
  845.     setTimeout(() => {
  846.       if (e.value === null) {
  847.         if (!this.patient.appointmentRecording && this.tabIndex === 0 && this.origin === 'sharepoint') { }
  848.         else {
  849.           this.patient.driveInId = e.previousValue;
  850.         }
  851.       }
  852.  
  853.       if (this.patient.driveInId && !this.patient.secondDriveInId && (this.patient.gesundTestung || this.patient.contactDate)) {
  854.         this.patient.secondDriveInId = this.patient.driveInId;
  855.       }
  856.       this.queryTimeSlots();
  857.     });
  858.   }
  859.  
  860.   onSecondDriveInChanged(e) {
  861.     setTimeout(() => {
  862.       this.queryTimeSlots();
  863.     });
  864.   }
  865.  
  866.   onAppointmentChanged(e) {
  867.     setTimeout(() => {
  868.       if (this.patient.appointment) {
  869.         this.status = AppConstants.STATUS_ACCEPTED;
  870.       }
  871.     });
  872.   }
  873.  
  874.   onPriorityChanged(e) {
  875.     if (e && e.value && e.value === 'PrivateTesting') {
  876.       this.laborInput.disabled = false;
  877.     } else {
  878.       this.laborInput.disabled = true;
  879.       this.patient.laboratoryId = null;
  880.     }
  881.  
  882.     if (e && e.value && (e.value === 'ContactPerson1WithNotification' || e.value === 'ContactPerson1')) {
  883.       this.contactDateInput.disabled = false;
  884.       this.patient.gesundTestung = false;
  885.       this.patient.gesundTestungEinfach = false;
  886.       this.patient.secondAppointment = null;
  887.     } else {
  888.       this.contactDateInput.disabled = true;
  889.       this.patient.contactDate = null;
  890.       if (e.previousValue === 'ContactPerson1WithNotification' || e.previousValue === 'ContactPerson1') {
  891.         this.patient.secondAppointment = null;
  892.         this.patient.secondDriveInId = null;
  893.         this.patient.contactPerson1OneAppointment = false;
  894.         this.patient.contactPerson1TwoAppointments = false;
  895.         this.canEditAppointmentHealth = false;
  896.       }
  897.     }
  898.  
  899.     if (e.previousValue === 'ReturneesVoluntarily') {
  900.       this.patient.countryOfResidence = null;
  901.     }
  902.   }
  903.  
  904.   priorityComparison() {
  905.     if (this.patient.priority === 'PrivateTesting' && !this.patient.laboratoryId)
  906.       return false;
  907.     else
  908.       return true;
  909.   }
  910.  
  911.   statusComparison() {
  912.     if (this.patient.appointment && !this.status)
  913.       return false;
  914.     else
  915.       return true;
  916.   }
  917.  
  918.   contactDateComparison() {
  919.     if ((this.patient.priority === 'ContactPerson1WithNotification' || this.patient.priority === 'ContactPerson1') && !this.patient.contactDate)
  920.       return false;
  921.     else
  922.       return true;
  923.   }
  924.  
  925.   contactSecondAppointmentComparison() {
  926.     if ((this.origin === 'sharepoint' && this.tabIndex === 0) || (this.origin === 'sharepoint' && this.tabIndex === 1 && this.status && this.status !== AppConstants.STATUS_ACCEPTED))
  927.       return true;
  928.  
  929.     let contactDate = new Date(this.patient.contactDate);
  930.     let days = Math.floor((new Date().getTime() - contactDate.getTime()) / 1000 / 60 / 60 / 24);
  931.  
  932.     if ((days < this.daysToContactDate || this.patient.contactPerson1TwoAppointments) && !this.patient.secondAppointment)
  933.       return false;
  934.     else
  935.       return true;
  936.   }
  937.  
  938.   phoneComparison() {
  939.     if (!this.patient.phone || this.patient.phone.length <= 3)
  940.       return false;
  941.     else
  942.       return true;
  943.   }
  944.  
  945.   onSetStatusChanged(e) {
  946.     setTimeout(() => {
  947.       if (e.value === null) {
  948.         this.patient.status = e.previousValue;
  949.       }
  950.     });
  951.   }
  952.  
  953.   onContactDateChanged(e) {
  954.     let contactDate = new Date(this.patient.contactDate);
  955.     let days = Math.floor((new Date().getTime() - contactDate.getTime()) / 1000 / 60 / 60 / 24);
  956.  
  957.     if (this.patient.contactDate && days < this.daysToContactDate)
  958.       this.patient.contactPerson1TwoAppointments = true;
  959.     else if (this.patient.contactDate)
  960.       this.patient.contactPerson1OneAppointment = true;
  961.  
  962.     if (this.patient.driveInId && !this.patient.secondDriveInId && (this.patient.gesundTestung || this.patient.contactDate)) {
  963.       this.patient.secondDriveInId = this.patient.driveInId;
  964.     }
  965.  
  966.     this.queryTimeSlots();
  967.   }
  968.  
  969.   queryTimeSlots() {
  970.     if (this.patient.driveInId || this.patient.secondDriveInId) {
  971.       this.schedulerService.queryTimeSlots([this.patient.driveInId], new Date(), true, this.daysInFuture ? this.daysInFuture : 3).subscribe(response => {
  972.         if (response && response.body && response.body.data && response.body.data.driveInTimeSlots) {
  973.           this.appointmentEntries = response.body.data.driveInTimeSlots;
  974.  
  975.           if (this.patient.appointment && !this.appointmentEntries.find(timeSlot => timeSlot.startDate === this.patient.appointment)) {
  976.             this.appointmentEntries.push(new TimeSlot('Frei', this.patient.appointment, 0));
  977.             this.appointmentEntries.sort((a, b) => a.startDate.localeCompare(b.startDate));
  978.           }
  979.         } else {
  980.           this.appointmentEntries = [];
  981.           if (this.patient.appointment) {
  982.             this.appointmentEntries.push(new TimeSlot('Frei', this.patient.appointment, 0));
  983.           }
  984.           this.notificationService.notifyError('Termindaten konnten nicht abgefragt werden');
  985.         }
  986.  
  987.         this.schedulerService.queryTimeSlots([this.patient.secondDriveInId], this.patient.appointment ? new Date(this.patient.appointment) : new Date(), true, this.calculateDaysInFuture()).subscribe(response => {
  988.           if (response && response.body && response.body.data && response.body.data.driveInTimeSlots) {
  989.             this.secAppointmentEntries = response.body.data.driveInTimeSlots;
  990.  
  991.             if (this.patient.secondAppointment && !this.secAppointmentEntries.find(timeSlot => timeSlot.startDate === this.patient.secondAppointment)) {
  992.               this.secAppointmentEntries.push(new TimeSlot('Frei', this.patient.secondAppointment, 0));
  993.               this.secAppointmentEntries.sort((a, b) => a.startDate.localeCompare(b.startDate));
  994.             }
  995.           } else {
  996.             this.secAppointmentEntries = [];
  997.             if (this.patient.secondAppointment) {
  998.               this.secAppointmentEntries.push(new TimeSlot('Frei', this.patient.secondAppointment, 0));
  999.             }
  1000.             this.notificationService.notifyError('Termindaten konnten nicht abgefragt werden');
  1001.           }
  1002.         });
  1003.       });
  1004.     }
  1005.   }
  1006.  
  1007.   calculateDaysInFuture(): number {
  1008.     if (this.patient.contactDate)
  1009.       return this.daysToContactDate;
  1010.     return this.daysInFuture;
  1011.   }
  1012.  
  1013.   driveInDisplayValue = (data) => {
  1014.     if (data) {
  1015.       if (data.address) {
  1016.         return data.name + " (" + data.address + ")";
  1017.       } else {
  1018.         return data.name;
  1019.       }
  1020.     }
  1021.   }
  1022.  
  1023. }
  1024.  

Editor

You can edit this paste and save as new:


File Description
  • patient-collection.component.ts
  • Paste Code
  • 22 Oct-2020
  • 41.33 Kb
You can Share it: