Skip to main content
Glama

FastMCP Server Template

by rdwj
update_patient_50.py6.24 kB
#!/usr/bin/env python3 """ Update Patient 50's DeviceRequest with a real FDA-approved hearing aid """ import json import requests # FHIR server base URL FHIR_BASE = "https://hapi-fhir-davinci-data.apps.cluster-sdzgj.sdzgj.sandbox319.opentlc.com/fhir" # Real FDA-approved hearing aid: Lexie Lumen Self-Fitting OTC Hearing Aids # FDA 510(k): K223137 # Manufacturer: hearX SA (Pty) Ltd. # Cleared: March 14, 2023 # Product Code: QUH (OTC hearing aid) # Updated DeviceRequest with real FDA data updated_device_request = { "resourceType": "DeviceRequest", "id": "device-request-hearing-aid-00050", "meta": { "profile": [ "http://hl7.org/fhir/StructureDefinition/DeviceRequest" ] }, "status": "active", "intent": "order", "codeCodeableConcept": { "coding": [ { "system": "http://snomed.info/sct", "code": "467138008", "display": "Hearing aid" } ], "text": "Lexie Lumen Self-Fitting OTC Hearing Aids" }, "parameter": [ { "code": { "coding": [ { "system": "http://hl7.org/fhir/device-parameter", "code": "fda-510k", "display": "FDA 510(k) Number" } ] }, "valueCodeableConcept": { "coding": [ { "system": "http://fda.gov/510k", "code": "K223137", "display": "FDA 510(k) Cleared Device" } ], "text": "K223137" } }, { "code": { "coding": [ { "system": "http://hl7.org/fhir/device-parameter", "code": "manufacturer", "display": "Manufacturer" } ] }, "valueString": "hearX SA (Pty) Ltd." }, { "code": { "coding": [ { "system": "http://hl7.org/fhir/device-parameter", "code": "otc-status", "display": "Over-The-Counter Status" } ] }, "valueBoolean": True } ], "subject": { "reference": "Patient/aud-patient-00050" }, "authoredOn": "2025-09-22", "requester": { "reference": "Practitioner/aud-practitioner-00050" }, "performer": { "display": "hearX SA (Pty) Ltd." }, "reasonCode": [ { "coding": [ { "system": "http://hl7.org/fhir/sid/icd-10-cm", "code": "H90.3", "display": "Sensorineural hearing loss, bilateral" } ] } ], "note": [ { "text": "FDA 510(k) Number: K223137 - Lexie Lumen Self-Fitting OTC Hearing Aids. FDA cleared March 14, 2023. Product code QUH (Self-Fitting Air-Conduction Hearing Aid, Over The Counter). Manufacturer: hearX SA (Pty) Ltd." } ] } def update_device_request(): """Update the DeviceRequest resource on the FHIR server.""" # Resource URL url = f"{FHIR_BASE}/DeviceRequest/device-request-hearing-aid-00050" print("=" * 80) print("Updating Patient 50's DeviceRequest") print("=" * 80) print(f"Patient: aud-patient-00050") print(f"Resource ID: device-request-hearing-aid-00050") print(f"\nUpdating with REAL FDA-approved device:") print(f" Device: Lexie Lumen Self-Fitting OTC Hearing Aids") print(f" FDA 510(k): K223137") print(f" Manufacturer: hearX SA (Pty) Ltd.") print(f" FDA Cleared: March 14, 2023") print(f" Product Code: QUH (OTC hearing aid)") print(f" Device Class: 2") print("=" * 80) # Update the resource headers = { "Content-Type": "application/fhir+json" } print("\nSending PUT request to FHIR server...") response = requests.put(url, json=updated_device_request, headers=headers) if response.status_code in [200, 201]: print(f"✅ SUCCESS: DeviceRequest updated (Status: {response.status_code})") print("\nUpdated resource details:") # Pretty print the response if response.json(): updated = response.json() print(f" Version: {updated.get('meta', {}).get('versionId', 'N/A')}") print(f" Last Updated: {updated.get('meta', {}).get('lastUpdated', 'N/A')}") print(f" Device: {updated.get('codeCodeableConcept', {}).get('text', 'N/A')}") # Show FDA parameters if 'parameter' in updated: print("\n FDA Parameters:") for param in updated['parameter']: code = param.get('code', {}).get('coding', [{}])[0].get('display', 'Unknown') if 'valueCodeableConcept' in param: value = param['valueCodeableConcept'].get('text', 'N/A') elif 'valueString' in param: value = param['valueString'] elif 'valueBoolean' in param: value = "Yes" if param['valueBoolean'] else "No" else: value = "N/A" print(f" • {code}: {value}") # Show notes if 'note' in updated: print("\n Notes:") for note in updated['note']: print(f" • {note.get('text', '')}") print("\n" + "=" * 80) print("✅ Patient 50's DeviceRequest has been updated with a real FDA-approved device!") print(" The device should now be APPROVABLE by the FDA verification agent.") print("=" * 80) else: print(f"❌ ERROR: Failed to update DeviceRequest") print(f" Status Code: {response.status_code}") print(f" Response: {response.text[:500]}") if __name__ == "__main__": update_device_request()

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/rdwj/fda-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server