示例#1
0
        public void Should_be_able_to_()
        {
            const string message1 = @"MSH|^~\&|LIFTLAB||MACHETE||201701131234||ORU^R01|K113|P|
VL1|ABC~XYZ~123|ABC~XYZ~123";

            ParseResult <HL7Entity> parsed = Parser.Parse(message1);

            var query = parsed.CreateQuery(q =>
                                           from msh in q.Select <MSHSegment>()
                                           from vl1 in q.Select <ValueListSegment>()
                                           select vl1);

            var result = parsed.Query(query);

            Assert.That(result.Select(x => x.RepeatedComplexType).HasValue, Is.True);
            Assert.AreEqual(3, result.Select(x => x.RepeatedComplexType).Count());

            string ct1 = result.Select(x => x.RepeatedComplexType)[0].Select(x => x.IdNumber).ValueOrDefault();
            string ct2 = result.Select(x => x.RepeatedComplexType)[1].Select(x => x.IdNumber).ValueOrDefault();
            string ct3 = result.Select(x => x.RepeatedComplexType)[2].Select(x => x.IdNumber).ValueOrDefault();

            Assert.AreEqual("ABC", ct1);
            Assert.AreEqual("XYZ", ct2);
            Assert.AreEqual("123", ct3);
        }
示例#2
0
        public void Verify_Get_can_safely_return_value_from_component()
        {
            const string message1 = @"MSH|^~\&|LIFTLAB||MACHETE||201701131234||ORU^R01|K113|P|";

            ParseResult <HL7Entity> parsed = Parser.Parse(message1);

            var query = parsed.CreateQuery(q =>
                                           from x in q.Select <MSHSegment>()
                                           select x);

            var result = parsed.Query(query);

            string actual = result.Select(x => x.MessageType).Select(x => x.MessageCode).ValueOrDefault();

            Assert.AreEqual("ORU", actual);
        }
示例#3
0
        public void Should_be_able_to_count_ValueList()
        {
            const string message = @"MSH|^~\&|LIFTLAB||MACHETE||201701131234||ORU^R01|K113|P|
VL1|ABC~XYZ~123|ABC~XYZ~123";

            ParseResult <HL7Entity> parsed = Parser.Parse(message);

            var query = parsed.CreateQuery(q =>
                                           from msh in q.Select <MSHSegment>()
                                           from vl1 in q.Select <ValueListSegment>()
                                           select vl1);

            var result = parsed.Query(query);

            Assert.That(result.Select(x => x.RepeatedComplexType).HasValue, Is.True);
            Assert.AreEqual(3, result.Select(x => x.RepeatedComplexType).Count());
        }
示例#4
0
        public void Verify_Get_can_safely_return_value_from_ValueList_component()
        {
            const string message1 = @"MSH|^~\&|LIFTLAB||MACHETE||201701131234||ORU^R01|K113|P|
VL1|ABC~XYZ~123";

            ParseResult <HL7Entity> parsed = Parser.Parse(message1);

            var query = parsed.CreateQuery(q =>
                                           from msh in q.Select <MSHSegment>()
                                           from vl1 in q.Select <ValueListSegment>()
                                           select vl1);

            var result = parsed.Query(query);

            string actual = result.Select(x => x.RepeatedString)[1].ValueOrDefault();

            Assert.AreEqual("XYZ", actual);
        }
示例#5
0
        public void Should_be_possible()
        {
            const string message = @"MSH|^~\&|LIFTLAB||UBERMED||201701131234||ORU^R01|K113|P|
NAX|125^34^-22^-234^569^442^-212^6|1.2^-3.5^5.2~2.0^3.1^-6.2~3.5^7.8^-1.3|^2^3^4~5^^^8~9^10~~17^18^19^20";

            ParseResult <HL7Entity> entityResult = Parser.Parse(message);

            var query = entityResult.CreateQuery(q =>
                                                 from msh in q.Select <MSHSegment>()
                                                 from nas in q.Select <NumericArraySegment>()
                                                 select nas);

            var result = entityResult.Query(query);

            decimal value1 = result.Select(x => x.Array1).Select(x => x.Value1).ValueOrDefault();
            decimal value2 = result.Select(x => x.Array1).Select(x => x.Value2).ValueOrDefault();
            decimal value3 = result.Select(x => x.Array1).Select(x => x.Value3).ValueOrDefault();
            decimal value4 = result.Select(x => x.Array1).Select(x => x.Value4).ValueOrDefault();

            Assert.AreEqual(125, value1);
            Assert.AreEqual(34, value2);
            Assert.AreEqual(-22, value3);
            Assert.AreEqual(-234, value4);
        }
示例#6
0
        public void Should_be_able_to_parse_primitive_typed_ValueList()
        {
            const string message1 = @"MSH|^~\&|LIFTLAB||MACHETE||201701131234||ORU^R01|K113|P|
VL1|ABC~XYZ~123|ABC~XYZ~123";

            ParseResult <HL7Entity> parsed = Parser.Parse(message1);

            var query = parsed.CreateQuery(q =>
                                           from msh in q.Select <MSHSegment>()
                                           from vl1 in q.Select <ValueListSegment>()
                                           select vl1);

            var result = parsed.Query(query);

            string actual = result.Select(x => x.RepeatedString)[0].ValueOrDefault();

            Assert.AreEqual("ABC", actual);
            Assert.That(result.Select(x => x.RepeatedComplexType)[0], Is.Not.Null);
            Assert.That(result.Select(x => x.RepeatedComplexType)[0].HasValue, Is.True);

            string actualId = result.Select(x => x.RepeatedComplexType[0]).Select(x => x.IdNumber).ValueOrDefault();

            Assert.AreEqual("ABC", actualId);
        }