plasma-fhir
  • What is Plasma FHIR?
  • Docs
    • Guides
      • Getting Started
      • Create an Epic Patient App
      • Create an Epic Clinician App
      • Create an Epic Backend App
      • Testing with SMART Health IT Sandbox
      • Developing/Contributing to Plasma FHIR
  • Packages
    • create-plasma-app
    • plasma-fhir-app-utils
      • PlasmaFHIRApi
      • Resources
      • PlasmaFHIRUtils
      • Conversions
      • DateTimeUtils
    • plasma-fhir-backend-utils
    • plasma-fhir-react-client-context
    • plasma-fhir-react-components
  • Sample Apps
    • Plasma Portal
    • Plasma Portal Lite
    • Family History Editor
    • Playground
Powered by GitBook
On this page
  • Patient
  • Identifier
  • HumanName
  • ContactPoint
  • Reference
  • CodeableConcept
  • Coding
  • Quantity
  • Age
  • Range
  • Period
  • Ratio
  • Address
  • Encounter
  • AdministrativeGender
  • FamilyMemberHistory_Relationship
  • FamilyMemberHistoryCondition
  • DeviceDeviceName
  • Flag
  • DocumentReference
  • Extension
  1. Packages
  2. plasma-fhir-app-utils

Resources

PreviousPlasmaFHIRApiNextPlasmaFHIRUtils

Last updated 2 years ago

Resources is a set of TypeScript objects representing FHIR resources. They are 100% compatible with the from this library. If a resource object does not exist in Resources, you can use the FHIR types in the linked library instead.

The Resources in this package provide:

  • Constructor methods to help when constructing new instances of a resource

  • Static methods that are useful when working with a resource (string formatting, filtering, etc.)

import { Resources } from "plasma-fhir-app-utils";

Patient

// Get the patient's "official" name...
const officialName = Resources.Patient.getOfficialName(patient);
// Get the patient's "home" address...
const addrHome = Resources.Patient.getHomeAddress(patient);

Identifier

// Get identifier by system...
const id = Resources.Identifier.getIdentifierBySystem(patient.identifier, "urn:...");
// Get a displayable string...
const display = Resources.Identifier.toString(patient.identifier[0]);

HumanName

// Gets all names based on the given "use"...
const names = Resources.HumanName.getNamesByUse(patient.name, "maiden");
const officialName = Resources.Patient.getOfficialName(patient);

// Convert a name to a displayable string...
const sName = Resources.HumanName.toString(officialName);

ContactPoint

// Get contact by use...
const contact = Resources.ContactPoint.getContactPointByUse(patient.telecom, "home");

Reference

// Get a reference to the given patient
const patientRef = Resources.Reference.createPatientReference(patientId);

CodeableConcept

// Create a CodeableConcept from a singl Coding resource...
const cc = Resources.CodeableConcept.fromSingleCoding(coding);
// Get a displayable string for this CodeableConcept...
const onlyFirstCode = true;
const sCC = Resources.CodeableConcept.getDisplayText(cc, onlyFirstCode);
let cc = [....];

// Sort a CodeableConcept by the display text
cc = cc.sort(Resources.CodeableConcept.sortByDisplayText);

Coding

// Filter codings by system or code...
const codes1 = Resources.Coding.getCodingsBySystem(codings, "http://my-system");
const codes2 = Resources.Coding.getCodingsByCode(codings, "12345-1");

Quantity

// Get displayable string...
const sQuantity = Resources.Quantity.toString(quantity);

Age

// Construct an Age from a given quantity...
const age = Resources.Age.fromQuantity(quantity);
// Construct an Age from a given number of years...
const age = Resources.Age.fromYears(25);

Range

// Construct a Range from a set of numbers...
const range = Resources.Range.fromNumbers(25, 30);
// Construct a Range from a string...
const range = Resources.Range.fromString("25 - 30");
// Construct a Range from an age string...
const r1 = Resources.Range.fromAgeString("20's");
const r2 = Resources.Range.fromAgeString("25-30");
// Get a displayable string...
const s = Resources.Range.toString(range);    // 25-30
// Get a displayabe string for a Range that represents an Age...
const s = Resources.Range.toAgeString(range);    // 25-30y

Period

// Construct a Period from two strings...
const period = new Resources.Period("2000-01-01", "2010-12-31");
// Get the start/end dates of the given Period...
const startDate = Resources.Period.getStartDate(period);
const endDate = Resources.Period.getEndDate(period);
// Construct a Period from a Range that represents an age...
const dobPeriod = Resources.Period.fromAgeRange(age);
// Construct a Period from an age string...
const dobPeriod = Resources.Period.fromAgeString("20's");
// Get a displayable string...
const s = Resources.Period.toString(period);

Ratio

// Get a displayable string...
const s = Resources.Ratio.toString(ratio);

Address

// Get the address(es) that corresponds to the given "use"...
const addr = Resources.Address.getAddressesByUse(patient.address, "home");
// Get a displayable string...
const s = Resources.Address.toString(address);

Encounter

let encounters = [...];

// Sort encounters by start date...
encounters = encounters.sort(Resources.Encounter.sort);

AdministrativeGender

Set of values for use as "Administrative Gender"

FamilyMemberHistory_Relationship

Set of values to be used for the relationship property in a FamilyMemberHistory

FamilyMemberHistoryCondition

// Get a FamilyMemberHistoryCondition from a SNOMED code...
const c = Resources.FamilyMemberHistoryCondition(code, display, text, ageOfOnset);

DeviceDeviceName

// Get a displayable string...
const s = Resources.DeviceDeviceName.toString(deviceName);

Flag

// Get all flags with a given status...
const f = Resources.Flag.getFlagsByStatus(flags, "active");

DocumentReference

// Get all documents by the given status...
const d = Resources.DocumentReference.getDocumentReferencesByStatus(docs, "current");

Extension

const ext = Resources.Extension.getExtensionByUrl(extensions, "http://...");

FHIR types