Skip to content

Commit

Permalink
finally fixed all tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
AnalogJ committed Jan 17, 2023
1 parent a97942c commit f818428
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<div>
<embed
src="data:${{displayModel.content_type}};base64,${{displayModel.data}}"
[src]="safeUrl"
type="{{displayModel?.content_type}}"
[style]="{
width: '100%',
Expand Down
11 changes: 9 additions & 2 deletions frontend/src/app/components/fhir/datatypes/pdf/pdf.component.ts
Original file line number Diff line number Diff line change
@@ -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',
Expand All @@ -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.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('')
}

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit f818428

Please sign in to comment.