Skip to content

Commit 6530d48

Browse files
committed
Fix OBX repeat counts for V24 (fixes #341).
1 parent f715b54 commit 6530d48

File tree

2 files changed

+344
-68
lines changed

2 files changed

+344
-68
lines changed

src/NHapi.Model.V24/Segment/OBX.cs

Lines changed: 220 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -53,15 +53,15 @@ public OBX(IGroup parent, IModelClassFactory factory) : base(parent,factory) {
5353
this.add(typeof(Varies), false, 0, 65536, new System.Object[]{message}, "Observation Value");
5454
this.add(typeof(CE), false, 1, 250, new System.Object[]{message}, "Units");
5555
this.add(typeof(ST), false, 1, 60, new System.Object[]{message}, "References Range");
56-
this.add(typeof(IS), false, 1, 5, new System.Object[]{message, 78}, "Abnormal Flags");
57-
this.add(typeof(NM), false, 5, 5, new System.Object[]{message}, "Probability");
58-
this.add(typeof(ID), false, 1, 2, new System.Object[]{message, 80}, "Nature of Abnormal Test");
56+
this.add(typeof(IS), false, 5, 5, new System.Object[]{message, 78}, "Abnormal Flags");
57+
this.add(typeof(NM), false, 1, 5, new System.Object[]{message}, "Probability");
58+
this.add(typeof(ID), false, 0, 2, new System.Object[]{message, 80}, "Nature of Abnormal Test");
5959
this.add(typeof(ID), true, 1, 1, new System.Object[]{message, 85}, "Observation Result Status");
6060
this.add(typeof(TS), false, 1, 26, new System.Object[]{message}, "Date Last Observation Normal Value");
6161
this.add(typeof(ST), false, 1, 20, new System.Object[]{message}, "User Defined Access Checks");
6262
this.add(typeof(TS), false, 1, 26, new System.Object[]{message}, "Date/Time of the Observation");
6363
this.add(typeof(CE), false, 1, 250, new System.Object[]{message}, "Producer's ID");
64-
this.add(typeof(XCN), false, 1, 250, new System.Object[]{message}, "Responsible Observer");
64+
this.add(typeof(XCN), false, 0, 250, new System.Object[]{message}, "Responsible Observer");
6565
this.add(typeof(CE), false, 0, 250, new System.Object[]{message}, "Observation Method");
6666
this.add(typeof(EI), false, 0, 22, new System.Object[]{message}, "Equipment Instance Identifier");
6767
this.add(typeof(TS), false, 1, 26, new System.Object[]{message}, "Date/Time of the Analysis");
@@ -269,6 +269,7 @@ public ST ReferencesRange
269269
///<summary>
270270
/// Returns Abnormal Flags(OBX-8).
271271
///</summary>
272+
[Obsolete("Use 'GetAbnormalFlags(int rep)' instead.")]
272273
public IS AbnormalFlags
273274
{
274275
get{
@@ -289,11 +290,71 @@ public IS AbnormalFlags
289290
}
290291
}
291292

293+
///<summary>
294+
/// Returns a single repetition of Abnormal Flags(OBX-8).
295+
/// throws HL7Exception if the repetition number is invalid.
296+
/// <param name="rep">The repetition number (this is a repeating field)</param>
297+
///</summary>
298+
public IS GetAbnormalFlags(int rep)
299+
{
300+
IS ret = null;
301+
try
302+
{
303+
IType t = this.GetField(8, rep);
304+
ret = (IS)t;
305+
} catch (System.Exception ex) {
306+
HapiLogFactory.GetHapiLog(GetType()).Error("Unexpected problem obtaining field value. This is a bug.", ex);
307+
throw new System.Exception("An unexpected error occurred", ex);
308+
}
309+
return ret;
310+
}
311+
312+
///<summary>
313+
/// Returns all repetitions of Abnormal Flags (OBX-8).
314+
///</summary>
315+
public IS[] GetAbnormalFlags() {
316+
IS[] ret = null;
317+
try {
318+
IType[] t = this.GetField(8);
319+
ret = new IS[t.Length];
320+
for (int i = 0; i < ret.Length; i++) {
321+
ret[i] = (IS)t[i];
322+
}
323+
} catch (HL7Exception he) {
324+
HapiLogFactory.GetHapiLog(this.GetType()).Error("Unexpected problem obtaining field value. This is a bug.", he);
325+
throw new System.Exception("An unexpected error occurred", he);
326+
} catch (System.Exception cce) {
327+
HapiLogFactory.GetHapiLog(GetType()).Error("Unexpected problem obtaining field value. This is a bug.", cce);
328+
throw new System.Exception("An unexpected error occurred", cce);
329+
}
330+
return ret;
331+
}
332+
333+
///<summary>
334+
/// Returns the total repetitions of Abnormal Flags (OBX-8).
335+
///</summary>
336+
public int AbnormalFlagsRepetitionsUsed
337+
{
338+
get{
339+
try {
340+
return GetTotalFieldRepetitionsUsed(8);
341+
}
342+
catch (HL7Exception he) {
343+
HapiLogFactory.GetHapiLog(this.GetType()).Error("Unexpected problem obtaining field value. This is a bug.", he);
344+
throw new System.Exception("An unexpected error occurred", he);
345+
} catch (System.Exception cce) {
346+
HapiLogFactory.GetHapiLog(GetType()).Error("Unexpected problem obtaining field value. This is a bug.", cce);
347+
throw new System.Exception("An unexpected error occurred", cce);
348+
}
349+
}
350+
}
351+
292352
///<summary>
293353
/// Returns a single repetition of Probability(OBX-9).
294354
/// throws HL7Exception if the repetition number is invalid.
295355
/// <param name="rep">The repetition number (this is a repeating field)</param>
296356
///</summary>
357+
[Obsolete("Use 'Probability' instead.")]
297358
public NM GetProbability(int rep)
298359
{
299360
NM ret = null;
@@ -311,6 +372,7 @@ public NM GetProbability(int rep)
311372
///<summary>
312373
/// Returns all repetitions of Probability (OBX-9).
313374
///</summary>
375+
[Obsolete("Use 'Probability' instead.")]
314376
public NM[] GetProbability() {
315377
NM[] ret = null;
316378
try {
@@ -332,6 +394,7 @@ public NM[] GetProbability() {
332394
///<summary>
333395
/// Returns the total repetitions of Probability (OBX-9).
334396
///</summary>
397+
[Obsolete("'Probability' should only have 1 repetition.")]
335398
public int ProbabilityRepetitionsUsed
336399
{
337400
get{
@@ -346,10 +409,93 @@ public int ProbabilityRepetitionsUsed
346409
throw new System.Exception("An unexpected error ocurred", cce);
347410
}
348411
}
412+
}
413+
414+
///<summary>
415+
/// Returns Probability(OBX-9).
416+
///</summary>
417+
public NM Probability
418+
{
419+
get{
420+
NM ret = null;
421+
try
422+
{
423+
IType t = this.GetField(9, 0);
424+
ret = (NM)t;
425+
}
426+
catch (HL7Exception he) {
427+
HapiLogFactory.GetHapiLog(GetType()).Error("Unexpected problem obtaining field value. This is a bug.", he);
428+
throw new System.Exception("An unexpected error occurred", he);
429+
} catch (System.Exception ex) {
430+
HapiLogFactory.GetHapiLog(GetType()).Error("Unexpected problem obtaining field value. This is a bug.", ex);
431+
throw new System.Exception("An unexpected error occurred", ex);
432+
}
433+
return ret;
434+
}
435+
}
436+
437+
///<summary>
438+
/// Returns a single repetition of Nature of Abnormal Test(OBX-10).
439+
/// throws HL7Exception if the repetition number is invalid.
440+
/// <param name="rep">The repetition number (this is a repeating field)</param>
441+
///</summary>
442+
public ID GetNatureOfAbnormalTest(int rep)
443+
{
444+
ID ret = null;
445+
try
446+
{
447+
IType t = this.GetField(10, rep);
448+
ret = (ID)t;
449+
} catch (System.Exception ex) {
450+
HapiLogFactory.GetHapiLog(GetType()).Error("Unexpected problem obtaining field value. This is a bug.", ex);
451+
throw new System.Exception("An unexpected error occurred", ex);
452+
}
453+
return ret;
454+
}
455+
456+
///<summary>
457+
/// Returns all repetitions of Nature of Abnormal Test (OBX-10).
458+
///</summary>
459+
public ID[] GetNatureOfAbnormalTest() {
460+
ID[] ret = null;
461+
try {
462+
IType[] t = this.GetField(10);
463+
ret = new ID[t.Length];
464+
for (int i = 0; i < ret.Length; i++) {
465+
ret[i] = (ID)t[i];
466+
}
467+
} catch (HL7Exception he) {
468+
HapiLogFactory.GetHapiLog(this.GetType()).Error("Unexpected problem obtaining field value. This is a bug.", he);
469+
throw new System.Exception("An unexpected error occurred", he);
470+
} catch (System.Exception cce) {
471+
HapiLogFactory.GetHapiLog(GetType()).Error("Unexpected problem obtaining field value. This is a bug.", cce);
472+
throw new System.Exception("An unexpected error occurred", cce);
473+
}
474+
return ret;
475+
}
476+
477+
///<summary>
478+
/// Returns the total repetitions of Nature of Abnormal Test (OBX-10).
479+
///</summary>
480+
public int NatureOfAbnormalTestRepetitionsUsed
481+
{
482+
get{
483+
try {
484+
return GetTotalFieldRepetitionsUsed(10);
485+
}
486+
catch (HL7Exception he) {
487+
HapiLogFactory.GetHapiLog(this.GetType()).Error("Unexpected problem obtaining field value. This is a bug.", he);
488+
throw new System.Exception("An unexpected error occurred", he);
489+
} catch (System.Exception cce) {
490+
HapiLogFactory.GetHapiLog(GetType()).Error("Unexpected problem obtaining field value. This is a bug.", cce);
491+
throw new System.Exception("An unexpected error occurred", cce);
492+
}
493+
}
349494
}
350495
///<summary>
351496
/// Returns Nature of Abnormal Test(OBX-10).
352497
///</summary>
498+
[Obsolete("Use 'GetNatureOfAbnormalTest(int rep)' instead.")]
353499
public ID NatureOfAbnormalTest
354500
{
355501
get{
@@ -485,29 +631,89 @@ public CE ProducerSID
485631
}
486632
}
487633

634+
///<summary>
635+
/// Returns Responsible Observer(OBX-16).
636+
///</summary>
637+
[Obsolete("Use 'GetResponsibleObserver(int rep)' instead.")]
638+
public XCN ResponsibleObserver
639+
{
640+
get{
641+
XCN ret = null;
642+
try
643+
{
644+
IType t = this.GetField(16, 0);
645+
ret = (XCN)t;
646+
}
647+
catch (HL7Exception he) {
648+
HapiLogFactory.GetHapiLog(GetType()).Error("Unexpected problem obtaining field value. This is a bug.", he);
649+
throw new System.Exception("An unexpected error ocurred", he);
650+
} catch (System.Exception ex) {
651+
HapiLogFactory.GetHapiLog(GetType()).Error("Unexpected problem obtaining field value. This is a bug.", ex);
652+
throw new System.Exception("An unexpected error ocurred", ex);
653+
}
654+
return ret;
655+
}
656+
}
657+
488658
///<summary>
489-
/// Returns Responsible Observer(OBX-16).
659+
/// Returns a single repetition of Responsible Observer(OBX-16).
660+
/// throws HL7Exception if the repetition number is invalid.
661+
/// <param name="rep">The repetition number (this is a repeating field)</param>
490662
///</summary>
491-
public XCN ResponsibleObserver
663+
public XCN GetResponsibleObserver(int rep)
492664
{
493-
get{
494665
XCN ret = null;
495666
try
496667
{
497-
IType t = this.GetField(16, 0);
668+
IType t = this.GetField(16, rep);
498669
ret = (XCN)t;
499-
}
500-
catch (HL7Exception he) {
501-
HapiLogFactory.GetHapiLog(GetType()).Error("Unexpected problem obtaining field value. This is a bug.", he);
502-
throw new System.Exception("An unexpected error ocurred", he);
503670
} catch (System.Exception ex) {
504671
HapiLogFactory.GetHapiLog(GetType()).Error("Unexpected problem obtaining field value. This is a bug.", ex);
505-
throw new System.Exception("An unexpected error ocurred", ex);
672+
throw new System.Exception("An unexpected error occurred", ex);
506673
}
507674
return ret;
508-
}
509675
}
510676

677+
///<summary>
678+
/// Returns all repetitions of Responsible Observer (OBX-16).
679+
///</summary>
680+
public XCN[] GetResponsibleObserver() {
681+
XCN[] ret = null;
682+
try {
683+
IType[] t = this.GetField(16);
684+
ret = new XCN[t.Length];
685+
for (int i = 0; i < ret.Length; i++) {
686+
ret[i] = (XCN)t[i];
687+
}
688+
} catch (HL7Exception he) {
689+
HapiLogFactory.GetHapiLog(this.GetType()).Error("Unexpected problem obtaining field value. This is a bug.", he);
690+
throw new System.Exception("An unexpected error occurred", he);
691+
} catch (System.Exception cce) {
692+
HapiLogFactory.GetHapiLog(GetType()).Error("Unexpected problem obtaining field value. This is a bug.", cce);
693+
throw new System.Exception("An unexpected error occurred", cce);
694+
}
695+
return ret;
696+
}
697+
698+
///<summary>
699+
/// Returns the total repetitions of Responsible Observer (OBX-16).
700+
///</summary>
701+
public int ResponsibleObserverRepetitionsUsed
702+
{
703+
get{
704+
try {
705+
return GetTotalFieldRepetitionsUsed(16);
706+
}
707+
catch (HL7Exception he) {
708+
HapiLogFactory.GetHapiLog(this.GetType()).Error("Unexpected problem obtaining field value. This is a bug.", he);
709+
throw new System.Exception("An unexpected error occurred", he);
710+
} catch (System.Exception cce) {
711+
HapiLogFactory.GetHapiLog(GetType()).Error("Unexpected problem obtaining field value. This is a bug.", cce);
712+
throw new System.Exception("An unexpected error occurred", cce);
713+
}
714+
}
715+
}
716+
511717
///<summary>
512718
/// Returns a single repetition of Observation Method(OBX-17).
513719
/// throws HL7Exception if the repetition number is invalid.

0 commit comments

Comments
 (0)