Medicines
Introduction
Mydex Data Services CIC provides an API known as the 'Master Reference Data Services' or MRD. This API provides access to a variety of non-personal, general purpose datasets that may be of use when integrating with the rest of the Mydex platform or simply a valuable managed API service for a range of datasets that can be subscribed to.
One of these services or datasets is Medicines, which itself is also offered to the public (see https://www.nhs.uk/medicines/) . Medicines is a service designed to help citizens find helpful information about medication.
Mydex hosts its own copy of Medicines and also consumes the Medicines API from the upstream source to keep our instance of Medicines current with regular updates.
Mydex's MRD Service hosts the data and adds the ability to search for data using keywords and filters. Mydex's MRD API also allows filtering to:
- remove any html tags from text fields
- to choose between updating urls/links to be hosted by Mydex MRD API or the NHS website, where relevant.
Subscribers to MRD use these managed lists, directories and look-ups to embed content into their own apps and services such as delivering personalised lists based on an individual's profile set in the subscribers application or service.
This guide explains:
- How to authenticate to Mydex's MRD API with OAuth2.0 in order to access the service.
- How to construct different search requests to Mydex's MRD API to obtain different types of results from the Medicines datasets.
If you encounter issues either getting authenticated to or using the MRD API, please contact support@mydex.org. Our team is ready and always happy to help you with any issues.
Authenticating with OAuth2.0
The Mydex MRD API requires authentication using the industry standard OAuth2.0 protocol. Please see our online documentation for more information on this: https://dev.mydex.org/mrd-api/mrd-authentication.html
Returning data via a specified Medicines route
The most basic request that can be made is to the root route: https://api-mrd.mydex.org/medicines
This will return a list of candidate routes that can be requested. Making a request to any of the routes listed will return the data linked to that route.
Some example requests for Live Well data are as follows:
- https://api-mrd.mydex.org/medicines/apixaban
- https://api-mrd.mydex.org/medicines/cyclizine/who-can-and-cannot-take-cyclizine
- https://api-mrd.mydex.org/medicines/insulin/biphasic-insulin/common-questions-about-biphasic-insulin
A simple request like this can be made to any route and it will return that data. There are also options (flags) available for stripping html tags and replacing links to our own MRD api with links to the NHS website which we will cover next.
[Example responses showing how the data is structured can be viewed under the heading Example responses at the end of this page. Referring to these will aid in understanding the effect the flag settings have]
Flag settings
There are two possible flag settings which can be set independently of each other or together. These settings are:
- no_html=true
- nhs_links=true
- https://api-mrd.mydex.org/medicines/apixaban?no_html=true
- https://api-mrd.mydex.org/medicines/cyclizine/who-can-and-cannot-take-cyclizine?no_html=true&nhs_links=true
- https://api-mrd.mydex.org/medicines/insulin/biphasic-insulin/common-questions-about-biphasic-insulin?nhs_links=true
Note: If both flags are set, the order in which they appear in the request does not matter.
No flags set: What is returned by default?
By default, other Mydex MRD API endpoints are made available for use directly within the response. This means that links can be made across different services to build a dynamic range of data payloads.
Setting this flag replaces any links to the NHS api with our relative MRD api endpoint. This applies to any endpoints that we currently have available for use. Currently that includes:
- https://api-mrd.mydex.org/conditions
- https://api-mrd.mydex.org/live-well
- https://api-mrd.mydex.org/medcines
- https://api-mrd.mydex.org/mental-health
These links are replaced in any text fields with an index which relates to an array of these links which is added to the payload along with the text. Standalone url fields are updated with the MRD api endpoint as appropriate.
What does no_html do?
Setting this flag removes all the html tags from any text field and stores any links in an array links[] along with the text field.
What does nhs_links do?
Any links to the nhs_api are updated to the nhs website. No links to the MRD api endpoint will be returned in the payload.
Returning data by searching/filtering on one or more keywords
* This feature is currently in development *
Flag setting examples
Here you can see some snippets of data to show how the different flag settings change parts of the content we return to you from your request.
Urls
The data contains url fields that can contain links to various NHS api services. Below you can see an example of how one of these fields is updated with each combination of flag-setting.
Default no flags |
---|
"url": "https://api-mrd.mydex.org/medicines/paxlovid/", |
?no_html=true |
"url": "https://api-mrd.mydex.org/medicines/paxlovid/", |
?nhs_links=true |
"url": "https://www.nhs.uk/medicines/paxlovid/", |
?nhs_links=true&no_html=true |
"url": "https://www.nhs.uk/medicines/paxlovid/", |
Text
The data contains text fields that are typically html and can contain links to various NHS website locations. Below you can see an example of how one of these fields is updated with each combination of flag-setting.
Default no flags |
---|
"text": "<p>Most adults aged 18 years old and over can take clonazepam tablets and liquid.</p><p>Most children from 1 month old can take it for epilepsy.</p><h2>Who may not be able to take clonazepam</h2><p>Clonazepam is not suitable for some people.</p><p>To make sure it's safe for you, tell your doctor before starting to take clonazepam if you:</p><ul><li>have ever had an allergic reaction to clonazepam or any other medicine</li><li>have <a index-link=[0]>myasthenia gravis</a>, a condition that causes muscle weakness</li><li>have <a index-link=[1]>sleep apnoea</a>, a condition that causes breathing problems when you're asleep</li><li>have lung, liver or kidney problems</li><li>have spinal or cerebellar ataxia, where you may become shaky and unsteady and have slurred speech</li><li>have ever had problems with alcohol or drugs</li><li>have recently had a loss or bereavement, depression or thoughts of harming yourself or suicide</li><li>have been diagnosed with a <a index-link=[2]>personality disorder</a></li><li>are trying to get pregnant, are already pregnant or breastfeeding</li><li>are going to be put to sleep (have a <a index-link=[3]>general anaesthetic</a>) for an operation or dental treatment</li></ul>", "links": [ { "key": "index-link=[0]", "mrd_api_link": "https://api-mrd.mydex.org/conditions/myasthenia-gravis/" }, { "key": "index-link=[1]", "mrd_api_link": "https://api-mrd.mydex.org/conditions/sleep-apnoea/" }, { "key": "index-link=[2]", "mrd_api_link": "https://api-mrd.mydex.org/mental-health/conditions/personality-disorder/" }, { "key": "index-link=[3]", "mrd_api_link": "https://api-mrd.mydex.org/conditions/general-anaesthesia/" } ] |
?no_html=true |
"text": "Most adults aged 18 years old and over can take clonazepam tablets and liquid. Most children from 1 month old can take it for epilepsy. Who may not be able to take clonazepam Clonazepam is not suitable for some people. To make sure it's safe for you, tell your doctor before starting to take clonazepam if you: have ever had an allergic reaction to clonazepam or any other medicine have myasthenia gravis, a condition that causes muscle weakness have sleep apnoea, a condition that causes breathing problems when you're asleep have lung, liver or kidney problems have spinal or cerebellar ataxia, where you may become shaky and unsteady and have slurred speech have ever had problems with alcohol or drugs have recently had a loss or bereavement, depression or thoughts of harming yourself or suicide have been diagnosed with a personality disorder are trying to get pregnant, are already pregnant or breastfeeding are going to be put to sleep (have a general anaesthetic) for an operation or dental treatment", "links": [ { "mrd_api_link": "https://api-mrd.mydex.org/conditions/myasthenia-gravis/" }, { "mrd_api_link": "https://api-mrd.mydex.org/conditions/sleep-apnoea/" }, { "mrd_api_link": "https://api-mrd.mydex.org/mental-health/conditions/personality-disorder/" }, { "mrd_api_link": "https://api-mrd.mydex.org/conditions/general-anaesthesia/" } ] |
?nhs_links=true |
"text": "<p>Most adults aged 18 years old and over can take clonazepam tablets and liquid.</p><p>Most children from 1 month old can take it for epilepsy.</p><h2>Who may not be able to take clonazepam</h2><p>Clonazepam is not suitable for some people.</p><p>To make sure it's safe for you, tell your doctor before starting to take clonazepam if you:</p><ul><li>have ever had an allergic reaction to clonazepam or any other medicine</li><li>have <a href=\"https://www.nhs.uk/conditions/myasthenia-gravis/\">myasthenia gravis</a>, a condition that causes muscle weakness</li><li>have <a href=\"https://www.nhs.uk/conditions/sleep-apnoea/\">sleep apnoea</a>, a condition that causes breathing problems when you're asleep</li><li>have lung, liver or kidney problems</li><li>have spinal or cerebellar ataxia, where you may become shaky and unsteady and have slurred speech</li><li>have ever had problems with alcohol or drugs</li><li>have recently had a loss or bereavement, depression or thoughts of harming yourself or suicide</li><li>have been diagnosed with a <a href=\"https://www.nhs.uk/mental-health/conditions/personality-disorder/\">personality disorder</a></li><li>are trying to get pregnant, are already pregnant or breastfeeding</li><li>are going to be put to sleep (have a <a href=\"https://www.nhs.uk/conditions/general-anaesthesia/\">general anaesthetic</a>) for an operation or dental treatment</li></ul>"
|
?nhs_links=true&no_html=true |
"text": "Most adults aged 18 years old and over can take clonazepam tablets and liquid. Most children from 1 month old can take it for epilepsy. Who may not be able to take clonazepam Clonazepam is not suitable for some people. To make sure it's safe for you, tell your doctor before starting to take clonazepam if you: have ever had an allergic reaction to clonazepam or any other medicine have myasthenia gravis, a condition that causes muscle weakness have sleep apnoea, a condition that causes breathing problems when you're asleep have lung, liver or kidney problems have spinal or cerebellar ataxia, where you may become shaky and unsteady and have slurred speech have ever had problems with alcohol or drugs have recently had a loss or bereavement, depression or thoughts of harming yourself or suicide have been diagnosed with a personality disorder are trying to get pregnant, are already pregnant or breastfeeding are going to be put to sleep (have a general anaesthetic) for an operation or dental treatment", "links": [ "https://www.nhs.uk/conditions/myasthenia-gravis/", "https://www.nhs.uk/conditions/sleep-apnoea/", "https://www.nhs.uk/mental-health/conditions/personality-disorder/", "https://www.nhs.uk/conditions/general-anaesthesia/" ] |