Skip to content

Commit eb9d796

Browse files
authored
Improve query relationship tests (#354)
* Improve query relationship tests - Update simple model to add relationships from Conditions to Encounters - Update simple model to add Medication record type - Update tests to use relationship clauses that use real relationships - Update tests to test relationships with empty secondary sources * npm audit fix
1 parent 89ff93b commit eb9d796

6 files changed

Lines changed: 797 additions & 164 deletions

File tree

package-lock.json

Lines changed: 12 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/simple-modelinfo.xml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,17 @@
2424
<ns4:typeInfo xsi:type="ns4:ClassInfo" name="Condition" baseType="Simple.Record" retrievable="true" primaryCodePath="code">
2525
<ns4:element name="code" elementType="System.Code"/>
2626
<ns4:element name="status" elementType="System.Code"/>
27+
<ns4:element name="encounterId" elementType="System.String"/>
28+
<ns4:element name="period">
29+
<ns4:elementTypeSpecifier xsi:type="ns4:IntervalTypeSpecifier">
30+
<ns4:pointTypeSpecifier xsi:type="ns4:NamedTypeSpecifier" modelName="System" name="DateTime"/>
31+
</ns4:elementTypeSpecifier>
32+
</ns4:element>
33+
</ns4:typeInfo>
34+
<ns4:typeInfo xsi:type="ns4:ClassInfo" name="Medication" baseType="Simple.Record" retrievable="true" primaryCodePath="code">
35+
<ns4:element name="code" elementType="System.Code"/>
36+
<ns4:element name="status" elementType="System.Code"/>
37+
<ns4:element name="encounterId" elementType="System.String"/>
2738
<ns4:element name="period">
2839
<ns4:elementTypeSpecifier xsi:type="ns4:IntervalTypeSpecifier">
2940
<ns4:pointTypeSpecifier xsi:type="ns4:NamedTypeSpecifier" modelName="System" name="DateTime"/>

test/elm/query/data.cql

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,22 @@ define multiSourceWithArrays:
3030

3131
// @Test: QueryRelationship
3232
define withQuery: [Encounter] E
33-
with [Condition] C such that C.id = 'http://cqframework.org/3/2'
33+
with [Condition] C such that C.encounterId = E.id
3434

3535
define withQuery2: [Encounter] E
36-
with [Condition] C such that C.id = 'http://cqframework.org/3'
36+
with [Condition] C such that C.encounterId = E.id and exists(C.status)
37+
38+
define withQueryEmptySecondarySource: [Encounter] E
39+
with [Medication] M such that M.encounterId = E.id
3740

3841
define withOutQuery: [Encounter] E
39-
without [Condition] C such that C.id = 'http://cqframework.org/3/'
42+
without [Condition] C such that C.encounterId = E.id and exists(C.status)
4043

4144
define withOutQuery2: [Encounter] E
42-
without [Condition] C such that C.id = 'http://cqframework.org/3/2'
45+
without [Condition] C such that C.encounterId = E.id
46+
47+
define withOutQueryEmptySecondarySource: [Encounter] E
48+
without [Medication] M such that M.encounterId = E.id
4349

4450
// @Test: QueryLet
4551
define query: [Encounter] E

0 commit comments

Comments
 (0)