Skip to content

Instantly share code, notes, and snippets.

import requests
with open("ccgcodes.txt") as f,open("ccgname.txt","w") as w : [w.write("%s,%s\n" % (ccg.strip(),requests.get("https://directory.spineservices.nhs.uk/STU3/Organization/%s" % ccg.strip()).json()["name"])) for ccg in f.readlines()]
@elementechemlyn
elementechemlyn / nginx.conf
Created December 27, 2018 18:28
OpenResty config to proxy a request into a SMART on FHIR launch request
location /foo {
set $target '';
access_by_lua_block {
local b64 = require("ngx.base64")
local b64_args = b64.encode_base64url(ngx.var.args)
ngx.var.args = "launch=" .. b64_args
}
proxy_pass 'http://localhost:8080';
}
@elementechemlyn
elementechemlyn / fhirvalidate.py
Last active March 29, 2019 12:49
Reads a set of FHIR resources from a folder, validates them against a server and dynamically builds a set of unittest cases Currently - put each JSON resource into the RESOURCE_FOLDER as a .json file (1 file per resource). #TODO Allow reading of XML resources and GETing a resource from a url.
import unittest
import os
import os.path
import json
import requests
"""
Reads a set of FHIR resources from a folder, validates them against a server
and dynamically builds a set of unittest cases
Currently - put each JSON resource into the RESOURCE_FOLDER as a .json file (1 file per resource).

Keybase proof

I hereby claim:

  • I am elementechemlyn on github.
  • I am emlynj (https://keybase.io/emlynj) on keybase.
  • I have a public key ASBzM-HIM3GvHdzcT5hQH7QiQxJXDzytOTU-X1IhQRHMoAo

To claim this, I am signing this object:

@elementechemlyn
elementechemlyn / NEMS Event MESH Workflow ID.md
Last active March 20, 2020 12:33
Table of MESH workflow IDs for NEMS event types
NEMS Event FHIR Event code MESH Workflow ID
Blood Spot Test Outcome blood-spot-test-outcome-1 BLOODSPOTTESTOUTCOME_1
Newborn Hearing newborn-hearing-1 NEWBORNHEARING_1
NIPE Outcome nipe-outcome-1 NIPEOUTCOME_1
PDS Birth Notification pds-birth-notification-1 BIRTHNOTIFICATION_1
PDS Change of Address pds-change-of-address-1 CHANGEOFADDRESS_1
PDS Change of GP pds-change-of-gp-1 CHANGEOFGP_1
PDS Death Notification pds-death-notification-1 DEATHNOTIFICATION_1
Professional Contacts professional-contacts-1 PROFESSIONACONTACTS_1
function meshAuthorisationToken (mailboxId, mailboxPassword, secretKey) {
// GS 2016-12-13
// construct MESH authorisation token
var d = new Date();
var ts = '' + d.getFullYear()
+ (d.getMonth() < 9 ? '0' + (d.getMonth()+1) : (d.getMonth()+1))
+ (d.getDate() < 9 ? '0' + (d.getDate()) : (d.getDate()))
+ (d.getHours() < 10 ? '0' + d.getHours() : d.getHours())
+ (d.getMinutes() < 10 ? '0' + d.getMinutes() : d.getMinutes());
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@elementechemlyn
elementechemlyn / meshapi.py
Last active September 10, 2020 16:11
Quick Python script to demo calling the NHS MESH API
import requests
import uuid
import datetime
import hmac
import hashlib
import logging
#This is the set of headers required for an authenticate request.
MESH_HEADERS = {
"Authorization":"",
Install OpenVPN. Must be Community version (otherwise get "TAP not supported" error). Service not required.
Import ovpn profile.
Find NEMS Party Key (not required uses the Spine party key: found here:https://digital.nhs.uk/services/path-to-live-environments/spine-core-common-issues-in-the-path-to-live-environments)
ldapsearch -x -H ldap://192.168.128.11 -b "ou=services, o=nhs" "(&(nhsIDCode=YES) (nhsAsSvcIA=urn:nhs:names:services:clinicals-sync:SubscriptionsApiPost))" uniqueIdentifier nhsMhsPartyKey
Lookup Message handling endpoint for Subscription Post:
ldapsearch -x -H ldap://192.168.128.11 -b "ou=services, o=nhs" "(&(nhsMhsPartyKey=[PARTY KEY GOES HERE]) (objectClass=nhsMhs) (nhsMhsSvcIA=urn:nhs:names:services:clinicals-sync:SubscriptionsApiPost))" nhsMhsEndPoint
Lookup Message handling endpoint for Subscription Read:
<Bundle xmlns="http://hl7.org/fhir">
<id value="6e824ff8-9b0a-11e8-9eb6-529269fb1459"/>
<meta>
<profile value="http://hl7.org/fhir/STU3/StructureDefinition/Bundle"/>
</meta>
<type value="transaction"/>
<entry>
<fullUrl value="urn:uuid:076db265-8799-4dda-9418-e2a4d6d1c0d0"/>
<resource>
<Immunization>