Skip to content

Commit

Permalink
Check function if message is siu message (#39)
Browse files Browse the repository at this point in the history
Add isSiu() check function
  • Loading branch information
lampi87 authored Dec 24, 2020
1 parent 786bdc1 commit 1a7a9d3
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/HL7/MessageHelpersTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,18 @@ public function isAdt(): bool
return false !== strpos($msh->getMessageType(), 'ADT');
}

/**
* Check if given message is a SIU
*
* @return bool
*/
public function isSiu(): bool
{
/** @var MSH $msh */
$msh = $this->getFirstSegmentInstance('MSH');
return false !== strpos($msh->getMessageType(), 'SIU');
}

/**
* Check if given segment is present in the message object
*
Expand Down
7 changes: 7 additions & 0 deletions tests/MessageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -321,10 +321,17 @@ public function message_type_can_be_checked(): void
$msg = new Message("MSH|^~\&|||||||ORM^O01||P|2.3.1|");
self::assertTrue($msg->isOrm());
self::assertFalse($msg->isOru());
self::assertFalse($msg->isSiu());

$msg = new Message("MSH|^~\&|||||||ORU^O01||P|2.3.1|");
self::assertTrue($msg->isOru());
self::assertFalse($msg->isOrm());
self::assertFalse($msg->isSiu());

$msg = new Message("MSH|^~\&|||||||SIU^S12||P|2.3.1|");
self::assertTrue($msg->isSiu());
self::assertFalse($msg->isOrm());
self::assertFalse($msg->isOru());
}

/**
Expand Down

0 comments on commit 1a7a9d3

Please sign in to comment.