Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import { Component, OnInit, OnDestroy } from '@angular/core';
- import { ROUTER_DIRECTIVES, ActivatedRoute } from '@angular/router';
- import {Questionnaire} from '../data/questionnaire/questionnaire';
- import { Client} from '../data/client/client';
- import {ClientStore} from '../data/client/client-store';
- import {ClientBackend} from '../data/client/client-backend';
- import {CareUnit} from '../data/care-unit/care-unit';
- import {CareUnitStore} from '../data/care-unit/care-unit-store';
- import {CareUnitBackend} from '../data/care-unit/care-unit-backend';
- import {Department} from '../data/department/department';
- import {DepartmentStore} from '../data/department/department-store';
- import {DepartmentBackend} from '../data/department/department-backend';
- import {District} from '../data/district/district';
- import {DistrictStore} from '../data/district/district-store';
- import {DistrictBackend} from '../data/district/district-backend';
- import {Municipality} from '../data/municipality/municipality';
- import {MunicipalityStore} from '../data/municipality/municipality-store';
- import {MunicipalityBackend} from '../data/municipality/municipality-backend';
- import {Region} from '../data/region/region';
- import {RegionStore} from '../data/region/region-store';
- import {RegionBackend} from '../data/region/region-backend';
- import { Observable } from 'rxjs/Observable';
- import { FilterClientsService } from '../cd-client/filtered-clients-service';
- import { Subscription } from 'rxjs/Subscription';
- import {IceContact} from '../data/ice-contact/ice-contact';
- import {IceContactStore} from '../data/ice-contact/ice-contact-store';
- import {IceContactBackend} from '../data/ice-contact/ice-contact-backend';
- import {Activity} from '../data/activity/activity';
- import {ActivityStore} from '../data/activity/activity-store';
- import {ActivityBackend} from '../data/activity/activity-backend';
- import {PlannedActivity} from '../data/planned-activity/planned-activity';
- import {PlannedActivityStore} from '../data/planned-activity/planned-activity-store';
- import {PlannedActivityBackend} from '../data/planned-activity/planned-activity-backend';
- import { TranslateLoader, TranslateService, TranslateStaticLoader, TranslatePipe } from "ng2-translate/ng2-translate";
- import {Day} from '../data/day/day';
- @Component({
- moduleId: module.id,
- selector: 'app-client-details',
- templateUrl: 'client-details.component.html',
- styleUrls: ['client-details.component.css'],
- pipes: [TranslatePipe],
- directives: [ROUTER_DIRECTIVES],
- providers: []
- })
- export class ClientDetailsComponent implements OnInit {
- subscription: Subscription;
- selectedTab: string = 'personal';
- dateB: Date = new Date;
- newClientRegion: string = '-1';
- newMedicalContact: string = "";
- newClientMunicipality: string = '-1';
- newClientCareUnit: string = '-1';
- newClientDepartment: string = '-1';
- client: Client;
- sub: any;
- prevDisabled: boolean = false;
- nextDisabled: boolean = false;
- clients: Array<Client>;
- currentClientPosition: number;
- careUnits: Observable<Array<CareUnit>>;
- regions: Observable<Array<Region>>;
- districts: Observable<Array<District>>;
- departments: Observable<Array<Department>>;
- municipalities: Observable<Array<Municipality>>;
- activities: Observable<Array<Activity>>;
- iceContactFirstName: string = "";
- iceContactLastName: string = "";
- iceContactAddressStreet: string = "";
- iceContactAddressCity: string = "";
- iceContactPhoneNumber: string = "";
- iceContactComment: string = "";
- newActivity: string = "-1";
- timesPerDay: number = 0;
- activity: PlannedActivity = {
- id: "",
- dayId: "",
- clientId: "string",
- repeated: 1,
- }
- dayIds: Array<string>;
- iceContact: IceContact = {
- id: "1",
- clientId: "1",
- lastName: "lastName",
- firstName: "firstName",
- addressStreet: "address",
- addressCity: "address",
- phoneNumber: "number",
- commentFreeText: "comment",
- }
- days: Array<Day> =
- [{
- id: '1',
- name: 'Monday',
- checked: false,
- },
- {
- checked: false,
- name: 'Tuesday',
- id: '2',
- },
- {
- checked: false,
- name: 'Wednesday',
- id: '3',
- },
- {
- checked: false,
- name: 'Thursday',
- id: '4',
- },
- {
- checked: false,
- name: 'Friday',
- id: '5',
- },
- {
- checked: false,
- name: 'Saturday',
- id: '6',
- },
- {
- checked: false,
- name: 'Sunday',
- id: '0',
- }]
- newC: Client = {
- id: "1",
- type: "Home Care",
- firstName: "VIktorija",
- lastName: "Denchovska",
- dateBirth: this.dateB,
- gender: "female",
- phoneNumber: "123456",
- addressStreet: "Pirinska",
- addressPostalCode: "1234",
- addressCity: "SKOPJE",
- status: "Active",
- socialSecurityNumber: "1234556",
- age: "76",
- departmentId: "1",
- departmentName: "DEPARTMENT1",
- careUnitId: "1",
- careUnitName: "Malmo"
- };
- questionnaire: Questionnaire = {
- id: '1',
- name: 'Medical care',
- questions: [
- {
- id: "1",
- questionContent: 'Qwerty?',
- answered: 0,
- answers: [
- {
- id: '1',
- answerContent: 'Answer 1',
- points: 1,
- questionId: '1',
- checked: false,
- },
- {
- id: '2',
- answerContent: 'Answer 2',
- points: 1,
- questionId: '1',
- checked: false,
- },
- {
- id: '3',
- answerContent: 'Answer 3',
- points: 1,
- questionId: '1',
- checked: false,
- },
- {
- id: '4',
- answerContent: 'Answer 4',
- points: 1,
- questionId: '1',
- checked: false,
- },
- {
- id: '5',
- answerContent: 'Answer 5',
- points: 1,
- questionId: '1',
- checked: false,
- }
- ],
- questionGroupName: 'Personal Info',
- questionnaireId: '1',
- },
- {
- id: "2",
- questionContent: 'Personal info?',
- answered: 0,
- answers: [
- {
- id: '1',
- answerContent: 'Answer 1',
- points: 1,
- questionId: '2',
- checked: false,
- },
- {
- id: '2',
- answerContent: 'Answer 2',
- points: 1,
- questionId: '2',
- checked: false,
- },
- {
- id: '3',
- answerContent: 'Answer 3',
- points: 1,
- questionId: '2',
- checked: false,
- },
- {
- id: '4',
- answerContent: 'Answer 4',
- points: 1,
- questionId: '2',
- checked: false,
- },
- {
- id: '5',
- answerContent: 'Answer 5',
- points: 1,
- questionId: '2',
- checked: false,
- }
- ],
- questionGroupName: 'Personal Info',
- questionnaireId: '1',
- },
- {
- id: "3",
- questionContent: 'Medical Care?',
- answered: 0,
- answers: [
- {
- id: '1',
- answerContent: 'Answer 1',
- points: 1,
- questionId: '3',
- checked: false,
- },
- {
- id: '2',
- answerContent: 'Answer 2',
- points: 1,
- questionId: '3',
- checked: false,
- },
- {
- id: '3',
- answerContent: 'Answer 3',
- points: 1,
- questionId: '3',
- checked: false,
- },
- {
- id: '4',
- answerContent: 'Answer 4',
- points: 1,
- questionId: '3',
- checked: false,
- },
- {
- id: '5',
- answerContent: 'Answer 5',
- points: 1,
- questionId: '3',
- checked: false,
- }
- ],
- questionGroupName: 'Personal Info',
- questionnaireId: '1',
- }
- ]
- }
- constructor(private clientStore: ClientStore, private careUnitStore: CareUnitStore, private regionStore: RegionStore, private districtStore: DistrictStore, private departmentStore: DepartmentStore, private municipalityStore: MunicipalityStore, private route: ActivatedRoute, private filteredClientsService: FilterClientsService, private translate: TranslateService, private iceContactStore: IceContactStore, private activityStore: ActivityStore, private plannedActivityStore: PlannedActivityStore) {
- }
- ngOnInit() {
- this.clients = this.filteredClientsService.getFilteredClients();
- this.clientStore.clients
- .map((clients: Array<Client>) => {
- return clients;
- })
- .subscribe((clients: Array<Client>) => {
- this.clients = clients;
- })
- this.sub = this.route.params.subscribe(params => {
- this.client = this.clients.find(function (client) {
- return client.id == params["id"]
- });
- this.currentClientPosition = this.clients.indexOf(this.client);
- });
- this.careUnits = this.careUnitStore.careUnits
- .map((careUnits: Array<CareUnit>) => {
- return careUnits;
- })
- this.regions = this.regionStore.regions
- .map((regions: Array<Region>) => {
- return regions;
- })
- this.districts = this.districtStore.districts
- .map((districts: Array<District>) => {
- return districts;
- })
- this.departments = this.departmentStore.departments
- .map((departments: Array<Department>) => {
- return departments;
- })
- this.municipalities = this.municipalityStore.municipalities
- .map((municipalities: Array<Municipality>) => {
- return municipalities;
- })
- this.activities = this.activityStore.activities
- .map((activities: Array<Activity>) => {
- return activities;
- })
- this.dayIds = [];
- if (this.currentClientPosition == this.clients.length - 1) {
- this.nextDisabled = true;
- }
- if (this.currentClientPosition == 0) {
- this.prevDisabled = true;
- }
- this.translate.use(this.translate.currentLang);
- }
- private ngOnDestroy() {
- this.sub.unsubscribe();
- }
- setSelected(tabS: string): void {
- this.selectedTab = tabS;
- }
- nextClient() {
- this.currentClientPosition++;
- if (this.currentClientPosition == this.clients.length - 1) {
- this.nextDisabled = true;
- this.prevDisabled = false;
- this.client = this.clients[this.currentClientPosition];
- }
- else {
- this.prevDisabled = false;
- this.nextDisabled = false;
- this.client = this.clients[this.currentClientPosition];
- }
- }
- previousClient() {
- this.currentClientPosition--;
- if (this.currentClientPosition == 0) {
- this.prevDisabled = true;
- this.nextDisabled = false;
- this.client = this.clients[this.currentClientPosition];
- }
- else {
- this.nextDisabled = false;
- this.prevDisabled = false;
- this.client = this.clients[this.currentClientPosition];
- }
- }
- changeSelected(currentTab: string): void {
- if (currentTab == 'personal') {
- this.clientStore.updateClient(this.client);
- this.selectedTab = 'ice-contacts';
- }
- if (currentTab == 'ice-contacts') {
- this.selectedTab = 'medical-contact';
- }
- if (currentTab == 'medical-contact') {
- this.selectedTab = 'doctors';
- }
- if (currentTab == 'doctors') {
- this.selectedTab = 'needs';
- }
- if (currentTab == 'needs') {
- this.selectedTab = 'doctors';
- }
- if (currentTab == 'needs') {
- this.selectedTab = 'plannedActivities';
- }
- if (currentTab == 'plannedActivities') {
- this.activity.id = this.newActivity;
- this.activity.clientId = this.client.id;
- this.activity.repeated = this.timesPerDay;
- console.log(this.days);
- // this.days.forEach(day => {
- // if(day.checked){
- // this.dayIds.push(day.id);
- // }
- // });
- console.log(this.activity);
- console.log(this.dayIds);
- }
- }
- // addClient() {
- // if (this.selectedTab == 'ice-contacts') {
- // this.newC.type = this.newClientType;
- // this.newC.socialSecurityNumber = this.newClientSSN;
- // this.newC.firstName = this.newClientFirstName;
- // this.newC.lastName = this.newClientLastName;
- // this.newC.dateBirth = this.newClientDateBirth;
- // this.newC.gender = this.newClientGender;
- // this.newC.phoneNumber = this.newClientPhoneNumber;
- // this.newC.addressStreet = this.newClientAStreet;
- // this.newC.addressPostalCode = this.newClientAPostalCode;
- // this.newC.addressCity = this.newClientACity;
- // this.clientStore.createClient(this.newC);
- // }
- // }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement