Refer to this Zulip chat: #cql > Data requirements bug for MedicationRequest @ 💬
When multiple ELM data requirements end up collapsed together, the Retrieve.includedIn and Retrieve.include.includeFrom fields end up set to null.
This results in the R5 DataRequirement returned by DataRequirementProcessor.gatherDataRequirements omitting the relatedRequirement extension on the included requirement.
Comments in the ElmCloner indicate it's unsafe to copy the Retrieve.includedIn and Retrieve.include.includeFrom attributes because those IDs could end up removed by the collapse algorithm, however logic was added to the collapse in #1262 to handle rewriting those IDs.
Proposed solution: