NextGen APIs

POST /work-orders/execution/r1/interventions/{interventionId}/taking-charge

Http Verb

POST

Url

/work-orders/execution/r1/interventions/{interventionId}/taking-charge

Permissions required


Personally Identifiable Information (PII)

No

Sensitive Information

No

Last Modified Version

r1

Released since

2024 W3 (FSM 18.0)

Deprecated since


Removed since


Tech Tags

PAGINATION ORDERING-SERVER-SIDE

Business Logic

This API take in charge a work order operation by its intervention id.

A user can handle only one intervention at a time. If the user has already taken charge another intervention, this one will be reverted to its previous state (SUBMITTED)

Please note that the "taking in charge" action is exclusively performed by the foreman of the intervention. While the assistants in the team will have access to the details of the intervention, they will not take charge of it; only the foreman holds that responsibility.

In a team scenario, assistants follow the same rules as the foreman, but their intervention information are linked to the foreman's intervention.

The result of this API call can be viewed by calling GET /work-orders/execution/r1/interventions/outcomes/{outcomeId}and passing the intervention Id as the outcome Id in the path parameter.

It is possible to skip this step in the intervention process and directly call the following API POST /work-orders/execution/r1/interventions/{interventionId}/outcomes

Steps

Retrieve Intervention

We will refer to interventionFromInputId as the intervention record with intervention.id equal to interventionId provided in the path parameter of this API.

Examples:

  • interventionFromInputId.statusId will be the statusId field of the intervention with id equal to interventionId.

  • interventionFromInputId.outcome will be the Intervention outcome of the intervention with id equal to interventionId, that can be retrieved by calling GET /work-orders/execution/r1/interventions/outcomes/{outcomeId} .

  1. Validate Intervention Status

    • Check if interventionFromInputId.statusId is one of ‘OPEN’, ‘FIXED’, ‘SUBMITTED’, or ‘ACCEPTED’.

    • Check if interventionFromInputId.workOrderOperationId is null.

    • Check if Core System Setting field "Outcome Minimum Date" < takeInChargeDate:

    • Check if takeInChargeDate < Date.now() + 1 (it should be at most a date in the present, not in the future):

    • Check if workOrderHeader.isWoByOrder())

      • If TRUE ->operation.getParentOperation() != null → you can take in charge an intervention only if it is the one of the parent operation

      • if not return the error EXECUTION_005.

  2. Handle Existing Interventions

    • Search for all intervention records associated with the same resource with statusId values ‘IN_CHARGE' or 'IN_EXECUTION’ and workOrderOperationId not equal to interventionFromInputId.workOrderOperationId

    • We will refer to this list of intervention records as interventionsToBeDeleted.

    • For each intervention in the interventionsToBeDeleted list:

      • Set intervention.outcome.arrivalDate to null

      • Set intervention.outcome.takeInChargeDate to null

      • Set intervention.outcome.startDate to null

      • Change intervention.statusId to ‘SUBMITTED’ by passing the ‘SUBMIT’ action.

      • Update intervention.workOrderOperationId.statusId

      • Update intervention.workOrderOperationId.workOrderId.statusId

      • Retrieve all records of resourceAccountedHourentity with resourceAccountedHour.interventionId equal to intervention.id and resourceAccountedHour.outcomeEndDate equal to null.

        • For each record, set:

          • resourceAccountedHour.takeInCharge to null

          • resourceAccountedHour.arrivalDate to null

          • resourceAccountedHour.outcomeStartDate to null

  3. Take In Charge the Intervention

    • If interventionFromInputId.outome.takeInChargeDate is null:

      • Set interventionFromInputId.outome.takeInChargeDate to the input takeInChargeDate

      • If not, set interventionFromInputId.outome.takeInChargeDate equal to interventionFromInputId.outcome.takeInChargeDate (we leave it as it was) and set interventionFromInputId.workOrderOperationId.lastPdaTakeInChargeDate equal to interventionFromInputId.takeInChargeDate

    • Set interventionFromInputId.statusId to 'IN_CHARGE' using the action 'TAKE_IN_CHARGE'.

    • If company.fsm.accounting.emptyAgendaResourceDeletion property is enabled, remove all empty resourceAccountedHour associated with the same interventionFromInputId, they will be removed if resourceAccountedHour.spentTime, resourceAccountedHour.takeInChargeDate are null and if resourceAccountedHour.resource is different from the resource associated with the interventionFromInputId

    • Update interventionFromInputId.workOrderOperationId.statusId

    • Update interventionFromInputId.workOrderOperationId.workOrderId.statusId

Header Parameters

Default.

Request Body Parameters

Field

Validations

Note

takeInChargeDate



Response documentation

Response payload fields

Response error codes

NOT_FOUND, BASE_0001, BASE_0003, BASE_0010, BASE_0011, BASE_0016, WORKORDERS_ORCHESTRATOR_006, EXECUTION_002, EXECUTION_003