Skip to content

Commit

Permalink
FHIRpath error message, new AOE codes, and zip code fix (#16821)
Browse files Browse the repository at this point in the history
* added missing AOE codes

* handle hyphenated zipcode

* log detailed message when evaluating fhirpath

* fix unit test for error log
  • Loading branch information
lucero-v authored Dec 17, 2024
1 parent 0d7a9f2 commit 226e3e8
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 5 deletions.
2 changes: 2 additions & 0 deletions prime-router/metadata/tables/local/observation-mapping.csv
Original file line number Diff line number Diff line change
Expand Up @@ -24283,3 +24283,5 @@ Code,Name,Status,Version,Created At,Descriptor,Member OID,Code System,Value Sour
30525-0,Public health laboratory ask at order entry panel,Active,2.04,2/24/2024,Age,,LOINC,LOINC.org,AOE,Ask at order entry question,ReportStream,1
76691-5,,Active,2.73,45346,Gender Identity,,LOINC,LOINC.org,AOE,Ask at order entry question,ReportStream,1
75617-1,,Active,2.73,45346,Residence,,LOINC,LOINC.org,AOE,Ask at order entry question,ReportStream,1
75325-1,COVID-19 health questions panel,Active,2.73,45346,Symptom,,LOINC,LOINC.org,AOE,Ask at order entry question,ReportStream,1
35659-2,Laboratory ask at order entry panel,Active,2.71,12/03/2024,Age at specimen collection,,LOINC,LOINC.org,AOE,Ask at order entry question,ReportStream,1
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ class CustomFhirPathFunctions : FhirPathFunctions {
val lookupTable = metadata.findLookupTable("zip-code-data")
var filters = lookupTable?.FilterBuilder() ?: error("Could not find table zip-code-data")

val zipCode = focus[0].primitiveValue()
val zipCode = focus[0].primitiveValue().substringBefore("-")
filters = filters.isEqualTo("zipcode", zipCode)
val result = filters.findAllUnique("state_abbr")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ object FhirPathUtils : Logging {
pathEngine.evaluate(appContext, focusResource, bundle, bundle, expressionNode)
}
} catch (e: FHIRLexer.FHIRLexerException) {
logger.error("${e.javaClass.name}: Syntax error in FHIR Path $expression.")
logger.error("FHIRLexerException: ${e.message}. Trying to evaluate: $expression.")
emptyList()
} catch (e: IndexOutOfBoundsException) {
// This happens when a non-string value is given to an extension field.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ class CustomFhirPathFunctionTest {
mockkObject(Metadata)
every { Metadata.getInstance() } returns UnitTestUtils.simpleMetadata

val result = CustomFhirPathFunctions().getStateFromZipCode(mutableListOf(StringType("92356")))
val result = CustomFhirPathFunctions().getStateFromZipCode(mutableListOf(StringType("92356-7678")))

assertThat(
(result[0] as StringType).value
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,8 @@ class FhirPathUtilsTests {

verify {
mockedLogger.error(
"org.hl7.fhir.r4.fhirpath.FHIRLexer\$FHIRLexerException: " +
"Syntax error in FHIR Path Bundle.#*(\$&id.exists()."
"FHIRLexerException: Error in ?? at 1, 1: Found # expecting a token name. " +
"Trying to evaluate: Bundle.#*(\$&id.exists()."
)
}
}
Expand Down

0 comments on commit 226e3e8

Please sign in to comment.