diff --git a/prime-router/src/main/kotlin/SettingsProvider.kt b/prime-router/src/main/kotlin/SettingsProvider.kt index ba98f8a168f..7eaa32d3dee 100644 --- a/prime-router/src/main/kotlin/SettingsProvider.kt +++ b/prime-router/src/main/kotlin/SettingsProvider.kt @@ -5,7 +5,6 @@ import com.fasterxml.jackson.annotation.JsonValue import gov.cdc.prime.router.CustomerStatus.ACTIVE import gov.cdc.prime.router.CustomerStatus.INACTIVE import gov.cdc.prime.router.CustomerStatus.TESTING -import gov.cdc.prime.router.fhirengine.utils.HL7Reader import gov.cdc.prime.router.validation.IItemValidator import gov.cdc.prime.router.validation.MarsOtcElrOnboardingValidator import gov.cdc.prime.router.validation.MarsOtcElrValidator @@ -55,7 +54,6 @@ enum class Topic( val isUniversalPipeline: Boolean = true, val isSendOriginal: Boolean = false, val validator: IItemValidator = NoopItemValidator(), - val hl7ParseConfiguration: HL7Reader.Companion.HL7MessageParseAndConvertConfiguration? = null, ) { FULL_ELR("full-elr", true, false), ETOR_TI("etor-ti", true, false), diff --git a/prime-router/src/main/kotlin/azure/service/SubmissionResponseBuilder.kt b/prime-router/src/main/kotlin/azure/service/SubmissionResponseBuilder.kt index ea6d1b64ee9..eff8dcd02da 100644 --- a/prime-router/src/main/kotlin/azure/service/SubmissionResponseBuilder.kt +++ b/prime-router/src/main/kotlin/azure/service/SubmissionResponseBuilder.kt @@ -110,7 +110,7 @@ class SubmissionResponseBuilder( val isBatch = HL7Reader.isBatch(requestBody, messageCount) if (!isBatch && messageCount == 1) { - val message = HL7Reader.parseHL7Message(requestBody, null) + val message = HL7Reader.parseHL7Message(requestBody) val acceptAcknowledgementType = HL7Reader.getAcceptAcknowledgmentType(message) val ackResponseRequired = acceptAcknowledgmentTypeRespondValues.contains(acceptAcknowledgementType) if (ackResponseRequired) { diff --git a/prime-router/src/main/kotlin/cli/ProcessFhirCommands.kt b/prime-router/src/main/kotlin/cli/ProcessFhirCommands.kt index f6d08814bd9..091f7169439 100644 --- a/prime-router/src/main/kotlin/cli/ProcessFhirCommands.kt +++ b/prime-router/src/main/kotlin/cli/ProcessFhirCommands.kt @@ -523,10 +523,8 @@ class ProcessFhirCommands : CliktCommand( // However, the library used to encode the HL7 message throws an error it there are more than 4 encoding // characters, so this work around exists for that scenario val stringToEncode = hl7String.replace("MSH|^~\\&#|", "MSH|^~\\&|") - val hl7message = HL7Reader.parseHL7Message( - stringToEncode, - null - ) + val hl7message = HL7Reader.parseHL7Message(stringToEncode) + // if a hl7 parsing failure happens, throw error and show the message if (hl7message.toString().lowercase().contains("failed")) { throw CliktError("HL7 parser failure. $hl7message") diff --git a/prime-router/src/main/kotlin/cli/ProcessHl7Commands.kt b/prime-router/src/main/kotlin/cli/ProcessHl7Commands.kt index 0fb2e908c18..9c23ab1c9ec 100644 --- a/prime-router/src/main/kotlin/cli/ProcessHl7Commands.kt +++ b/prime-router/src/main/kotlin/cli/ProcessHl7Commands.kt @@ -47,11 +47,11 @@ class ProcessHl7Commands : CliktCommand( val starterMessages = Hl7InputStreamMessageStringIterator(starterFile.byteInputStream()).asSequence() .map { rawItem -> - HL7Reader.parseHL7Message(rawItem, null) + HL7Reader.parseHL7Message(rawItem) }.toList() val comparisonMessages = Hl7InputStreamMessageStringIterator(comparisonFile.byteInputStream()).asSequence() .map { rawItem -> - HL7Reader.parseHL7Message(rawItem, null) + HL7Reader.parseHL7Message(rawItem) }.toList() starterMessages.forEachIndexed { counter, message -> diff --git a/prime-router/src/main/kotlin/fhirengine/engine/FHIRConverter.kt b/prime-router/src/main/kotlin/fhirengine/engine/FHIRConverter.kt index 2bb90729107..0ce0eb45ab7 100644 --- a/prime-router/src/main/kotlin/fhirengine/engine/FHIRConverter.kt +++ b/prime-router/src/main/kotlin/fhirengine/engine/FHIRConverter.kt @@ -50,11 +50,9 @@ import gov.cdc.prime.router.fhirengine.translation.hl7.FhirTransformer import gov.cdc.prime.router.fhirengine.translation.hl7.utils.CustomContext import gov.cdc.prime.router.fhirengine.translation.hl7.utils.FhirPathUtils import gov.cdc.prime.router.fhirengine.utils.FhirTranscoder -import gov.cdc.prime.router.fhirengine.utils.HL7Reader import gov.cdc.prime.router.fhirengine.utils.HL7Reader.Companion.parseHL7Message import gov.cdc.prime.router.fhirengine.utils.getObservations import gov.cdc.prime.router.fhirengine.utils.getRSMessageType -import gov.cdc.prime.router.fhirengine.utils.isElr import gov.cdc.prime.router.logging.LogMeasuredTime import gov.cdc.prime.router.report.ReportService import gov.cdc.prime.router.validation.IItemValidator @@ -479,7 +477,7 @@ class FHIRConverter( "format" to format.name ) ) { - getBundlesFromRawHL7(rawReport, validator, input.topic.hl7ParseConfiguration) + getBundlesFromRawHL7(rawReport, validator) } } catch (ex: ParseFailureError) { actionLogger.error( @@ -571,7 +569,6 @@ class FHIRConverter( private fun getBundlesFromRawHL7( rawReport: String, validator: IItemValidator, - hL7MessageParseAndConvertConfiguration: HL7Reader.Companion.HL7MessageParseAndConvertConfiguration?, ): List> { val itemStream = Hl7InputStreamMessageStringIterator(rawReport.byteInputStream()).asSequence() @@ -580,17 +577,16 @@ class FHIRConverter( }.toList() return maybeParallelize(itemStream.size, itemStream.stream(), "Generating FHIR bundles in").map { item -> - parseHL7Item(item, hL7MessageParseAndConvertConfiguration) + parseHL7Item(item) }.map { item -> - validateAndConvertHL7Item(item, validator, hL7MessageParseAndConvertConfiguration) + validateAndConvertHL7Item(item, validator) }.collect(Collectors.toList()) } private fun parseHL7Item( item: ProcessedHL7Item, - hL7MessageParseAndConvertConfiguration: HL7Reader.Companion.HL7MessageParseAndConvertConfiguration?, ) = try { - val message = parseHL7Message(item.rawItem, hL7MessageParseAndConvertConfiguration) + val message = parseHL7Message(item.rawItem) item.updateParsed(message) } catch (e: HL7Exception) { item.updateParsed( @@ -605,20 +601,11 @@ class FHIRConverter( private fun validateAndConvertHL7Item( item: ProcessedHL7Item, validator: IItemValidator, - hL7MessageParseAndConvertConfiguration: HL7Reader.Companion.HL7MessageParseAndConvertConfiguration?, ): ProcessedHL7Item = if (item.parsedItem != null) { val validationResult = validator.validate(item.parsedItem) if (validationResult.isValid()) { try { - val bundle = when (hL7MessageParseAndConvertConfiguration) { - null -> HL7toFhirTranslator.getHL7ToFhirTranslatorInstance().translate(item.parsedItem) - else -> - HL7toFhirTranslator - .getHL7ToFhirTranslatorInstance( - hL7MessageParseAndConvertConfiguration.hl7toFHIRMappingLocation - ) - .translate(item.parsedItem) - } + val bundle = HL7toFhirTranslator.getHL7ToFhirTranslatorInstance().translate(item.parsedItem) item.setBundle(bundle) } catch (ex: Exception) { item.setConversionError( diff --git a/prime-router/src/main/kotlin/fhirengine/translation/TranslationSchemaManager.kt b/prime-router/src/main/kotlin/fhirengine/translation/TranslationSchemaManager.kt index 305e02bc35e..b5c97da7463 100644 --- a/prime-router/src/main/kotlin/fhirengine/translation/TranslationSchemaManager.kt +++ b/prime-router/src/main/kotlin/fhirengine/translation/TranslationSchemaManager.kt @@ -442,8 +442,7 @@ class TranslationSchemaManager : Logging { HL7Reader.parseHL7Message( Hl7InputStreamMessageStringIterator(rawValidationInput.output.byteInputStream()) .asSequence() - .first(), - null + .first() ), ) } diff --git a/prime-router/src/main/kotlin/fhirengine/utils/HL7MessageHelpers.kt b/prime-router/src/main/kotlin/fhirengine/utils/HL7MessageHelpers.kt index 4ff78152fac..cbd8b1b4700 100644 --- a/prime-router/src/main/kotlin/fhirengine/utils/HL7MessageHelpers.kt +++ b/prime-router/src/main/kotlin/fhirengine/utils/HL7MessageHelpers.kt @@ -39,7 +39,7 @@ object HL7MessageHelpers : Logging { // Grab the first message to extract some data if not set in the settings val firstMessage = if (hl7RawMsgs.isNotEmpty()) { try { - val message = HL7Reader.parseHL7Message(hl7RawMsgs[0], null) + val message = HL7Reader.parseHL7Message(hl7RawMsgs[0]) Terser(message) } catch (exception: Hl7InputStreamMessageStringIterator.ParseFailureError) { logger.warn("Unable to extract batch header values from HL7: ${hl7RawMsgs[0].take(80)} ...") diff --git a/prime-router/src/main/kotlin/fhirengine/utils/HL7Reader.kt b/prime-router/src/main/kotlin/fhirengine/utils/HL7Reader.kt index 48a842f0e51..2061f59d5ab 100644 --- a/prime-router/src/main/kotlin/fhirengine/utils/HL7Reader.kt +++ b/prime-router/src/main/kotlin/fhirengine/utils/HL7Reader.kt @@ -48,18 +48,6 @@ class HL7Reader { */ data class HL7MessageType(val msh93: String, val msh12: String, val msh213: String) - /** - * Configuration class that contains details on how to parse an HL7 message and then how - * to convert it to FHIR - * - * @param messageModelClass a class that inherits from [Message] - * @param hl7toFHIRMappingLocation the location of the mappings files to convert the message to FHIR - */ - data class HL7MessageParseAndConvertConfiguration( - val messageModelClass: Class, - val hl7toFHIRMappingLocation: String, - ) - /** * Accepts a raw HL7 string and uses the MSH segment to detect the [HL7MessageType] which is then used * to parse the string into an instance of [Message]. If the type is not one that is supported in @@ -67,58 +55,52 @@ class HL7Reader { * * @param rawHL7 the HL7 string to convert into a [Message] * - * @return a [Pair] with parsed message and optional type + * @return a [Message] with parsed message and optional type */ fun parseHL7Message( rawHL7: String, - parseConfiguration: HL7MessageParseAndConvertConfiguration?, ): Message { // A carriage return is the official segment delimiter; a newline is not recognized so we replace // them val carriageReturnFixedHL7 = rawHL7.replace(newLineRegex, "\r") val hl7MessageType = getMessageType(carriageReturnFixedHL7) - return getHL7ParsingContext(hl7MessageType, parseConfiguration).pipeParser.parse(carriageReturnFixedHL7) + return getHL7ParsingContext(hl7MessageType).pipeParser.parse(carriageReturnFixedHL7) } /** * Creates a HAPI context that can be used to parse an HL7 string. If no configuration is passed, the function * will return a context with the HAPI defaults which will defer to that library to determine the kind of message * - * @param hl7MessageParseAndConvertConfiguration optional configuration to use when creating a context */ private fun getHL7ParsingContext( hl7MessageType: HL7MessageType?, - hl7MessageParseAndConvertConfiguration: HL7MessageParseAndConvertConfiguration?, ): HapiContext { - return if (hl7MessageParseAndConvertConfiguration == null) { - if (hl7MessageType?.msh93 == "ORU_R01") { + return when (hl7MessageType?.msh93) { + "ORU_R01" -> { DefaultHapiContext( ParserConfiguration(), ValidationContextFactory.noValidation(), ReportStreamCanonicalModelClassFactory(ORU_R01::class.java), ) - } else if (hl7MessageType?.msh93 == "OML_O21") { + } + "OML_O21" -> { DefaultHapiContext( ParserConfiguration(), ValidationContextFactory.noValidation(), ReportStreamCanonicalModelClassFactory(OML_O21::class.java), ) - } else if (hl7MessageType?.msh93 == "ORM_O01") { + } + "ORM_O01" -> { DefaultHapiContext( ParserConfiguration(), ValidationContextFactory.noValidation(), ReportStreamCanonicalModelClassFactory(ORM_O01::class.java), ) - } else { + } + else -> { DefaultHapiContext(ValidationContextFactory.noValidation()) } - } else { - DefaultHapiContext( - ParserConfiguration(), - ValidationContextFactory.noValidation(), - ReportStreamCanonicalModelClassFactory(hl7MessageParseAndConvertConfiguration.messageModelClass), - ) } } @@ -136,7 +118,7 @@ class HL7Reader { */ @Throws(HL7Exception::class) internal fun getMessageType(rawHL7: String): HL7MessageType { - val message = getHL7ParsingContext(null, null) + val message = getHL7ParsingContext(null) .pipeParser // In order to determine the message configuration, only parse the MSH segment since the type of message // is required in order to accurately parse the message in its entirety diff --git a/prime-router/src/test/kotlin/cli/helpers/HL7DiffHelperTests.kt b/prime-router/src/test/kotlin/cli/helpers/HL7DiffHelperTests.kt index 7164e304dd3..07e2b485888 100644 --- a/prime-router/src/test/kotlin/cli/helpers/HL7DiffHelperTests.kt +++ b/prime-router/src/test/kotlin/cli/helpers/HL7DiffHelperTests.kt @@ -106,8 +106,8 @@ OBR|1||232270000212^ProPhase Diagnostics^2.16.840.1.114222.4.1.238646^ISO|55454- @Test fun `diff hl7`() { - val inputMessage = HL7Reader.parseHL7Message(originalMessage, null) - val outputMessage = HL7Reader.parseHL7Message(comparisonMessage, null) + val inputMessage = HL7Reader.parseHL7Message(originalMessage) + val outputMessage = HL7Reader.parseHL7Message(comparisonMessage) val differences = hl7DiffHelper.diffHl7(inputMessage, outputMessage) assertThat(differences.size).isEqualTo(15) val differences2 = hl7DiffHelper.diffHl7(outputMessage, inputMessage) @@ -116,7 +116,7 @@ OBR|1||232270000212^ProPhase Diagnostics^2.16.840.1.114222.4.1.238646^ISO|55454- @Test fun `test index structure`() { - val outputMessage = HL7Reader.parseHL7Message(comparisonMessage, null) + val outputMessage = HL7Reader.parseHL7Message(comparisonMessage) val outputNames = outputMessage.names val outputMap: MutableMap = mutableMapOf() @@ -133,8 +133,8 @@ OBR|1||232270000212^ProPhase Diagnostics^2.16.840.1.114222.4.1.238646^ISO|55454- @Test fun `test compareHl7Type primitive`() { - val inputMessage = HL7Reader.parseHL7Message(originalMessage, null) - val outputMessage = HL7Reader.parseHL7Message(comparisonMessage, null) + val inputMessage = HL7Reader.parseHL7Message(originalMessage) + val outputMessage = HL7Reader.parseHL7Message(comparisonMessage) val inputVal = ST(inputMessage) inputVal.value = "blah" val outputVal = ST(outputMessage) @@ -168,8 +168,8 @@ OBR|1||232270000212^ProPhase Diagnostics^2.16.840.1.114222.4.1.238646^ISO|55454- @Test fun `test compareHl7Type varies`() { - val inputMessage = HL7Reader.parseHL7Message(originalMessage, null) - val outputMessage = HL7Reader.parseHL7Message(comparisonMessage, null) + val inputMessage = HL7Reader.parseHL7Message(originalMessage) + val outputMessage = HL7Reader.parseHL7Message(comparisonMessage) val inputType = ST(inputMessage) inputType.value = "blah" val outputType = ST(outputMessage) @@ -208,7 +208,7 @@ OBR|1||232270000212^ProPhase Diagnostics^2.16.840.1.114222.4.1.238646^ISO|55454- @Test fun `test compareHl7Type composite`() { - val inputMessage = HL7Reader.parseHL7Message(originalMessage, null) + val inputMessage = HL7Reader.parseHL7Message(originalMessage) val id = ID(inputMessage) id.value = "blah" val nm = NM(inputMessage) @@ -224,7 +224,7 @@ OBR|1||232270000212^ProPhase Diagnostics^2.16.840.1.114222.4.1.238646^ISO|55454- ) assertThat(sameComposite).isEmpty() - val outputMessage = HL7Reader.parseHL7Message(comparisonMessage, null) + val outputMessage = HL7Reader.parseHL7Message(comparisonMessage) val differentComposite = hl7DiffHelper.compareHl7Type( "", inputMessage.msh.getField(4)[0], @@ -239,8 +239,8 @@ OBR|1||232270000212^ProPhase Diagnostics^2.16.840.1.114222.4.1.238646^ISO|55454- @Test fun `test compareHl7Type different types`() { - val inputMessage = HL7Reader.parseHL7Message(originalMessage, null) - val outputMessage = HL7Reader.parseHL7Message(comparisonMessage, null) + val inputMessage = HL7Reader.parseHL7Message(originalMessage) + val outputMessage = HL7Reader.parseHL7Message(comparisonMessage) val inputType = ST(inputMessage) inputType.value = "blah" val outputType = ST(outputMessage) @@ -264,8 +264,8 @@ OBR|1||232270000212^ProPhase Diagnostics^2.16.840.1.114222.4.1.238646^ISO|55454- @Test fun `expect no diff messages have blank vs empty MSH 8 (ST), OBR 49 (CWE) respectively`() { - val inputMessage = HL7Reader.parseHL7Message(msgMSH8OBR49Blank, null) - val outputMessage = HL7Reader.parseHL7Message(msgMSH8OBR49Empty, null) + val inputMessage = HL7Reader.parseHL7Message(msgMSH8OBR49Blank) + val outputMessage = HL7Reader.parseHL7Message(msgMSH8OBR49Empty) val differences = hl7DiffHelper.diffHl7(inputMessage, outputMessage) assertThat(differences.size).isEqualTo(0) val differences2 = hl7DiffHelper.diffHl7(outputMessage, inputMessage) @@ -276,8 +276,8 @@ OBR|1||232270000212^ProPhase Diagnostics^2.16.840.1.114222.4.1.238646^ISO|55454- fun `diff output, input missing segments`() { val msg = originalMessage.split("\n").toMutableList() msg.removeAt(1) - val inputMessage = HL7Reader.parseHL7Message(msg.joinToString("\n"), null) - val outputMessage = HL7Reader.parseHL7Message(originalMessage, null) + val inputMessage = HL7Reader.parseHL7Message(msg.joinToString("\n")) + val outputMessage = HL7Reader.parseHL7Message(originalMessage) val differences = hl7DiffHelper.diffHl7(inputMessage, outputMessage) // input missing seg SFT assertThat(differences.size).isEqualTo(1) diff --git a/prime-router/src/test/kotlin/fhirengine/translation/HL7toFhirTranslatorTests.kt b/prime-router/src/test/kotlin/fhirengine/translation/HL7toFhirTranslatorTests.kt index 2ad69e90898..a7d8e1838a4 100644 --- a/prime-router/src/test/kotlin/fhirengine/translation/HL7toFhirTranslatorTests.kt +++ b/prime-router/src/test/kotlin/fhirengine/translation/HL7toFhirTranslatorTests.kt @@ -48,7 +48,7 @@ OBX|1|CWE|94558-4^SARS-CoV-2 (COVID-19) Ag [Presence] in Respiratory specimen by @Test fun `test get message template`() { - val message = HL7Reader.parseHL7Message(supportedHL7, null) + val message = HL7Reader.parseHL7Message(supportedHL7) assertThat( HL7MessageHelpers.messageCount(supportedHL7) ).isEqualTo(1) @@ -57,7 +57,7 @@ OBX|1|CWE|94558-4^SARS-CoV-2 (COVID-19) Ag [Presence] in Respiratory specimen by @Test fun `test get message model`() { - val supportedMessage = HL7Reader.parseHL7Message(supportedHL7, null) + val supportedMessage = HL7Reader.parseHL7Message(supportedHL7) assertThat( HL7MessageHelpers.messageCount(supportedHL7) ).isEqualTo(1) @@ -74,7 +74,7 @@ ORC|NW|ORD448811^NIST EHR|||||||20120628070100|||5742200012^Radon^Nicholas^^^^^^ OBR|1|ORD448811^NIST EHR||1000^Hepatitis A B C Panel^99USL|||20120628070100|||||||||5742200012^Radon^Nicholas^^^^^^NPI^L^^^NPI DG1|1||F11.129^Opioid abuse with intoxication,unspecified^I10C|||W|||||||||1 """.trimIndent() - val unsupportedMessage = HL7Reader.parseHL7Message(unsupportedHL7, null) + val unsupportedMessage = HL7Reader.parseHL7Message(unsupportedHL7) assertThat( HL7MessageHelpers.messageCount(unsupportedHL7) ).isEqualTo(1) @@ -84,7 +84,7 @@ DG1|1||F11.129^Opioid abuse with intoxication,unspecified^I10C|||W|||||||||1 @Test fun `test a quick translation to FHIR`() { // Note that FHIR content will be tested as an integration test - val message = HL7Reader.parseHL7Message(supportedHL7, null) + val message = HL7Reader.parseHL7Message(supportedHL7) assertThat( HL7MessageHelpers.messageCount(supportedHL7) ).isEqualTo(1) @@ -96,7 +96,7 @@ DG1|1||F11.129^Opioid abuse with intoxication,unspecified^I10C|||W|||||||||1 @Test fun `test birth date extension addition`() { - val message = HL7Reader.parseHL7Message(supportedHL7ORMWithBirthDateTime, null) + val message = HL7Reader.parseHL7Message(supportedHL7ORMWithBirthDateTime) assertThat( HL7MessageHelpers.messageCount(supportedHL7ORMWithBirthDateTime) ).isEqualTo(1) @@ -121,7 +121,7 @@ DG1|1||F11.129^Opioid abuse with intoxication,unspecified^I10C|||W|||||||||1 @Test fun `test birth date extension is missing when birthdate is only date`() { - val message = HL7Reader.parseHL7Message(supportedHL7ORMWithBirthDate, null) + val message = HL7Reader.parseHL7Message(supportedHL7ORMWithBirthDate) assertThat( HL7MessageHelpers.messageCount(supportedHL7ORMWithBirthDateTime) ).isEqualTo(1) diff --git a/prime-router/src/test/kotlin/fhirengine/translation/hl7/utils/HL7ACKUtilsTest.kt b/prime-router/src/test/kotlin/fhirengine/translation/hl7/utils/HL7ACKUtilsTest.kt index 32250c9c76b..8fb1d4308ee 100644 --- a/prime-router/src/test/kotlin/fhirengine/translation/hl7/utils/HL7ACKUtilsTest.kt +++ b/prime-router/src/test/kotlin/fhirengine/translation/hl7/utils/HL7ACKUtilsTest.kt @@ -47,12 +47,12 @@ class HL7ACKUtilsTest { MSH|^~\&|ReportStream|CDC|Epic|Hospital|20240921000000+0000||ACK|$id|T|2.5.1|||NE|NE MSA|CA|4AFA57FE-D41D-4631-9500-286AAAF797E4 """.trimIndent() - val parsedIncomingMessage = HL7Reader.parseHL7Message(incomingMessage, null) + val parsedIncomingMessage = HL7Reader.parseHL7Message(incomingMessage) val ack = f.utils.generateOutgoingACKMessage(parsedIncomingMessage) - val expected = HL7Reader.parseHL7Message(expectedMessage, null) - val actual = HL7Reader.parseHL7Message(ack, null) + val expected = HL7Reader.parseHL7Message(expectedMessage) + val actual = HL7Reader.parseHL7Message(ack) val diffs = f.hl7DiffHelper.diffHl7(expected, actual) if (diffs.isNotEmpty()) { diff --git a/prime-router/src/test/kotlin/fhirengine/utils/HL7QueueMessageHelpersTests.kt b/prime-router/src/test/kotlin/fhirengine/utils/HL7QueueMessageHelpersTests.kt index 84d749328fc..6f08e4cc95d 100644 --- a/prime-router/src/test/kotlin/fhirengine/utils/HL7QueueMessageHelpersTests.kt +++ b/prime-router/src/test/kotlin/fhirengine/utils/HL7QueueMessageHelpersTests.kt @@ -137,7 +137,7 @@ OBX|1|ST|MLI-4000.15^TEMPERATURE||97.7|deg f|||||R|||19980601184619 val batchFile = HL7MessageHelpers.batchMessages(listOf(hl7Message, hl7Message), receiver) val messages = Hl7InputStreamMessageStringIterator(batchFile.byteInputStream()).asSequence() .map { rawItem -> - HL7Reader.parseHL7Message(rawItem, null) + HL7Reader.parseHL7Message(rawItem) }.toList() assertThat(messages).isNotEmpty() assertThat(messages.size).isEqualTo(2) diff --git a/prime-router/src/test/kotlin/fhirengine/utils/HL7ReaderTests.kt b/prime-router/src/test/kotlin/fhirengine/utils/HL7ReaderTests.kt index d9a25af33d3..dc812f75e97 100644 --- a/prime-router/src/test/kotlin/fhirengine/utils/HL7ReaderTests.kt +++ b/prime-router/src/test/kotlin/fhirengine/utils/HL7ReaderTests.kt @@ -41,7 +41,7 @@ class HL7ReaderTests { // Empty data val badData1 = "" try { - HL7Reader.parseHL7Message(badData1, null) + HL7Reader.parseHL7Message(badData1) } catch (e: Exception) { assertThat(e is HL7Exception).isTrue() assertThat(ExceptionUtils.getRootCause(e) is EncodingNotSupportedException).isTrue() @@ -53,7 +53,7 @@ class HL7ReaderTests { 1,2,3 """.trimIndent() try { - HL7Reader.parseHL7Message(badData2, null) + HL7Reader.parseHL7Message(badData2) } catch (e: Exception) { assertThat(e is HL7Exception).isTrue() assertThat(ExceptionUtils.getRootCause(e) is EncodingNotSupportedException).isTrue() @@ -62,7 +62,7 @@ class HL7ReaderTests { // Some truncated HL7 val badData3 = "MSH|^~\\&#|MEDITECH^2.16.840.1.114222.4.3.2.2.1.321.111^ISO|COCAA^1.2." try { - HL7Reader.parseHL7Message(badData3, null) + HL7Reader.parseHL7Message(badData3) } catch (e: Exception) { assertThat(e is HL7Exception).isTrue() assertThat(ExceptionUtils.getRootCause(e) is EncodingNotSupportedException).isTrue() @@ -86,7 +86,7 @@ OBX|6|CWE|82810-3^Pregnant^LN^^^^2.69||N^No^HL70136||||||F|||202102090000-0600|| NTE|1|L|This is a note|RE SPM|1|b518ef23-1d9a-40c1-ac4b-ed7b438dfc4b||258500001^Nasopharyngeal swab^SCT||||71836000^Nasopharyngeal structure (body structure)^SCT^^^^2020-09-01|||||||||202102090000-0600|202102090000-0600 """.trimIndent() - val message = HL7Reader.parseHL7Message(goodData1, null) + val message = HL7Reader.parseHL7Message(goodData1) assertThat(message.isEmpty).isFalse() } @@ -101,7 +101,7 @@ ORC|RE|73a6e9bd-aaec-418e-813a-0ad33366ca85|73a6e9bd-aaec-418e-813a-0ad33366ca85 OBR|1|73a6e9bd-aaec-418e-813a-0ad33366ca85|b518ef23-1d9a-40c1-ac4b-ed7b438dfc4b|94558-4^SARS-CoV-2 (COVID-19) Ag [Presence] in Respiratory specimen by Rapid immunoassay^LN|||202102090000-0600|202102090000-0600||||||||1629082607^Eddin^Husam^^^^^^CMS&2.16.840.1.113883.3.249&ISO^^^^NPI|^WPN^^^1^386^6825220|||||202102090000-0600|||F OBX|1|CWE|94558-4^SARS-CoV-2 (COVID-19) Ag [Presence] in Respiratory specimen by Rapid immunoassay^LN||260415000^Not detected^SCT|||N^Normal (applies to non-numeric results)^HL70078|||F|||202102090000-0600|||CareStart COVID-19 Antigen test_Access Bio, Inc._EUA^^99ELR||202102090000-0600||||Avante at Ormond Beach^^^^^CLIA&2.16.840.1.113883.4.7&ISO^^^^10D0876999^CLIA|170 North King Road^^Ormond Beach^FL^32174^^^^12127 """.trimIndent() - val message = HL7Reader.parseHL7Message(rawData, null) + val message = HL7Reader.parseHL7Message(rawData) assertThat(message.isEmpty).isFalse() return message } @@ -127,7 +127,7 @@ OBX|1|CWE|94558-4^SARS-CoV-2 (COVID-19) Ag [Presence] in Respiratory specimen by MSH|^~\&|CDC PRIME - Atlanta, Georgia (Dekalb)^2.16.840.1.114222.4.1.237821^ISO|Avante at Ormond Beach^10D0876999^CLIA|PRIME_DOH|Prime ReportStream|20210210170737||ORU^R01^ORU_R01|371784|P||||NE|NE|USA||||PHLabReportNoAck^ELR_Receiver^2.16.840.1.113883.9.11^ISO """.trimIndent() try { - HL7Reader.parseHL7Message(goodData1, null) + HL7Reader.parseHL7Message(goodData1) } catch (e: HL7Exception) { assertThat(e.errorCode).isEqualTo(ErrorCode.REQUIRED_FIELD_MISSING.code) assertThat(ExceptionUtils.getMessage(e)).contains("Can't find version ID - MSH.12 is null") @@ -141,7 +141,7 @@ MSH|^~\&|CDC PRIME - Atlanta, Georgia (Dekalb)^2.16.840.1.114222.4.1.237821^ISO| OBX|1|test|94558-4^SARS-CoV-2 (COVID-19) Ag [Presence] in Respiratory specimen by Rapid immunoassay^LN||260415000^Not detected^SCT|||N^Normal (applies to non-numeric results)^HL70078|||F|||202102090000-0600|||CareStart COVID-19 Antigen test_Access Bio, Inc._EUA^^99ELR||202102090000-0600||||Avante at Ormond Beach^^^^^CLIA&2.16.840.1.113883.4.7&ISO^^^^10D0876999^CLIA|170 North King Road^^Ormond Beach^FL^32174^^^^12127 """.trimIndent() try { - HL7Reader.parseHL7Message(goodData1, null) + HL7Reader.parseHL7Message(goodData1) } catch (e: HL7Exception) { assertThat(ExceptionUtils.getMessage(e)).contains("trying to set data type of OBX-5") } @@ -241,7 +241,7 @@ OBX|1|test|94558-4^SARS-CoV-2 (COVID-19) Ag [Presence] in Respiratory specimen b val justMSH = """ MSH|^~\&|CDC PRIME - Atlanta, Georgia (Dekalb)^2.16.840.1.114222.4.1.237821^ISO|Avante at Ormond Beach^10D0876999^CLIA|PRIME_DOH|Prime ReportStream|20210210170737||ORU^R01^ORU_R01|371784|P|2.5.1|||NE|NE|USA||||PHLabReportNoAck^ELR_Receiver^2.16.840.1.113883.9.11^ISO """.trimIndent() - val message = HL7Reader.parseHL7Message(justMSH, null) + val message = HL7Reader.parseHL7Message(justMSH) val type = HL7Reader.getMessageType(message) assertThat(type).isEqualTo("ORU") } @@ -279,7 +279,7 @@ OBX|1|test|94558-4^SARS-CoV-2 (COVID-19) Ag [Presence] in Respiratory specimen b SFT|Centers for Disease Control and Prevention|0.1-SNAPSHOT|PRIME ReportStream|0.1-SNAPSHOT||20210210 PID|1||2a14112c-ece1-4f82-915c-7b3a8d152eda^^^Avante at Ormond Beach^PI||Buckridge^Kareem^Millie^^^^L||195808100102034|F||2106-3^White^HL70005^^^^2.5.1|688 Leighann Inlet^^South Rodneychester^TX^67071^^^^48077||7275555555:1:^PRN^^roscoe.wilkinson@email.com^1^211^2240784|||||||||U^Unknown^HL70189||||||||N """.trimIndent() - val message = HL7Reader.parseHL7Message(birthTimeMessage, null) + val message = HL7Reader.parseHL7Message(birthTimeMessage) val type = HL7Reader.getBirthTime(message) assertThat(type).isEqualTo("195808100102034") } @@ -291,7 +291,7 @@ OBX|1|test|94558-4^SARS-CoV-2 (COVID-19) Ag [Presence] in Respiratory specimen b SFT|Centers for Disease Control and Prevention|0.1-SNAPSHOT|PRIME ReportStream|0.1-SNAPSHOT||20210210 PID|1||2a14112c-ece1-4f82-915c-7b3a8d152eda^^^Avante at Ormond Beach^PI||Buckridge^Kareem^Millie^^^^L||19580810|F||2106-3^White^HL70005^^^^2.5.1|688 Leighann Inlet^^South Rodneychester^TX^67071^^^^48077||7275555555:1:^PRN^^roscoe.wilkinson@email.com^1^211^2240784|||||||||U^Unknown^HL70189||||||||N """.trimIndent() - val message = HL7Reader.parseHL7Message(birthDateMessage, null) + val message = HL7Reader.parseHL7Message(birthDateMessage) val type = HL7Reader.getBirthTime(message) assertThat(type).isEqualTo("19580810") } @@ -303,7 +303,7 @@ OBX|1|test|94558-4^SARS-CoV-2 (COVID-19) Ag [Presence] in Respiratory specimen b SFT|Centers for Disease Control and Prevention|0.1-SNAPSHOT|PRIME ReportStream|0.1-SNAPSHOT||20210210 PID|1||2a14112c-ece1-4f82-915c-7b3a8d152eda^^^Avante at Ormond Beach^PI||Buckridge^Kareem^Millie^^^^L||19580810|F||2106-3^White^HL70005^^^^2.5.1|688 Leighann Inlet^^South Rodneychester^TX^67071^^^^48077||7275555555:1:^PRN^^roscoe.wilkinson@email.com^1^211^2240784|||||||||U^Unknown^HL70189||||||||N """.trimIndent() - val message = HL7Reader.parseHL7Message(birthDateMessage, null) + val message = HL7Reader.parseHL7Message(birthDateMessage) val type = HL7Reader.getPatientPath(message) assertThat(type).isEqualTo("PATIENT") } @@ -315,7 +315,7 @@ OBX|1|test|94558-4^SARS-CoV-2 (COVID-19) Ag [Presence] in Respiratory specimen b SFT|Centers for Disease Control and Prevention|0.1-SNAPSHOT|PRIME ReportStream|0.1-SNAPSHOT||20210210 PID|1||2a14112c-ece1-4f82-915c-7b3a8d152eda^^^Avante at Ormond Beach^PI||Buckridge^Kareem^Millie^^^^L||19580810|F||2106-3^White^HL70005^^^^2.5.1|688 Leighann Inlet^^South Rodneychester^TX^67071^^^^48077||7275555555:1:^PRN^^roscoe.wilkinson@email.com^1^211^2240784|||||||||U^Unknown^HL70189||||||||N """.trimIndent() - val message = HL7Reader.parseHL7Message(birthDateMessage, null) + val message = HL7Reader.parseHL7Message(birthDateMessage) val type = HL7Reader.getPatientPath(message) assertThat(type).isEqualTo("PATIENT") } @@ -327,7 +327,7 @@ OBX|1|test|94558-4^SARS-CoV-2 (COVID-19) Ag [Presence] in Respiratory specimen b SFT|Centers for Disease Control and Prevention|0.1-SNAPSHOT|PRIME ReportStream|0.1-SNAPSHOT||20210210 PID|1||2a14112c-ece1-4f82-915c-7b3a8d152eda^^^Avante at Ormond Beach^PI||Buckridge^Kareem^Millie^^^^L||19580810|F||2106-3^White^HL70005^^^^2.5.1|688 Leighann Inlet^^South Rodneychester^TX^67071^^^^48077||7275555555:1:^PRN^^roscoe.wilkinson@email.com^1^211^2240784|||||||||U^Unknown^HL70189||||||||N """.trimIndent() - val message = HL7Reader.parseHL7Message(birthDateMessage, null) + val message = HL7Reader.parseHL7Message(birthDateMessage) val type = HL7Reader.getPatientPath(message) assertThat(type).isEqualTo("PATIENT_RESULT/PATIENT") } @@ -339,7 +339,7 @@ OBX|1|test|94558-4^SARS-CoV-2 (COVID-19) Ag [Presence] in Respiratory specimen b SFT|Centers for Disease Control and Prevention|0.1-SNAPSHOT|PRIME ReportStream|0.1-SNAPSHOT||20210210 PID|1||2a14112c-ece1-4f82-915c-7b3a8d152eda^^^Avante at Ormond Beach^PI||Buckridge^Kareem^Millie^^^^L||19580810|F||2106-3^White^HL70005^^^^2.5.1|688 Leighann Inlet^^South Rodneychester^TX^67071^^^^48077||7275555555:1:^PRN^^roscoe.wilkinson@email.com^1^211^2240784|||||||||U^Unknown^HL70189||||||||N """.trimIndent() - val message = HL7Reader.parseHL7Message(birthDateMessage, null) + val message = HL7Reader.parseHL7Message(birthDateMessage) val type = HL7Reader.getPatientPath(message) assertThat(type).isEqualTo(null) } @@ -349,7 +349,7 @@ OBX|1|test|94558-4^SARS-CoV-2 (COVID-19) Ag [Presence] in Respiratory specimen b @Suppress("ktlint:standard:max-line-length") val rawMessage = "MSH|^~\\&|Epic|Hospital|LIMS|StatePHL|20241003000000||ORM^O01^ORM_O01|4AFA57FE-D41D-4631-9500-286AAAF797E4|T|2.5.1|||AL|NE" - val message = HL7Reader.parseHL7Message(rawMessage, null) + val message = HL7Reader.parseHL7Message(rawMessage) assertThat( HL7Reader.getSendingApplication(message) diff --git a/prime-router/src/test/kotlin/validation/MarsOtcElrOnboardingValidatorTests.kt b/prime-router/src/test/kotlin/validation/MarsOtcElrOnboardingValidatorTests.kt index c58020415a1..851576300b1 100644 --- a/prime-router/src/test/kotlin/validation/MarsOtcElrOnboardingValidatorTests.kt +++ b/prime-router/src/test/kotlin/validation/MarsOtcElrOnboardingValidatorTests.kt @@ -16,7 +16,7 @@ class MarsOtcElrOnboardingValidatorTests { this.javaClass.classLoader.getResourceAsStream("validation/marsotcelr/fail_onboarding_pass_prod.hl7") val sampleMessage = sampleMessageInputStream!!.bufferedReader().use { it.readText() } - val message = HL7Reader.parseHL7Message(sampleMessage, null) + val message = HL7Reader.parseHL7Message(sampleMessage) val report = validator.validate(message) assertThat(report.isValid()).isFalse() } @@ -27,7 +27,7 @@ class MarsOtcElrOnboardingValidatorTests { this.javaClass.classLoader.getResourceAsStream("validation/marsotcelr/valid.hl7") val sampleMessage = sampleMessageInputStream!!.bufferedReader().use { it.readText() } - val message = HL7Reader.parseHL7Message(sampleMessage, null) + val message = HL7Reader.parseHL7Message(sampleMessage) val report = validator.validate(message) assertThat(report.isValid()).isTrue() } diff --git a/prime-router/src/test/kotlin/validation/MarsOtcElrValidatorTests.kt b/prime-router/src/test/kotlin/validation/MarsOtcElrValidatorTests.kt index 645a74ddab4..ee5ceb366a0 100644 --- a/prime-router/src/test/kotlin/validation/MarsOtcElrValidatorTests.kt +++ b/prime-router/src/test/kotlin/validation/MarsOtcElrValidatorTests.kt @@ -16,7 +16,7 @@ class MarsOtcElrValidatorTests { this.javaClass.classLoader.getResourceAsStream("validation/marsotcelr/sample_2.hl7") val sampleMessage = sampleMessageInputStream!!.bufferedReader().use { it.readText() } - val message = HL7Reader.parseHL7Message(sampleMessage, null) + val message = HL7Reader.parseHL7Message(sampleMessage) val report = validator.validate(message) assertThat(report.isValid()).isFalse() } @@ -27,7 +27,7 @@ class MarsOtcElrValidatorTests { this.javaClass.classLoader.getResourceAsStream("validation/marsotcelr/valid.hl7") val sampleMessage = sampleMessageInputStream!!.bufferedReader().use { it.readText() } - val message = HL7Reader.parseHL7Message(sampleMessage, null) + val message = HL7Reader.parseHL7Message(sampleMessage) val report = validator.validate(message) assertThat(report.isValid()).isTrue() } @@ -38,7 +38,7 @@ class MarsOtcElrValidatorTests { this.javaClass.classLoader.getResourceAsStream("validation/marsotcelr/valid_altered_msh.hl7") val sampleMessage = sampleMessageInputStream!!.bufferedReader().use { it.readText() } - val message = HL7Reader.parseHL7Message(sampleMessage, null) + val message = HL7Reader.parseHL7Message(sampleMessage) val report = validator.validate(message) assertThat(report.isValid()).isTrue() } diff --git a/prime-router/src/testIntegration/kotlin/datatests/TranslationTests.kt b/prime-router/src/testIntegration/kotlin/datatests/TranslationTests.kt index cfca5b5c76a..f18c57cfbdc 100644 --- a/prime-router/src/testIntegration/kotlin/datatests/TranslationTests.kt +++ b/prime-router/src/testIntegration/kotlin/datatests/TranslationTests.kt @@ -453,10 +453,7 @@ class TranslationTests { * @return a FHIR bundle as a JSON input stream */ private fun translateToFhir(hl7: String, profile: String? = null): InputStream { - val hl7message = HL7Reader.parseHL7Message( - hl7, - null - ) + val hl7message = HL7Reader.parseHL7Message(hl7) val fhirBundle = if (profile == null) { HL7toFhirTranslator().translate(hl7message) } else {