コード例 #1
0
 def test_parse_batch3(self):
     batch = hl7.parse_batch(sample_batch3)
     self.assertEqual(len(batch), 1)
     self.assertIsInstance(batch[0], hl7.Message)
     self.assertIsInstance(batch.header, hl7.Segment)
     self.assertEqual(batch.header[0][0], "BHS")
     self.assertEqual(batch.header[4][0], "ABCHS")
     self.assertIsInstance(batch.trailer, hl7.Segment)
     self.assertEqual(batch.trailer[0][0], "BTS")
コード例 #2
0
 def test_parse_batch2(self):
     batch = hl7.parse_batch(sample_batch2)
     self.assertEqual(len(batch), 2)
     self.assertIsInstance(batch[0], hl7.Message)
     self.assertEqual(batch[0][0][10][0], "12334456778890")
     self.assertIsInstance(batch[1], hl7.Message)
     self.assertEqual(batch[1][0][10][0], "12334456778891")
     self.assertFalse(batch.header)
     self.assertFalse(batch.trailer)
コード例 #3
0
ファイル: test.py プロジェクト: LikaloLLC/likalo.com
def send_message(server, port):
    client = MLLPClient(server, port)

    f = open('test.dat', 'r')
    ff = f.read()

    messages = hl7.parse_batch(ff)

    for message in messages:

        client.send_message(str(message))
コード例 #4
0
 def test_parse_batch1(self):
     batch = hl7.parse_batch(sample_batch1)
     self.assertEqual(len(batch), 2)
     self.assertIsInstance(batch[0], hl7.Message)
     self.assertEqual(batch[0][0][10][0], "12334456778890")
     self.assertIsInstance(batch[1], hl7.Message)
     self.assertEqual(batch[1][0][10][0], "12334456778891")
     self.assertIsInstance(batch.header, hl7.Segment)
     self.assertEqual(batch.header[0][0], "BHS")
     self.assertEqual(batch.header[4][0], "ABCHS")
     self.assertIsInstance(batch.trailer, hl7.Segment)
     self.assertEqual(batch.trailer[0][0], "BTS")
     self.assertEqual(batch.trailer[1][0], "2")
コード例 #5
0
 def test_parse_batch4(self):
     batch = hl7.parse_batch(sample_batch4)
     self.assertEqual(len(batch), 1)
     self.assertIsInstance(batch[0], hl7.Message)
     self.assertIsNone(batch.header)
     self.assertIsNone(batch.trailer)
コード例 #6
0
 def test_parse_bad_batch1(self):
     with self.assertRaises(ParseException) as cm:
         hl7.parse_batch(sample_bad_batch1)
     self.assertIn(
         "Batch cannot have more than one BHS segment", cm.exception.args[0]
     )
コード例 #7
0
 def test_parse_bad_batch(self):
     with self.assertRaises(ParseException) as cm:
         hl7.parse_batch(sample_bad_batch)
     self.assertIn("Segment received before message header", cm.exception.args[0])