Utilities for NHS EPS testing and message generation, including:
- NHS number, ODS code, and prescription ID generation
- FHIR prescription bundle generation, signing, submission, and cancellation
- PSU generation and submission
- PfP retrieval and PfP-to-PSU interactive workflows
This repository is an npm workspace monorepo with one TypeScript package per tool. All cli tools have a -h option to print their usage.
From the repository root:
make install
make build
make linkFor PfP and user-restricted browser login flows, install Playwright browsers:
make install-playwright
# or: cd packages && npx playwright installgenerate-nhs-numbersgenerate-ods-codesgenerate-prescription-idscreate-prescription-bundlefhir-prescribingsign-prescriptiongenerate-psu-requestsend-psu-requestsend-pfp-requestmake-psu-request
This is an example end-to-end flow for a single test prescription:
- Generate a prescription bundle
- Create the prescription in the FHIR facade, with the
fhir-prescribingtool - Send a PSU update with business status
With Pharmacy - Cancel the prescription with the FHIR facade
Notes:
- PSU updates represent status and can be submitted whether or not the prescription was previously created on the server.
- This flow still performs create first, then PSU, then cancel.
# 1) Generate one prescription bundle
create-prescription-bundle --count 1
# Resolve the newest generated bundle file
BUNDLE_FILE="$(ls -1t data/prescriptions/prescription-bundle_* | head -n 1)"
# 2) Create (prepare, sign, submit)
fhir-prescribing --action create --input "$BUNDLE_FILE"
# Extract NHS number from filename pattern: ..._nhs-num-<nhs>.json
NHS_NUMBER="$(basename "$BUNDLE_FILE" | sed -E 's/.*_nhs-num-([0-9]{10})\.json/\1/')"
# 3) Generate and submit PSU update: With Pharmacy
generate-psu-request --business-status "With Pharmacy" --nhs-number "$NHS_NUMBER" -o /tmp/psu-with-pharmacy.json
send-psu-request --input /tmp/psu-with-pharmacy.json
# 4) Cancel the original prescription bundle
fhir-prescribing --action cancel --input "$BUNDLE_FILE"generate-nhs-numbers -n 10
generate-ods-codes -n 5
generate-prescription-ids -n 3create-prescription-bundle --nhs-number 9998481732 --count 2Output file pattern:
./data/prescriptions/prescription-bundle_<timestamp>_nhs-num-<number>.json
fhir-prescribing --action create --input ./data/prescriptions/prescription-bundle_<timestamp>_nhs-num-<number>.jsonOutput file pattern:
./data/prescriptions/create-bundle_<timestamp>_nhs-num-<number>.json
fhir-prescribing --action cancel --input ./data/prescriptions/prescription-bundle_<timestamp>_nhs-num-<number>.json
fhir-prescribing --action cancel --input ./data/prescriptions/prescription-bundle_<timestamp>_nhs-num-<number>.json --cancel-reason-type 0003Output file pattern:
./data/prescriptions/cancel-bundle_<timestamp>_nhs-num-<number>.json
sign-prescription --input ./data/prescriptions/prescription-bundle_<timestamp>_nhs-num-<number>.json
sign-prescription --input ./data/prescriptions/prescription-bundle_<timestamp>_nhs-num-<number>.json --prepare-onlygenerate-psu-request --business-status "With Pharmacy" -o psu.json
send-psu-request --input psu.jsonmake-psu-request --nhs-number 9991234567 --sendHOST
PRESCRIBE_API_KEYPRESCRIBE_KID- one of:
PRESCRIBE_PRIVATE_KEYPRESCRIBE_PRIVATE_KEY_PATH
PRESCRIBE_APP_KEYPRESCRIBE_APP_CLIENT_SECRETPRESCRIBE_CALLBACK_URL- one of:
PRESCRIBE_PRIVATE_KEYPRESCRIBE_PRIVATE_KEY_PATH
- optional:
HEADLESSFIREFOX_TMP_DIR
API_KEYPSU_KID- one of:
PRIVATE_KEYPSU_PRIVATE_KEY_PATH
- optional:
IS_PRPR_NUMBER
PFP_API_KEYPFP_CLIENT_SECRET- optional:
REDIRECT_URIAUTH_USERNAMEHEADLESSFIREFOX_TMP_DIR
./data/prescriptions: prescription bundles and cancellation bundles./data/psu_requests: PSU requests and PfP responses./data/keys: JWKS key material