diff --git a/src/HL7/Segments/MSH.php b/src/HL7/Segments/MSH.php index 0ef97e0..b196096 100644 --- a/src/HL7/Segments/MSH.php +++ b/src/HL7/Segments/MSH.php @@ -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); } diff --git a/tests/Segments/MSHTest.php b/tests/Segments/MSHTest.php index 0970213..930a9cd 100644 --- a/tests/Segments/MSHTest.php +++ b/tests/Segments/MSHTest.php @@ -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 {