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

node-medmij

v0.2.1

Published

Nodejs implementation of the MedMij OpenPGO building blocks

Downloads

7

Readme

NPM version Build Status Sonar License: AGPL v3 License: CC BY-SA 4.0

MedMij Nodejs library

Nodejs implementation of the MedMij OpenPGO building blocks.

Version Guidance

This library follows Semantic Versioning. The versions of the Afspraken set are mapped to the versions of the library as follows:

| Version Afsprakenset | Status | Version library | |----------------------------|------------|-----------------| | Afsprakenset release 1.1 | Latest | 0.2.* | | Afsprakenset release 1.0 | EOL | 0.1.* |

Installation

npm install node-medmij

Design

The MedMij implementation for lists consists of four classes. First, there is a generic List class that takes care of downloading XML and schema files from URLs, validating XML's against schema and translating XML into Javascript objects. Three classes specialise the List class: they inherit from the generic List class and add specific methods for Whitelist, Zorgaanbiederslijst and OAuth client list.

Class diagram for node-medmij

It is assumed that XML Schema's are on the local filesystem, and that XML files are retrieved from a URL. Locations are configurable in a settings file.

Whitelist

On creation the whitelist object downloads the whitelist schema, the whitelist itself and then validates the whitelist against the schema.

var medmij = require('node-medmij');
new medmij.Whitelist(function(error, whitelist) {
  // do something with the whitelist
});

Settings are in src/settings.js. Following settings are relevant for whitelist parsing:

{
  ...
  "whitelistSchemaPath": "./src/xsd/MedMij_Whitelist.xsd",
  "whitelistURL": "https://afsprakenstelsel.medmij.nl/download/...",
  ...
}

To get the complete whitelist:

console.log(whitelist.getList());
// an array of whitelisted MedMij nodes

To validate a hostname:

console.log(whitelist.isMedMijNode('iets'));
// false

Zorgaanbiederslijst

On creation the ZAL object downloads the Zorgaanbiederslijst schema, the Zorgaanbiederslijst itself and then validates the list against the schema.

var medmij = require('node-medmij');
new medmij.ZAL(function(error, zal) {
  // do something with the Zorgaanbiederslijst
});

Settings are in src/settings.js. Following settings are relevant for the Zorgaanbiederslijst:

{
  ...
  "zalSchemaPath" : "./src/xsd/MedMij_Zorgaanbiederslijst.xsd",
  "zalURL" : "https://afsprakenstelsel.medmij.nl/download/...",
  ...
}

To get the complete Zorgaanbiederslijst:

console.log(zal.getList());
// an array of Zorgaanbieders

To get a zorgaanbieder by name:

console.log(zal.getZorgaanbieder('umcharderwijk@medmij'));
// returns the complete object

The name is matched with Zorgaanbiedernaam.

OpenAuth Client list

On creation the OCL object downloads the OAuth Client List schema, the client list itself and then validates the list against the schema.

var medmij = require('node-medmij');
new medmij.OCL(function(error, ocl) {
  // do something with the client list
});

Settings are in src/settings.js. Following settings are relevant for the client list:

{
  ...
  "oclSchemaPath": "./src/xsd/MedMij_OAuthclientlist.xsd",
  "oclURL": "https://afsprakenstelsel.medmij.nl/download/..."
}

To get the complete client list:

console.log(ocl.getList());
// an array of OAuth clients

To get a OAuth client by name:

console.log(ocl.getClient('De Enige Echte PGO'));
// returns the complete object

The name is matched with OAuthclientOrganisatienaam.

Getting zorgaanbieder OAuth URL

To obtain the URL to which to redirect a zorggebruiker for authentication:

const zao = new medmij.ZAOAuth();
console.log(zao.makeRedirectURI("https://pgo.example.com/oauth", "abc", "xyz"));
// https://pgo.example.com/oauth/cb?state=abc&code=xyz

Obtaining access tokens

Getting the URL at which to request an access token:

const PGOOAuth = medmij.PGOOAuth;
const ZAL = medmij.ZAL;
const OCL = medmij.OCL;

new OCL(function (error, ocl) {
  if (error) {
    console.log(`Error instantiating OCL: ${error}`);
  } else {
    new ZAL(function (error, zal) {
      if (error) {
         console.log(`Error instantiating ZAL: ${error}`);
      } else {
        const za = zal.getZorgaanbieder("umcharderwijk@medmij");
        const geg = za.Gegevensdiensten[0].Gegevensdienst[0];
        const authEndpoint = geg.AuthorizationEndpoint[0].AuthorizationEndpointuri[0];
        const zorgaanbieder = "umcharderwijk";
        const gegID = geg.GegevensdienstId[0];

        const oc = ocl.getClient("De Enige Echte PGO");
        console.log(pgoGlobal.makeAuthURL(authEndpoint, zorgaanbieder, gegID, oc.Hostname[0], "https://pgo.example.com/oauth", "abcd").href);
      }
    });
  }
});
// URL for requesting an access token at the PGO

Requesting the access token at the obtained URL:

new ZAL(function (error, zal) {
  if (error) {
    console.log(`Error instantiating ZAL: ${error}`);
  } else {
    const za = zal.getZorgaanbieder("umcharderwijk@medmij");
    const geg = za.Gegevensdiensten[0].Gegevensdienst[0];
    const tokenEndpoint = geg.TokenEndpoint[0].TokenEndpointuri[0];
    const zorgaanbieder = "umcharderwijk";
    const gegID = geg.GegevensdienstId[0];

    pgoGlobal.getAccessToken(tokenEndpoint, "xyz", "https://pgo.example.com/oauth", function(token, error) {
      if (error) {
        console.log(`Error obtaining access token: ${error}`);
      } else {
        console.log(token);
      }
    });
  }
});
// The obtained access token

Gegevensdienstnamenlijst

On creation the GNL object downloads the Gegevensdienstnamenlijst schema, the Gegevensdienstnamenlijst itself and then validates the list against the schema.

var medmij = require('node-medmij');
new medmij.GNL(function(error, gnl) {
  // do something with the Gegevensdienstnamenlijst
});

Settings are in src/settings.js. Following settings are relevant for the Gegevensdienstnamenlijst:

{
  ...
  "gnlSchemaPath" : "./src/xsd/MedMij_Gegevensdienstnamenlijst.xsd",
  "gnlURL" : "https://afsprakenstelsel.medmij.nl/download/...",
  ...
}

To get the complete Gegevensdienstnamenlijst:

console.log(gnl.getList());
// an array of gegevensdienstnamen in the original format from xml2js

To get a map from id to gegevensdienstnaam use the following:

console.log(gnl.getMapIdToName());
// a map from id to gegevensdienstnaam

Testing

Unit tests are written using jasmine-node. These can be started as follows:

npm test

or

jasmine-node ./test

Settings

Current settings for schema and example files follow the MedMij Afsprakenstelsel.

Dependencies

  • jasmine-node: for unit testing
  • node-xmllint: for validating XML files against schemas
  • xml2js: for translating XML files to Javascript objects

Licenses

Source code: GNU AFFERO GENERAL PUBLIC LICENSE Version 3

Content: Creative Commons Attribution Sharealike 4.0 International