diff --git a/frontend/src/app/components/report-header/report-header.component.html b/frontend/src/app/components/report-header/report-header.component.html index 58723ec3..17611874 100644 --- a/frontend/src/app/components/report-header/report-header.component.html +++ b/frontend/src/app/components/report-header/report-header.component.html @@ -7,7 +7,7 @@
-
Oct 10, 2018
+
{{lastUpdated ? (lastUpdated | date:'MMM d, yyyy') : ''}}
diff --git a/frontend/src/app/components/report-header/report-header.component.spec.ts b/frontend/src/app/components/report-header/report-header.component.spec.ts index f5c315b4..e661cccb 100644 --- a/frontend/src/app/components/report-header/report-header.component.spec.ts +++ b/frontend/src/app/components/report-header/report-header.component.spec.ts @@ -11,7 +11,7 @@ describe('ReportHeaderComponent', () => { let mockedFastenApiService beforeEach(async () => { - mockedFastenApiService = jasmine.createSpyObj('FastenApiService', ['getResources']) + mockedFastenApiService = jasmine.createSpyObj('FastenApiService', ['getResources', 'getSummary']) await TestBed.configureTestingModule({ imports: [ RouterTestingModule ], @@ -23,6 +23,7 @@ describe('ReportHeaderComponent', () => { }) .compileComponents(); mockedFastenApiService.getResources.and.returnValue(of({})); + mockedFastenApiService.getSummary.and.returnValue(of({sources: []})); fixture = TestBed.createComponent(ReportHeaderComponent); component = fixture.componentInstance; diff --git a/frontend/src/app/components/report-header/report-header.component.ts b/frontend/src/app/components/report-header/report-header.component.ts index ce2de89a..f0e26390 100644 --- a/frontend/src/app/components/report-header/report-header.component.ts +++ b/frontend/src/app/components/report-header/report-header.component.ts @@ -3,6 +3,7 @@ import {ResourceFhir} from '../../models/fasten/resource_fhir'; import {FastenApiService} from '../../services/fasten-api.service'; import * as fhirpath from 'fhirpath'; import {PractitionerModel} from '../../../lib/models/resources/practitioner-model'; +import {Summary} from '../../../app/models/fasten/summary'; @Component({ selector: 'report-header', @@ -12,14 +13,22 @@ import {PractitionerModel} from '../../../lib/models/resources/practitioner-mode export class ReportHeaderComponent implements OnInit { patient: ResourceFhir = null primaryCare: PractitionerModel = null + lastUpdated: Date = null @Input() reportHeaderTitle: string = "" @Input() reportHeaderSubTitle: string = "Organized by condition and encounters" - constructor( private fastenApi: FastenApiService, ) { } ngOnInit(): void { + this.fastenApi.getSummary().subscribe((summary: Summary) => { + if (summary.sources && summary.sources.length > 0) { + this.lastUpdated = summary.sources.reduce((latest, source) => { + const sourceDate = new Date(source.updated_at); + return sourceDate > latest ? sourceDate : latest; + }, new Date(0)); + } + }) this.fastenApi.getResources("Patient").subscribe(results => { this.patient = results[0] if(!this.patient) return diff --git a/frontend/src/app/pages/dashboard/dashboard.component.html b/frontend/src/app/pages/dashboard/dashboard.component.html index 865f260e..7c2ea751 100644 --- a/frontend/src/app/pages/dashboard/dashboard.component.html +++ b/frontend/src/app/pages/dashboard/dashboard.component.html @@ -11,7 +11,7 @@
-
Oct 10, 2018
+
{{lastUpdated ? (lastUpdated | date:'MMM d, yyyy') : ''}}
diff --git a/frontend/src/app/pages/dashboard/dashboard.component.ts b/frontend/src/app/pages/dashboard/dashboard.component.ts index 7c900730..798020eb 100644 --- a/frontend/src/app/pages/dashboard/dashboard.component.ts +++ b/frontend/src/app/pages/dashboard/dashboard.component.ts @@ -9,7 +9,7 @@ import { GridStack, GridStackOptions, GridStackWidget } from 'gridstack'; import {GridstackComponent, NgGridStackOptions} from '../../components/gridstack/gridstack.component'; import {DashboardConfig} from '../../models/widget/dashboard-config'; import {NgbModal} from '@ng-bootstrap/ng-bootstrap'; - +import {Summary} from '../../models/fasten/summary'; // unique ids sets for each item for correct ngFor updating //TODO: fix this @@ -23,6 +23,8 @@ let ids = 1; export class DashboardComponent implements OnInit { loading: boolean = false + lastUpdated: Date = null + sources: Source[] = [] encounterCount: number = 0 recordsCount: number = 0 @@ -50,6 +52,15 @@ export class DashboardComponent implements OnInit { ngOnInit() { this.loading = true + this.fastenApi.getSummary().subscribe((summary: Summary) => { + if (summary.sources && summary.sources.length > 0) { + this.lastUpdated = summary.sources.reduce((latest, source) => { + const sourceDate = new Date(source.updated_at); + return sourceDate > latest ? sourceDate : latest; + }, new Date(0)); + } + }) + forkJoin([ this.fastenApi.getDashboards(), diff --git a/frontend/src/app/pages/medical-history/medical-history.component.spec.ts b/frontend/src/app/pages/medical-history/medical-history.component.spec.ts index 9f1619db..73203f62 100644 --- a/frontend/src/app/pages/medical-history/medical-history.component.spec.ts +++ b/frontend/src/app/pages/medical-history/medical-history.component.spec.ts @@ -14,7 +14,7 @@ describe('MedicalHistoryComponent', () => { beforeEach(async () => { - mockedFastenApiService = jasmine.createSpyObj('FastenApiService', ['getResources', 'getResourceGraph']) + mockedFastenApiService = jasmine.createSpyObj('FastenApiService', ['getResources', 'getResourceGraph', 'getSummary']) await TestBed.configureTestingModule({ declarations: [ MedicalHistoryComponent, ReportHeaderComponent ], imports: [ RouterTestingModule ], @@ -26,6 +26,7 @@ describe('MedicalHistoryComponent', () => { .compileComponents(); mockedFastenApiService.getResourceGraph.and.returnValue(of({"Condition":[],"Encounter":[]})); mockedFastenApiService.getResources.and.returnValue(of([])); + mockedFastenApiService.getSummary.and.returnValue(of({sources: []})); fixture = TestBed.createComponent(MedicalHistoryComponent); component = fixture.componentInstance; diff --git a/frontend/src/app/pages/patient-profile/patient-profile.component.spec.ts b/frontend/src/app/pages/patient-profile/patient-profile.component.spec.ts index 4fdc9c09..e78e1aec 100644 --- a/frontend/src/app/pages/patient-profile/patient-profile.component.spec.ts +++ b/frontend/src/app/pages/patient-profile/patient-profile.component.spec.ts @@ -13,7 +13,7 @@ describe('PatientProfileComponent', () => { let mockedFastenApiService beforeEach(async () => { - mockedFastenApiService = jasmine.createSpyObj('FastenApiService', ['getResources']) + mockedFastenApiService = jasmine.createSpyObj('FastenApiService', ['getResources', 'getSummary']) await TestBed.configureTestingModule({ declarations: [ PatientProfileComponent, ReportHeaderComponent ], imports: [PipesModule, RouterTestingModule], @@ -24,7 +24,7 @@ describe('PatientProfileComponent', () => { }) .compileComponents(); mockedFastenApiService.getResources.and.returnValue(of([{}])); - + mockedFastenApiService.getSummary.and.returnValue(of({sources: []})); fixture = TestBed.createComponent(PatientProfileComponent); component = fixture.componentInstance; fixture.detectChanges(); diff --git a/frontend/src/app/pages/report-labs/report-labs.component.spec.ts b/frontend/src/app/pages/report-labs/report-labs.component.spec.ts index 11227c76..1389cdd4 100644 --- a/frontend/src/app/pages/report-labs/report-labs.component.spec.ts +++ b/frontend/src/app/pages/report-labs/report-labs.component.spec.ts @@ -14,7 +14,7 @@ describe('ReportLabsComponent', () => { beforeEach(async () => { - mockedFastenApiService = jasmine.createSpyObj('FastenApiService', ['getResources', 'queryResources']) + mockedFastenApiService = jasmine.createSpyObj('FastenApiService', ['getResources', 'queryResources', 'getSummary']) await TestBed.configureTestingModule({ declarations: [ ReportLabsComponent, ReportHeaderComponent ], imports: [RouterTestingModule, LoadingSpinnerComponent, RouterTestingModule], @@ -26,6 +26,7 @@ describe('ReportLabsComponent', () => { .compileComponents(); mockedFastenApiService.getResources.and.returnValue(of([])); mockedFastenApiService.queryResources.and.returnValue(of([])); + mockedFastenApiService.getSummary.and.returnValue(of({sources: []})); fixture = TestBed.createComponent(ReportLabsComponent); component = fixture.componentInstance;