@startuml skinparam shadowing false title DeleteAccidentService\Delete() start :GetPatientById; :GetAccidents; if (Number of **Accidents** > 1) then (yes) :GetPatientCasesForAccident; if (Number of **Cases** > 0) then (yes) :GetLastestAccidentForPatient; note left: except the \n accident you \n want to delete while (loop over cases) :set latest **Accident** in **Case**; endwhile else (no) :no related cases found; endif :DeleteInsuranceItems; note right: softdelete :DeleteHospitalisationItems; note right: softdelete :DeleteDocumentTracker; note right: softdelete :DeleteDocuments; note right: softdelete \n (optional move files to bin) :DeleteAccident; note right: softdelete :return true; else (no) :return false; endif end @enduml