Skip to content

Commit 3af7a3c

Browse files
committed
Add test for segment IDs greater than three characters
1 parent 4082cbb commit 3af7a3c

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

test/com/nervestaple/hl7_parser/message_test.clj

+12
Original file line numberDiff line numberDiff line change
@@ -104,3 +104,15 @@
104104
{:id "MSA", :fields [{:content ["AR"]} nil {:content [""]}]}]}
105105
(sut/ack-message-fallback {:message-id "20230218125600"}
106106
"AR" "BLERG!")))))
107+
(deftest message-with-long-segment-id
108+
(testing "Parses a message that includes a long segment identifier"
109+
(is (= {:id "ZQRY"
110+
:fields [{:content ["Y"]} {:content ["Y"]} {:content []}
111+
{:content []} {:content []} {:content []} {:content []}
112+
{:content []} {:content []} {:content []} {:content []}
113+
{:content []} {:content []} {:content []}
114+
{:content ["20230915"]} {:content ["000072816"]}
115+
{:content ["1907838"]} {:content []} {:content []}
116+
{:content []} {:content []} {:content []} {:content []}
117+
{:content []} {:content []} {:content []}]}
118+
(first (sut/get-segments (parser/parse (sample/message-long-segment-id)) "ZQRY"))))))

test/com/nervestaple/hl7_parser/sample_message.clj

+11
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,14 @@
3131
"PV1||O|OP^^||||4652^Paulson^Robert|||OP|||||||||9|||||||||||||||||||||||||20061019172717|20061019172718" (char parser/ASCII_CR)
3232
"ORC|NW|20061019172719" (char parser/ASCII_CR)
3333
"OBR|1|20061019172719||76770^Ultrasound: retroperitoneal^C4|||12349876" (char parser/ASCII_CR)))
34+
35+
(defn message-long-segment-id
36+
"Returns a short message that includes a proprietary segment with a long identifier"
37+
[]
38+
(str "MSH|^~\\&|AcmeHIS|StJohn|CATH|StJohn|20061019172719||ORM^O01|"
39+
(. (new Date) getTime) "|P|2.3" (char parser/ASCII_CR)
40+
"PID|||20301||Durden^Tyler^^^Mr.||19700312|M|||88 Punchward Dr.^^Los Angeles^CA^11221^USA|||||||" (char parser/ASCII_CR)
41+
"PV1||O|OP^^||||4652^Paulson^Robert|||OP|||||||||9|||||||||||||||||||||||||20061019172717|20061019172718" (char parser/ASCII_CR)
42+
"ORC|NW|20061019172719" (char parser/ASCII_CR)
43+
"OBR|1|20061019172719||76770^Ultrasound: retroperitoneal^C4|||12349876" (char parser/ASCII_CR)
44+
"ZQRY|Y|Y|||||||||||||20230915|000072816|1907838|||||||||" (char parser/ASCII_CR)))

0 commit comments

Comments
 (0)