adding loading property to each component.

updated lighthouse service to handle "show_hidden" when requesting metadata sources.
This commit is contained in:
Jason Kulatunga 2023-01-05 08:15:19 -08:00
parent 396e25ce20
commit 4294880d79
10 changed files with 60 additions and 49 deletions

View File

@ -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,

View File

@ -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,

View File

@ -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
});

View File

@ -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
})
}

View File

@ -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

View File

@ -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
})
}

View File

@ -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 || []

View File

@ -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
});
}

View File

@ -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
});
}

View File

@ -17,8 +17,13 @@ export class LighthouseService {
constructor(private _httpClient: HttpClient) {
}
public getLighthouseSourceMetadataMap(): Observable<{[name: string]: MetadataSource}> {
return this._httpClient.get<ResponseWrapper>(`${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<ResponseWrapper>(endpointUrl.toString())
.pipe(
map((response: ResponseWrapper) => {
console.log("Metadata RESPONSE", response)