finally fixed all tests.

This commit is contained in:
Jason Kulatunga 2023-01-16 18:01:42 -08:00
parent a97942c954
commit f818428dfd
4 changed files with 14 additions and 8 deletions

View File

@ -1,6 +1,6 @@
<div>
<embed
src="data:${{displayModel.content_type}};base64,${{displayModel.data}}"
[src]="safeUrl"
type="{{displayModel?.content_type}}"
[style]="{
width: '100%',

View File

@ -1,5 +1,6 @@
import {Component, Input, OnInit} from '@angular/core';
import {BinaryModel} from '../../../../../lib/models/resources/binary-model';
import {DomSanitizer, SafeUrl} from '@angular/platform-browser';
@Component({
selector: 'fhir-pdf',
@ -10,15 +11,21 @@ export class PdfComponent implements OnInit {
@Input() displayModel: BinaryModel
height: number
constructor() { }
constructor(private sanitized: DomSanitizer) { }
safeUrl: SafeUrl
ngOnInit(): void {
const maxHeight = 600;
if (this.displayModel){
const contentHeight = (1111 * this.displayModel?.data.length) / (24996 / 7.5);
this.height = Math.min(maxHeight, contentHeight);
}
const contentHeight = (1111 * this.displayModel?.data.length) / (24996 / 7.5);
this.safeUrl = this.sanitized.bypassSecurityTrustResourceUrl(`data:${this.displayModel?.content_type};base64,${this.displayModel?.data}`);
this.height = Math.min(maxHeight, contentHeight);
} else {
this.safeUrl = this.sanitized.bypassSecurityTrustResourceUrl('')
}
}
}

View File

@ -52,7 +52,7 @@ export class FhirResourceComponent implements OnInit, OnChanges {
const viewContainerRef = this.fhirResourceOutlet.viewContainerRef;
viewContainerRef.clear();
let componentType = this.typeLookup(this.displayModel.source_resource_type)
let componentType = this.typeLookup(this.displayModel?.source_resource_type)
if(componentType != null){
console.log("Attempting to create fhir display component", this.displayModel, componentType)
const componentRef = viewContainerRef.createComponent<FhirResourceComponentInterface>(componentType);

View File

@ -65,7 +65,6 @@ export class ReportMedicalHistoryConditionComponent implements OnInit {
constructor() { }
ngOnInit(): void {
//add resources to the lookup table, ensure uniqueness.
this.conditionDisplayModel = this.recExtractResources(this.conditionGroup)
@ -142,7 +141,7 @@ export class ReportMedicalHistoryConditionComponent implements OnInit {
//ensure display model is populated
if(!resourceDisplayModel){
try{
resourceDisplayModel = fhirModelFactory(resource.source_resource_type as ResourceType, resource)
resourceDisplayModel = fhirModelFactory(resource?.source_resource_type as ResourceType, resource)
this.resourcesLookup[resourceId] = resourceDisplayModel
}catch(e){
console.error(e) //failed to parse a model