akarah/hprim

HPRIM 解析器和生成器。

维护者

详细信息

github.com/Akarah/HPRIM

源代码

2.0.5 2021-04-24 04:35 UTC

README

Build Status Total Downloads Latest Stable Version License

重要:支持的 PHP 版本已更新到 7.3+。最后支持的版本:对于 PHP 7.2 => 2.0.2,对于 PHP 7.0 或 7.1 => 1.5.4

介绍

基于 PHP 的 HPRIM v2.x 解析和生成库,灵感来源于 Net-HL7 包(perl)。

安装

composer require Akarah/hprim

使用

导入库

// First, import classes from the library as needed...
use Akarah\HPRIM\Message;
use Akarah\HPRIM\Segment;
use Akarah\HPRIM\Segments\H;
use Akarah\HPRIM\Segments\P;

解析

// Create a Message object from a HL7 string
$msg = new Message("MSH|^~\\&|1|\rPID|||abcd|\r"); // Either \n or \r can be used as segment endings
$P = $msg->getSegmentByIndex(1);
echo $pid->getField(3); // prints 'John'
echo $msg->toString(true); // Prints entire HPRIM string

// Get the first segment
$msg->getFirstSegmentInstance('H'); // Returns the first PID segment. Same as $msg->getSegmentsByName('PID')[0];

// Check if a segment is present in the message object
$msg->hasSegment('P'); // return true or false based on whether PID is present in the $msg object

// Check if a message is empty
$msg = new Message();
$msg->isempty(); // Returns true

创建新消息

// Create an empty Message object, and populate H and P segments... 

其他

有关可用 API 的详细信息,请访问 docs\README

  • 所有以 H 段开头的 HPRIM 消息
  • 所有 HPIM 消息在末尾都有 L 段