Skip to content

Commit 2f4adc2

Browse files
committed
Remove MaxRepetition check, fixes #276 keeps nhapi inline with hapi
1 parent fc250de commit 2f4adc2

File tree

2 files changed

+30
-7
lines changed

2 files changed

+30
-7
lines changed

src/NHapi.Base/Model/AbstractSegment.cs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -167,13 +167,6 @@ public virtual IType GetField(int number, int rep)
167167
ErrorCode.APPLICATION_INTERNAL_ERROR);
168168
}
169169

170-
if (rep > items[number - 1].MaxRepetitions)
171-
{
172-
throw new HL7Exception(
173-
$"Can't get repetition {rep} from field {number} - maximum repetitions is only {items[number - 1].MaxRepetitions} reps.",
174-
ErrorCode.APPLICATION_INTERNAL_ERROR);
175-
}
176-
177170
// add a rep if necessary ...
178171
if (rep == currentReps)
179172
{

tests/NHapi.NUnit/Parser/PipeParserV25Tests.cs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@ namespace NHapi.NUnit.Parser
22
{
33
using System;
44
using System.Collections.Generic;
5+
using System.Linq;
56

67
using global::NUnit.Framework;
78

9+
using NHapi.Base.Model;
810
using NHapi.Base.Parser;
911
using NHapi.Model.V25.Datatype;
1012
using NHapi.Model.V25.Message;
@@ -91,6 +93,34 @@ public void TestObx5DataTypeIsSetFromObx2_AndAllDataTypesAreConstructable(Type e
9193
Assert.IsAssignableFrom(expectedObservationValueType, actualObservationValueType);
9294
}
9395

96+
/// <summary>
97+
/// https://github.com/nHapiNET/nHapi/issues/276.
98+
/// </summary>
99+
[Test]
100+
public void TestParsingQPD3_WhenQPD3HasMultipleRepetitions_NoExceptionIsThrown()
101+
{
102+
var message =
103+
"MSH|^~\\&|PatientManager|IHE|ICS|FORTH|20220215130712||QBP^Q22^QBP_Q21|5b2e49550924456db9e0844e35348144|P|2.5||||||UNICODE UTF-8\r"
104+
+ "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"
105+
+ "RCP|I";
106+
107+
var parser = new PipeParser();
108+
var parsed = (QBP_Q21)parser.Parse(message);
109+
110+
var qpd3Fields = parsed.QPD.GetField(3).Cast<Varies>().ToList();
111+
112+
Assert.AreEqual(3, qpd3Fields.Count);
113+
114+
Assert.AreEqual("@PID.5.2", ((GenericPrimitive)((Varies)((GenericComposite)qpd3Fields[0].Data)[0]).Data).Value);
115+
Assert.AreEqual("fname", ((GenericPrimitive)((Varies)((GenericComposite)qpd3Fields[0].Data)[1]).Data).Value);
116+
117+
Assert.AreEqual("@PID.7.1", ((GenericPrimitive)((Varies)((GenericComposite)qpd3Fields[1].Data)[0]).Data).Value);
118+
Assert.AreEqual("20220202", ((GenericPrimitive)((Varies)((GenericComposite)qpd3Fields[1].Data)[1]).Data).Value);
119+
120+
Assert.AreEqual("@PID.8", ((GenericPrimitive)((Varies)((GenericComposite)qpd3Fields[2].Data)[0]).Data).Value);
121+
Assert.AreEqual("M", ((GenericPrimitive)((Varies)((GenericComposite)qpd3Fields[2].Data)[1]).Data).Value);
122+
}
123+
94124
[Test]
95125
public void TestObx5DataTypeIsSetFromObx2_WhenObx2IsEmptyAndDefaultIsSet_DefaultTypeIsUsed()
96126
{

0 commit comments

Comments
 (0)