Created
June 15, 2022 12:07
-
-
Save janpauldahlke/d32b88d98a93fd4fc6206e57ba606bc9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { R4 } from "@ahryman40k/ts-fhir-types"; | |
import { Pipe, PipeTransform } from "@angular/core"; | |
import { UntilDestroy } from "@ngneat/until-destroy"; | |
import { Subscription } from 'rxjs/internal/Subscription'; | |
import { LocalizedValueSetService } from "src/app/resources/foundation/terminology/value-set/state/localized-value-set.service"; | |
import { ListItem } from 'src/app/state/abstract/list-item.model'; | |
@UntilDestroy() | |
@Pipe({ | |
name: 'dosageText', | |
pure: false | |
}) | |
export class DosageTextPipe implements PipeTransform { | |
listOfResasonCodes: ListItem[]; | |
subscribeListOfResasonCodes: Subscription; | |
setAndSystem = 'http://fhir.synios.eu/ValueSet/Medication-Units'; | |
constructor( | |
private valueSetService: LocalizedValueSetService | |
) { | |
this.subscribeListOfResasonCodes = this.valueSetService.get(this.setAndSystem).selectList(this.setAndSystem).subscribe({ | |
next: (list) => this.listOfResasonCodes = list, | |
error: (err) => console.log(err), | |
}); | |
} | |
transform(doseUnit: R4.ICodeableConcept) { | |
const code = doseUnit.coding[0]?.code; | |
if (!code) { return '' } | |
const result = (this.listOfResasonCodes ?? []).find(item => item.key === code)?.text ?? ''; | |
return result; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment