diff --git a/modules/operation-measure-evaluate-measure/src/blaze/fhir/operation/evaluate_measure/middleware/params.clj b/modules/operation-measure-evaluate-measure/src/blaze/fhir/operation/evaluate_measure/middleware/params.clj index 2b282e8ac..234fab567 100644 --- a/modules/operation-measure-evaluate-measure/src/blaze/fhir/operation/evaluate_measure/middleware/params.clj +++ b/modules/operation-measure-evaluate-measure/src/blaze/fhir/operation/evaluate_measure/middleware/params.clj @@ -13,6 +13,10 @@ (format "Invalid parameter `%s` with value `%s`. Should be a date in format YYYY, YYYY-MM or YYYY-MM-DD." name value)) +(defn- invalid-string-param-msg [name value] + (format "Invalid parameter `%s` with value `%s`. Should be a string." + name value)) + (defn- get-param-value-from-resource [body name] (when (identical? :fhir/Parameters (fhir-spec/fhir-type body)) (some #(when (= name (:name %)) (:value %)) (:parameter body)))) @@ -57,6 +61,14 @@ :fhir/operation-outcome "MSG_PARAM_INVALID" :fhir.issue/expression name)) +(defn- invalid-string-param-anom + [name value] + (ba/incorrect + (invalid-string-param-msg name value) + :fhir/issue "value" + :fhir/operation-outcome "MSG_PARAM_INVALID" + :fhir.issue/expression name)) + (defn- coerce-date "Coerces `value` into a System.Date. @@ -70,6 +82,9 @@ (defn- validate-date [name value] (if (system/date? value) value (invalid-date-param-anom name value))) +(defn- validate-string [name value] + (if (string? value) value (invalid-string-param-anom name value))) + (defn- invalid-report-type-param-msg [report-type] (format "Invalid parameter `reportType` with value `%s`. Should be one of `subject`, `subject-list` or `population`." report-type)) @@ -105,9 +120,9 @@ period-end (get-required-param-value request "periodEnd" coerce-date validate-date) measure (get-param-value - request "measure" (fn [_n v] v)) + request "measure" (fn [_n v] v) validate-string) report-type (get-param-value - request "reportType" coerce-report-type) + request "reportType" coerce-report-type validate-string) subject-ref (coerce-subject-ref-param request)] (let [report-type (some-> report-type type/value)] (if (and (= :get request-method) (= "subject-list" report-type))