Skip to content

Instantly share code, notes, and snippets.

@janpauldahlke
Created June 15, 2022 12:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save janpauldahlke/d32b88d98a93fd4fc6206e57ba606bc9 to your computer and use it in GitHub Desktop.
Save janpauldahlke/d32b88d98a93fd4fc6206e57ba606bc9 to your computer and use it in GitHub Desktop.
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