Skip to content

Commit

Permalink
Fixed HL7MessageTest tests
Browse files Browse the repository at this point in the history
  • Loading branch information
basiliskus committed Dec 17, 2024
1 parent b4380a6 commit acafb51
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ class HL7ExpressionEvaluatorTest extends Specification {
TestApplicationContext.register(HL7ExpressionEvaluator, evaluator)

messageContent = """MSH|^~\\&|Sender Application^sender.test.com^DNS|Sender Facility^0.0.0.0.0.0.0.0^ISO|Receiver Application^0.0.0.0.0.0.0.0^ISO|Receiver Facility^simulated-lab-id^DNS|20230101010000-0000||ORM^O01^ORM_O01|111111|T|2.5.1
PID|1||11102779^^^CR^MR||SMITH^BB SARAH^^^^^L
"""
PID|1||11102779^^^CR^MR||SMITH^BB SARAH^^^^^L"""
hl7Message = HL7Parser.parse(messageContent)

TestApplicationContext.injectRegisteredImplementations()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,46 +3,21 @@ package gov.hhs.cdc.trustedintermediary.rse2e.hl7
import spock.lang.Specification

class HL7MessageTest extends Specification {
def encodingChars = HL7Parser.getEncodingCharacters("|^~\\&")

def "getUnderlyingData should correctly return itself"() {
given:
def segments = [
MSH: [
"MSH|^~\\&|Epic^1.2.840.114350.1.13.145.2.7.2.695071^ISO\n"
],
PID: [
"PID|1||11102779^^^CR^MR||SMITH^BB SARAH^^^^^L\n"
]
]
def hl7Message = new HL7Message(segments as Map<String, List<String>>, encodingChars)
def messageContent = """MSH|^~\\&|Epic^1.2.840.114350.1.13.145.2.7.2.695071^ISO
PID|1||11102779^^^CR^MR||SMITH^BB SARAH^^^^^L"""
def hl7Message = HL7Parser.parse(messageContent)

expect:
hl7Message.getUnderlyingData() == hl7Message
}

def "getIdentifier should return the MSH-10 identifier of the underlying message"() {
given:
def expectedIdentifier = "0001"
def segments = [
MSH: [
"|",
"^~\\&",
"SISGDSP",
"SISGDSP",
"SISHIERECEIVER^11223344^L,M,N",
"^^L,M,N",
"20230706093730",
"",
"ORU^R01^ORU_R01",
"0001",
"D",
"2.5.1"
]
]

and:
def hl7Message = new HL7Message(segments, encodingChars)
def expectedIdentifier = "001"
def messageContent = "MSH|^~\\&|SISGDSP|SISGDSP|SISHIERECEIVER^11223344^L,M,N|^^L,M,N|20230706093730||ORU^R01^ORU_R01|" + expectedIdentifier + "|D|2.5.1"
def hl7Message = HL7Parser.parse(messageContent)

when:
def name = hl7Message.getIdentifier()
Expand Down

0 comments on commit acafb51

Please sign in to comment.