{"id":23421321,"url":"https://github.com/nhsdigital/prescriptionsforpatients","last_synced_at":"2026-03-05T14:06:09.384Z","repository":{"id":163996031,"uuid":"639033464","full_name":"NHSDigital/prescriptionsforpatients","owner":"NHSDigital","description":null,"archived":false,"fork":false,"pushed_at":"2025-04-10T04:08:08.000Z","size":7550,"stargazers_count":5,"open_issues_count":3,"forks_count":0,"subscribers_count":26,"default_branch":"main","last_synced_at":"2025-04-10T04:36:32.912Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/NHSDigital.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-05-10T16:03:13.000Z","updated_at":"2025-04-10T03:54:33.000Z","dependencies_parsed_at":"2024-02-05T04:33:04.141Z","dependency_job_id":"650feca3-9ebb-4967-9bd4-f3bf45d5d4c1","html_url":"https://github.com/NHSDigital/prescriptionsforpatients","commit_stats":null,"previous_names":["nhsdigital/prescriptionsforpatients"],"tags_count":975,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NHSDigital%2Fprescriptionsforpatients","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NHSDigital%2Fprescriptionsforpatients/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NHSDigital%2Fprescriptionsforpatients/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NHSDigital%2Fprescriptionsforpatients/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/NHSDigital","download_url":"https://codeload.github.com/NHSDigital/prescriptionsforpatients/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248578864,"owners_count":21127713,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-12-23T02:14:47.849Z","updated_at":"2026-03-05T14:06:09.366Z","avatar_url":"https://github.com/NHSDigital.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Prescriptions API\n\n![Build](https://github.com/NHSDigital/prescriptionsforpatients/actions/workflows/ci.yml/badge.svg?branch=main)\n![Release](https://github.com/NHSDigital/prescriptionsforpatients/actions/workflows/release.yml/badge.svg?branch=main)  \n\n## Versions and deployments\n\nVersion release history can be found ot \u003chttps://github.com/NHSDigital/prescriptionsforpatients/releases\u003e.\nWe use eslint convention for commit messages for commits to main branch. Descriptions for the types of changes in a release can be found in the [contributing guidelines](./CONTRIBUTING.md).   \nDeployment history can be found at \u003chttps://nhsdigital.github.io/prescriptionsforpatients/\u003e\n\n## Introduction\n\nThis is the AWS layer that provides an API for accessing prescription information for a patient.  \nIt is called by an Apigee proxy that is defined at \u003chttps://github.com/NHSDigital/prescriptions-for-patients\u003e\n\n- `packages/getMyPrescriptions/` Get prescription details for /Bundle endpoint.\n- `packages/enrichPrescriptions/` Get prescription status updates for prescriptions retrieved by getMyPrescriptions.\n- `packages/nhsd-pfp-sandbox/` Returns [static data](./packages/nhsd-pfp-sandbox/examples/GetMyPrescriptions/Bundle/success.json) from the Sandbox.\n- `packages/statusLambda/` Returns the status of the getMyPrescriptions endpoint.\n- `packages/capabilityStatement/` Returns a static capability statement.\n- `packages/serviceSearchClient/` Module for connecting to service search.\n- `packages/distanceSelling/` Module for using Service Search client and enriching the data being returned.\n- `packages/common/utilities` Module containing commonly referenced functions, data types and configuration data.\n- `packages/common/testing` Module that contains some test data used for tests in other modules.\n- `postman/` Contains a postman collection for interacting with the API.\n- `scripts/` Utilities helpful to developers of this specification.\n- `cloudformation/` Contains cloudformation files used to create resources for CI builds and deployments.\n- `SAMtemplates/` Contains the SAM templates used to define the stacks.\n- `privateCA/` Contains script to create self signed CA certificate and a client certificate used for mutual TLS.\n- `.github` Contains github workflows that are used for building and deploying from pull requests and releases.\n- `.devcontainer` Contains a dockerfile and vscode devcontainer definition.\n- `.vscode` Contains vscode workspace file.\n- `.releaserc` semantic-release config file\n\nConsumers of the API will find developer documentation on the [NHS Digital Developer Hub](https://digital.nhs.uk/developer/api-catalogue).\n\n## Contributing\n\nContributions to this project are welcome from anyone, providing that they conform to the [guidelines for contribution](https://github.com/NHSDigital/prescriptionsforpatients/blob/main/CONTRIBUTING.md) and the [community code of conduct](https://github.com/NHSDigital/prescriptionsforpatients/blob/main/CODE_OF_CONDUCT.md).\n\n### Licensing\n\nThis code is dual licensed under the MIT license and the OGL (Open Government License). Any new work added to this repository must conform to the conditions of these licenses. In particular this means that this project may not depend on GPL-licensed or AGPL-licensed libraries, as these would violate the terms of those libraries' licenses.\n\nThe contents of this repository are protected by Crown Copyright (C).\n\n## Development\n\nIt is recommended that you use visual studio code and a devcontainer as this will install all necessary components and correct versions of tools and languages.  \nSee \u003chttps://code.visualstudio.com/docs/devcontainers/containers\u003e for details on how to set this up on your host machine.  \nThere is also a workspace file in .vscode that should be opened once you have started the devcontainer. The workspace file can also be opened outside of a devcontainer if you wish.  \nThe project uses [SAM](https://aws.amazon.com/serverless/sam/) to develop and deploy the APIs and associated resources.\n\nAll commits must be made using [signed commits](https://docs.github.com/en/authentication/managing-commit-signature-verification/signing-commits)\n\nOnce the steps at the link above have been completed. Add to your ~/.gnupg/gpg.conf as below:\n\n```bash\nuse-agent\npinentry-mode loopback\n```\n\nand to your ~/.gnupg/gpg-agent.conf as below:\n\n```bash\nallow-loopback-pinentry\n```\n\nAs described here:\n\u003chttps://stackoverflow.com/a/59170001\u003e\n\nYou will need to create the files, if they do not already exist.\nThis will ensure that your VSCode bash terminal prompts you for your GPG key password.\n\nYou can cache the gpg key passphrase by following instructions at \u003chttps://superuser.com/questions/624343/keep-gnupg-credentials-cached-for-entire-user-session\u003e\n\n### SAM setup and usage\n\n[SAM](https://aws.amazon.com/serverless/sam/) allows rapid local development and deployment to AWS for development and testing.\n\n### Setup\n\nEnsure you have the following lines in the file .envrc\n\n```bash\nexport AWS_DEFAULT_PROFILE=prescription-dev\nexport stack_name=\u003cUNIQUE_NAME_FOR_YOU\u003e\nexport TARGET_SPINE_SERVER=\u003cNAME OF DEV TARGET SPINE SERVER\u003e\nexport TARGET_SERVICE_SEARCH_SERVER=\u003cNAME OF DEV TARGET SERVICE SEARCH SERVER\u003e\n```\n\nUNIQUE_NAME_FOR_YOU should be a unique name for you with no underscores in it - eg anthony-brown-1\n\nOnce you have saved .envrc, start a new terminal in vscode and run this command to authenticate against AWS\n\n```bash\nmake aws-configure\n```\n\nPut the following values in:\n\n```text\nSSO session name (Recommended): sso-session\nSSO start URL [None]: \u003cUSE VALUE OF SSO START URL FROM AWS LOGIN COMMAND LINE ACCESS INSTRUCTIONS ACCESSED FROM https://myapps.microsoft.com\u003e\nSSO region [None]: eu-west-2\nSSO registration scopes [sso:account:access]:\n```\n\nThis will then open a browser window and you should authenticate with your hscic credentials\nYou should then select the development account and set default region to be eu-west-2.\n\nYou will now be able to use AWS and SAM CLI commands to access the dev account. You can also use the AWS extension to view resources.\n\nWhen the token expires, you may need to reauthorise using `make aws-login`\n\n### CI Setup\n\nThe GitHub Actions require a secret to exist on the repo called \"SONAR_TOKEN\".\nThis can be obtained from [SonarCloud](https://sonarcloud.io/)\nas described [here](https://docs.sonarsource.com/sonarqube/latest/user-guide/user-account/generating-and-using-tokens/).\nYou will need the \"Execute Analysis\" permission for the project (NHSDigital_prescriptionsforpatients) in order for the token to work.\n\n### Upstream dependencies\n\n#### Directory of Healthcare Services API (aka Service Search) - version 3 \n\n[Service Search v3](https://digital.nhs.uk/developer/api-catalogue/directory-of-healthcare-services/version-3) uses\n[application-restricted RESTful API - API key authentication](https://digital.nhs.uk/developer/guides-and-documentation/security-and-authorisation/application-restricted-restful-apis-api-key-authentication).\nTo achieve this the following applications have been created on the\n[Int/Prod onboarding portal](https://onboarding.prod.api.platform.nhs.uk/):\n\n* `PFP-INTERNAL-DEV-DOHS` - managed by [EPS_team](https://onboarding.prod.api.platform.nhs.uk/MyApplications/Teams/TeamDetails?id=060896ea-ba43-4df8-a011-7cb0f45fd8ed) - connected to [Service Search - REST API (Integration Testing Environment)](https://int.api.service.nhs.uk/service-search-api/)\n* `PFP-QA-DOHS` - managed by [EPS_team](https://onboarding.prod.api.platform.nhs.uk/MyApplications/Teams/TeamDetails?id=060896ea-ba43-4df8-a011-7cb0f45fd8ed) - connected to [Service Search - REST API (Integration Testing Environment)](https://int.api.service.nhs.uk/service-search-api/)\n* `PFP-REF-DOHS` - managed by [EPS_team](https://onboarding.prod.api.platform.nhs.uk/MyApplications/Teams/TeamDetails?id=060896ea-ba43-4df8-a011-7cb0f45fd8ed) - connected to [Service Search - REST API (Integration Testing Environment)](https://int.api.service.nhs.uk/service-search-api/)\n* `PFP-INT-DOHS` - managed by EPS_Team_Prod - connected to [Service Search - REST API (Production Environment)](https://api.service.nhs.uk/service-search-api/)\n* `PFP-PROD-DOHS` - managed by EPS_Team_Prod - connected to [Service Search - REST API (Production Environment)](https://api.service.nhs.uk/service-search-api/)\n\nAfter `IaC` creates the secret `pfp-PfP-ServiceSearch-API-Key`\nits value must be set manually to the API key from the appropriate app.\n\nIn addition the Service Search URL must be set as a GitHub secret:\n\n* DEV_TARGET_SERVICE_SEARCH_SERVER: \u003chttps://int.api.service.nhs.uk/service-search-api/\u003e\n* QA_TARGET_SERVICE_SEARCH_SERVER: \u003chttps://int.api.service.nhs.uk/service-search-api/\u003e\n* REF_TARGET_SERVICE_SEARCH_SERVER: \u003chttps://int.api.service.nhs.uk/service-search-api/\u003e\n* INT_TARGET_SERVICE_SEARCH_SERVER: \u003chttps://api.service.nhs.uk/service-search-api/\u003e\n* PROD_TARGET_SERVICE_SEARCH_SERVER: \u003chttps://api.service.nhs.uk/service-search-api/\u003e\n\n### GitHub Packages Setup\n\nTo work with the GitHub Package Registry, you need to generate a [personal access token (classic)](https://docs.github.com/en/enterprise-cloud@latest/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens#personal-access-tokens-classic) with appropriate permissions.\n\nFollow these steps:\n\n- [Generate a personal access token (classic)](https://docs.github.com/en/enterprise-cloud@latest/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens#creating-a-personal-access-token-classic)\n  - Go to your GitHub account settings and navigate to \"Developer settings\" \u003e \"Personal access tokens\". Select the \"Tokens(classic)\" from the left bar.\n  - Click on the \"Generate a personal access token\" link and select the `read:packages` scope. Ensure the token has no expiration.\n\n- [Authorize a personal access token for use with SAML single sign-on](https://docs.github.com/en/enterprise-cloud@latest/authentication/authenticating-with-saml-single-sign-on/authorizing-a-personal-access-token-for-use-with-saml-single-sign-on)\n  - Click \"Configure SSO\". If you don't see this option, ensure that you have authenticated at least once through your SAML IdP to access resources on GitHub.com\n  - In the dropdown menu, to the right of the organization you'd like to authorize the token for, click \"Authorize\".\n\n- [Authenticating with a personal access token in to npm](https://docs.github.com/en/enterprise-cloud@latest/packages/working-with-a-github-packages-registry/working-with-the-npm-registry#authenticating-with-a-personal-access-token)\n  - To authenticate with npm, use the following command, replacing `USERNAME` with your GitHub username, `TOKEN` with your personal access token (classic), and `PUBLIC-EMAIL-ADDRESS` with your email address.\n\n```bash\n$ npm login --scope=@NHSDigital --auth-type=legacy --registry=https://npm.pkg.github.com\n\u003e Username: USERNAME\n\u003e Password: TOKEN\n```\n\n### Continuous deployment for testing\n\nYou can run the following command to deploy the code to AWS for testing\n\n```bash\nmake sam-sync\n```\n\nThis will take a few minutes to deploy - you will see something like this when deployment finishes\n\n```text\n......\nCloudFormation events from stack operations (refresh every 0.5 seconds)\n---------------------------------------------------------------------------------------------------------------------------------------------------------------------\nResourceStatus                            ResourceType                              LogicalResourceId                         ResourceStatusReason\n---------------------------------------------------------------------------------------------------------------------------------------------------------------------\n.....\nCREATE_IN_PROGRESS                        AWS::ApiGatewayV2::ApiMapping             HttpApiGatewayApiMapping                  -\nCREATE_IN_PROGRESS                        AWS::ApiGatewayV2::ApiMapping             HttpApiGatewayApiMapping                  Resource creation Initiated\nCREATE_COMPLETE                           AWS::ApiGatewayV2::ApiMapping             HttpApiGatewayApiMapping                  -\nCREATE_COMPLETE                           AWS::CloudFormation::Stack                ab-1                                      -\n---------------------------------------------------------------------------------------------------------------------------------------------------------------------\n\n\nStack creation succeeded. Sync infra completed.\n```\n\nNote - the command will keep running and should not be stopped.\nYou can now call this api - note getMyPrescriptions requires an nhsd-nhslogin-user header\n\n```bash\ncurl --header \"nhsd-nhslogin-user: P9:9446041481\" --header \"x-request-id: $(cat /proc/sys/kernel/random/uuid)\" \\\n  https://${stack_name}.dev.eps.national.nhs.uk/Bundle\n```\n\nYou can also use the AWS vscode extension to invoke the API or lambda directly\n\nAny code changes you make are automatically uploaded to AWS while `make sam-sync` is running allowing you to quickly test any changes you make\n\n### Pre-commit hooks\n\nSome pre-commit hooks are installed as part of the install above, to run basic lint checks and ensure you can't accidentally commit invalid changes.\nThe pre-commit hook uses python package pre-commit and is configured in the file .pre-commit-config.yaml.\nA combination of these checks are also run in CI.\n\n### Make commands\n\nThere are `make` commands that are run as part of the CI pipeline and help alias some functionality during development.\n\n#### install targets\n\n- `install-node` installs node dependencies\n- `install-python` installs python dependencies\n- `install-hooks` installs git pre commit hooks\n- `install` runs all install targets\n\n#### SAM targets\n\nThese are used to do common commands\n\n- `sam-build` prepares the lambdas and SAM definition file to be used in subsequent steps\n- `sam-run-local` run the API and lambdas locally\n- `sam-sync` sync the API and lambda to AWS. This keeps running and automatically uploads any changes to lambda code made locally. Needs AWS_DEFAULT_PROFILE, stack_name, TARGET_SERVICE_SEARCH_SERVER and TARGET_SPINE_SERVER environment variables set.\n- `sam-sync-sandbox` sync the API and lambda to AWS. This keeps running and automatically uploads any changes to lambda code made locally. Needs stack_name environment variables set, the path and file name where the AWS SAM template is located.\n- `sam-deploy` deploys the compiled SAM template from sam-build to AWS. Needs AWS_DEFAULT_PROFILE and stack_name environment variables set.\n- `sam-delete` deletes the deployed SAM cloud formation stack and associated resources. Needs AWS_DEFAULT_PROFILE and stack_name environment variables set.\n- `sam-list-endpoints` lists endpoints created for the current stack. Needs AWS_DEFAULT_PROFILE and stack_name environment variables set.\n- `sam-list-resources` lists resources created for the current stack. Needs AWS_DEFAULT_PROFILE and stack_name environment variables set.\n- `sam-list-outputs` lists outputs from the current stack. Needs AWS_DEFAULT_PROFILE and stack_name environment variables set.\n- `sam-validate` validates the main SAM template and the splunk firehose template.\n- `sam-validate-sandbox` validates the sandbox SAM template and the splunk firehose template.\n- `sam-deploy-package` deploys a package created by sam-build. Used in CI builds. Needs the following environment variables set\n  - artifact_bucket - bucket where uploaded packaged files are\n  - artifact_bucket_prefix - prefix in bucket of where uploaded packaged files ore\n  - stack_name - name of stack to deploy\n  - template_file - name of template file created by sam-package\n  - cloud_formation_execution_role - ARN of role that cloud formation assumes when applying the changeset\n\n#### Download secrets\n\n- `download-get-secrets-layer` creates the necessary directory structure and downloads the `get-secrets-layer.zip` artifact from NHSDigital's `electronic-prescription-service-get-secrets` releases\n\n#### Clean and deep-clean targets\n\n- `clean` clears up any files that have been generated by building or testing locally.\n- `deep-clean` runs clean target and also removes any node_modules and python libraries installed locally.\n\n#### Linting and testing\n\n- `lint` runs lint for all code\n- `lint-node` runs lint for node code\n- `lint-cloudformation` runs lint for cloudformation templates\n- `lint-samtemplates` runs lint for SAM templates\n- `test` runs unit tests for all code\n- `cfn-guard` runs cfn-guard for sam and cloudformation templates\n\n#### Compiling\n\n- `compile` compiles all code\n- `compile-node` runs tsc to compile typescript code\n\n#### Check licenses\n\n- `check-licenses` checks licenses for all packages used - calls check-licenses-node, check-licenses-python, check-licenses-golang\n- `check-licenses-node` checks licenses for all node code\n- `check-licenses-python` checks licenses for all python code\n\n#### CLI Login to AWS\n\n- `aws-configure` configures a connection to AWS\n- `aws-login` reconnects to AWS from a previously configured connection\n\n### Github folder\n\nThis .github folder contains workflows and templates related to github\n\n- `pull_request_template.yml`: Template for pull requests.\n\nWorkflows are in the .github/workflows folder\n\n- `ci.yml` Workflow run when code merged to main. Deploys to dev and qa environments.\n- `combine-dependabot-prs.yml`: Workflow for combining dependabot pull requests. Runs on demand\n- `delete_old_cloudformation_stacks.yml`: Workflow for deleting old cloud formation stacks. Runs daily\n- `pull_request.yml`: Called when pull request is opened or updated. Calls sam_package_code and sam_release_code to build and deploy the code. Deploys to dev AWS account. The main and sandbox stacks deployed have PR-\u003cPULL_REQUEST_ID\u003e in the name\n- `release.yml`: Runs on demand to create a release and deploy to all environments.\n- `sam_package_code.yml`: Packages code and uploads to a github artifact for later deployment\n- `sam_release_code.yml`: Release code built by sam_package_code.yml to an environment\n- `pr-link.yaml`: This workflow template links Pull Requests to Jira tickets and runs when a pull request is opened.\n- `dependabot.yml`: Dependabot definition file\n\n### Github pages\n\nGithub pages is used to display deployment information. The source for github pages is in the gh-pages branch.\nAs part of the ci and release workflows, the release tag (either the short commit SHA or release tag) is appended to `_data/{environment}_deployments.csv` so we have a history of releases and replaced in `_data/{environment}_latest.csv` so we now what the latest released version is.\nThere are different makefile targets in this branch. These are\n\n- `run-jekyll` - runs the site locally so changes can be previewed during development\n- `sync-main` - syncs common files from main branch to gh-pages branch. You must commit and push after running this\n- `install-python` installs python dependencies\n- `install-hooks` installs git pre commit hooks\n- `install-node` installs node dependencies\n- `install-jekyll` installs dependencies to be able to run jekyll locally\n- `install` runs all install targets\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnhsdigital%2Fprescriptionsforpatients","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnhsdigital%2Fprescriptionsforpatients","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnhsdigital%2Fprescriptionsforpatients/lists"}