npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

fhir-resource-generator

v0.3.3

Published

Generate random FHIR resources

Downloads

4

Readme

fhir-resource-generator

Ever needed to generate a FHIR resource quickly? Don't want to have multiple data files containing your test data? Then give fhir-resource-generator a go to randomly generate complete or user-specified FHIR-compliant resources!

Build Status npm version

Usage

import generator from 'fhir-resource-generator'

// Full random FHIR DSTU2 Patient resource
const patient = generator.dstu2.patient();

// Random FHIR DSTU2 AllergyIntolerance resource with fields identifier containing two identifiers and substance
const allergyIntolerance = generator.dstu2.allergyIntolerance({ identifier: 2, substance: 1 });

API

Only DSTU2 resources are available currently so all API methods are prefixed by generator.dstu2. See [http://www.hl7.org/fhir/dstu2/documentation.html](FHIR DSTU2 documentation) for fields available on each resource.

Complete Resources

To obtain a full random resource, simply call the relevant resource name:

  • patient()
  • allergyIntolerance()

Partial Resources

If you only want certain fields in your resource then you can provide an object to any resource containing key:value pairs representing fields and the requested count of each field. Note that the count number only takes affect for fields with cardinality denoted by 0..* in the specifications.

Note that the fields resourceType and id are generated for every resource, regardless of the fields passed in.

Example: Generator a FHIR AllergyIntolerance resource with 2 identifiers and criticality only.

generator.dstu2.allergyIntolerance({ identifier: 2, criticality: 1 });

{
  "resourceType": "AllergyIntolerance",
  "id": "cd540504-e053-46db-8fd0-0d1dcdbe2a84",
  "identifier": [
    {
      "use": "temp",
      "type": {
        "text": "integrated deposit",
        "coding": [
          {
            "system": "https://estelle.com",
            "code": "Handcrafted",
            "display": "Buckinghamshire Kansas withdrawal"
          }
        ]
      },
      "system": "http://rodrigo.com",
      "value": "Soap"
    },
    {
      "use": "usual",
      "type": {
        "text": "Business-focused plug-and-play leverage",
        "coding": [
          {
            "system": "http://devon.com",
            "code": "International",
            "display": "Small mobile Gorgeous Steel Bike"
          }
        ]
      },
      "system": "http://cecil.org",
      "value": "invoice"
    }
  ],
  "criticality": "CRITH"
}

Overrides

As each resource is randomly generated, the details of the resource cannot be guaranteed. However, you can supply overrides so that you get a resource with known values.

Example: Set the value of the first identifier to a known string.

generator.dstu2.patient({ identifier: 1, gender: 1 }, {
  'identifier.0.value': 'Overridden Identifier Value',
});

{
  "resourceType": "Patient",
  "id": "d5646f24-ac13-42b6-a247-41215a18ae9f",
  "identifier": [
    {
      "use": "official",
      "type": {
        "text": "Fresh Rapids",
        "coding": [
          {
            "system": "https://garth.org",
            "code": "Pants",
            "display": "Jersey synthesizing"
          },
          {
            "system": "http://georgiana.net",
            "code": "Borders",
            "display": "grey"
          }
        ]
      },
      "system": "https://kamryn.org",
      "value": "Overridden Identifier Value"
    }
  ],
  "gender": "male"
}

Extensions

Each resource can also have an extension field. Extensions are generated separate to resources but can be added to your generated resource automatically by specifying { extension: <extension> } as an override.

Extensions can also have their values overridden in the same fashion as resources.

Available Extensions

  • Coding
  • Identifier
  • Inner Extension

Example:

generator.dstu2.extension({ coding: 1, extension: { identifier: 1 } };

[
  {
    "url": "https://stephania.biz",
    "valueCoding": {
      "system": "https://geovanny.info",
      "code": "transmitting",
      "display": "pixel SQL maximize"
    }
  },
  {
    "url": "http://enid.org",
    "extension": [
      {
        "url": "https://elliott.info",
        "valueIdentifier": {
          "use": "temp",
          "type": {
            "text": "Montana",
            "coding": [
              {
                "system": "http://shanon.com",
                "code": "Lilangeni",
                "display": "bandwidth world-class"
              }
            ]
          },
          "system": "https://ophelia.org",
          "value": "Lead"
        }
      }
    ]
  }
]