fhirbuilder
Version:
Another FHIR Tool to build FHIR Resources
31 lines (30 loc) • 1.39 kB
TypeScript
import { IBuildable } from '../base/IBuildable';
import { Annotation } from '../../models';
import { IAnnotation, IElement, IReference } from 'fhirtypes/dist/r4';
import { ElementBuilder } from '../base/ElementBuilder';
import { UnderscoreKeys } from '../base/resource-type-map.interface';
type PrimitiveExtensionFields = keyof Pick<IAnnotation, UnderscoreKeys<IAnnotation>>;
type ExtractAuthor<T> = Extract<{
[K in keyof T]: K extends `author${string}` ? K : never;
}[keyof T], keyof T>;
type ExtractAuthorType = keyof Pick<IAnnotation, ExtractAuthor<IAnnotation>>;
interface IAnnotationBuilder extends IBuildable<Annotation> {
setAuthor<T extends ExtractAuthorType>(type: T, value: T extends 'authorReference' ? IReference : string): this;
setTime(time: string): this;
setText(text: string): this;
}
export declare class AnnotationBuilder extends ElementBuilder implements IAnnotationBuilder {
private readonly annotation;
constructor();
setAuthor<T extends ExtractAuthorType>(type: T, value: T extends 'authorReference' ? IReference : string): this;
setTime(time: string): this;
setText(text: string): this;
/**
* @description Add a primitive extension to the element
* @param param
* @param extension
*/
addPrimitiveExtension(param: PrimitiveExtensionFields, extension: IElement): this;
build(): Annotation;
}
export {};