akarah / hprim
HPRIM parser and generator .
2.0.5
2021-04-24 04:35 UTC
Requires
- php: >=7.3
- ext-mbstring: *
- ext-sockets: *
Requires (Dev)
- ext-pcntl: *
- dms/phpunit-arraysubset-asserts: ^0.2
- phpunit/phpunit: ^9
This package is not auto-updated.
Last update: 2025-03-28 07:45:36 UTC
README
Important: Supported PHP version has been updated to 7.3+. Last supported versions: for PHP 7.2 => 2.0.2, for PHP 7.0 or 7.1 => 1.5.4
Introduction
A PHP-based HPRIM v2.x Parsing and Generating library, inspired by Net-HL7 package (perl).
Installation
composer require Akarah/hprim
Usage
Import library
// 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;
Parsing
// 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
Creating new messages
// Create an empty Message object, and populate H and P segments...
Other
Visit docs\README for details on available APIs
- All HPRIM message beginning with H segment
- All HPIM message have L segment at end