FHIR 的使用

前言

这2年 ,俺写的很多接口都是基于FHIR的 ,所以就这个FHIR 介绍一下。

FHIR(Fast Healthcare Interoperability Resources,快速医疗保健互操作性资源)是由HL7国际组织制定的现代医疗数据交换标准,旨在实现不同医疗系统之间的高效、安全数据共享,打破"信息孤岛" 。

它将医疗信息拆分为模块化的"资源"(Resources),如患者(Patient)、就诊(Encounter)、诊断报告(DiagnosticReport)等,每个资源都是一个结构清晰的数据单元,便于系统间灵活调用与组合 。FHIR采用现代Web技术(如RESTful API、JSON/XML格式),让开发者能更快速地构建和集成医疗应用,支持移动端、互联网医院、远程诊疗等新兴场景 。

背景

这几年,经常和 EPIC 进行对接,EPIC 的接口提供了FHIR的通讯。

这个EPIC不是那个做游戏的 EPIC。如果是医疗行业的朋友或者女程序员 应该比较熟悉 。Epic 是美国最大的医疗信息化厂商之一,专注于为大型医院和医疗机构提供电子健康档案(EHR)系统。截至2023年,其市场占有率达 ‌39.1% ‌,服务近 ‌**2400家医疗机构。**2026年,Epic正式上线自研AI病历工具,深度集成微软DAX Copilot与GPT-4技术,支持实时语音转结构化SOAP病历,显著提升医生文书效率 。 推出四大AI智能体:ART(临床医生助手)、Emmie(患者导航)、Cosmos AI(大数据决策支持)、Penny(行政优化),构建统一医疗AI生态 。

为啥说 女程序员 应该比较熟悉,因为Epic 创始人兼CEO ‌Judy Faulkner(朱迪·福克纳) ‌ 是一位从代码起步的女程序员,坚持拒绝风投、拒绝IPO,2025年11月的实时数据显示朱迪·福克纳 净资产达 ‌81.9亿美元。

开始

俺以EPIC的接口为例进行说明。为啥用 EPIC ,因为他的官网支持邮箱注册,用QQ邮箱就可以注册,它还提供了沙盒进行测试 ,沙盒里有一些病人和数据 可以用来调试,另外帮助也很全。缺点是要 梯子。

https://fhir.epic.com/Developer/Apps

每个API的说明都有,还可以 Try It 直接试试

Request 和 Response 都有例子

例如 下面是 Patient.Read 的例子

