Skip to content

Commit

Permalink
Simplify Terminology Service Error Messages
Browse files Browse the repository at this point in the history
Removed the phrase "with URL".
  • Loading branch information
alexanderkiel committed Dec 29, 2024
1 parent 783d99d commit 361206f
Show file tree
Hide file tree
Showing 9 changed files with 248 additions and 268 deletions.
2 changes: 1 addition & 1 deletion .github/value-set-expand/expand-all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ for url in $(blazectl --server "$BASE" download ValueSet -q "_elements=url&_coun
# content: fragment (http://fhir.de/CodeSystem/dkgev/Fachabteilungsschluessel)
continue
else
echo "Expand ValueSet with URL: $url"
echo "Expand ValueSet: $url"
curl -sfH "Accept: application/fhir+json" -o /dev/null "$BASE/ValueSet/\$expand?url=$url"
fi
done
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
:fhir/type := :fhir/OperationOutcome
[:issue 0 :severity] := #fhir/code"error"
[:issue 0 :code] := #fhir/code"not-found"
[:issue 0 :diagnostics] := "The code system with URL `153404` was not found."))))
[:issue 0 :diagnostics] := "The code system `153404` was not found."))))

(testing "without url or id"
(with-handler [handler]
Expand All @@ -102,53 +102,53 @@
:fhir/type := :fhir/OperationOutcome
[:issue 0 :severity] := #fhir/code"error"
[:issue 0 :code] := #fhir/code"invalid"
[:issue 0 :diagnostics] := "Missing required parameter `url`."))))
[:issue 0 :diagnostics] := "Missing required parameter `url`.")))))

(testing "unsupported parameters"
(with-handler [handler]
(doseq [param ["codeableConcept" "date" "abstract"]]
(testing "GET"
(let [{:keys [status body]}
@(handler {:query-params {param "foo"}})]

(is (= 400 status))

(given body
:fhir/type := :fhir/OperationOutcome
[:issue 0 :severity] := #fhir/code"error"
[:issue 0 :code] := #fhir/code"not-supported"
[:issue 0 :diagnostics] := (format "Unsupported parameter `%s`." param))))

(testing "POST"
(let [{:keys [status body]}
@(handler {:request-method :post
:body {:fhir/type :fhir/Parameters
:parameter
[{:fhir/type :fhir.Parameters/parameter
:name (type/string param)
:value (type/string "foo")}]}})]
(testing "unsupported parameters"
(with-handler [handler]
(doseq [param ["codeableConcept" "date" "abstract"]]
(testing "GET"
(let [{:keys [status body]}
@(handler {:query-params {param "foo"}})]

(is (= 400 status))
(is (= 400 status))

(given body
:fhir/type := :fhir/OperationOutcome
[:issue 0 :severity] := #fhir/code"error"
[:issue 0 :code] := #fhir/code"not-supported"
[:issue 0 :diagnostics] := (format "Unsupported parameter `%s`." param)))))))
(given body
:fhir/type := :fhir/OperationOutcome
[:issue 0 :severity] := #fhir/code"error"
[:issue 0 :code] := #fhir/code"not-supported"
[:issue 0 :diagnostics] := (format "Unsupported parameter `%s`." param))))

(testing "unsupported GET parameters"
(with-handler [handler]
(doseq [param ["codeSystem" "coding"]]
(testing "POST"
(let [{:keys [status body]}
@(handler {:query-params {param "foo"}})]
@(handler {:request-method :post
:body {:fhir/type :fhir/Parameters
:parameter
[{:fhir/type :fhir.Parameters/parameter
:name (type/string param)
:value (type/string "foo")}]}})]

(is (= 400 status))

(given body
:fhir/type := :fhir/OperationOutcome
[:issue 0 :severity] := #fhir/code"error"
[:issue 0 :code] := #fhir/code"not-supported"
[:issue 0 :diagnostics] := (format "Unsupported parameter `%s` in GET request. Please use POST." param)))))))
[:issue 0 :diagnostics] := (format "Unsupported parameter `%s`." param)))))))

(testing "unsupported GET parameters"
(with-handler [handler]
(doseq [param ["codeSystem" "coding"]]
(let [{:keys [status body]}
@(handler {:query-params {param "foo"}})]

(is (= 400 status))

(given body
:fhir/type := :fhir/OperationOutcome
[:issue 0 :severity] := #fhir/code"error"
[:issue 0 :code] := #fhir/code"not-supported"
[:issue 0 :diagnostics] := (format "Unsupported parameter `%s` in GET request. Please use POST." param))))))

