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-starter

v0.14.1

Published

Reausable and composable FHIR components built with React and Material UI. Normative maturity level 5 resources only.

Downloads

17

Readme

fhir-starter

npm package

Material-FHIR UI is a set of React components that implement HL7 FHIR Resources using Google's Material Design specification. It is intended as an extension to the Material UI component library.

We intend to track normative level resources only; which as of R4 are primarily the Patient and Observation tables and detail cards. Stay tuned for R5 though!

If you're interested in non-normative resources, feel free to peruse the /client/react directories of any of the hl7-resource-* repositories in the clinical-meteor organization.

Prerequisites

Fast Healthcare Interoperatbility Resources
Material - User Interface
Semantically Awesome Style Sheets
React - Component Rendering

Installation

fhir-starter is available as an npm package.

npm install fhir-starter

To save the package to your Meteor app's package.json file, run the following:

meteor npm install --save fhir-starter winston

Roboto Font

Material-UI was designed with the Roboto font in mind. So be sure to include it in your project. Here are some instructions on how to do so.

Theming

fhir-starter components require a theme to be provided. The quickest way to get up and running is by using the MuiThemeProvider to inject the theme into your application context. Following that, you can to use any of the components as demonstrated in the documentation. Here is a quick example to get you started:

import React from 'react';
import ReactDOM from 'react-dom';
import * as ReactDOMClient from 'react-dom/client';
import MuiThemeProvider from 'material-ui/styles/MuiThemeProvider';
import MyAwesomeReactComponent from './MyAwesomeReactComponent';

import { PatientCard } from 'fhir-starter';

import {
  MuiThemeProvider,
  makeStyles,
  createMuiTheme,
} from '@material-ui/core/styles';


const App = () => (
  <MuiThemeProvider>
    <PatientCard />
  </MuiThemeProvider>
);

// ReactDReactDOM
OM.render(
ReactDOMClient.createRoot(
  <App />,
  document.getElementById('app')
);

Patient Table Example

import React from 'react';
import { PatientsTable } from 'fhir-starter';

const MyFhirWorkflowComponent = () => (
  <div>
    <PatientsTable 
      noDataMessagePadding={100}
      patients={ Patients.find().fetch() }
      paginationLimit={ t100 }
      appWidth={ Session.get('appWidth') }
      actionButtonLabel="Send"
      onRowClick={ function(patientId){ 
        Session.set('selectedPatientId', patientId);
      }}
      />
      <hr />
      <PatientDetail 
        id='patientDetails' 
        fhirVersion="3.0.1"
        patient={ Patients.findOne("").fetch() }
        patientId={ this.data.selectedPatientId }
        onDelete={ function(patientId){
          Patients.remove({_id: patientId})
        }}
        onUpsert={ function(context){          
          let newPatient = context.state.patient;
          newPatient.resourceType = "Patient";
          Patients.insert(newPatient)      
        }}
        onCancel={ this.onCancelUpsertPatient } 
      />
  </div>
);

export default MyFhirWorkflowComponent;

Please refer to each component's documentation page to see how they should be imported.

Component Demos and API Examples

PatientCard
PatientsTable
PatientDetail

ObservationTable

Logging

Material FHIR UI has a peer dependency on the winston library. The idea is that we wanted to slowly migrate away from using console.log messages. While widely supported, they cause security and performance problems. Our general approach in this refactor has been to attach the winston logger object on the global window scope, in essentially the same place that console is located. The idea is that if the code could do a console.log it will also be able to do a logger.log. Which begins our refactor. Eventually, we plan on passing the logger object down through the render tree via the props object.


  // if you don't use winston, or otherwise wish to simply disable logging, 
  // attach the following to the global scope
  window.logger = {
    error: function(){},
    warn: function(){},
    info: function(){},
    verbose: function(){},
    debug: function(){},
    trace: function(){},
    data: function(){},
    log: function(){}
  }

  // otherwise, we import the necessary objects form winston
  import { createLogger, addColors, format, transports, config } from 'winston';

   // lets create a global logger
   const logger = createLogger({
    level: get(Meteor, 'settings.public.loggingThreshold') ,
    levels: {
      error: 0, 
      warn: 1, 
      info: 2, 
      verbose: 3, 
      debug: 4, 
      trace: 5, 
      data: 6 
    },
    transports: [
      new transports.Console({
        colorize: true,
        format: format.combine(
          hideDataLogLevel(),
          format.colorize(),
          format.simple(),
          format.splat(),
          format.timestamp()
        )
      })
    ],
    exitOnError: false
  });

  // introspection for the win
  logger.info('Starting the Winston Logging Service');
  logger.data('Winston Logging Service', {data: logger}, {source: "AppContainer.jsx"});

  // attaching to the global scope is not generally recommended
  // logging is one debatable exception to the general rule, however
  window.logger = global.logger = logger;

License

This project is licensed under the terms of the MIT license

Conbtributing

If you would like to develop more FHIR components using this pattern, please take a look at the [material-fhir-demo], which is the minimalist Meteor rig we use to build these components. We intend to move towards Chromatic and Storybook in the future.

https://github.com/meteor/chromatic/
https://storybook.js.org/
https://github.com/clinical-meteor/material-fhir-demo

Development

// LOCAL DEVELOPMENT
git clone https://github.com/clinical-meteor/fhir-starter packages/fhir-starter
meteor npm link packages/fhir-starter

cd packages/fhir-starter

yarn add rollup rollup-plugin-terser rollup-plugin-typescript2 typescript rollup-plugin-babel rollup-plugin-commonjs rollup-plugin-node-resolve rollup-plugin-replace rollup-plugin-progress @babel/core @babel/preset-env --only=dev 


// bump the fhir-starter/package.json version number
nano package.json

// bump the application's dependency on fhir-starter
nano ../../package.json

// get rollup working
yarn rollup --config rollup.config.js

// once you get the above working, use --watch to automatically recompile on file change
yarn rollup --config --watch


// resync
// sometimes you need to resync the package
yarn rollup --config
meteor reset
rm -rf node_modules
meteor npm install
meteor npm link packages/fhir-starter

Deployment

cd packages/fhir-starter
rm -rf node_modules

npm update


// typical rollupt
yarn rollup --config

npm login

npm publish

Other References