From acdd74850defd2951a365e7d5786b47696094d0b Mon Sep 17 00:00:00 2001 From: Juho Leinonen Date: Thu, 23 Nov 2023 14:57:23 +0200 Subject: [PATCH 1/8] =?UTF-8?q?AE-2014:=20Update=20k=C3=A4yt=C3=B6nvalvont?= =?UTF-8?q?a=20asha=20definitions=20based=20on=20new=20process?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../etp/service/valvonta_kaytto/asha.clj | 26 +++++-------------- .../service/valvonta_kaytto/toimenpide.clj | 2 -- .../valvonta_kaytto/toimenpide_test.clj | 8 +++--- 3 files changed, 10 insertions(+), 26 deletions(-) diff --git a/etp-backend/src/main/clj/solita/etp/service/valvonta_kaytto/asha.clj b/etp-backend/src/main/clj/solita/etp/service/valvonta_kaytto/asha.clj index 544e42f37..d3fe9c8be 100644 --- a/etp-backend/src/main/clj/solita/etp/service/valvonta_kaytto/asha.clj +++ b/etp-backend/src/main/clj/solita/etp/service/valvonta_kaytto/asha.clj @@ -137,9 +137,9 @@ :contact (map osapuoli->contact osapuolet)} :document (toimenpide-type->document (:type-id toimenpide))} :decision-order-hearing-letter {:identity {:case {:number (:diaarinumero toimenpide)} - :processing-action {:name-identity "Päätöksenteko"}} + :processing-action {:name-identity "Käsittely"}} :document (toimenpide-type->document (:type-id toimenpide)) - :processing-action {:name "Kuulemiskirje käskypäätöksestä" + :processing-action {:name "Kuuleminen uhkasakon asettamisesta" :reception-date (Instant/now) :contacting-direction "SENT" :contact (map osapuoli->contact osapuolet)}} @@ -147,14 +147,7 @@ :processing-action {:name-identity "Päätöksenteko"}} :document (toimenpide-type->document (:type-id toimenpide)) :attachment (toimenpide-type->attachment (:type-id toimenpide)) - :processing-action {:name "Käskypäätös" - :reception-date (Instant/now) - :contacting-direction "SENT" - :contact (map osapuoli->contact osapuolet)}} - :decision-order-notice-first-mailing {:identity {:case {:number (:diaarinumero toimenpide)} - :processing-action {:name-identity "Tiedoksianto ja toimeenpano"}} - :document (toimenpide-type->document (:type-id toimenpide)) - :processing-action {:name "Päätös tiedoksi - ensimmäinen postitus" + :processing-action {:name "Uhkasakon asettaminen" :reception-date (Instant/now) :contacting-direction "SENT" :contact (map osapuoli->contact osapuolet)}} @@ -166,9 +159,9 @@ :contacting-direction "SENT" :contact (map osapuoli->contact osapuolet)}} :penalty-decision-hearing-letter {:identity {:case {:number (:diaarinumero toimenpide)} - :processing-action {:name-identity "Päätöksenteko"}} + :processing-action {:name-identity "Käsittely"}} :document (toimenpide-type->document (:type-id toimenpide)) - :processing-action {:name "Kuulemiskirje uhkasakkopäätöksestä" + :processing-action {:name "Kuuleminen uhkasakon tuomitsemisesta" :reception-date (Instant/now) :contacting-direction "SENT" :contact (map osapuoli->contact osapuolet)}} @@ -176,14 +169,7 @@ :processing-action {:name-identity "Päätöksenteko"}} :document (toimenpide-type->document (:type-id toimenpide)) :attachment (toimenpide-type->attachment (:type-id toimenpide)) - :processing-action {:name "Sakkopäätös" - :reception-date (Instant/now) - :contacting-direction "SENT" - :contact (map osapuoli->contact osapuolet)}} - :penalty-decision-notice-first-mailing {:identity {:case {:number (:diaarinumero toimenpide)} - :processing-action {:name-identity "Päätöksenteko"}} - :document (toimenpide-type->document (:type-id toimenpide)) - :processing-action {:name "Uhkasakkopäätös tiedoksi - ensimmäinen postitus" + :processing-action {:name "Uhkasakon tuomitseminen maksettavaksi" :reception-date (Instant/now) :contacting-direction "SENT" :contact (map osapuoli->contact osapuolet)}} diff --git a/etp-backend/src/main/clj/solita/etp/service/valvonta_kaytto/toimenpide.clj b/etp-backend/src/main/clj/solita/etp/service/valvonta_kaytto/toimenpide.clj index a3707ab70..199429565 100644 --- a/etp-backend/src/main/clj/solita/etp/service/valvonta_kaytto/toimenpide.clj +++ b/etp-backend/src/main/clj/solita/etp/service/valvonta_kaytto/toimenpide.clj @@ -83,11 +83,9 @@ :rfi-warning :decision-order-hearing-letter :decision-order-actual-decision - :decision-order-notice-first-mailing :decision-order-notice-bailiff :penalty-decision-hearing-letter :penalty-decision-actual-decision - :penalty-decision-notice-first-mailing :penalty-decision-notice-bailiff})) diff --git a/etp-backend/src/test/clj/solita/etp/service/valvonta_kaytto/toimenpide_test.clj b/etp-backend/src/test/clj/solita/etp/service/valvonta_kaytto/toimenpide_test.clj index 077f310d8..442032e4a 100644 --- a/etp-backend/src/test/clj/solita/etp/service/valvonta_kaytto/toimenpide_test.clj +++ b/etp-backend/src/test/clj/solita/etp/service/valvonta_kaytto/toimenpide_test.clj @@ -174,8 +174,8 @@ (t/is (true? (toimenpide/kaskypaatos-toimenpide? {:type-id 9})))) (t/testing "is not sakkopaatos-toimenpide?" (t/is (false? (toimenpide/sakkopaatos-toimenpide? {:type-id 9})))) - (t/testing "is asha-toimenpide?" - (t/is (true? (toimenpide/asha-toimenpide? {:type-id 9}))))) + (t/testing "is not asha-toimenpide?" + (t/is (false? (toimenpide/asha-toimenpide? {:type-id 9}))))) (t/testing "Käskypäätös / tiedoksianto (toinen postitus)" (t/testing "has type-id 10 and type-key :decision-order-notice-second-mailing" @@ -234,8 +234,8 @@ (t/is (false? (toimenpide/kaskypaatos-toimenpide? {:type-id 16})))) (t/testing "is sakkopaatos-toimenpide?" (t/is (true? (toimenpide/sakkopaatos-toimenpide? {:type-id 16})))) - (t/testing "is asha-toimenpide?" - (t/is (true? (toimenpide/asha-toimenpide? {:type-id 16}))))) + (t/testing "is not asha-toimenpide?" + (t/is (false? (toimenpide/asha-toimenpide? {:type-id 16}))))) (t/testing "Sakkopäätös / tiedoksianto (toinen postitus)" (t/testing "has type-id 17 and type-key :penalty-decision-notice-second-mailing" From f3ac69eaf8b79946e1531e6635725d204bdf86a5 Mon Sep 17 00:00:00 2001 From: Juho Leinonen Date: Mon, 4 Dec 2023 10:20:35 +0200 Subject: [PATCH 2/8] =?UTF-8?q?AE-2014:=20Implement=20new=20asha=20transit?= =?UTF-8?q?ion=20for=20k=C3=A4yt=C3=B6nvalvonta?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Allow moving "backwards" in the process as the new transitions need to move back in it --- .../src/main/clj/solita/etp/service/asha.clj | 39 +++++++++++++------ 1 file changed, 28 insertions(+), 11 deletions(-) diff --git a/etp-backend/src/main/clj/solita/etp/service/asha.clj b/etp-backend/src/main/clj/solita/etp/service/asha.clj index 0eaede0b8..3773cb002 100644 --- a/etp-backend/src/main/clj/solita/etp/service/asha.clj +++ b/etp-backend/src/main/clj/solita/etp/service/asha.clj @@ -185,14 +185,32 @@ "Move the case to the next step, if it the new action (processing-action parameter) is in Käsittely or Päätöksenteko and the desired state is not already reached (not in processing-action-states)." [sender-id request-id case-number processing-action-states processing-action] - (when-let [action (case processing-action - "Käsittely" {:processing-action "Vireillepano" - :decision "Siirry käsittelyyn"} - "Päätöksenteko" {:processing-action "Käsittely" - :decision "Siirry päätöksentekoon"} - "Valitusajan umpeutuminen" {:processing-action "Tiedoksianto ja toimeenpano" - :decision "Valmis"} - nil)] + (when-let [action (cond + (and (= processing-action "Käsittely") + (every? #(not= ["Tiedoksianto ja toimeenpano" "UNFINISHED"] %) processing-action-states)) + {:processing-action "Vireillepano" + :decision "Siirry käsittelyyn"} + + (= processing-action "Päätöksenteko") + {:processing-action "Käsittely" + :decision "Siirry päätöksentekoon"} + + (= processing-action "Valitusajan umpeutuminen") + {:processing-action "Tiedoksianto ja toimeenpano" + :decision "Valmis"} + + (= processing-action "Tiedoksianto ja toimeenpano") + {:processing-action "Päätöksenteko" + :decision "Siirry tiedoksiantoon"} + + + (and (= processing-action "Käsittely") + (some #(= ["Tiedoksianto ja toimeenpano" "UNFINISHED"] %) processing-action-states)) + {:processing-action "Tiedoksianto ja toimeenpano" + :decision "Uudelleenkäsittele asia"} + + :else nil)] + (when (not (get processing-action-states processing-action)) (proceed-operation! sender-id request-id case-number (:processing-action action) (:decision action))))) @@ -231,9 +249,8 @@ require-vireillepano (= {"Vireillepano" "NEW"} processing-action-states) processing-action (-> processing-action ;; Possibly redirect the processing action to Vireillepano - (with-vireillepano require-vireillepano) - ;; Prevent going backwards in the process - (with-latest-processing-action processing-action-states))] + (with-vireillepano require-vireillepano)) + _ (println "toteutettava processing-action" processing-action)] (move-processing-action! sender-id request-id From b664ebb0dfb64716c56f0b23d872c254955ef455 Mon Sep 17 00:00:00 2001 From: Juho Leinonen Date: Tue, 5 Dec 2023 11:36:03 +0200 Subject: [PATCH 3/8] AE-2014: Remove test checking that move-processing-action! doesn't move Tiedoksianto ja toimeenpano as it's now a valid move - Fix testing string saying states backwards --- etp-backend/src/test/clj/solita/etp/service/asha_test.clj | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/etp-backend/src/test/clj/solita/etp/service/asha_test.clj b/etp-backend/src/test/clj/solita/etp/service/asha_test.clj index 59b965087..66d5e6948 100644 --- a/etp-backend/src/test/clj/solita/etp/service/asha_test.clj +++ b/etp-backend/src/test/clj/solita/etp/service/asha_test.clj @@ -266,9 +266,7 @@ case-number 100] (t/testing "Move ignores the toimenpide if the action is" (t/testing "Vireillepano" - (asha-service/move-processing-action! sender-id request-id case-number {} "Vireillepano")) - (t/testing "Tiedoksianto ja toimeenpano" - (asha-service/move-processing-action! sender-id request-id case-number {} "Tiedoksianto ja toimeenpano"))) + (asha-service/move-processing-action! sender-id request-id case-number {} "Vireillepano"))) (t/testing "Move is skipped if the toimenpide is already in correct state" (let [processing-action-states {"Vireillepano" "READY" "Käsittely" "NEW"} processing-action "Käsittely"] @@ -288,7 +286,7 @@ :request-received move-called}})] (asha-service/move-processing-action! sender-id request-id case-number {} "Käsittely") (t/is (= 1 @move-called))))) - (t/testing "Move from Päätöksenteko to Käsittely" + (t/testing "Move from Käsittely to Päätöksenteko" (let [move-called (atom 0)] (binding [asha-service/post! (handle-requests {(render-resource "asha/moveaction/move-template.xml" {:sender-id sender-id :request-id request-id From 4a052961169d36fe0fb26a7dd07c701bb60b692e Mon Sep 17 00:00:00 2001 From: Juho Leinonen Date: Tue, 5 Dec 2023 13:00:52 +0200 Subject: [PATCH 4/8] AE-2014: Clarify parameter naming and docstring in move-processing-action! - Add tests to new transitions - Remove Valitusajan umpeutuminen as it's not used --- .../src/main/clj/solita/etp/service/asha.clj | 31 +++++++++---------- .../test/clj/solita/etp/service/asha_test.clj | 26 ++++++++++++++++ 2 files changed, 40 insertions(+), 17 deletions(-) diff --git a/etp-backend/src/main/clj/solita/etp/service/asha.clj b/etp-backend/src/main/clj/solita/etp/service/asha.clj index 3773cb002..02ccb9aaf 100644 --- a/etp-backend/src/main/clj/solita/etp/service/asha.clj +++ b/etp-backend/src/main/clj/solita/etp/service/asha.clj @@ -16,8 +16,7 @@ ["Vireillepano" "Käsittely" "Päätöksenteko" - "Tiedoksianto ja toimeenpano" - "Valitusajan umpeutuminen"]) + "Tiedoksianto ja toimeenpano"]) (defn- must-exist! [n] (when (< n 0) @@ -182,36 +181,35 @@ last)) (defn move-processing-action! - "Move the case to the next step, if it the new action (processing-action parameter) is in Käsittely or Päätöksenteko - and the desired state is not already reached (not in processing-action-states)." - [sender-id request-id case-number processing-action-states processing-action] + "Move the case to the next step, if the new action (wanted-processing-action parameter) is in Käsittely or Päätöksenteko + and the desired state is not already reached (not in processing-action-states). + + `processing-action-states` parameter is a map containing the processing actions that are already made and their states. + + Note that this is used for both käytönvalvonta and oikeellisuuden valvonta." + [sender-id request-id case-number processing-action-states wanted-processing-action] (when-let [action (cond - (and (= processing-action "Käsittely") + (and (= wanted-processing-action "Käsittely") (every? #(not= ["Tiedoksianto ja toimeenpano" "UNFINISHED"] %) processing-action-states)) {:processing-action "Vireillepano" :decision "Siirry käsittelyyn"} - (= processing-action "Päätöksenteko") + (= wanted-processing-action "Päätöksenteko") {:processing-action "Käsittely" :decision "Siirry päätöksentekoon"} - (= processing-action "Valitusajan umpeutuminen") - {:processing-action "Tiedoksianto ja toimeenpano" - :decision "Valmis"} - - (= processing-action "Tiedoksianto ja toimeenpano") + (= wanted-processing-action "Tiedoksianto ja toimeenpano") {:processing-action "Päätöksenteko" :decision "Siirry tiedoksiantoon"} - - (and (= processing-action "Käsittely") + (and (= wanted-processing-action "Käsittely") (some #(= ["Tiedoksianto ja toimeenpano" "UNFINISHED"] %) processing-action-states)) {:processing-action "Tiedoksianto ja toimeenpano" :decision "Uudelleenkäsittele asia"} :else nil)] - (when (not (get processing-action-states processing-action)) + (when (not (get processing-action-states wanted-processing-action)) (proceed-operation! sender-id request-id case-number (:processing-action action) (:decision action))))) (defn mark-processing-action-as-ready! [sender-id request-id case-number processing-action] @@ -249,8 +247,7 @@ require-vireillepano (= {"Vireillepano" "NEW"} processing-action-states) processing-action (-> processing-action ;; Possibly redirect the processing action to Vireillepano - (with-vireillepano require-vireillepano)) - _ (println "toteutettava processing-action" processing-action)] + (with-vireillepano require-vireillepano))] (move-processing-action! sender-id request-id diff --git a/etp-backend/src/test/clj/solita/etp/service/asha_test.clj b/etp-backend/src/test/clj/solita/etp/service/asha_test.clj index 66d5e6948..2dcd806ec 100644 --- a/etp-backend/src/test/clj/solita/etp/service/asha_test.clj +++ b/etp-backend/src/test/clj/solita/etp/service/asha_test.clj @@ -297,4 +297,30 @@ :response-status 200 :request-received move-called}})] (asha-service/move-processing-action! sender-id request-id case-number {} "Päätöksenteko") + (t/is (= 1 @move-called))))) + + (t/testing "Move from Päätöksenteko to Tiedoksianto ja toimeenpano" + (let [move-called (atom 0)] + (binding [asha-service/post! (handle-requests {(render-resource "asha/moveaction/move-template.xml" {:sender-id sender-id + :request-id request-id + :case-number case-number + :processing-action "Päätöksenteko" + :proceed-decision "Siirry tiedoksiantoon"}) + {:response-body "Irrelevant" + :response-status 200 + :request-received move-called}})] + (asha-service/move-processing-action! sender-id request-id case-number {} "Tiedoksianto ja toimeenpano") + (t/is (= 1 @move-called))))) + + (t/testing "Move from Tiedoksianto ja toimeenpano to Käsittely using 'uudelleenkäsittele asia' decision" + (let [move-called (atom 0)] + (binding [asha-service/post! (handle-requests {(render-resource "asha/moveaction/move-template.xml" {:sender-id sender-id + :request-id request-id + :case-number case-number + :processing-action "Tiedoksianto ja toimeenpano" + :proceed-decision "Uudelleenkäsittele asia"}) + {:response-body "Irrelevant" + :response-status 200 + :request-received move-called}})] + (asha-service/move-processing-action! sender-id request-id case-number {"Tiedoksianto ja toimeenpano" "UNFINISHED"} "Käsittely") (t/is (= 1 @move-called)))))))) From 7ae1eb3c423615d922c9858669c5af2a275c9707 Mon Sep 17 00:00:00 2001 From: Juho Leinonen Date: Tue, 5 Dec 2023 15:01:18 +0200 Subject: [PATCH 5/8] AE-2014: Remove with-latest-processing-action as unused --- etp-backend/src/main/clj/solita/etp/service/asha.clj | 6 ------ 1 file changed, 6 deletions(-) diff --git a/etp-backend/src/main/clj/solita/etp/service/asha.clj b/etp-backend/src/main/clj/solita/etp/service/asha.clj index 02ccb9aaf..a8cc471c1 100644 --- a/etp-backend/src/main/clj/solita/etp/service/asha.clj +++ b/etp-backend/src/main/clj/solita/etp/service/asha.clj @@ -229,12 +229,6 @@ "Vireillepano") processing-action)) -(defn with-latest-processing-action [processing-action states] - (update-in processing-action - [:identity :processing-action :name-identity] - (fn [name-identity] (reduce toplevel-processing-action-max - (cons name-identity (keys states)))))) - (defn log-toimenpide! ([sender-id request-id case-number processing-action] (log-toimenpide! sender-id request-id case-number processing-action [] [])) From fa6571c1ee5519d11aba3ed984e3dea7a3b289f1 Mon Sep 17 00:00:00 2001 From: Juho Leinonen Date: Thu, 7 Dec 2023 12:41:48 +0200 Subject: [PATCH 6/8] AE-2014: Add type hint and import in solita.etp.service.asha-test --- etp-backend/src/test/clj/solita/etp/service/asha_test.clj | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/etp-backend/src/test/clj/solita/etp/service/asha_test.clj b/etp-backend/src/test/clj/solita/etp/service/asha_test.clj index 2dcd806ec..c52c9b2b6 100644 --- a/etp-backend/src/test/clj/solita/etp/service/asha_test.clj +++ b/etp-backend/src/test/clj/solita/etp/service/asha_test.clj @@ -6,13 +6,14 @@ [solita.etp.service.valvonta-kaytto.hallinto-oikeus-attachment :as hao] [solita.etp.test-system :as ts] [clostache.parser :refer [render-resource]]) - (:import (java.nio.charset StandardCharsets) + (:import (clojure.lang ExceptionInfo) + (java.nio.charset StandardCharsets) (java.time Instant) (java.util Base64))) (t/use-fixtures :each ts/fixture) -(defn- handle-request [request-resource response-resource response-status & [exception]] +(defn- handle-request [request-resource response-resource response-status & [^String exception]] (fn [request] (t/is (= (str/trim request) (-> request-resource io/resource slurp str/trim))) (if exception @@ -99,7 +100,7 @@ "asha/case-create-response-without-sender-id.xml" 400 "clj-http: status 400")] - (t/is (thrown-with-msg? clojure.lang.ExceptionInfo + (t/is (thrown-with-msg? ExceptionInfo #"Asiahallinta request failed. Posting the request failed." (asha-service/open-case! {:request-id "ETP-1" From dbf0cb33e1a79e69533c67d13e4be827f6b8fb8c Mon Sep 17 00:00:00 2001 From: Juho Leinonen Date: Thu, 14 Dec 2023 15:59:09 +0200 Subject: [PATCH 7/8] =?UTF-8?q?AE-2014:=20Allow=20moving=20to=20k=C3=A4sit?= =?UTF-8?q?tely=20with=20uudelleenk=C3=A4sittele=20asia=20transition=20eve?= =?UTF-8?q?n=20if=20k=C3=A4sittely=20has=20already=20been=20done?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - The process can be repeated multiple times so käsittely and the following toimenpiteet and their transitions need to be allowed even though they have already been done --- etp-backend/src/main/clj/solita/etp/service/asha.clj | 8 +++++--- etp-backend/src/test/clj/solita/etp/service/asha_test.clj | 3 ++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/etp-backend/src/main/clj/solita/etp/service/asha.clj b/etp-backend/src/main/clj/solita/etp/service/asha.clj index a8cc471c1..4a6ffeca3 100644 --- a/etp-backend/src/main/clj/solita/etp/service/asha.clj +++ b/etp-backend/src/main/clj/solita/etp/service/asha.clj @@ -181,8 +181,8 @@ last)) (defn move-processing-action! - "Move the case to the next step, if the new action (wanted-processing-action parameter) is in Käsittely or Päätöksenteko - and the desired state is not already reached (not in processing-action-states). + "Move the case to the next step, if the new action (wanted-processing-action parameter) if the action is valid and + the case is not already in that state. `processing-action-states` parameter is a map containing the processing actions that are already made and their states. @@ -209,7 +209,9 @@ :else nil)] - (when (not (get processing-action-states wanted-processing-action)) + ;; If the action is already in the desired state, do nothing. It is allowed to move to a state that + ;; has already been handled previously (state is READY). + (when-not (contains? #{"NEW" "UNFINISHED"} (get processing-action-states wanted-processing-action)) (proceed-operation! sender-id request-id case-number (:processing-action action) (:decision action))))) (defn mark-processing-action-as-ready! [sender-id request-id case-number processing-action] diff --git a/etp-backend/src/test/clj/solita/etp/service/asha_test.clj b/etp-backend/src/test/clj/solita/etp/service/asha_test.clj index c52c9b2b6..da7e3ec80 100644 --- a/etp-backend/src/test/clj/solita/etp/service/asha_test.clj +++ b/etp-backend/src/test/clj/solita/etp/service/asha_test.clj @@ -323,5 +323,6 @@ {:response-body "Irrelevant" :response-status 200 :request-received move-called}})] - (asha-service/move-processing-action! sender-id request-id case-number {"Tiedoksianto ja toimeenpano" "UNFINISHED"} "Käsittely") + (asha-service/move-processing-action! sender-id request-id case-number {"Tiedoksianto ja toimeenpano" "UNFINISHED" + "Käsittely" "FINISHED"} "Käsittely") (t/is (= 1 @move-called)))))))) From abd1b02105aa8e116a98cdd30e9e6ff10a54e74f Mon Sep 17 00:00:00 2001 From: Juho Leinonen Date: Mon, 18 Dec 2023 15:07:53 +0200 Subject: [PATCH 8/8] AE-2014: Improve documentation of the asha transitions in move-processing-action! --- .../src/main/clj/solita/etp/service/asha.clj | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/etp-backend/src/main/clj/solita/etp/service/asha.clj b/etp-backend/src/main/clj/solita/etp/service/asha.clj index 4a6ffeca3..7bce65568 100644 --- a/etp-backend/src/main/clj/solita/etp/service/asha.clj +++ b/etp-backend/src/main/clj/solita/etp/service/asha.clj @@ -181,7 +181,7 @@ last)) (defn move-processing-action! - "Move the case to the next step, if the new action (wanted-processing-action parameter) if the action is valid and + "Move the case to the next step, if the new action (wanted-processing-action parameter) is valid and the case is not already in that state. `processing-action-states` parameter is a map containing the processing actions that are already made and their states. @@ -189,19 +189,31 @@ Note that this is used for both käytönvalvonta and oikeellisuuden valvonta." [sender-id request-id case-number processing-action-states wanted-processing-action] (when-let [action (cond + ;; First time going to käsittely, Tiedoksianto ja toimeenpano toimenpide doesn't exist yet + ;; Transition from Vireillepano to Käsittely is Siirry käsittelyyn (and (= wanted-processing-action "Käsittely") (every? #(not= ["Tiedoksianto ja toimeenpano" "UNFINISHED"] %) processing-action-states)) {:processing-action "Vireillepano" :decision "Siirry käsittelyyn"} + ;; Moving from Käsittely to Päätöksenteko is done by Siirry päätöksentekoon transition. + ;; The transition is the same no matter if it's the first or second or + ;; nth time moving to Päätöksenteko (= wanted-processing-action "Päätöksenteko") {:processing-action "Käsittely" :decision "Siirry päätöksentekoon"} + ;; Moving from Päätöksenteko to Tiedoksianto ja toimeenpano is done by Siirry tiedoksiantoon transition. + ;; The transition is the same no matter if it's the first or second or + ;; nth time moving to Tiedoksianto ja toimeenpano (= wanted-processing-action "Tiedoksianto ja toimeenpano") {:processing-action "Päätöksenteko" :decision "Siirry tiedoksiantoon"} + ;; Moving from Tiedoksianto ja toimeenpano to Käsittely is done by Uudelleenkäsittele asia transition. + ;; If wanted-processing-action is Käsittely and Tiedoksianto ja toimeenpano toimenpide exists + ;; and is UNFINISHED, Uudelleenkäsittele asia transition is used. + ;; This is used in käytönvalvonta when moving to Sakkopäätös / kuulemiskirje toimenpide. (and (= wanted-processing-action "Käsittely") (some #(= ["Tiedoksianto ja toimeenpano" "UNFINISHED"] %) processing-action-states)) {:processing-action "Tiedoksianto ja toimeenpano"