(testing "successful validation by id"
(with-handler [handler]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
(assoc code-system :default/graph (graph/build-graph concepts))
(ba/not-found
(if version
(format "The code system with URL `%s` and version `%s` was not found." url version)
(format "The code system with URL `%s` was not found." url))))))
(format "The code system `%s` with version `%s` was not found." url version)
(format "The code system `%s` was not found." url))))))

(defmethod c/enhance :default
[_ {concepts :concept :as code-system}]
Expand All @@ -36,7 +36,7 @@

(defn- not-found-msg [{:keys [url]} code]
(if url
(format "The provided code `%s` was not found in the code system with URL `%s`." code (type/value url))
(format "The provided code `%s` was not found in the code system `%s`." code (type/value url))
(format "The provided code `%s` was not found in the provided code system." code)))

(defn- find-concept
Expand All @@ -46,7 +46,7 @@

(defn- check-complete [{:keys [content] :as code-system}]
(when-not (= "complete" (type/value content))
(ba/incorrect (format "Can't use the code system with URL `%s` because it is not complete. It's content is `%s`." (type/value (:url code-system)) (type/value content)))))
(ba/incorrect (format "Can't use the code system `%s` because it is not complete. It's content is `%s`." (type/value (:url code-system)) (type/value content)))))

(defmethod c/validate-code :default
[{:keys [url] :as code-system} request]
Expand All @@ -66,7 +66,7 @@
(u/parameter "message" (type/string message))]})))

(defn- code-system-not-complete-msg [{:keys [url content]}]
(format "Can't expand the code system with URL `%s` because it is not complete. It's content is `%s`."
(format "Can't expand the code system `%s` because it is not complete. It's content is `%s`."
url (type/value content)))

(defn- code-system-not-complete-anom [code-system]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
:sct/version version)))

(defn- code-system-not-found-msg [version]
(format "The code system with URL `http://snomed.info/sct` and version `%s` was not found." version))
(format "The code system `http://snomed.info/sct` with version `%s` was not found." version))

(defmethod c/find :sct
[{:keys [db] :sct/keys [context]} _ & [version]]
Expand All @@ -51,7 +51,7 @@
(assoc-context code-system context))

(defn- not-found-msg [code]
(format "The provided code `%s` was not found in the code system with URL `http://snomed.info/sct`." code))
(format "The provided code `%s` was not found in the code system `http://snomed.info/sct`." code))

(defn- find-concept
[{{:keys [concept-index]} :sct/context :sct/keys [module-id version]} code]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

(defn- validate [code]
(when (.validate ^UcumService service code)
(ba/incorrect (format "The provided code `%s` was not found in the code system with URL `http://unitsofmeasure.org`." code))))
(ba/incorrect (format "The provided code `%s` was not found in the code system `http://unitsofmeasure.org`." code))))

(defmethod c/validate-code :ucum
[{:keys [url version]} request]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
(let [{:keys [system code]} (-> request :coding)]
(if (= url (type/value system))
(type/value code)
(ba/incorrect (format "The system of the provided coding `%s` does not match the code system with URL `%s`." (type/value system) url))))))
(ba/incorrect (format "The system of the provided coding `%s` does not match the code system `%s`." (type/value system) url))))))

(defn parameter [name value]
{:fhir/type :fhir.Parameters/parameter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@
([db url version]
(do-sync [code-systems (d/pull-many db (d/type-query db "ValueSet" [["url" url] ["version" version]]))]
(or (first (priority/sort-by-priority code-systems))
(ba/not-found (format "The value set `%s` and version `%s` was not found." url version))))))
(ba/not-found (format "The value set `%s` with version `%s` was not found." url version))))))
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
[java-time.api :as time]))

(defn- all-version-expansion-msg [url]
(format "Expanding the code system with URL `%s` in all versions is unsupported." url))
(format "Expanding the code system `%s` in all versions is unsupported." url))

(defn- all-version-expansion-anom [url]
(ba/unsupported (all-version-expansion-msg url)))
Expand Down
Loading

0 comments on commit 361206f

Please sign in to comment.