文章
· 九月 3, 2023 阅读大约需 8 分钟

独立模式下 EMPI 的安装和适配 - FHIR之转换和摄取

大家好。

在上一篇文章中,我们了解了如何配置 EMPI 来接收 FHIR 消息。为此,我们安装了 InterSystems 提供的 FHIR 适配器,该适配器配置了一个可以向其发送 FHIR 消息的 REST 端点。然后,我们将获取消息并将其转换为 %String,我们将通过 TCP 将其发送到 HSPIDATA 命名空间中配置的 EMPI 的输出。

好吧,是时候看看我们如何检索消息、将其转换回 %DynamicObject 并将其解析为 EMPI 用来存储信息的类。

TCP消息接收

正如我们所指出的,从配置了 FHIR 资源接收的生产中,我们已将消息发送到我们有业务服务侦听的特定 TCP 端口,在我们的例子中,该业务服务将是一个简单的EnsLib.TCP。 PassthroughService的目标是捕获消息并将其转发到业务流程,我们将在其中执行所需的数据转换。

这里有我们的商业服务:

这是它的基本配置:

FHIR 消息的转变

正如你所看到的,我们只配置了通过 TCP 接收消息的端口以及我们将向其发送消息的组件,在我们的例子中我们将其称为 Local.BP.FHIRProcess,让我们看一下说类来看看我们如何从 FHIR 资源中检索信息:

 Class Local.BP.FHIRProcess Extends Ens.BusinessProcess [ ClassType = persistent ] { Method OnRequest(pRequest As Ens.StreamContainer, Output pResponse As Ens.Response) As %Status { set tDynObj = {}. %FromJSON (pRequest.Stream) If (tDynObj '= "" ) { set hubRequest = ##class (HS.Message.AddUpdateHubRequest). %New () // Create AddUpdateHub Message // Name, sex, DOB set givenIter = tDynObj.name. %Get ( 0 ).given. %GetIterator () while givenIter. %GetNext (, .givenName){ if (hubRequest.FirstName '= "" ) { Set hubRequest.FirstName=givenName } else { Set hubRequest.FirstName=hubRequest.FirstName_ " " _givenName } } Set hubRequest.FirstName=tDynObj.name. %Get ( 0 ).given. %Get ( 0 ) Set hubRequest.LastName=tDynObj.name. %Get ( 0 ).family Set hubRequest.Sex=tDynObj.gender Set hubRequest.DOB=hubRequest.DOBDisplayToLogical(tDynObj.birthDate) // Inserts full birth name information for the patient set nameIter = tDynObj.name. %GetIterator () while nameIter. %GetNext (, .name){ Set tName = ##class (HS.Types.PersonName). %New () if (name.prefix '= "" ) { Set tName.Prefix = name.prefix. %Get ( 0 ) } Set tName.Given = name.given. %Get ( 0 ) Set tName.Middle = "" Set tName.Family = name.family Set tName.Suffix = "" Set tName.Type= ^Ens .LookupTable( "TypeOfName" ,name. use ) Do hubRequest.Names.Insert(tName) } set identIter = tDynObj.identifier. %GetIterator () while identIter. %GetNext (, .identifier){ if (identifier.type'= "" ){ if (identifier.type.coding. %Get ( 0 ).code = "MR" ) { Set hubRequest.MRN = identifier.value Set hubRequest.AssigningAuthority = ^Ens .LookupTable( "hospital" ,identifier.system) Set hubRequest.Facility = ^Ens .LookupTable( "hospital" ,identifier.system) } elseif (identifier.type.coding. %Get ( 0 ).code = "SS" ) { Set hubRequest.SSN = identifier.value } else { Set tIdent= ##class (HS.Types.Identifier). %New () Set tIdent.Root = identifier.system // refers to an Assigning Authority entry in the OID Registry Set tIdent.Extension = identifier.value Set tIdent.AssigningAuthorityName = identifier.system Set tIdent. Use = identifier.type.coding. %Get ( 0 ).code Do hubRequest.Identifiers.Insert(tIdent) } } } // Address set addressIter = tDynObj.address. %GetIterator () while addressIter. %GetNext (, .address){ Set addr= ##class (HS.Types.Address). %New () Set addr.City=address.city Set addr.State=address.state Set addr.Country=address.country Set addr.StreetLine=address.line. %Get ( 0 ) Do hubRequest.Addresses.Insert(addr) } //Telephone set identTel = tDynObj.telecom. %GetIterator () while identTel. %GetNext (, .telecom){ if (telecom.system = "phone" ) { Set tel= ##class (HS.Types.Telecom). %New () Set tel.PhoneNumber=telecom.value Do hubRequest.Telecoms.Insert(tel) } } } Set tSC = ..SendRequestSync ( "HS.Hub.MPI.Manager" , hubRequest, .pResponse) Quit tSC } Storage Default { <Type> %Storage.Persistent </Type> } }

让我们更详细地看看我们正在做什么:

首先我们收到了业务服务发来的消息:

 Method OnRequest(pRequest As Ens.StreamContainer, Output pResponse As Ens.Response) As %Status { set tDynObj = {}. %FromJSON (pRequest.Stream)

正如我们在 OnRequest 方法的签名中看到的,输入消息对应于Ens.StreamContainer类型的类。 %String 类型消息的这种转换已在业务服务中进行。在该方法的第一行中,我们要做的是检索在 pRequest 变量中作为 Stream 找到的消息。然后,我们使用 %FromJSON 语句将其转换为 %DynamicObject。

通过将消息映射到动态对象,我们将能够访问已发送的 FHIR 资源的每个字段:

 set tDynObj = {}. %FromJSON (pRequest.Stream) If (tDynObj '= "" ) { set hubRequest = ##class (HS.Message.AddUpdateHubRequest). %New () // Create AddUpdateHub Message // Name, sex, DOB set givenIter = tDynObj.name. %Get ( 0 ).given. %GetIterator () while givenIter. %GetNext (, .givenName){ if (hubRequest.FirstName '= "" ) { Set hubRequest.FirstName=givenName } else { Set hubRequest.FirstName=hubRequest.FirstName_ " " _givenName } } Set hubRequest.FirstName=tDynObj.name. %Get ( 0 ).given. %Get ( 0 ) Set hubRequest.LastName=tDynObj.name. %Get ( 0 ).family Set hubRequest.Sex=tDynObj.gender Set hubRequest.DOB=hubRequest.DOBDisplayToLogical(tDynObj.birthDate)

在此片段中,我们看到如何创建HS.Message.AddUpdateHubRequest类的对象,该对象是我们将发送到负责在 EMPI 内执行相应操作的业务操作 HS.Hub.MPI.Manager 的对象,无论是是创建新患者或更新它,以及将其与 EMPI 中已有的其他患者可能存在的可能匹配项链接起来。

下一步是使用从业务服务接收到的数据填充新对象。正如您所看到的,我们所做的就是从刚刚创建的动态对象的不同字段中检索数据。动态对象的格式与 HL7 FHIR 为患者资源定义的格式完全对应,您可以直接在HL7 FHIR 网页上查看示例

对于我们的示例,我们从 HL7 FHIR 页面本身提供的列表中选择了该患者:

 { "resourceType" : "Patient" , "id" : "example" , "text" : { "status" : "generated" , "div" : "<div xmlns=\"http://www.w3.org/1999/xhtml\">\n\t\t\t<table>\n\t\t\t\t<tbody>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td>Name</td>\n\t\t\t\t\t\t<td>Peter James \n <b>Chalmers</b> (&quot;Jim&quot;)\n </td>\n\t\t\t\t\t</tr>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td>Address</td>\n\t\t\t\t\t\t<td>534 Erewhon, Pleasantville, Vic, 3999</td>\n\t\t\t\t\t</tr>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td>Contacts</td>\n\t\t\t\t\t\t<td>Home: unknown. Work: (03) 5555 6473</td>\n\t\t\t\t\t</tr>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td>Id</td>\n\t\t\t\t\t\t<td>MRN: 12345 (Acme Healthcare)</td>\n\t\t\t\t\t</tr>\n\t\t\t\t</tbody>\n\t\t\t</table>\n\t\t</div>" }, "identifier" : [ { "use" : "usual" , "type" : { "coding" : [ { "system" : "http://terminology.hl7.org/CodeSystem/v2-0203" , "code" : "MR" } ] }, "system" : "urn:oid:1.2.36.146.595.217.0.1" , "value" : "12345" , "period" : { "start" : "2001-05-06" }, "assigner" : { "display" : "Acme Healthcare" } } ], "active" : true , "name" : [ { "use" : "official" , "family" : "Chalmers" , "given" : [ "Peter" , "James" ] }, { "use" : "usual" , "given" : [ "Jim" ] }, { "use" : "maiden" , "family" : "Windsor" , "given" : [ "Peter" , "James" ], "period" : { "end" : "2002" } } ], "telecom" : [ { "use" : "home" }, { "system" : "phone" , "value" : "(03) 5555 6473" , "use" : "work" , "rank" : 1 }, { "system" : "phone" , "value" : "(03) 3410 5613" , "use" : "mobile" , "rank" : 2 }, { "system" : "phone" , "value" : "(03) 5555 8834" , "use" : "old" , "period" : { "end" : "2014" } } ], "gender" : "male" , "birthDate" : "1974-12-25" , "_birthDate" : { "extension" : [ { "url" : "http://hl7.org/fhir/StructureDefinition/patient-birthTime" , "valueDateTime" : "1974-12-25T14:35:45-05:00" } ] }, "deceasedBoolean" : false , "address" : [ { "use" : "home" , "type" : "both" , "text" : "534 Erewhon St PeasantVille, Rainbow, Vic 3999" , "line" : [ "534 Erewhon St" ], "city" : "PleasantVille" , "district" : "Rainbow" , "state" : "Vic" , "postalCode" : "3999" , "period" : { "start" : "1974-12-25" } } ], "contact" : [ { "relationship" : [ { "coding" : [ { "system" : "http://terminology.hl7.org/CodeSystem/v2-0131" , "code" : "N" } ] } ], "name" : { "family" : "du Marché" , "_family" : { "extension" : [ { "url" : "http://hl7.org/fhir/StructureDefinition/humanname-own-prefix" , "valueString" : "VV" } ] }, "given" : [ "Bénédicte" ] }, "telecom" : [ { "system" : "phone" , "value" : "+33 (237) 998327" } ], "address" : { "use" : "home" , "type" : "both" , "line" : [ "534 Erewhon St" ], "city" : "PleasantVille" , "district" : "Rainbow" , "state" : "Vic" , "postalCode" : "3999" , "period" : { "start" : "1974-12-25" } }, "gender" : "female" , "period" : { "start" : "2012" } } ], "managingOrganization" : { "reference" : "Organization/1" } }

首先,我们创建了 2 个查找表,用于映射姓名类型和分配医疗记录号 (MR) 的权限,第一个与 EMPI 管理的类型兼容,第二个用于识别分配权限生成标识符:

 Set tName.Type= ^Ens .LookupTable( "TypeOfName" ,name. use )
 Set hubRequest.AssigningAuthority = ^Ens .LookupTable( "hospital" ,identifier.system) Set hubRequest.Facility = ^Ens .LookupTable( "hospital" ,identifier.system)

启动测试消息

完美,让我们针对我们在上一篇文章中定义的端点启动 FHIR 消息:

正如您所看到的,我们收到了 200 响应,这仅意味着 EMPI 已正确接收到消息,现在让我们看看在我们的生产中生成的跟踪:

这里我们有我们的病人,您可以看到转换已成功执行,并且 FHIR 消息中报告的所有字段都已正确分配。可以看到,一条IDUpdateNotificationRequest通知消息已经生成了。当在系统中执行创建或更新患者的操作时,会生成此类通知。

很好,让我们通过按姓名搜索患者来检查患者是否在我们的系统中正确注册:

答对了!让我们更详细地看看我们亲爱的Peter的数据:

相当完美!我们的 EMPI 中已经包含了有关患者的所有必要信息。正如您所看到的,该机制非常简单,让我们回顾一下我们执行的步骤:

  1. 我们已将 InterSystems 提供的 FHIR 适配器工具安装在配置为支持互操作性的命名空间(与 EMPI 独立安装生成的命名空间不同的命名空间,在我的例子中称为 WEBINAR)中。
  2. 我们在此命名空间中创建了一个业务操作,它将接收到的HS.FHIRServer.Interop.Request类型的消息转换为 %String,并将其发送到在 EMPI 命名空间 (HSPIDATA) 的生产中配置的业务服务。
  3. 接下来,我们添加了EnsLib.TCP.PassthroughService类的业务服务,该类接收从 WEBINAR 命名空间的生成发送的消息并重定向到业务流程Local.BP.FHIRProcess
  4. 在 BP Local.BP.FHIRProcess 中,我们已将接收到的 Stream 转换为HS.Message.AddUpdateHubRequest类型的对象,并将其发送到业务运营HS.Hub.MPI.Manager ,该管理器将负责将其注册到我们的EMPI。

正如您所看到的,EMPI 功能与 IRIS 集成引擎提供的功能的结合使我们能够使用几乎任何类型的技术。

我希望这篇文章对您有用。如果您有任何问题或建议,您已经知道,请发表评论,我将很乐意为您解答。

原贴作者:@Luis Angel

讨论 (0)1
登录或注册以继续