Skip to content

Commit

Permalink
failing unit test for issue phatboyg#58 with condition logic in place
Browse files Browse the repository at this point in the history
fixed test issue

add more conditions to X12 maps

added conditional logic to several X12 maps

created more conditions in maps and created failing unit test for issue phatboyg#65

added new failing test for issue phatboyg#65

updated readme and added tests for issue phatboyg#65

fixed gitter link

added appveyor badge

added nuget version badge

added appveyor test status badge

added appveyor test status badge

added appveyor test status badge

modified the readme

added license section to readme

modified readme

added more stuff to readme

modified readme

modified readme

modified readme and tests

updated tests and readme

added tests for X12

added more X12 tests

fixed issue phatboyg#68 and added tests

fixed issue phatboyg#69 and added more X12 parsing tests

added more tests and fixed some X12 schema issues
  • Loading branch information
ahives committed Dec 16, 2018
1 parent 010ac95 commit 52793f1
Show file tree
Hide file tree
Showing 138 changed files with 10,912 additions and 317 deletions.
845 changes: 838 additions & 7 deletions README.md

Large diffs are not rendered by default.

12 changes: 12 additions & 0 deletions src/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Default ignored files
/.idea/shelf/
/.idea/workspace.xml

# Datasource local storage ignored files
/.idea/.idea.Machete/.idea/dataSources/
dataSources.local.xml

# Editor-based HTTP Client requests
/.idea/httpRequests/
rest-client.private.env.json
http-client.private.env.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ public void Should_be_able_to_format_layout()

Assert.That(Schema.TryGetLayoutFormatter(out ILayoutFormatter<TestSchema.ORM_O01_ORDER> formatter), Is.True);

// var formatted = await Formatter.FormatToStringAsync(result);
var context = new StringBuilderFormatContext();

formatter.Format(context, orders[0].Value);
Expand Down
11 changes: 11 additions & 0 deletions src/Machete.HL7.Tests/QueryTests/AdvancedQueryTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,17 @@ select new
};
});

foreach (var orc in result.Result.Tests)
{
if (orc.ORC.PlacerGroupNumber.Select(x => x.EntityIdentifier).IsEqualTo("X0934N"))
{
string placerGroupNumber = orc.ORC
.PlacerGroupNumber
.Select(x => x.EntityIdentifier)
.ValueOrDefault();
}
}

