Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
bergomi02 committed Jun 17, 2024
1 parent 41dcc9b commit 2b4f05f
Show file tree
Hide file tree
Showing 7 changed files with 150 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,29 +25,60 @@
</app-summary-card>

<hr class="divider">

<div class="add-site">
<button mat-button
type="button"
color="primary"
(click)="addSite()">
<mat-icon>add_business</mat-icon>
Add Site
</button>
<div class="row">
<div class="col-8">

<form [formGroup]="form"
novalidate>
<mat-form-field class="filter">
<mat-label>Vendor</mat-label>
<mat-select formControlName="vendorCode">
<mat-option value="all">All</mat-option>
<mat-option *ngFor="let vendor of vendors"
[value]="vendor.code">
{{ vendor.name }}
</mat-option>
</mat-select>
</mat-form-field>

<mat-form-field class="filter">
<mat-label>Care Type</mat-label>
<mat-select formControlName="careTypeCode">
<mat-option value="all">All</mat-option>
<mat-option *ngFor="let careType of careTypes"
[value]="careType.name">
{{ careType.name }}
</mat-option>
</mat-select>
</mat-form-field>
</form>
</div>
<div class="col-4">
<div class="add-site">
<button mat-button
type="button"
color="primary"
(click)="addSite()">
<mat-icon>add_business</mat-icon>
Add Site
</button>
</div>
</div>
</div>

</ng-container>

<ng-container *ngFor="let healthAuthoritySite of healthAuthoritySites$ | async; trackBy: trackBySiteId">
<ng-container *ngFor="let healthAuthoritySite of healthAuthoritySites ; trackBy: trackBySiteId">

<app-summary-card icon="store"
title="Site Information"
[menu]="healthAuthoritySiteMenu"
[menuOutletContext]="{ healthAuthoritySite: healthAuthoritySite, healthAuthorityId: healthAuthorityId }"
[properties]="[
{ key: 'Site Name', value: healthAuthoritySite?.siteName },
{ key: 'Site ID', value: healthAuthoritySite?.pec },
{ key: 'Vendor', value: healthAuthoritySite?.healthAuthorityVendor?.vendorCode | configCode : 'vendors' },
{ key: 'Site Name', value: healthAuthoritySite?.siteName, _50: true },
{ key: 'Site ID', value: healthAuthoritySite?.pec, _50: true },
{ key: 'Care Type', value: healthAuthoritySite?.healthAuthorityCareType?.careType, _50: true },
{ key: 'Vendor', value: healthAuthoritySite?.healthAuthorityVendor?.vendorCode | configCode : 'vendors', _50: true },
{ key: healthAuthoritySite?.submittedDate ? 'Last Submitted by' : 'Last Updated by', value: getLastUpdatedUser(healthAuthoritySite?.authorizedUserName, healthAuthoritySite?.updatedTimeStamp)},
]">
<ng-container *ngIf="healthAuthoritySite.isIncomplete()"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ div.add-site {
margin-left: -1rem;
padding-top: .2rem;
}

.mat-card-content {
div {
color: theme-palette(blue, light);
Expand All @@ -48,6 +49,7 @@ div.add-site {
}
}
}

