fetching-fhir-resources
ما الذي تفعله
تسترجع هذه المهارة مستندات التقارير الخاصة بالمريض من واجهة FHIR API لنظام السجلات الصحية الإلكتروني، وتفك ترميز نص الملاحظة المرفق، وتتعامل مع النتائج المتعددة الصفحات. وهي موجهة للمطورين الذين يربطون العمل النصي السريري بنظام EHR حي.
متى تستخدمها
- ✓عندما تحتاج إلى مستندات المريض أو تقاريره من واجهة FHIR API لنظام EHR للتحليل النصي.
- ✓عندما يُرجع بحث FHIR عدة صفحات وتحتاج إلى كلها.
- ✓عندما يكون نص الملاحظة مرفقاً كمحتوى base64 ويجب فك ترميزه قبل التحليل.
رابط المهارة
https://github.com/maziyarpanahi/openmed/blob/master/skills/fetching-fhir-resources/SKILL.mdانسخه والصقه في الذكاء الاصطناعي الذي تستخدمه (Claude أو ChatGPT أو Cursor) واطلب منه اتباع التعليمات.
طريقة الاستخدام
أسهل طريقة: انسخ الرسالة والصقها في الذكاء الاصطناعي الذي تستخدمه. سيقرأ المهارة وينفّذ تعليماتها.
رسالة جاهزة للصق
لـ Claude Code أو Codex أو Cursor: شغّله داخل مجلد مشروعك وستُثبَّت المهارة.
نزّل ملف SKILL.md وضعه في مجلد مهارات وكيلك.
مثال على ما تطلبه من الذكاء الاصطناعي
“اسحب كل الملاحظات السريرية للمريض abc من خادم FHIR عندنا، وفك ترميز المرفقات، وأعطني نص الملاحظات.”
5 مهارات جديدة كل أسبوع. قراءة في دقيقة واحدة.
كيف تعمل
يرسل وكيلك طلبات بحث FHIR، ويتبع روابط الصفحة التالية، ويفك ترميز المرفقات base64، ثم يعيد نص الملاحظات للإزالة والتحليل.
المحتوى التقني (ملف SKILL.md الأصلي)
النص الأصلي من المؤلف، مباشرة من GitHub.
Fetching FHIR R4 Resources for OpenMed
FHIR R4 is the modern EHR API: a RESTful, JSON-or-XML interface over resources
like Patient, Encounter, Condition, Observation, DiagnosticReport,
and DocumentReference. The unstructured clinical text you want for NLP lives
in DocumentReference.content.attachment and
DiagnosticReport.presentedForm — usually base64-encoded PDF, RTF, or
plain text. This skill pulls those resources, pages through results, decodes the
attachments, and hands the narrative to OpenMed.
When to use
- You have FHIR R4 access to an EHR (Epic, Oracle Health/Cerner, HAPI, Medplum, Azure/Google/AWS HealthLake) and want note text for de-id and NER.
- You need to page a large search result set safely (
Bundle.link[next]). - You want to pull a patient's documents/reports and rejoin NLP output by patient and encounter.
FHIR REST in one minute
Search is GET [base]/[Type]?param=value. Results come back as a
searchset Bundle; the next page is the URL in Bundle.link where
relation == "next". Use _count to size pages, _revinclude to pull related
resources in one round trip, and _since/_lastUpdated for incremental sync.
GET /Patient?identifier=http://hospital.org/mrn|12345
GET /DocumentReference?patient=Patient/abc&category=clinical-note&_count=50
GET /DiagnosticReport?patient=Patient/abc&_revinclude=Observation:related
Quick start
Page a search, decode attachments, hand narrative to OpenMed:
import base64
import requests
import openmed
BASE = "https://fhir.example.org/r4"
HEADERS = {"Accept": "application/fhir+json", "Authorization": "Bearer <token>"}
def iter_bundle(url, params=None):
"""Yield resources across all pages following Bundle.link[next]."""
while url:
bundle = requests.get(url, params=params, headers=HEADERS, timeout=30).json()
for entry in bundle.get("entry", []):
yield entry.get("resource", {})
params = None # next links are fully-qualified
url = next(
(l["url"] for l in bundle.get("link", []) if l.get("relation") == "next"),
None,
)
def attachment_text(att):
"""Decode a FHIR Attachment to text (handles base64 and inline text/plain)."""
if att.get("data"):
raw = base64.b64decode(att["data"])
if att.get("contentType", "").startswith("text/"):
return raw.decode("utf-8", "replace")
return "" # PDF/RTF: route to OpenMed multimodal/OCR intake instead
return ""
# Pull a patient's clinical notes and analyze each.
for doc in iter_bundle(f"{BASE}/DocumentReference",
{"patient": "Patient/abc",
"category": "clinical-note", "_count": 50}):
for content in doc.get("content", []):
text = attachment_text(content.get("attachment", {}))
if not text.strip():
continue
deid = openmed.deidentify(text, method="replace", policy="hipaa_safe_harbor")
result = openmed.analyze_text(deid.text, output_format="dict")
patient_ref = doc.get("subject", {}).get("reference") # rejoin key
Workflow
- Authenticate. Most production FHIR endpoints use SMART-on-FHIR OAuth2
(client-credentials for backend services). Scope to the minimum
(
system/DocumentReference.read,system/DiagnosticReport.read). - Search narrowly. Filter by
patient,category,type(LOINC),date, and_count. Prefer server-side filtering over client-side. - Page via
Bundle.link[next]until exhausted. Never assume one page. - Extract narrative:
DocumentReference.content.attachmentandDiagnosticReport.presentedForm. Decode base64; for PDF/RTF/scanned content, route bytes to OpenMed's document intake (multimodal/ocr) rather than decoding as UTF-8. - De-identify → analyze each narrative with OpenMed.
- Rejoin results to
subject.reference(patient) andcontext.encounterso downstream consumers can group by patient/encounter — storing hashed, not raw, identifiers.
Hand-off to / from OpenMed
- To OpenMed (client-side): decoded narrative →
openmed.deidentify→openmed.analyze_text. Carrysubject.referenceas the rejoin key. - Server-side
$de-identify:openmed.interop.fhir_operationsimplements the FHIR$de-identifyoperation logic over the OpenMed privacy pipeline:de_identify_resource(resource, policy=..., method=...)- `de_identi
الأسئلة الشائعة
أي أنظمة EHR تعمل معها؟
تعمل مع أي خادم FHIR R4، مثل Epic وOracle Health وHAPI أو خادم US Core.
هل تزيل هوية الملاحظات؟
تُرسل الملاحظات إلى خطوة إزالة هوية منفصلة قبل التحليل.
هل يمكنها مزامنة السجلات الجديدة فقط؟
نعم. تغطي المزامنة التزايدية بالفلاتر الزمنية.
التفاصيل
الوصف الأصلي من المؤلف
Fetches and pages FHIR R4 resources (Patient, DocumentReference, DiagnosticReport, Observation, Condition) from a FHIR REST server, decodes base64 attachments, and extracts clinical narrative for OpenMed. Use before OpenMed processing when pulling charts from an EHR FHIR API (Epic, Cerner/Oracle, HAPI, or any US Core server) and you need the note text de-identified and analyzed, then results rejoined by patient. Hand narrative to openmed.deidentify and openmed.analyze_text; openmed.interop.fhir_operations implements a $de-identify operation over Bundles. Trigger keywords: FHIR, R4, US Core, Do
repo: maziyarpanahi/openmed
الشعبية
- نجوم GitHub
- 5.8k
- الترتيب
- #14704
- الترخيص
- Apache-2.0
- آخر تحديث
- 2/11/2026
التعليقات
- …
المزيد من المهارات من هذا المستودع
annotating-variants
5.8kيساعد وكيلك على توقع تأثير المتغير الجيني، وتحويل أسماء HGVS إلى مواضع في الجينوم، وإضافة ترددات السكان، باستخدام أدوات تعليق عامة ومجانية.
ask-openmed
5.8kيساعد وكيلك على اختيار سير عمل OpenMed المناسب لطلب نصوص سريرية، مع البدء دائمًا بفحص الخصوصية عندما تحتمل وجود بيانات مرضى.
assembling-fhir-bundles
5.8kيجمع عدة سجلات صحية بصيغة FHIR في حزمة (Bundle) واحدة للمعاملات، جاهزة للإرسال إلى EHR، مع ربط المراجع الداخلية بشكل صحيح.
auditing-deid-leakage
5.8kيفحص النصوص السريرية التي أُزيلت هويتها بحثًا عن معرّفات متبقية، مثل أرقام الضمان الاجتماعي وأرقام البطاقات والبريد الإلكتروني والتواريخ، ويوقف النشر إذا بقي أي منها.
مهارات مشابهة
discrawl
394kيتيح لوكيلك البحث في أرشيف محلي محفوظ لرسائل Discord وتلخيصه، والتحقق من مدى حداثته، وقراءة الرسائل المباشرة.
clickhouse-io
280kيساعد وكيلك على تحسين الاستعلامات والمخططات في ClickHouse وتطبيق أفضل ممارسات التحليل عالي الأداء، ويفيد عندما تكون الاستعلامات التحليلية بطيئة.
scientific-db-pubmed-database
280kيساعد وكيلك على البحث عن المقالات العلمية في المجال الطبي الحيوي. مفيد للبحوث التي تحتاج إلى معلومات طبية محددة.