javascript 复制代码
{
  "resourceType": "Patient",
  "id": "e63wRTbPfr1p8UW81d8Seiw3",
  "extension": [
    {
      "valueCodeableConcept": {
        "coding": [
          {
            "system": "urn:oid:1.2.840.114350.1.13.0.1.7.10.698084.130.657370.19999000",
            "code": "male",
            "display": "male"
          }
        ],
        "text": "Male"
      },
      "url": "http://open.epic.com/FHIR/StructureDefinition/extension/legal-sex"
    },
    {
      "valueCodeableConcept": {
        "coding": [
          {
            "system": "urn:oid:1.2.840.114350.1.13.0.1.7.10.698084.130.657370.19999000",
            "code": "male",
            "display": "male"
          }
        ]
      },
      "url": "http://open.epic.com/FHIR/StructureDefinition/extension/sex-for-clinical-use"
    },
    {
      "extension": [
        {
          "valueCoding": {
            "system": "urn:oid:2.16.840.1.113883.6.238",
            "code": "2106-3",
            "display": "White"
          },
          "url": "ombCategory"
        },
        {
          "valueString": "White",
          "url": "text"
        }
      ],
      "url": "http://hl7.org/fhir/us/core/StructureDefinition/us-core-race"
    },
    {
      "extension": [
        {
          "valueString": "Unknown",
          "url": "text"
        }
      ],
      "url": "http://hl7.org/fhir/us/core/StructureDefinition/us-core-ethnicity"
    },
    {
      "valueCode": "248153007",
      "url": "http://hl7.org/fhir/us/core/StructureDefinition/us-core-sex"
    },
    {
      "valueCodeableConcept": {
        "coding": [
          {
            "system": "http://loinc.org",
            "code": "LA29518-0",
            "display": "he/him/his/his/himself"
          }
        ]
      },
      "url": "http://open.epic.com/FHIR/StructureDefinition/extension/calculated-pronouns-to-use-for-text"
    }
  ],
  "identifier": [
    {
      "use": "usual",
      "type": {
        "text": "CEID"
      },
      "system": "urn:oid:1.2.840.114350.1.13.0.1.7.3.688884.100",
      "value": "FHRBVLJ14NQZWWL"
    },
    {
      "use": "usual",
      "type": {
        "text": "EPIC"
      },
      "system": "urn:oid:1.2.840.114350.1.13.0.1.7.5.737384.0",
      "value": "E2734"
    },
    {
      "use": "usual",
      "type": {
        "coding": [
          {
            "system": "http://hl7.org/fhir/us/carin-bb/CodeSystem/C4BBIdentifierType",
            "code": "um"
          }
        ],
        "text": "EXTERNAL"
      },
      "system": "urn:oid:1.2.840.114350.1.13.0.1.7.2.698084",
      "value": "Z4575"
    },
    {
      "use": "usual",
      "type": {
        "text": "FHIR"
      },
      "system": "http://open.epic.com/FHIR/StructureDefinition/patient-dstu2-fhir-id",
      "value": "T81lum-5p6QvDR7l6hv7lfE52bAbA2ylWBnv9CZEzNb0B"
    },
    {
      "use": "usual",
      "type": {
        "text": "FHIR STU3"
      },
      "system": "http://open.epic.com/FHIR/StructureDefinition/patient-fhir-id",
      "value": "e63wRTbPfr1p8UW81d8Seiw3"
    },
    {
      "use": "usual",
      "type": {
        "text": "INTERNAL"
      },
      "system": "urn:oid:1.2.840.114350.1.13.0.1.7.2.698084",
      "value": "     Z4575"
    },
    {
      "use": "usual",
      "type": {
        "text": "EPI"
      },
      "system": "urn:oid:1.2.840.114350.1.13.0.1.7.5.737384.14",
      "value": "202500"
    },
    {
      "use": "usual",
      "type": {
        "text": "MYCHARTLOGIN"
      },
      "system": "urn:oid:1.2.840.114350.1.13.0.1.7.3.878082.110",
      "value": "MYCHARTTEDDY"
    },
    {
      "use": "usual",
      "type": {
        "text": "WPRINTERNAL"
      },
      "system": "urn:oid:1.2.840.114350.1.13.0.1.7.2.878082",
      "value": "19"
    },
    {
      "use": "usual",
      "type": {
        "coding": [
          {
            "system": "http://terminology.hl7.org/CodeSystem/v2-0203",
            "code": "MB"
          }
        ]
      },
      "system": "https://open.epic.com/FHIR/StructureDefinition/PayerMemberId",
      "value": "530002010"
    },
    {
      "use": "usual",
      "type": {
        "coding": [
          {
            "system": "http://terminology.hl7.org/CodeSystem/v2-0203",
            "code": "MB"
          }
        ]
      },
      "system": "https://open.epic.com/FHIR/StructureDefinition/PayerMemberId",
      "value": "A0296438559"
    },
    {
      "use": "usual",
      "system": "urn:oid:2.16.840.1.113883.4.1",
      "value": "437-32-4199"
    }
  ],
  "active": true,
  "name": [
    {
      "use": "official",
      "text": "Mr. Theodore Mychart",
      "family": "Mychart",
      "given": [
        "Theodore"
      ],
      "prefix": [
        "MR."
      ]
    },
    {
      "use": "usual",
      "text": "Mr. Theodore Mychart",
      "family": "Mychart",
      "given": [
        "Theodore"
      ],
      "prefix": [
        "MR."
      ]
    }
  ],
  "telecom": [
    {
      "system": "phone",
      "value": "+1 608-213-5806",
      "use": "home"
    },
    {
      "system": "phone",
      "value": "+1 608-272-5000",
      "use": "work"
    }
  ],
  "gender": "male",
  "birthDate": "1948-07-07",
  "deceasedBoolean": false,
  "address": [
    {
      "use": "home",
      "text": "134 Elm St\r\nMadison WI 53706\r\nUnited States of America",
      "line": [
        "134 Elm Street"
      ],
      "city": "Madison",
      "state": "WI",
      "postalCode": "53706",
      "country": "US",
      "period": {
        "start": "2018-11-26"
      }
    },
    {
      "use": "old",
      "text": "134 Elm St\r\nMadison WI 53706",
      "line": [
        "134 Elm Street"
      ],
      "city": "Madison",
      "state": "WI",
      "postalCode": "53706",
      "period": {
        "start": "2006-07-07",
        "end": "2018-11-26"
      }
    }
  ],
  "maritalStatus": {
    "text": "Married"
  },
  "contact": [
    {
      "relationship": [
        {
          "coding": [
            {
              "system": "urn:oid:1.2.840.114350.1.13.0.1.7.4.827665.1000",
              "code": "14",
              "display": "Sister"
            }
          ],
          "text": "Sister"
        }
      ],
      "name": {
        "use": "usual",
        "text": "Sally Tonga"
      },
      "telecom": [
        {
          "system": "phone",
          "value": "+1 608-921-8342",
          "use": "home"
        }
      ]
    },
    {
      "relationship": [
        {
          "coding": [
            {
              "system": "http://terminology.hl7.org/CodeSystem/v2-0131",
              "code": "E",
              "display": "Employer"
            }
          ]
        }
      ],
      "organization": {
        "display": "Ehs Generic Employer"
      }
    }
  ],
  "communication": [
    {
      "extension": [
        {
          "extension": [
            {
              "valueCoding": {
                "system": "http://terminology.hl7.org/CodeSystem/v3-LanguageAbilityMode",
                "code": "ESP",
                "display": "Expressed spoken"
              },
              "url": "type"
            }
          ],
          "url": "http://hl7.org/fhir/StructureDefinition/patient-proficiency"
        }
      ],
      "language": {
        "coding": [
          {
            "system": "urn:ietf:bcp:47",
            "code": "sgn",
            "display": "Sign Languages"
          }
        ],
        "text": "Sign Languages"
      },
      "preferred": true,
      "_preferred": {
        "extension": [
          {
            "valueCoding": {
              "system": "http://hl7.org/fhir/language-preference-type",
              "code": "verbal",
              "display": "verbal"
            },
            "url": "http://hl7.org/fhir/StructureDefinition/patient-preferenceType"
          }
        ]
      }
    }
  ],
  "generalPractitioner": [
    {
      "reference": "Practitioner/eM5CWtq15N0WJeuCet5bJlQ3",
      "type": "Practitioner",
      "display": "Physician Family Medicine, MD"
    }
  ],
  "managingOrganization": {
    "reference": "Organization/enRyWnSP963FYDpoks4NHOA3",
    "display": "Epic Hospital System"
  }
}

