Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions src/NHapi.Base/Model/AbstractSegment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -167,13 +167,6 @@ public virtual IType GetField(int number, int rep)
ErrorCode.APPLICATION_INTERNAL_ERROR);
}

if (rep > items[number - 1].MaxRepetitions)
{
throw new HL7Exception(
$"Can't get repetition {rep} from field {number} - maximum repetitions is only {items[number - 1].MaxRepetitions} reps.",
ErrorCode.APPLICATION_INTERNAL_ERROR);
}

// add a rep if necessary ...
if (rep == currentReps)
{
Expand Down
30 changes: 30 additions & 0 deletions tests/NHapi.NUnit/Parser/PipeParserV25Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ namespace NHapi.NUnit.Parser
{
using System;
using System.Collections.Generic;
using System.Linq;

using global::NUnit.Framework;

using NHapi.Base.Model;
using NHapi.Base.Parser;
using NHapi.Model.V25.Datatype;
using NHapi.Model.V25.Message;
Expand Down Expand Up @@ -91,6 +93,34 @@ public void TestObx5DataTypeIsSetFromObx2_AndAllDataTypesAreConstructable(Type e
Assert.IsAssignableFrom(expectedObservationValueType, actualObservationValueType);
}

/// <summary>
/// https://github.com/nHapiNET/nHapi/issues/276.
/// </summary>
[Test]
public void TestParsingQPD3_WhenQPD3HasMultipleRepetitions_NoExceptionIsThrown()
{
var message =
"MSH|^~\\&|PatientManager|IHE|ICS|FORTH|20220215130712||QBP^Q22^QBP_Q21|5b2e49550924456db9e0844e35348144|P|2.5||||||UNICODE UTF-8\r"
+ "QPD|IHE PDQ Query|20220215130712|@PID.5.2^[email protected]^[email protected]^M|||||^^^IHEFACILITY&1.3.6.1.4.1.21367.3000.1.6&ISO~^^^IHEBLUE&1.3.6.1.4.1.21367.13.20.3000&ISO\r"
+ "RCP|I";

var parser = new PipeParser();
var parsed = (QBP_Q21)parser.Parse(message);

var qpd3Fields = parsed.QPD.GetField(3).Cast<Varies>().ToList();

Assert.AreEqual(3, qpd3Fields.Count);

Assert.AreEqual("@PID.5.2", ((GenericPrimitive)((Varies)((GenericComposite)qpd3Fields[0].Data)[0]).Data).Value);
Assert.AreEqual("fname", ((GenericPrimitive)((Varies)((GenericComposite)qpd3Fields[0].Data)[1]).Data).Value);

Assert.AreEqual("@PID.7.1", ((GenericPrimitive)((Varies)((GenericComposite)qpd3Fields[1].Data)[0]).Data).Value);
Assert.AreEqual("20220202", ((GenericPrimitive)((Varies)((GenericComposite)qpd3Fields[1].Data)[1]).Data).Value);

Assert.AreEqual("@PID.8", ((GenericPrimitive)((Varies)((GenericComposite)qpd3Fields[2].Data)[0]).Data).Value);
Assert.AreEqual("M", ((GenericPrimitive)((Varies)((GenericComposite)qpd3Fields[2].Data)[1]).Data).Value);
}

[Test]
public void TestObx5DataTypeIsSetFromObx2_WhenObx2IsEmptyAndDefaultIsSet_DefaultTypeIsUsed()
{
Expand Down