1. Go to this page and download the library: Download roundingwell/hl7 library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
roundingwell / hl7 example snippets
use RoundingWell\HL7\MessageFactory;
$factory = new MessageFactory();
// Parse from a string...
$message = $factory->parse($rawHl7);
// ...or straight from a file.
$message = $factory->parseFile('/path/to/message.hl7');
$msh = $message->getMSH();
echo $msh->getMessageControlId()->getValue(); // "599102"
echo $msh->getMessageType()->getTriggerEvent()->getValue(); // "A01"
// Assuming the message is an A01
$pid = $message->getPID();
echo $pid->getDateOfBirth()->getValue();
// Repeating fields return a list of data-type instances.
foreach ($pid->getPatientName() as $name) {
echo $name->getGivenName()->getValue(); // "DONALD"
echo $name->getFamilyName()->getSurname()->getValue(); // "DUCK"
}
// Multiple occurrences of the same segment (e.g. DG1) are available too.
$diagnoses = $message->listDG1();
use RoundingWell\HL7\AcknowledgmentCode;
use RoundingWell\HL7\SymfonyUidGenerator;
use Symfony\Component\Clock\NativeClock;
$ack = $message->generateACK(
AcknowledgmentCode::AA,
new NativeClock(),
new SymfonyUidGenerator(),
);