### Input > DeleteAccident

#### Class Diagram

```plantuml

skinparam shadowing false
skinparam rectangle {
    roundCorner<<Input>> 25
}

rectangle "DeleteAccident" <<Input>> {

namespace App\RegBurns\Application\Input\DeleteAccident {

    class DeleteAccident {
        - patientId
        - uuid
        ---
        - construct()
        + hydrateFromJson()
        ---
        + patientId()
        + uuid()
    }

    class DeleteAccidentService {
        - patientRepository
        - accidentRepository
        + construct(patientRepository,accidentRepository)
        + Delete(DeleteAccident $command)
    }

    DeleteAccident ..> DeleteAccidentService

    }
}

```

#### Flow Delete()

```plantuml

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

```
