microsoft / microsoft/fhir-server
Observation-code-value-date search not work
- Dominant language
- TSQL
- Stars
- 1.4k
- Forks
- 592
- Avg merge
- 2d 7h
- Merged PRs (30d)
- 41
Description
**Describe the bug**
When create a Observation resource with code and valueDateTime, search for Observation-code-value-date not return correct result.
I believe the root cause is the definition for SearchParameter is incorrect.
"expression" : "value.as(DateTime) | value.as(Period)" should be "expression" : "value.as(dateTime) | value.as(period)"
**FHIR Version?**
Stu3/R4/R5
**Data provider?**
CosmosDB/SQL Server
**To Reproduce**
Steps to reproduce the behavior:
1. Create resource with following payload.
```
{
"resourceType": "Observation",
"id": "f205",
"text": {
"status": "generated",
"div": "
Generated Narrative
status: entered-in-error
category: Vital Signs
code: Temperature
issued: Apr 4, 2013 12:27:00 PM
value: 39 degrees C
interpretation: High
bodySite: Oral cavity
method: Oral temperature taking
ReferenceRanges
-High*38.2 degrees C},
"status": "entered-in-error",
"category": [
{
"coding": [
{
"system": "http://terminology.hl7.org/CodeSystem/observation-category",
"code": "vital-signs",
"display": "Vital Signs"
}
]
}
],
"code": {
"coding": [
{
"system": "http://acme.lab",
"code": "BT",
"display": "Body temperature"
},
{
"system": "http://loinc.org",
"code": "8310-5",
"display": "Body temperature"
},
{
"system": "http://loinc.org",
"code": "8331-1",
"display": "Oral temperature"
},
{
"system": "http://snomed.info/sct",
"code": "56342008",
"display": "Temperature taking"
}
],
"text": "Temperature"
},
"subject": {
"reference": "Patient/f201",
"display": "Roel"
},
"issued": "2013-04-04T13:27:00+01:00",
"performer": [
{
"reference": "Practitioner/f201"
}
],
"valueDateTime": "2013-04-04T13:27:00+01:00",
"interpretation": [
{
"coding": [
{
"system": "http://terminology.hl7.org/CodeSystem/v3-ObservationInterpretation",
"code": "H"
}
]
}
],
"bodySite": {
"coding": [
{
"system": "http://snomed.info/sct",
"code": "74262004",
"display": "Oral cavity"
}
]
},
"method": {
"coding": [
{
"system": "http://snomed.info/sct",
"code": "89003005",
"display": "Oral temperature taking"
}
]
},
"referenceRange": [
{
"high": {
"value": 38.2,
"unit": "degrees C"
}
}
]
}
```
2. Search query:
```
https://import-k.azurewebsites.net/Observation?code-value-date=http://loinc.org|8331-1$lt2022-04-04'
```
**Expected behavior**
Observation should return
**Actual behavior**
search result is empty
Contributor guide
Research direction
Inspect the SearchParameter definition used by Observation-code-value-date and compare its expression with the casing shown in the issue. Reproduce the supplied Observation creation and search query, then verify that the expected Observation is returned after the definition is corrected.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- sql
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100