NextGen APIs

POST /work-orders/execution/r1/interventions/{interventionId}/outcomes

Http Verb

POST

Url

/work-orders/execution/r1/interventions/{interventionId}/outcomes

Permissions required


Personally Identifiable Information (PII)

No

Sensitive Information

No

Last Modified Version

r1 - 2025 W2 (FSM 20.0)

Released since

2024 W3 (FSM 18.0)

Deprecated since


Removed since


Tech Tags


Business Logic

This API inserts an intervention outcome starting from the intervention id.

This API manages the intervention outcome related to interventions in status not CLOSED.

To retrieve the interventionId, you can call the API GET /work-orders/execution/r1/interventions .

This API updates information related to:

Steps:

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

  • Few examples:

    • interventionFromInputId.workOrderOperationId will be the workOrderOperationId field of intervention record with intervention.id = interventionId set in path parameter of this API.

    • interventionFromInputId.outcome.startDate will be the startDate field of the interventionOutcome related to intervention with id = interventionId set in path parameter of this API.

  1. Retrieve Related Intervention Records:

    • Fetch all related intervention records with interventions.workOrderOperationId = interventionFromInputId.workOrderOperationId.

    • Check if there is at least one already accounted intervention record by filtering the list:

      • interventions.startDate > startDate

      • interventions.outcome.reasonId is not null

      • interventions.status is 'CANCELLED' or 'CLOSED'

    • If at least one record is found, return error ALREADY_ACCOUNTED_INTERVENTION.

  2. Retrieve Set Dates:

    • Set Start Date:

      • If startDate is not null, set interventionFromInputId.outcome.startDate = startDate.

      • Otherwise, get interventionFromInputId.startDate.

        • If interventionFromInputId.startDate <= Date.now, set interventionFromInputId.outcome.startDate = interventionFromInputId.startDate.

      • Check for other related interventions not yet accounted for, filtering by:

        • interventions.startDate < interventionFromInputId.startDate

        • interventions.outcome.reasonId is null

      • If a record is found on previous point, overwrite interventionFromInputId.outcome.startDate with the startDate of the found intervention record.

    • Set End Date:

      • If endDate is not null, set interventionFromInputId.outcome.endDate = {endDate}.

      • Otherwise, if interventionFromInputId.endDate <= Date.now, set interventionFromInputId.outcome.endDate = interventionFromInputId.endDate.

    • Additional validations

      • If interventionFromInputId.outcome.startDate >interventionFromInputId.outcome.endDate return ERROR.

      • If interventionFromInputId.outcome.endDate > now return ERROR.

      • if interventionFromInputId.outcome.arrivalOnSiteDate is not null, if yes return ERROR. If not:

        • Check if interventionFromInputId.outcome.takeInChargeDate < interventionFromInputId.outcome.arrivalOnSiteDate. If yes return E

      • if interventionFromInputId.outcome.arrivalOnSiteDate is not null, if yes return ERROR. If not:

        • Check if interventionFromInputId.outcome.arrivalOnSiteDate > interventionFromInputId.outcome.endDate. If yes, return ERROR.

      • if reasonId.mandatoryEncodedNote = true:

  3. Save Outcome and Update Work Order Operation and Work Order:

    • Validate Status:

      • We are managing intervention outcomes related to interventions in status not CLOSED.

      • If interventionFromInputId.status is not 'CLOSED' and interventionFromInputId.workOrderOperationId.status is 'CLOSED' or 'CANCELLED', return error INVALID_WO_OPERATION_STATUS.

    • Validate Measures (FSM 20.0):

    • Save Outcome:

    • Update Work Order Operation:

      • Retrieve and update the workOrderOperation related to interventionFromInputId.workOrderOperationId:

        • Status ID: Update interventionFromInputId.workOrderOperationId.statusId based on interventionFromInputId.outcome.reasonId.outcomeTypeId.

        • Current Duration: Update interventionFromInputId.workOrderOperationId.currentDuration

        • Progress Percentage: Calculate and update interventionFromInputId.workOrderOperationId.progressPercentage.

        • Outcome Count: Update interventionFromInputId.workOrderOperationId.outcomeCount by counting all related intervention records where intervention.outcome.reasonId is null.

        • Last Outcome Intervention ID: Set interventionFromInputId.workOrderOperationId.lastOutcomeInterventionId = interventionFromInputId

        • Last Outcome Reason ID: Set interventionFromInputId.workOrderOperationId.lastOutcomeReasonId = interventionFromInputId.outcome.reasonId.

        • Last Outcome Date: Set interventionFromInputId.workOrderOperationId.lastOutcomeDate = interventionFromInputId.endDate.

        • Last Outcome Origin ID: Set interventionFromInputId.workOrderOperationId.lastOutcomeOriginId = interventionFromInputId.originId.

        • Last Outcome User ID: Set interventionFromInputId.workOrderOperationId.lastOutcomeUserId to the user ID of the caller.

    • Update Work Order:

      • Retrieve and update the work order related to interventionFromInputId.workOrderOperationId:

        • Last Outcome Reason ID: Set interventionFromInputId.workOrderOperationId.workOrderId.lastOutcomeReasonId = interventionFromInputId.workOrderOperationId.lastOutcomeReasonId.

        • Last Outcome Date: Set interventionFromInputId.workOrderOperationId.workOrderId.lastOutcomeDate =interventionFromInputId.workOrderOperationId.lastOutcomeDate.

        • Last Outcome Origin ID: Set interventionFromInputId.workOrderOperationId.workOrderId.lastOutcomeOriginId=interventionFromInputId.workOrderOperationId.lastOutcomeOriginId.

        • Last Outcome User ID: Set interventionFromInputId.workOrderOperationId.workOrderId.lastOutcomeUserId =interventionFromInputId.workOrderOperationId.lastOutcomeUserId.



Path Parameters

Field

Note

interventionId

 

Header Parameters

Default.

Request Body Parameters

Field

Validations

Note

takeInChargeDate

Mandatory → it can be specified in the body or by previously calling the taking-charge API POST /work-orders/execution/r1/interventions/{interventionId}/taking-charge


arrivalDate

Mandatory → it can be specified in the body or by previously calling the arrival-on-site API


startDate

Mandatory → it can be specified in the body or by previously calling the running API TODO


endDate

Mandatory


reasonId

Mandatory

Referenced resource id existance check


encodedNoteId

Referenced resource id existance check


validationDate



validationStatusId

Referenced resource id existance check


notes

Max length: 4000


originId

Mandatory

Referenced resource id existance check


Response documentation

Response payload fields

Field

Note

Example value

payload

 

 

Response error codes

NOT_FOUND, BASE_0001, BASE_0003, BASE_0012, WORKORDERS_ORCHESTRATOR_001, WORKORDERS_ORCHESTRATOR_002, WORKORDERS_ORCHESTRATOR_005