microsoft / microsoft/fhir-server

ExpressionParser.ParseInclude() for parameter value 'MedicationRequest:patient' returns SearchParameter not following the R4 and R5 spec

Open
#1,308 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

VSTS-Backlog
Dominant language
TSQL
Stars
1.4k
Forks
592
Avg merge
2d 7h
Merged PRs (30d)
41

Description

**Describe the bug**
ExpressionParser.ParseInclude() for parameter value 'MedicationRequest:patient' returns SearchParameter not following the R4 and R5 spec.
The expression.SearchParameter.TargetResourceType includes { Group, Patient } types.
However the spec specifies that 'MedicationRequest:patient' is of type Patient.
The likely reason for that is that MedicationRequest:subject is of type (Group | Patient) and MedicationRequest:patient is a subset of it.

![image](https://user-images.githubusercontent.com/1086572/94618286-92c94e80-02b3-11eb-94ca-c99b46f1f7a1.png)

[MedicationRequest (R5)](http://hl7.org/fhir/2020Sep/medicationrequest.html)
[MedicationRequest (R4)](http://hl7.org/fhir/medication.html)

This creates an issue in the _revinclude:iterate (WIP) implementation, which requires specifying target type in case there is more than one possible type. Otherwise throws BadRequest.

**To Reproduce**
Steps to reproduce the behavior:
1. run query: "MedicationRequest?_include:MedicationRequest:patient"
2. Debug and stop on this line in SearchOptionsFactory.cs:
var expression = _expressionParser.ParseInclude(parsedIncludeResourceType.ToString(), p.Item2, reversed, true);
3. See that expression.SearchParameter.TargetResourceTypes is of length 2 (Group, Patient) instead of Patient.

**Expected behavior**
The parsed expression.SearchParameter.TargetResourceTypes is of length 2 instead of 1

**Actual behavior**
expression.SearchParameter.TargetResourceTypes is of length 2 (Group, Patient) instead of Patient.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in SearchOptionsFactory.cs at the ParseInclude call shown in the report, then trace ExpressionParser.ParseInclude for the MedicationRequest:patient value. Reproduce the MedicationRequest?_include:MedicationRequest:patient query and verify that the resulting TargetResourceTypes contains only Patient, matching the R4 and R5 references.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
api, backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.