make last updated dynamic from summary api endpoint (#499)

This commit is contained in:
David Radcliffe 2024-08-11 05:55:51 -04:00 committed by GitHub
parent c5d7717cbd
commit 01caa24719
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 32 additions and 9 deletions

View File

@ -7,7 +7,7 @@
<div class="media">
<div class="media-body">
<label>Last Updated</label>
<h6>Oct 10, 2018</h6>
<h6>{{lastUpdated ? (lastUpdated | date:'MMM d, yyyy') : ''}}</h6>
</div><!-- media-body -->
</div><!-- media -->
<div *ngIf="primaryCare" class="media">

View File

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

View File

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

View File

@ -11,7 +11,7 @@
<div class="media">
<div class="media-body">
<label>Last Updated</label>
<h6>Oct 10, 2018</h6>
<h6>{{lastUpdated ? (lastUpdated | date:'MMM d, yyyy') : ''}}</h6>
</div><!-- media-body -->
</div><!-- media -->
<div class="media">

View File

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

View File

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

View File

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

View File

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