简体   繁体   English

如何在C#中找到HL7字符串的重复字段值?

[英]How do I find the repeating fields value of a HL7 string in C#?

string input = 
@"MSH|^~\&|||||20171218104936.3464||ADT^A01^ADT_A01|56ca00f2-a99a-4593-b6cb-1c141c0ae0cb||2.3.1
EVN||20171218104936.3464
PID|||15197||Test^Dummy^HK||19770628000000.0000|O
PV1||0";

In the string above, the name field ( Test^Dummy^HK ) is a repeating field . 在上面的字符串中,名称字段( Test^Dummy^HK )是重复字段 How can I get that in C# using the nHapi DLL? 如何使用nHapi DLL在C#中获取该信息?

It is quite simple, but before any attempt to retrieve a field, the message needs to be parsed: 这很简单,但是在尝试检索字段之前,需要先对消息进行解析:

string input = 
@"MSH|^~\&|||||20171218104936.3464||ADT^A01^ADT_A01|56ca00f2-a99a-4593-b6cb-1c141c0ae0cb||2.3.1
EVN||20171218104936.3464
PID|||15197||Test^Dummy^HK||19770628000000.0000|O
PV1||0";

ADT_A01 adt = (ADT_A01)(new PipeParser()).Parse(input);

next, the field you are looking for is an XPN datatype, namely an Extended Patient Name. 接下来,您要查找的字段是XPN数据类型,即扩展患者姓名。 The following table lists the first 3 components of the Patient Name. 下表列出了患者姓名的前3个组成部分。

SEQ     LENGTH  DT  OPT TBL#    NAME
XPN.1   194     FN  O           Family Name
XPN.2   30      ST  O           FirstName   Given Name
XPN.3   30      ST  O           Second And Further Given Names Or Initials Thereof

These components can be accessed through thier properties so: 可以通过其属性访问这些组件,以便:

string surname = adt.PID.GetPatientName(0).FamilyName.Surname.Value; //Test
string givenName = adt.PID.GetPatientName(0).GivenName.Value; //Dummy
string secondAndFurtherGivenNamesOrInitialsThereof = adt.PID.GetPatientName(0).SecondAndFurtherGivenNamesOrInitialsThereof.Value; //HK

Since there is no tilde character, the parser assumes that the value provided in the PID-5 corresponds to the first repetition, this is why I have GetPatientName(0) to specify the first repetition. 由于没有波浪号字符,因此解析器假定PID-5中提供的值对应于第一个重复,这就是为什么我要使用GetPatientName(0)来指定第一个重复的原因。 Any attempt to retrieve other repetitions will fail, or yield to null value. 检索其他重复项的任何尝试都将失败,或产生为空值。

Notice that the Family Name is a composite datatype of type FN, here is the FN's component table: 注意,Family Name是FN类型的复合数据类型,这是FN的组件表:

FN.1    50  ST  R       Surname
FN.2    20  ST  O       Own Surname Prefix
FN.3    50  ST  O       Own Surname
FN.4    20  ST  O       Surname Prefix From Partner/Spouse
FN.5    50  ST  O       Surname From Partner/Spouse

An alternative is: 一种替代方法是:

Terser adtTerser = new Terser(adt);
string surname = adtTerser.Get("PID-5.1") = adtTerser.Get("PID-5-1-1")
string givenName = adtTerser.Get("PID-5.2") = adtTerser.Get("PID-5-2-1")
string secondAndFurtherGivenNamesOrInitialsThereof = adtTerser.Get("PID-5-3") = adtTerser.Get("PID-5-3-1")

I have found this useful documentation check it out. 我发现此有用的文档将其签出。 hope that it could help you. 希望对您有帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM