fixing tests. make sure fhirPath can handle null value.
This commit is contained in:
parent
c5e2991c33
commit
db9f289b54
|
@ -3,10 +3,10 @@
|
||||||
<div class="row" >
|
<div class="row" >
|
||||||
<!-- Condition Header -->
|
<!-- Condition Header -->
|
||||||
<div class="col-6">
|
<div class="col-6">
|
||||||
<span routerLink="/source/{{observations[0]?.source_id}}/resource/{{observations[0]?.source_resource_id}}">{{observationTitle}}</span>
|
<span routerLink="/source/{{firstObservation?.source_id}}/resource/{{firstObservation?.source_resource_id}}">{{observationTitle}}</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-6">
|
<div class="col-6">
|
||||||
{{observations[0] | fhirPath: "Observation.effectiveDateTime": "Observation.issued" | date}}
|
{{firstObservation | fhirPath: "Observation.effectiveDateTime": "Observation.issued" | date}}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div><!-- card-header -->
|
</div><!-- card-header -->
|
||||||
|
@ -20,13 +20,13 @@
|
||||||
<div class="row pl-3">
|
<div class="row pl-3">
|
||||||
<div class="col-12 mt-3 mb-2">
|
<div class="col-12 mt-3 mb-2">
|
||||||
<p>
|
<p>
|
||||||
<strong>Short Name:</strong> {{observations[0] | fhirPath: "Observation.code.text"}} <br/>
|
<strong>Short Name:</strong> {{firstObservation | fhirPath: "Observation.code.text"}} <br/>
|
||||||
<strong>Result:</strong> {{observations[0] | fhirPath: "Observation.valueQuantity.value"}} {{observations[0] | fhirPath: "Observation.valueQuantity.unit"}} <br/>
|
<strong>Result:</strong> {{firstObservation | fhirPath: "Observation.valueQuantity.value"}} {{firstObservation | fhirPath: "Observation.valueQuantity.unit"}} <br/>
|
||||||
<br/>
|
<br/>
|
||||||
<strong>Latest Test Date:</strong> {{observations[0] | fhirPath: "Observation.effectiveDateTime": "Observation.issued" | date}} <br/>
|
<strong>Latest Test Date:</strong> {{firstObservation | fhirPath: "Observation.effectiveDateTime": "Observation.issued" | date}} <br/>
|
||||||
<strong>Ordered By:</strong> {{observations[0] | fhirPath: "Observation.encounter.display"}} <br/>
|
<strong>Ordered By:</strong> {{firstObservation | fhirPath: "Observation.encounter.display"}} <br/>
|
||||||
<strong>LOINC Code:</strong> {{observationCode}} <br/>
|
<strong>LOINC Code:</strong> {{observationCode}} <br/>
|
||||||
<strong>Notes:</strong> {{observations[0] | fhirPath: "Observation.note.text"}}
|
<strong>Notes:</strong> {{firstObservation | fhirPath: "Observation.note.text"}}
|
||||||
|
|
||||||
<br/>
|
<br/>
|
||||||
<br/>
|
<br/>
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||||
|
|
||||||
import { ReportLabsObservationComponent } from './report-labs-observation.component';
|
import { ReportLabsObservationComponent } from './report-labs-observation.component';
|
||||||
|
import {PipesModule} from '../../pipes/pipes.module';
|
||||||
|
import {NgbCollapseModule} from '@ng-bootstrap/ng-bootstrap';
|
||||||
|
|
||||||
describe('ReportLabsObservationComponent', () => {
|
describe('ReportLabsObservationComponent', () => {
|
||||||
let component: ReportLabsObservationComponent;
|
let component: ReportLabsObservationComponent;
|
||||||
|
@ -8,6 +10,7 @@ describe('ReportLabsObservationComponent', () => {
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
await TestBed.configureTestingModule({
|
await TestBed.configureTestingModule({
|
||||||
|
imports: [PipesModule, NgbCollapseModule],
|
||||||
declarations: [ ReportLabsObservationComponent ]
|
declarations: [ ReportLabsObservationComponent ]
|
||||||
})
|
})
|
||||||
.compileComponents();
|
.compileComponents();
|
||||||
|
|
|
@ -14,10 +14,11 @@ import {formatDate} from '@angular/common';
|
||||||
})
|
})
|
||||||
export class ReportLabsObservationComponent implements OnInit {
|
export class ReportLabsObservationComponent implements OnInit {
|
||||||
|
|
||||||
@Input() observations: ResourceFhir[]
|
@Input() observations: ResourceFhir[] = []
|
||||||
@Input() observationCode: string
|
@Input() observationCode: string
|
||||||
@Input() observationTitle: string
|
@Input() observationTitle: string
|
||||||
|
|
||||||
|
firstObservation: ResourceFhir = null
|
||||||
// based on https://stackoverflow.com/questions/38889716/chartjs-2-stacked-bar-with-marker-on-top
|
// based on https://stackoverflow.com/questions/38889716/chartjs-2-stacked-bar-with-marker-on-top
|
||||||
// https://stackoverflow.com/questions/62711919/chart-js-horizontal-lines-per-bar
|
// https://stackoverflow.com/questions/62711919/chart-js-horizontal-lines-per-bar
|
||||||
|
|
||||||
|
@ -161,9 +162,11 @@ export class ReportLabsObservationComponent implements OnInit {
|
||||||
let referenceRanges = []
|
let referenceRanges = []
|
||||||
|
|
||||||
//sort observations
|
//sort observations
|
||||||
this.observations = this.observations.sort((a, b) => a.sort_date > b.sort_date ? -1 : a.sort_date < b.sort_date ? 1 : 0)
|
this.observations = this.observations?.sort((a, b) => a.sort_date > b.sort_date ? -1 : a.sort_date < b.sort_date ? 1 : 0)
|
||||||
|
|
||||||
|
|
||||||
|
if(this.observations.length > 0){
|
||||||
|
this.firstObservation = this.observations[0]
|
||||||
|
}
|
||||||
for(let observation of this.observations){
|
for(let observation of this.observations){
|
||||||
//get label
|
//get label
|
||||||
this.barChartLabels.push(
|
this.barChartLabels.push(
|
||||||
|
@ -188,6 +191,8 @@ export class ReportLabsObservationComponent implements OnInit {
|
||||||
])
|
])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
this.barChartData[0].data = referenceRanges
|
this.barChartData[0].data = referenceRanges
|
||||||
this.barChartData[1].data = currentValues.map(v => [v, v])
|
this.barChartData[1].data = currentValues.map(v => [v, v])
|
||||||
|
|
|
@ -8,6 +8,9 @@ import { evaluate } from 'fhirpath'
|
||||||
export class FhirPathPipe implements PipeTransform {
|
export class FhirPathPipe implements PipeTransform {
|
||||||
|
|
||||||
transform(resourceFhir: ResourceFhir, ...pathQueryWithFallback: string[]): string {
|
transform(resourceFhir: ResourceFhir, ...pathQueryWithFallback: string[]): string {
|
||||||
|
if(!resourceFhir){
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
for(let pathQuery of pathQueryWithFallback){
|
for(let pathQuery of pathQueryWithFallback){
|
||||||
let result = evaluate(resourceFhir.resource_raw, pathQuery).join(", ")
|
let result = evaluate(resourceFhir.resource_raw, pathQuery).join(", ")
|
||||||
|
|
Loading…
Reference in New Issue