Skip to content

Commit

Permalink
Support array type for MSH Version ID (#111)
Browse files Browse the repository at this point in the history
  • Loading branch information
senaranya authored Nov 17, 2023
1 parent f31ff81 commit ee4408d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/HL7/Segments/MSH.php
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ public function getProcessingId(int $position = 11)
/**
* Get HL7 version, e.g. 2.1, 2.3, 3.0 etc.
*/
public function getVersionId(int $position = 12): string
public function getVersionId(int $position = 12): string|array
{
return $this->getField($position);
}
Expand Down
11 changes: 11 additions & 0 deletions tests/Segments/MSHTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,17 @@ public function more_than_one_character_as_field_separator_is_not_accepted(): vo
self::assertSame('|', $msh->getField(1), 'MSH Field sep field (MSH(1))');
}

/** @test */
public function version_id_can_be_string_or_array_for_v2_7_onwards(): void
{
$msh = new MSH();
$msh->setVersionId('2.3');
self::assertSame('2.3', $msh->getVersionId());

$msh->setVersionId(['2.7', 'NZL', '1.0']);
self::assertSame(['2.7', 'NZL', '1.0'], $msh->getVersionId());
}

/** @test */
public function index_2_in_MSH_accepts_only_4_character_strings(): void
{
Expand Down

0 comments on commit ee4408d

Please sign in to comment.