Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Fhir

Hierarchy

  • Fhir

Index

Constructors

constructor

Events

resolve

  • resolve(reference: string): void
  • A callback which is executed when a reference needs to be resolved to a resource during evaluation of FhirPath. This should be overridden by the caller of the class.

    Parameters

    • reference: string

      The reference that needs to be resolved

    Returns void

    Should return a Resource instance

Properties

Readonly parser

Methods

evaluate

  • evaluate(resource: string | Object, fhirPathString: string): any
  • Evaluates a FhirPath against the specified resource(s)

    see

    FhirPath

    example

    var results = fhir.evaluate(resources, "Bundle.entry.where(fullUrl = 'http://xxx')") // Only one of the 8 resources in the bundle have an entry with that URL assert(results.fullUrl === 'http://xxx')

    example

    var results = fhir.evaluate([ resource1, resource2 ], "Bundle.entry.resource.where(resourceType = 'StructureDefinition')") // Only one of the resources was a StructureDefinition, so the one StructureDefinition is returned assert(results.resourceType === 'StructureDefinition')

    example

    var results = fhir.evaluate([ resource1, resource2 ], "StructureDefinition.snapshot.element") // results in a combination of all elements in both StructureDefinition resources assert(results.length == 84)

    Parameters

    • resource: string | Object
    • fhirPathString: string

    Returns any

    The result of the FhirPath evaluation. Can be a single value or multiple values. When FhirPath represents a operator comparison, returns a single boolean value.

generateSnapshot

  • generateSnapshot(bundle: Bundle): void
  • Generates a snapshot for each of the StructureDefinition resources in the Bundle. To generate a snapshot, the parser used by the Fhir instance needs to have the structure definitions explicitly loaded during runtime. In other words, you cannot generate snapshots using a cached ParseConformance instance. You can use SnapshotGenerator.createBundle(sd1, sd2, sd3) to easily create a bundle based on an arbitrary number of StructureDefinitions. The returned bundle can be passed to generateSnapshot().

    Parameters

    • bundle: Bundle

      A bundle containing StructureDefinition resources that need a snapshot generated for them

    Returns void

jsonToXml

  • jsonToXml(json: string): string
  • Serializes a JSON resource object to XML

    Parameters

    • json: string

    Returns string

    XML

objToXml

  • objToXml(obj: Object): string
  • Serializes a JS resource object to XML

    Parameters

    • obj: Object

    Returns string

validate

  • Validates the specified resource (either a JS object or XML string)

    Parameters

    • input: string | Object

      The input to validate. Can be XML string, JSON string or an object

    • Optional options: ValidatorOptions

      The options to use while validating

    Returns ValidatorResponse

    The results of the validation

xmlToJson

  • xmlToJson(xml: string): string
  • Serializes an XML resource to JSON

    Parameters

    • xml: string

    Returns string

    JSON

xmlToObj

  • xmlToObj(xml: string): { resourceType: any }
  • Serializes an XML resource to a JS object

    Parameters

    • xml: string

    Returns { resourceType: any }

    • resourceType: any

Generated using TypeDoc