开发

其实开发倒是比较简单 ,C# 可以直接nuget 一些包用。

public static Resource get_Resource(string url)

{

FhirClient client = get_FhirClient();

if (url.IndexOf("http") < 0)

{

url = Authentication.instance.option.fhir_url + url;

}

Resource r = client.Get(url);

return r;

}

public static FhirClient get_FhirClient()

{

FhirClient client;

if (Authentication.instance.option.proxy_url != "")

{

WebProxy proxy = new WebProxy(Authentication.instance.option.proxy_url + ":" + Authentication.instance.option.proxy_port);

HttpClientHandler handler = new HttpClientHandler() { Proxy = proxy };

HttpClient httpClient = new HttpClient(handler);

client = new FhirClient(Authentication.instance.option.fhir_url, httpClient, get_FhirClientSettings());

}

else

{

client = new FhirClient(Authentication.instance.option.fhir_url, get_FhirClientSettings());

}

client.RequestHeaders.Add("accept", "application/fhir+json");

client.RequestHeaders.Add("Authorization", "Bearer " + Authentication.instance.get_access_token());

return client;

}

相关推荐
小吴同学·2 小时前
吴恩达机器学习下:二分类问题、逻辑回归、过拟合问题
人工智能·机器学习
程序员Shawn2 小时前
【机器学习 | 第四篇】- 逻辑回归
人工智能·机器学习·逻辑回归
tyler_download2 小时前
揉扁搓圆Transformer架构: 激活函数说明
人工智能·深度学习·transformer
HarryPoint2 小时前
Claude Code Auto Mode:不用点"同意",也能保证安全
人工智能
孤烟2 小时前
伯克利研究:AI 未减负反加压,77% 职场人工作量飙升
人工智能·ai编程
公子小六2 小时前
基于.NET的Windows窗体编程之WinForms控件简介
windows·microsoft·c#·.net
jinanwuhuaguo2 小时前
OpenClaw全网使用人群全景深度分析报告
网络·人工智能·网络协议·rpc·openclaw
踩着两条虫2 小时前
AI驱动的Vue3应用开发平台 深入探究(十四):扩展与定制之插件系统开发指南
vue.js·人工智能·低代码·重构·架构
spider'3 小时前
ROS2开发环境搭建
人工智能