Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove Bare Polymorph JSON Properties #772

Merged
merged 1 commit into from
Jul 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/scripts/evaluate-measure-subject-list.sh
Original file line number Diff line number Diff line change
Expand Up @@ -71,15 +71,15 @@ cat <<END
"parameter": [
{
"name": "periodStart",
"value": "2000"
"valueDate": "2000"
},
{
"name": "periodEnd",
"value": "2030"
"valueDate": "2030"
},
{
"name": "reportType",
"value": "subject-list"
"valueCode": "subject-list"
}
]
}
Expand Down
2 changes: 1 addition & 1 deletion docs/cql-queries/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ Under `group[0].population[0].count` the result of the query can be found.
By default, the evaluation results in a MeasureReport of type `summary`. Such a MeasureReport contains only the number of resources of each population. However, if you also need the resources itself, you can have a MeasureReport of type `subject-list` generated. This works as follows:

```sh
curl -sd '{"resourceType": "Parameters", "parameter": [{"name": "periodStart", "value": "2000"}, {"name": "periodEnd", "value": "2030"}, {"name": "measure", "value": "urn:uuid:49f4c7de-3320-4208-8e60-ecc0d8824e08"}, {"name": "reportType", "value": "subject-list"}]}' -H "Content-Type: application/fhir+json" 'http://localhost:8080/fhir/Measure/$evaluate-measure'
curl -sd '{"resourceType": "Parameters", "parameter": [{"name": "periodStart", "valueDate": "2000"}, {"name": "periodEnd", "valueDate": "2030"}, {"name": "measure", "valueString": "urn:uuid:49f4c7de-3320-4208-8e60-ecc0d8824e08"}, {"name": "reportType", "valueCode": "subject-list"}]}' -H "Content-Type: application/fhir+json" 'http://localhost:8080/fhir/Measure/$evaluate-measure'
```

the result should be the following MeasureReport:
Expand Down
2 changes: 1 addition & 1 deletion evaluate-measure.sh
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ evaluate-measure() {
}

evaluate-measure-list() {
curl -sd '{"resourceType": "Parameters", "parameter": [{"name": "periodStart", "value": "2000"}, {"name": "periodEnd", "value": "2030"}, {"name": "reportType", "value": "subject-list"}]}' \
curl -sd '{"resourceType": "Parameters", "parameter": [{"name": "periodStart", "valueDate": "2000"}, {"name": "periodEnd", "valueDate": "2030"}, {"name": "reportType", "valueCode": "subject-list"}]}' \
-H "Content-Type: application/fhir+json" "$BASE/Measure/$1/\$evaluate-measure"
}

Expand Down
8 changes: 5 additions & 3 deletions modules/fhir-structure/src/blaze/fhir/spec/impl.clj
Original file line number Diff line number Diff line change
Expand Up @@ -374,14 +374,16 @@


(defn remove-choice-type
"Removes the type suffix from the first key of a choice typed data element."
"Removes the type suffix from the first key of a choice typed data element.

Also removes bare properties with key `key` if no typed keys were found."
[m typed-keys key]
(loop [[k & keys] typed-keys]
(if k
(if-some [v (get m k)]
(-> (dissoc m k) (assoc key v))
(recur keys))
m)))
(dissoc m key))))


(def ^:private choice-type-key-cache
Expand All @@ -392,7 +394,7 @@
(keyword (str (name key) (str/capital (name type)))))))))


(defn choice-type-key [key type]
(defn- choice-type-key [key type]
(.get ^LoadingCache choice-type-key-cache [key type]))


Expand Down
28 changes: 25 additions & 3 deletions modules/fhir-structure/test/blaze/fhir/spec_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -4332,9 +4332,9 @@
[#fhir/Extension
{:value #fhir/Reference{:reference "Patient/153540"}}]}
#fhir/uri
{:extension
[#fhir/Extension
{:value #fhir/Reference{:reference "Observation/153628"}}]}]}
{:extension
[#fhir/Extension
{:value #fhir/Reference{:reference "Observation/153628"}}]}]}
[["Procedure" "153904"]
["Condition" "153931"]
["Patient" "153540"]
Expand Down Expand Up @@ -4381,6 +4381,28 @@
["Observation" "204754"]])))


(deftest task-test
(testing "conforming"
(s2/form :fhir.json.Task/output)
(testing "JSON"
(are [json fhir] (= fhir (s2/conform :fhir.json/Task json))
{:resourceType "Task"
:output
[{:valueReference {:reference "bar"}}]}
{:fhir/type :fhir/Task
:output
[{:fhir/type :fhir.Task/output
:value #fhir/Reference{:reference "bar"}}]})

(testing "bare :value properties are removed"
(are [json fhir] (= fhir (s2/conform :fhir.json/Task json))
{:resourceType "Task"
:output
[{:value {:reference "bar"}}]}
{:fhir/type :fhir/Task
:output
[{:fhir/type :fhir.Task/output}]})))))

(deftest primitive-val-test
(are [x] (fhir-spec/primitive-val? x)
"foo"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@
:value #fhir/date"2015"}
{:fhir/type :fhir.Parameters/parameter
:name "measure"
:value "measure-202606"}]}}]]
:value #fhir/string"measure-202606"}]}}]]
(let [{:blaze.fhir.operation.evaluate-measure/keys [params]}
@(handler request)]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,7 @@
:parameter
[{:fhir/type :fhir.Parameters/parameter
:name "measure"
:value "url-181501"}
:value #fhir/string"url-181501"}
{:fhir/type :fhir.Parameters/parameter
:name "periodStart"
:value #fhir/date"2014"}
Expand Down