Fetch Categories
Overview
The fetchCategories
endpoint retrieves a list of medication categories, including associated drugs, formatted according to the FHIR (Fast Healthcare Interoperability Resources) standards for MedicationKnowledge.
HTTP Request
GET /api/v1/categories
Headers
Header Name | Value | Description |
---|---|---|
Content-Type | application/json | Indicates the media type of the resource |
Authorization | Bearer {API_KEY} | (Optional) Authorization token if endpoint is secured |
Query Parameters
This endpoint does not require any query parameters.
Request Example
GET /api/v1/categories HTTP/1.1
Host: {baseURL}
Content-Type: application/json
Authorization: Bearer {API_KEY}
Success Response
Code
200 OK
Content
An array of MedicationKnowledge
resources representing medication categories.
[
{
"resourceType": "MedicationKnowledge",
"id": "category-id",
"code": {
"coding": [
{
"system": "http://terminology.hl7.org/CodeSystem/ATC",
"code": "ATC-code",
"display": "Category Name"
}
],
"text": "Category Description"
},
"medicineClassification": {
"type": {
"coding": [
{
"system": "http://terminology.hl7.org/CodeSystem/medication-category",
"code": "atc-level",
"display": "Categorization Kind"
}
],
"text": "Synonyms"
},
"classification": [
{
"coding": [
{
"system": "http://hl7.org/fhir/sid/ndc",
"code": "registration-number",
"display": "Drug Trade Name"
}
],
"text": "Simple Drug Description"
}
]
},
"relatedMedicationKnowledge": [
{
"type": "has-equivalent",
"reference": {
"reference": "Medication/drug-id"
}
}
]
}
]
Error Responses
Code | Content | Description |
---|---|---|
404 | {"message": "No categories found"} | No categories were found in the database. |
500 | {"message": "An error occurred while fetching categories"} | There was an error on the server while processing the request. |
Example
Below is an example of a fetchCategories
function implementation in Next.js:
// Next.js API route
export async function fetchCategories(req: NextRequest) {
// ... existing implementation ...
}
Notes
- Ensure the base URL is configured correctly in your environment when making the request.
- If the API requires authorization, the
API_KEY
must be provided in theAuthorization
header. - The response adheres to the FHIR standard for
MedicationKnowledge
resources, ensuring interoperability with other FHIR-compliant systems. - This endpoint is read-only and does not support modifications to the medication categories or drugs.