.mat-card-actions {
text-align: right;
}
Expand All @@ -64,3 +66,7 @@ div.add-site {
.green-icon {
color: theme-palette(green);
}

.filter {
margin-right: 10px;
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Component, OnInit } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router';

import { Observable, Subscription } from 'rxjs';
import { Subscription } from 'rxjs';

import { ArrayUtils } from '@lib/utils/array-utils.class';
import { RouteUtils } from '@lib/utils/route-utils.class';
Expand All @@ -16,6 +16,10 @@ import { HealthAuthoritySite } from '@health-auth/shared/models/health-authority
import { HealthAuthoritySiteList } from '@health-auth/shared/models/health-authority-site-list.model';
import { AuthorizedUserService } from '@health-auth/shared/services/authorized-user.service';
import { FormatDatePipe } from '@shared/pipes/format-date.pipe';
import { Config } from '@config/config.model';
import { ConfigService } from '@config/config.service';
import { CareSettingEnum } from '@shared/enums/care-setting.enum';
import { FormBuilder, FormControl, FormGroup } from '@angular/forms';

@Component({
selector: 'app-site-management-page',
Expand All @@ -27,20 +31,39 @@ export class SiteManagementPageComponent implements OnInit {
public busy: Subscription;
public title: string;
public healthAuthorityId: number;
public healthAuthoritySites$: Observable<HealthAuthoritySiteList[] | null>;
public healthAuthoritySites: HealthAuthoritySiteList[];
public displaySites: HealthAuthoritySiteList[];
public routeUtils: RouteUtils;
public HealthAuthorityEnum = HealthAuthorityEnum;
public SiteStatusType = SiteStatusType;
public vendors: Config<number>[];
public careTypes: Config<number>[];
public form: FormGroup;

constructor(
private route: ActivatedRoute,
private fb: FormBuilder,
private router: Router,
private authorizedUserService: AuthorizedUserService,
private authorizedUserResource: AuthorizedUserResource,
private formatDatePipe: FormatDatePipe
private formatDatePipe: FormatDatePipe,
private configService: ConfigService,
) {
this.title = this.route.snapshot.data.title;
this.routeUtils = new RouteUtils(route, router, HealthAuthSiteRegRoutes.MODULE_PATH);

this.careTypes = this.configService.careTypes;
this.vendors = this.configService.vendors
.filter(v => v.careSettingCode === CareSettingEnum.HEALTH_AUTHORITY)
.sort((a, b) => a.name.localeCompare(b.name));
}

public get vendorCode(): FormControl {
return this.form.get('vendorCode') as FormControl;
}

public get careTypeCode(): FormControl {
return this.form.get('careTypeCode') as FormControl;
}

public viewAuthorizedUser(healthAuthorityId: number): void {
Expand Down Expand Up @@ -82,11 +105,62 @@ export class SiteManagementPageComponent implements OnInit {
}

public ngOnInit(): void {
this.createFormInstance();
this.initForm();
const authorizedUser = this.authorizedUserService.authorizedUser;
this.healthAuthorityId = authorizedUser.healthAuthorityCode;
this.healthAuthoritySites$ = this.authorizedUserResource.getAuthorizedUserSites(authorizedUser.id);
this.authorizedUserResource.getAuthorizedUserSites(authorizedUser.id)
.subscribe((sites: HealthAuthoritySiteList[]) => {
this.healthAuthoritySites = sites.sort((a, b) => a.siteName.toLocaleLowerCase().localeCompare(b.siteName.toLocaleLowerCase()))

const haVendors = this.healthAuthoritySites.map((s) => {
return s.healthAuthorityVendor.vendorCode;
});

const haCareTypes = this.healthAuthoritySites.map((s) => {
return s.healthAuthorityCareType.careType;
});

this.careTypes = this.careTypes.filter((c) => haCareTypes.some((hac) => hac === c.name));
this.vendors = this.vendors.filter((v) => haVendors.some((hav) => hav === v.code));
});
}

private createFormInstance() {
this.form = this.fb.group({
vendorCode: ['all', []],
careTypeCode: ['all', []],
});
}

private initForm() {
this.vendorCode.valueChanges.subscribe(() => {
this.filterSites();
});
this.careTypeCode.valueChanges.subscribe(() => {
this.filterSites();
})
}

public filterSites() {
const authorizedUser = this.authorizedUserService.authorizedUser;
this.authorizedUserResource.getAuthorizedUserSites(authorizedUser.id)
.subscribe((sites: HealthAuthoritySiteList[]) => {
this.healthAuthoritySites = sites.sort((a, b) => a.siteName.toLocaleLowerCase().localeCompare(b.siteName.toLocaleLowerCase()));
if (this.careTypeCode.value !== "all") {
this.healthAuthoritySites = this.healthAuthoritySites.filter((s) => {
return s.healthAuthorityCareType.careType === this.careTypeCode.value;
})
}
if (this.vendorCode.value !== "all") {
this.healthAuthoritySites = this.healthAuthoritySites.filter((s) => {
return s.healthAuthorityVendor.vendorCode === this.vendorCode.value;
})
}
});
}


private redirectTo(healthAuthorityId: number, healthAuthoritySiteId: number, pagePath: string): void {
this.routeUtils.routeRelativeTo([
HealthAuthSiteRegRoutes.HEALTH_AUTHORITIES,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ import { SiteStatusType } from '@lib/enums/site-status.enum';

import { AbstractBaseHealthAuthoritySite } from '@health-auth/shared/models/abstract-base-health-authority-site.class';
import { BaseHealthAuthoritySite } from '@health-auth/shared/models/base-health-authority-site.model';
import { HealthAuthorityCareType } from './health-authority-care-type.model';

export interface HealthAuthoritySiteListDto extends BaseHealthAuthoritySite {
healthAuthorityVendor: HealthAuthorityVendor;
healthAuthorityCareType: HealthAuthorityCareType;
siteName: string;
pec: string;
updatedTimeStamp: string;
Expand All @@ -18,6 +20,7 @@ export class HealthAuthoritySiteList extends AbstractBaseHealthAuthoritySite imp
public id: number,
public healthAuthorityOrganizationId: HealthAuthorityEnum,
public healthAuthorityVendor: HealthAuthorityVendor,
public healthAuthorityCareType: HealthAuthorityCareType,
public siteName,
public pec: string,
public readonly completed: boolean,
Expand All @@ -30,6 +33,7 @@ export class HealthAuthoritySiteList extends AbstractBaseHealthAuthoritySite imp
super(id, healthAuthorityOrganizationId, completed, submittedDate, approvedDate, status);

this.healthAuthorityVendor = healthAuthorityVendor;
this.healthAuthorityCareType = healthAuthorityCareType;
this.siteName = siteName;
this.pec = pec;
this.updatedTimeStamp = updatedTimeStamp;
Expand All @@ -51,6 +55,7 @@ export class HealthAuthoritySiteList extends AbstractBaseHealthAuthoritySite imp
healthAuthoritySiteListDto.id,
healthAuthoritySiteListDto.healthAuthorityOrganizationId,
healthAuthoritySiteListDto.healthAuthorityVendor,
healthAuthoritySiteListDto.healthAuthorityCareType,
healthAuthoritySiteListDto.siteName,
healthAuthoritySiteListDto.pec,
healthAuthoritySiteListDto.completed,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,9 @@ export class SiteManagementPageComponent implements OnInit {
: expiryDates;
}, []);
this.organizations = organizations;
return this.organization = organization;
this.organization = organization;
this.organization.sites = this.organization.sites.sort((a, b) => b.doingBusinessAs.toLocaleLowerCase().localeCompare(a.doingBusinessAs.toLocaleLowerCase()) * -1);
return this.organization;
}),
exhaustMap((organization: Organization) =>
this.organizationResource.getOrganizationAgreements(organization.id)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@
[ngTemplateOutletContext]="menuOutletContext"></ng-container>
</mat-card-header>
<mat-card-content>
<ng-container *ngFor="let prop of properties"
[ngTemplateOutlet]="property"
[ngTemplateOutletContext]="{ property: prop }">
</ng-container>
<div class="row">
<ng-container *ngFor="let prop of properties"
[ngTemplateOutlet]="property"
[ngTemplateOutletContext]="{ property: prop }">
</ng-container>
</div>

<ng-content></ng-content>
</mat-card-content>
Expand All @@ -29,8 +31,13 @@

<ng-template #property
let-property="property">
<div *ngIf="property.value">
<div *ngIf="property.value"
[ngClass]="property._50 ? 'col-md-6' : 'col-12'">
<strong>{{ property.key }}</strong>
<span [ngClass]="{ 'text-danger font-weight-bold' : property.danger }">{{ property.value | default }}</span>
<span [ngClass]="
{ 'text-danger font-weight-bold'
:
property.danger
}">{{ property.value | default }}</span>
</div>
</ng-template>
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public class HealthAuthoritySiteListViewModel
public string SiteName { get; set; }
public string PEC { get; set; }
public HealthAuthorityVendorViewModel HealthAuthorityVendor { get; set; }
public HealthAuthorityCareTypeViewModel HealthAuthorityCareType { get; set; }
public bool Completed { get; set; }
public DateTimeOffset? SubmittedDate { get; set; }
public DateTimeOffset? ApprovedDate { get; set; }
Expand Down

0 comments on commit 2b4f05f

Please sign in to comment.