From 9c1f3c2ae22fdbf2b31ec54ad4761eb6abf59d12 Mon Sep 17 00:00:00 2001 From: Aaron Zavora Date: Wed, 8 Mar 2023 16:32:46 -0500 Subject: [PATCH] repeating_index --- .../databricks/labs/smolder/functionsSuite.scala | 13 +++++++++++++ version.sbt | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/test/scala/com/databricks/labs/smolder/functionsSuite.scala b/src/test/scala/com/databricks/labs/smolder/functionsSuite.scala index 1617903..212e0e0 100644 --- a/src/test/scala/com/databricks/labs/smolder/functionsSuite.scala +++ b/src/test/scala/com/databricks/labs/smolder/functionsSuite.scala @@ -70,6 +70,19 @@ class functionsSuite extends SmolderBaseTest { assert(evnType.first().getString(0) === "A03") } + test("Test repeating segment function"){ + //get a "stable identifier" i.e. val for import + val spark2 = spark + import spark2.implicits._ + + val df = Seq("MSH\rTST^1234567890^^^HOSPITALONE^MRN~4646464646^^^HOSPITALTWO^MRN~9431675613^^^HOSPITALTHRE^MRN").toDF("text") + val hl7Df = df.select(parse_hl7_message(df("text")).alias("hl7")) + assert( hl7Df.select(segment_field("TST", 0, col("hl7.segments")).alias("TST_0")).select(repeating_field(col("TST_0"), 0, "~")).first().getString(0) === "1234567890^^^HOSPITALONE^MRN" ) + assert( hl7Df.select(segment_field("TST", 0, col("hl7.segments")).alias("TST_0")).select(repeating_field(col("TST_0"), 1, "~")).first().getString(0) === "4646464646^^^HOSPITALTWO^MRN" ) + assert( hl7Df.select(segment_field("TST", 0, col("hl7.segments")).alias("TST_0")).select(repeating_field(col("TST_0"), 2, "~")).first().getString(0) === "9431675613^^^HOSPITALTHRE^MRN" ) + + } + test("use the segment field and subfield functions to extract the patient's first name") { val file = testFile("single_record.hl7") diff --git a/version.sbt b/version.sbt index de734f7..7131d35 100644 --- a/version.sbt +++ b/version.sbt @@ -1 +1 @@ -version in ThisBuild := "0.0.1-SNAPSHOT" +version in ThisBuild := "0.0.2-SNAPSHOT"