Skip to content

Commit

Permalink
Add test for segment IDs greater than three characters
Browse files Browse the repository at this point in the history
  • Loading branch information
cmiles74 committed Oct 10, 2023
1 parent 4082cbb commit 3af7a3c
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
12 changes: 12 additions & 0 deletions test/com/nervestaple/hl7_parser/message_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -104,3 +104,15 @@
{:id "MSA", :fields [{:content ["AR"]} nil {:content [""]}]}]}
(sut/ack-message-fallback {:message-id "20230218125600"}
"AR" "BLERG!")))))
(deftest message-with-long-segment-id
(testing "Parses a message that includes a long segment identifier"
(is (= {:id "ZQRY"
:fields [{:content ["Y"]} {:content ["Y"]} {:content []}
{:content []} {:content []} {:content []} {:content []}
{:content []} {:content []} {:content []} {:content []}
{:content []} {:content []} {:content []}
{:content ["20230915"]} {:content ["000072816"]}
{:content ["1907838"]} {:content []} {:content []}
{:content []} {:content []} {:content []} {:content []}
{:content []} {:content []} {:content []}]}
(first (sut/get-segments (parser/parse (sample/message-long-segment-id)) "ZQRY"))))))
11 changes: 11 additions & 0 deletions test/com/nervestaple/hl7_parser/sample_message.clj
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,14 @@
"PV1||O|OP^^||||4652^Paulson^Robert|||OP|||||||||9|||||||||||||||||||||||||20061019172717|20061019172718" (char parser/ASCII_CR)
"ORC|NW|20061019172719" (char parser/ASCII_CR)
"OBR|1|20061019172719||76770^Ultrasound: retroperitoneal^C4|||12349876" (char parser/ASCII_CR)))

(defn message-long-segment-id
"Returns a short message that includes a proprietary segment with a long identifier"
[]
(str "MSH|^~\\&|AcmeHIS|StJohn|CATH|StJohn|20061019172719||ORM^O01|"
(. (new Date) getTime) "|P|2.3" (char parser/ASCII_CR)
"PID|||20301||Durden^Tyler^^^Mr.||19700312|M|||88 Punchward Dr.^^Los Angeles^CA^11221^USA|||||||" (char parser/ASCII_CR)
"PV1||O|OP^^||||4652^Paulson^Robert|||OP|||||||||9|||||||||||||||||||||||||20061019172717|20061019172718" (char parser/ASCII_CR)
"ORC|NW|20061019172719" (char parser/ASCII_CR)
"OBR|1|20061019172719||76770^Ultrasound: retroperitoneal^C4|||12349876" (char parser/ASCII_CR)
"ZQRY|Y|Y|||||||||||||20230915|000072816|1907838|||||||||" (char parser/ASCII_CR)))

0 comments on commit 3af7a3c

Please sign in to comment.