@@ -4,14 +4,15 @@ import (
44 "encoding/json"
55 "errors"
66 "fmt"
7- "github.com/samply/blazectl/data"
8- "github.com/samply/blazectl/fhir"
9- fm "github.com/samply/golang-fhir-models/fhir-models/fhir"
10- "github.com/stretchr/testify/assert"
117 "net/http"
128 "net/http/httptest"
139 "net/url"
1410 "testing"
11+
12+ "github.com/samply/blazectl/data"
13+ "github.com/samply/blazectl/fhir"
14+ fm "github.com/samply/golang-fhir-models/fhir-models/fhir"
15+ "github.com/stretchr/testify/assert"
1516)
1617
1718func TestCreateMeasureResource (t * testing.T ) {
@@ -106,6 +107,52 @@ func TestCreateMeasureResource(t *testing.T) {
106107 assert .Equal (t , "InInitialPopulation" , * resource .Group [0 ].Population [0 ].Criteria .Expression )
107108 })
108109
110+ t .Run ("with one group with code and one population" , func (t * testing.T ) {
111+ m := data.Measure {
112+ Group : []data.Group {
113+ {
114+ Code : "observation" ,
115+ Population : []data.Population {
116+ {
117+ Expression : "InInitialPopulation" ,
118+ },
119+ },
120+ },
121+ },
122+ }
123+
124+ resource , err := CreateMeasureResource (m , measureUrl , libraryUrl )
125+ if err != nil {
126+ t .Fatalf ("error while generating the measure resource: %v" , err )
127+ }
128+
129+ assert .Equal (t , 1 , len (resource .Group ))
130+ assert .Equal (t , "observation" , * resource .Group [0 ].Code .Text )
131+ })
132+
133+ t .Run ("with one group with description and one population" , func (t * testing.T ) {
134+ m := data.Measure {
135+ Group : []data.Group {
136+ {
137+ Description : "all the observations" ,
138+ Population : []data.Population {
139+ {
140+ Expression : "InInitialPopulation" ,
141+ },
142+ },
143+ },
144+ },
145+ }
146+
147+ resource , err := CreateMeasureResource (m , measureUrl , libraryUrl )
148+ if err != nil {
149+ t .Fatalf ("error while generating the measure resource: %v" , err )
150+ }
151+
152+ assert .Equal (t , 1 , len (resource .Group ))
153+ assert .Equal (t , "all the observations" , * resource .Group [0 ].Description )
154+ })
155+
109156 t .Run ("with one group and one population and one empty stratifier" , func (t * testing.T ) {
110157 m := data.Measure {
111158 Group : []data.Group {
@@ -185,6 +232,36 @@ func TestCreateMeasureResource(t *testing.T) {
185232 assert .Equal (t , "foo" , * resource .Group [0 ].Stratifier [0 ].Code .Text )
186233 })
187234
235+ t .Run ("with one group and one population and one stratifier with description" , func (t * testing.T ) {
236+ m := data.Measure {
237+ Group : []data.Group {
238+ {
239+ Population : []data.Population {
240+ {
241+ Expression : "InInitialPopulation" ,
242+ },
243+ },
244+ Stratifier : []data.Stratifier {
245+ {
246+ Code : "foo" ,
247+ Description : "the foo stratifier" ,
248+ Expression : "Foo" ,
249+ },
250+ },
251+ },
252+ },
253+ }
254+
255+ resource , err := CreateMeasureResource (m , measureUrl , libraryUrl )
256+ if err != nil {
257+ t .Fatalf ("error while generating the measure resource: %v" , err )
258+ }
259+
260+ assert .Equal (t , 1 , len (resource .Group ))
261+ assert .Equal (t , 1 , len (resource .Group [0 ].Stratifier ))
262+ assert .Equal (t , "the foo stratifier" , * resource .Group [0 ].Stratifier [0 ].Description )
263+ })
264+
188265 t .Run ("with one Condition group" , func (t * testing.T ) {
189266 m := data.Measure {
190267 Group : []data.Group {
0 commit comments