Assert.That(result.HasResult, Is.True);
Assert.AreEqual(3, result.Result.Tests.Count);
Assert.AreEqual(4, result.Result.Notes.Count);
Expand Down
42 changes: 42 additions & 0 deletions src/Machete.HL7.Tests/QueryTests/FirstOrDefaultQueryTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
namespace Machete.HL7.Tests.QueryTests
{
using NUnit.Framework;
using Testing;
using TestSchema;


[TestFixture]
public class FirstOrDefaultQueryTests :
HL7MacheteTestHarness<TestHL7Entity, HL7Entity>
{
[Test]
public void Test()
{
const string message = @"MSH|^~\&|MACHETELAB|^DOSC|MACHETE|18779|20130405125146269||ORM^O01|1999077678|P|2.3|||AL|AL
PID|1|000000000026|60043^^^MACHETE^MRN||MACHETE^JOE||19890909|F|||123 SEASAME STREET^^Oakland^CA^94600||5101234567|5101234567||||||||||||||||N
VL1|a~b~c
VL1|d~e~f
VL1|g~h~i
VL1|j~k~l
VL1|m~n~o
VL1|p~q~r
VL1|s~t~u
VL1|v~w~x
VL1|y~z";

var parse = Parser.Parse(message);

var result = parse.Query(q =>
from msh in q.Select<MSHSegment>()
from pid in q.Select<PIDSegment>()
from vls in q.Select<ValueListSegment>().ZeroOrMore().FirstOrDefault()
select vls);

Assert.IsTrue(result.HasResult);

int count = result.Select(x => x.RepeatedString).Count();

Assert.AreEqual(3, count);
}
}
}
34 changes: 34 additions & 0 deletions src/Machete.HL7.Tests/QueryTests/SelectManyQueryTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
namespace Machete.HL7.Tests.QueryTests
{
using NUnit.Framework;
using Testing;
using TestSchema;


[TestFixture]
public class SelectManyQueryTests :
HL7MacheteTestHarness<TestHL7Entity, HL7Entity>
{
[Test]
public void Test()
{
const string message = @"MSH|^~\&|MACHETELAB|^DOSC|MACHETE|18779|20130405125146269||ORM^O01|1999077678|P|2.3|||AL|AL
PID|1|000000000026|60043^^^MACHETE^MRN||MACHETE^JOE||19890909|F|||123 SEASAME STREET^^Oakland^CA^94600||5101234567|5101234567||||||||||||||||N
VL1|a~b~c
VL1|d~e~f
VL1|g~h~i
VL1|j~k~l
VL1|m~n~o
VL1|p~q~r
VL1|s~t~u
VL1|v~w~x
VL1|y~z";

var parse = Parser.Parse(message);

// var result = parse.Query(q => from msh in q.Select<MSHSegment>()
// from pid in q.Select<PIDSegment>()
// from vls in q.Select<ValueListSegment>().SelectMany(q.Select<ValueListSegment>(), x => x.RepeatedString).ZeroOrMore())
}
}
}
34 changes: 34 additions & 0 deletions src/Machete.HL7.Tests/QueryTests/SingleOrDefaultQueryTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
namespace Machete.HL7.Tests.QueryTests
{
using NUnit.Framework;
using Testing;
using TestSchema;


[TestFixture]
public class SingleOrDefaultQueryTests :
HL7MacheteTestHarness<TestHL7Entity, HL7Entity>
{
[Test]
public void Test()
{
const string message = @"MSH|^~\&|MACHETELAB|^DOSC|MACHETE|18779|20130405125146269||ORM^O01|1999077678|P|2.3|||AL|AL
PID|1|000000000026|60043^^^MACHETE^MRN||MACHETE^JOE||19890909|F|||123 SEASAME STREET^^Oakland^CA^94600||5101234567|5101234567||||||||||||||||N
VL1|a~b~c";

var parse = Parser.Parse(message);

var result = parse.Query(q =>
from msh in q.Select<MSHSegment>()
from pid in q.Select<PIDSegment>()
from vls in q.Select<ValueListSegment>().ZeroOrMore().SingleOrDefault()
select vls);

Assert.IsTrue(result.HasResult);

int count = result.Select(x => x.RepeatedString).Count();

Assert.AreEqual(3, count);
}
}
}
16 changes: 16 additions & 0 deletions src/Machete.HL7.Tests/TestSchema/CNEComponent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
namespace Machete.HL7.Tests.TestSchema
{
public interface CNEComponent :
HL7Component
{
Value<string> Identifier { get; }
Value<string> Text { get; }
Value<string> NameOfCodingSystem { get; }
Value<string> AlternateIdentifier { get; }
Value<string> AlternateText { get; }
Value<string> NameOfAlternateCodingSystem { get; }
Value<string> CodingSystemVersionId { get; }
Value<string> AlternateCodingSystemVersionId { get; }
Value<string> OriginalText { get; }
}
}
19 changes: 19 additions & 0 deletions src/Machete.HL7.Tests/TestSchema/CNEComponentMap.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
namespace Machete.HL7.Tests.TestSchema
{
public class CNEComponentMap :
HL7ComponentMap<CNEComponent, HL7Component>
{
public CNEComponentMap()
{
Value(x => x.Identifier, 0);
Value(x => x.Text, 1);
Value(x => x.NameOfCodingSystem, 2);
Value(x => x.AlternateIdentifier, 3);
Value(x => x.AlternateText, 4);
Value(x => x.NameOfAlternateCodingSystem, 5);
Value(x => x.CodingSystemVersionId, 6);
Value(x => x.AlternateCodingSystemVersionId, 7);
Value(x => x.OriginalText, 8);
}
}
}
18 changes: 18 additions & 0 deletions src/Machete.HL7.Tests/TestSchema/MSASegment.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
namespace Machete.HL7.Tests.TestSchema
{
using System;


public interface MSASegment :
HL7Segment
{
Value<string> AcknowledgmentCode { get; }
Value<string> MessageControlId { get; }
Value<string> TextMessage { get; }
Value<decimal> ExpectedSequenceNumber { get; }
Value<DateTimeOffset> DelayedAcknowledgmentType { get; }
Value<CNEComponent> ErrorCondition { get; }
Value<decimal> MessageWaitingNumber { get; }
Value<string> MessageWaitingPriority { get; }
}
}
22 changes: 22 additions & 0 deletions src/Machete.HL7.Tests/TestSchema/MSASegmentMap.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
namespace Machete.HL7.Tests.TestSchema
{
public class MSASegmentMap :
HL7SegmentMap<MSASegment, HL7Entity>
{
public MSASegmentMap()
{
Id = "MSA";

Name = "Message Acknowledgment";

Value(x => x.AcknowledgmentCode, 1, x => x.IsRequired());
Value(x => x.MessageControlId, 2, x => x.IsRequired());
Value(x => x.TextMessage, 3);
Value(x => x.ExpectedSequenceNumber, 4);
Value(x => x.DelayedAcknowledgmentType, 5, x => {x.Converter = HL7ValueConverters.VariableLongDateTime;});
Entity(x => x.ErrorCondition, 6);
Value(x => x.MessageWaitingNumber, 7);
Value(x => x.MessageWaitingPriority, 8);
}
}
}
5 changes: 5 additions & 0 deletions src/Machete.HL7/HL7LayoutExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
namespace Machete.HL7
{
using System;
using System.Diagnostics;


public static class HL7LayoutExtensions
Expand All @@ -17,6 +18,8 @@ public static class HL7LayoutExtensions
where TLayout : Layout
where TSegment : HL7Segment
{
Debug.Assert(source != null);

if (source == null || !source.HasValue)
return Segment.Missing<TSegment>();

Expand All @@ -35,6 +38,8 @@ public static class HL7LayoutExtensions
where TLayout : Layout
where TSegment : HL7Segment
{
Debug.Assert(source != null);

if (source == null || !source.HasValue)
return SegmentList.Missing<TSegment>();

Expand Down
21 changes: 18 additions & 3 deletions src/Machete.HL7/HL7SegmentExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
namespace Machete.HL7
{
using System;
using System.Diagnostics;


public static class HL7SegmentExtensions
Expand All @@ -17,6 +18,8 @@ public static class HL7SegmentExtensions
where TSegment : HL7Segment
where T : HL7Segment
{
Debug.Assert(source != null);

if (source == null || !source.HasValue)
return Segment.Missing<T>();

Expand All @@ -35,6 +38,8 @@ public static class HL7SegmentExtensions
where TSegment : HL7Segment
where T : HL7Segment
{
Debug.Assert(source != null);

if (source == null || !source.HasValue)
return SegmentList.Missing<T>();

Expand All @@ -48,19 +53,29 @@ public static class HL7SegmentExtensions
/// <returns></returns>
public static bool IsEmpty(this HL7Segment segment)
{
Debug.Assert(segment != null);

if (segment == null)
return true;

return !segment.ParsedText.TryGetSlice(1, out _);
}

/// <summary>
/// Returns true if the component is empty (doesn't contain any text beyond the segmentId)
/// </summary>
/// <param name="segment"></param>
/// <param name="component"></param>
/// <returns></returns>
public static bool IsEmpty(this HL7Component segment)
public static bool IsEmpty(this HL7Component component)
{
Debug.Assert(component != null);

if (component == null)
return true;

for (int i = 0;; i++)
{
if (!segment.ParsedText.TryGetSlice(i, out var nextSlice))
if (!component.ParsedText.TryGetSlice(i, out var nextSlice))
return true;

if (nextSlice.TryGetSlice(0, out _))
Expand Down
Loading

0 comments on commit 52793f1

Please sign in to comment.