|
2378 | 2378 | [0 :fhir/type] := :fhir/Patient |
2379 | 2379 | [0 :id] := "0"))) |
2380 | 2380 |
|
2381 | | - ;; TODO: fix this https://github.com/samply/blaze/issues/904 |
2382 | | - #_(testing "sorting by _lastUpdated returns only the newest version of the patient" |
2383 | | - (with-system-data [{:blaze.db/keys [node]} (with-system-clock config)] |
2384 | | - [[[:put {:fhir/type :fhir/Patient :id "0"}]] |
2385 | | - [[:put {:fhir/type :fhir/Patient :id "1"}]]] |
| 2381 | + (testing "sorting by _lastUpdated returns every resource only once" |
| 2382 | + (with-system-data [{:blaze.db/keys [node]} system-clock-config] |
| 2383 | + [[[:put {:fhir/type :fhir/Patient :id "0"}]] |
| 2384 | + [[:put {:fhir/type :fhir/Patient :id "1"}]]] |
2386 | 2385 |
|
2387 | | - ;; we have to sleep more than one second here because dates are index only with second resolution |
2388 | | - (Thread/sleep 2000) |
2389 | | - @(d/transact node [[:put {:fhir/type :fhir/Patient :id "0"}]]) |
| 2386 | + ;; we have to sleep more than one second here because dates are index only with second resolution |
| 2387 | + (Thread/sleep 1100) |
| 2388 | + @(d/transact node [[:put {:fhir/type :fhir/Patient :id "0"}]]) |
2390 | 2389 |
|
2391 | | - (doseq [dir [:asc :desc]] |
2392 | | - (given-type-query node "Patient" [[:sort "_lastUpdated" dir]] |
2393 | | - count := 2 |
2394 | | - [0 :fhir/type] := :fhir/Patient |
2395 | | - [0 :id] := "0" |
2396 | | - [0 :active] := #fhir/boolean false)))) |
| 2390 | + (let [clauses [[:sort "_lastUpdated" :desc]]] |
| 2391 | + (given-type-query node "Patient" clauses |
| 2392 | + count := 2 |
| 2393 | + [0 :id] := "0" |
| 2394 | + [1 :id] := "1") |
| 2395 | + |
| 2396 | + (testing "it is possible to start with the second patient" |
| 2397 | + (given (pull-type-query node "Patient" clauses "1") |
| 2398 | + count := 1 |
| 2399 | + [0 :id] := "1"))))) |
2397 | 2400 |
|
2398 | 2401 | (testing "a node with three patients in one transaction" |
2399 | 2402 | (with-system-data [{:blaze.db/keys [node]} config] |
|
2402 | 2405 | [:put {:fhir/type :fhir/Patient :id "2" :active #fhir/boolean true}]]] |
2403 | 2406 |
|
2404 | 2407 | (testing "two active patients will be found" |
2405 | | - (given-type-query node "Patient" [["active" "true"]] |
2406 | | - count := 2 |
2407 | | - [0 :fhir/type] := :fhir/Patient |
2408 | | - [0 :id] := "0" |
2409 | | - [1 :fhir/type] := :fhir/Patient |
2410 | | - [1 :id] := "2")) |
| 2408 | + (let [clauses [["active" "true"]]] |
| 2409 | + (given-type-query node "Patient" clauses |
| 2410 | + count := 2 |
| 2411 | + [0 :id] := "0" |
| 2412 | + [1 :id] := "2") |
2411 | 2413 |
|
2412 | | - (testing "it is possible to start with the second patient" |
2413 | | - (given (pull-type-query node "Patient" [["active" "true"]] "2") |
2414 | | - count := 1 |
2415 | | - [0 :fhir/type] := :fhir/Patient |
2416 | | - [0 :id] := "2")))) |
| 2414 | + (testing "it is possible to start with the second patient" |
| 2415 | + (given (pull-type-query node "Patient" clauses "2") |
| 2416 | + count := 1 |
| 2417 | + [0 :id] := "2")))))) |
2417 | 2418 |
|
2418 | 2419 | (testing "special case of _lastUpdated date search parameter" |
2419 | 2420 | (testing "inequality searches do return every resource only once" |
|
2422 | 2423 | [[:put {:fhir/type :fhir/Patient :id "1"}]]] |
2423 | 2424 |
|
2424 | 2425 | ;; we have to sleep more than one second here because dates are index only with second resolution |
2425 | | - (Thread/sleep 2000) |
| 2426 | + (Thread/sleep 1100) |
2426 | 2427 | @(d/transact node [[:put {:fhir/type :fhir/Patient :id "0"}]]) |
2427 | 2428 |
|
2428 | 2429 | (given-type-query node "Patient" [["_lastUpdated" "ge2000-01-01"]] |
|
0 commit comments