From 4294880d7945798fb30a14c00a243f4640ee0d9d Mon Sep 17 00:00:00 2001 From: Jason Kulatunga Date: Thu, 5 Jan 2023 08:15:19 -0800 Subject: [PATCH] adding loading property to each component. updated lighthouse service to handle "show_hidden" when requesting metadata sources. --- .../auth-signin/auth-signin.component.ts | 4 +-- .../auth-signup/auth-signup.component.ts | 3 ++- .../pages/dashboard/dashboard.component.ts | 23 ++++------------- .../medical-history.component.ts | 6 +++++ .../medical-sources.component.ts | 24 ++++++++---------- .../patient-profile.component.ts | 25 +++++++++++-------- .../report-labs/report-labs.component.ts | 3 ++- .../resource-detail.component.ts | 7 +++++- .../source-detail/source-detail.component.ts | 5 ++++ .../src/app/services/lighthouse.service.ts | 9 +++++-- 10 files changed, 60 insertions(+), 49 deletions(-) diff --git a/frontend/src/app/pages/auth-signin/auth-signin.component.ts b/frontend/src/app/pages/auth-signin/auth-signin.component.ts index 2117a508..1aab0f06 100644 --- a/frontend/src/app/pages/auth-signin/auth-signin.component.ts +++ b/frontend/src/app/pages/auth-signin/auth-signin.component.ts @@ -13,13 +13,13 @@ import {Location} from '@angular/common'; styleUrls: ['./auth-signin.component.scss'] }) export class AuthSigninComponent implements OnInit { + loading: boolean = false + submitted: boolean = false existingUser: User = new User() errorMsg: string = "" showExternalIdP: boolean = environment.environment_cloud - loading: boolean = false - constructor( private authService: AuthService, private router: Router, diff --git a/frontend/src/app/pages/auth-signup/auth-signup.component.ts b/frontend/src/app/pages/auth-signup/auth-signup.component.ts index 0ad1fd3b..769134e8 100644 --- a/frontend/src/app/pages/auth-signup/auth-signup.component.ts +++ b/frontend/src/app/pages/auth-signup/auth-signup.component.ts @@ -11,10 +11,11 @@ import {AuthService} from '../../services/auth.service'; styleUrls: ['./auth-signup.component.scss'] }) export class AuthSignupComponent implements OnInit { + loading: boolean = false + submitted: boolean = false newUser: User = new User() errorMsg: string = "" - loading: boolean = false constructor( private authService: AuthService, diff --git a/frontend/src/app/pages/dashboard/dashboard.component.ts b/frontend/src/app/pages/dashboard/dashboard.component.ts index bfd23de4..4843da3c 100644 --- a/frontend/src/app/pages/dashboard/dashboard.component.ts +++ b/frontend/src/app/pages/dashboard/dashboard.component.ts @@ -14,6 +14,7 @@ import {LighthouseService} from '../../services/lighthouse.service'; styleUrls: ['./dashboard.component.scss'] }) export class DashboardComponent implements OnInit { + loading: boolean = false sources: Source[] = [] encounterCount: number = 0 @@ -29,26 +30,10 @@ export class DashboardComponent implements OnInit { ) { } ngOnInit() { - - // this.fastenApi.getSummary() - // .subscribe( (summary) => { - // console.log(summary); - // this.sources = summary.sources - // - // //calculate the number of records - // summary.resource_type_counts.forEach((resourceTypeInfo) => { - // this.recordsCount += resourceTypeInfo.count - // if(resourceTypeInfo.resource_type == "Encounter"){ - // this.encounterCount = resourceTypeInfo.count - // } - // }) - // - // summary.patients.forEach((resourceFhir) => { - // this.patientForSource[resourceFhir.source_id] = resourceFhir - // }) - // }) + this.loading = true forkJoin([this.fastenApi.getSummary(), this.lighthouseApi.getLighthouseSourceMetadataMap()]).subscribe(results => { + this.loading = false let summary = results[0] as Summary let metadataSource = results[1] as { [name: string]: MetadataSource } @@ -74,6 +59,8 @@ export class DashboardComponent implements OnInit { summary.patients.forEach((resourceFhir) => { this.patientForSource[resourceFhir.source_id] = resourceFhir }) + }, error => { + this.loading = false }); diff --git a/frontend/src/app/pages/medical-history/medical-history.component.ts b/frontend/src/app/pages/medical-history/medical-history.component.ts index aefcd526..a73f1fcd 100644 --- a/frontend/src/app/pages/medical-history/medical-history.component.ts +++ b/frontend/src/app/pages/medical-history/medical-history.component.ts @@ -12,6 +12,8 @@ import {forkJoin} from 'rxjs'; styleUrls: ['./medical-history.component.scss'] }) export class MedicalHistoryComponent implements OnInit { + loading: boolean = false + closeResult = ''; conditions: ResourceFhir[] = [] @@ -25,7 +27,9 @@ export class MedicalHistoryComponent implements OnInit { ngOnInit(): void { + this.loading = true this.fastenApi.getResourceGraph().subscribe(results => { + this.loading = false this.conditions = results["Condition"] this.unassigned_encounters = results["Encounter"] @@ -54,6 +58,8 @@ export class MedicalHistoryComponent implements OnInit { } + }, error => { + this.loading = false }) } diff --git a/frontend/src/app/pages/medical-sources/medical-sources.component.ts b/frontend/src/app/pages/medical-sources/medical-sources.component.ts index ff151aa9..2887d4b0 100644 --- a/frontend/src/app/pages/medical-sources/medical-sources.component.ts +++ b/frontend/src/app/pages/medical-sources/medical-sources.component.ts @@ -29,21 +29,10 @@ export class SourceListItem { styleUrls: ['./medical-sources.component.scss'] }) export class MedicalSourcesComponent implements OnInit { - - constructor( - private lighthouseApi: LighthouseService, - private fastenApi: FastenApiService, - private modalService: NgbModal, - private route: ActivatedRoute, - private router: Router, - private location: Location, - private toastService: ToastService - ) { } - + loading: boolean = false environment_name = environment.environment_name status: { [name: string]: string } = {} - loading: boolean = true metadataSources: {[name:string]: MetadataSource} = {} @@ -57,9 +46,18 @@ export class MedicalSourcesComponent implements OnInit { searchIndex = null searchTerm: string = "" + constructor( + private lighthouseApi: LighthouseService, + private fastenApi: FastenApiService, + private modalService: NgbModal, + private route: ActivatedRoute, + private router: Router, + private location: Location, + private toastService: ToastService + ) { } ngOnInit(): void { - + this.loading = true forkJoin([this.lighthouseApi.getLighthouseSourceMetadataMap(), this.fastenApi.getSources()]).subscribe(results => { this.loading = false //handle source metadata map response diff --git a/frontend/src/app/pages/patient-profile/patient-profile.component.ts b/frontend/src/app/pages/patient-profile/patient-profile.component.ts index 203ad9f5..cd9aa0a7 100644 --- a/frontend/src/app/pages/patient-profile/patient-profile.component.ts +++ b/frontend/src/app/pages/patient-profile/patient-profile.component.ts @@ -1,6 +1,7 @@ import { Component, OnInit } from '@angular/core'; import {ResourceFhir} from '../../models/fasten/resource_fhir'; import {FastenApiService} from '../../services/fasten-api.service'; +import {forkJoin} from 'rxjs'; @Component({ selector: 'app-patient-profile', @@ -8,6 +9,7 @@ import {FastenApiService} from '../../services/fasten-api.service'; styleUrls: ['./patient-profile.component.scss'] }) export class PatientProfileComponent implements OnInit { + loading: boolean = false patient: ResourceFhir = null immunizations: ResourceFhir[] = [] @@ -17,19 +19,20 @@ export class PatientProfileComponent implements OnInit { ) { } ngOnInit(): void { - this.fastenApi.getResources("Patient").subscribe(results => { - console.log(results) - this.patient = results[0] - }) + this.loading = true - this.fastenApi.getResources("Immunization").subscribe(results => { + forkJoin([ + this.fastenApi.getResources("Patient"), + this.fastenApi.getResources("Immunization"), + this.fastenApi.getResources("AllergyIntolerance") + ]).subscribe(results => { + this.loading = false console.log(results) - this.immunizations = results - }) - - this.fastenApi.getResources("AllergyIntolerance").subscribe(results => { - console.log(results) - this.allergyIntolerances = results + this.patient = results[0][0] + this.immunizations = results[1] + this.allergyIntolerances = results[2] + }, error => { + this.loading = false }) } diff --git a/frontend/src/app/pages/report-labs/report-labs.component.ts b/frontend/src/app/pages/report-labs/report-labs.component.ts index 7b576bdb..0c89ed7d 100644 --- a/frontend/src/app/pages/report-labs/report-labs.component.ts +++ b/frontend/src/app/pages/report-labs/report-labs.component.ts @@ -10,11 +10,11 @@ import * as fhirpath from 'fhirpath'; styleUrls: ['./report-labs.component.scss'] }) export class ReportLabsComponent implements OnInit { + loading: boolean = false observationGroups: {[key: string]: ResourceFhir[]} = {} observationGroupTitles: {[key: string]: string} = {} - loading = true isEmptyReport = false constructor( @@ -22,6 +22,7 @@ export class ReportLabsComponent implements OnInit { ) { } ngOnInit(): void { + this.loading = true this.fastenApi.getResources("Observation").subscribe(results => { this.loading = false results = results || [] diff --git a/frontend/src/app/pages/resource-detail/resource-detail.component.ts b/frontend/src/app/pages/resource-detail/resource-detail.component.ts index 9344ccba..d75bb04e 100644 --- a/frontend/src/app/pages/resource-detail/resource-detail.component.ts +++ b/frontend/src/app/pages/resource-detail/resource-detail.component.ts @@ -10,6 +10,8 @@ import {fhirModelFactory} from '../../../lib/models/factory'; styleUrls: ['./resource-detail.component.scss'] }) export class ResourceDetailComponent implements OnInit { + loading: boolean = false + sourceId: string = "" sourceName: string = "" resource: ResourceFhir = null @@ -18,7 +20,9 @@ export class ResourceDetailComponent implements OnInit { } ngOnInit(): void { + this.loading = true this.fastenApi.getResourceBySourceId(this.route.snapshot.paramMap.get('source_id'), this.route.snapshot.paramMap.get('resource_id')).subscribe((resourceFhir) => { + this.loading = false console.log("RESOURECE FHIR", resourceFhir) this.resource = resourceFhir; this.sourceId = this.route.snapshot.paramMap.get('source_id') @@ -31,7 +35,8 @@ export class ResourceDetailComponent implements OnInit { console.log("FAILED TO PARSE", resourceFhir) console.error(e) } - + }, error => { + this.loading = false }); } diff --git a/frontend/src/app/pages/source-detail/source-detail.component.ts b/frontend/src/app/pages/source-detail/source-detail.component.ts index ae205185..31d77960 100644 --- a/frontend/src/app/pages/source-detail/source-detail.component.ts +++ b/frontend/src/app/pages/source-detail/source-detail.component.ts @@ -11,6 +11,7 @@ import {getPath} from '../../components/list-generic-resource/utils'; styleUrls: ['./source-detail.component.scss'] }) export class SourceDetailComponent implements OnInit { + loading: boolean = false selectedSource: Source = null selectedPatient: ResourceFhir = null @@ -26,13 +27,17 @@ export class SourceDetailComponent implements OnInit { } ngOnInit(): void { + this.loading = true //always request the source summary this.fastenApi.getSourceSummary(this.route.snapshot.paramMap.get('source_id')).subscribe((sourceSummary) => { + this.loading = false this.selectedSource = sourceSummary.source; this.selectedPatient = sourceSummary.patient; for(let resourceTypeCount of sourceSummary.resource_type_counts){ this.resourceTypeCounts[resourceTypeCount.resource_type] = resourceTypeCount.count } + }, error => { + this.loading = false }); } diff --git a/frontend/src/app/services/lighthouse.service.ts b/frontend/src/app/services/lighthouse.service.ts index 01df8bf5..c0d115e6 100644 --- a/frontend/src/app/services/lighthouse.service.ts +++ b/frontend/src/app/services/lighthouse.service.ts @@ -17,8 +17,13 @@ export class LighthouseService { constructor(private _httpClient: HttpClient) { } - public getLighthouseSourceMetadataMap(): Observable<{[name: string]: MetadataSource}> { - return this._httpClient.get(`${environment.lighthouse_api_endpoint_base}/list`) + public getLighthouseSourceMetadataMap(showHidden = false): Observable<{[name: string]: MetadataSource}> { + const endpointUrl = new URL(`${environment.lighthouse_api_endpoint_base}/list`); + if(showHidden){ + endpointUrl.searchParams.set('show_hidden', 'true'); + } + + return this._httpClient.get(endpointUrl.toString()) .pipe( map((response: ResponseWrapper) => { console.log("Metadata RESPONSE", response)