Update Batch Production Records

  • Inserts, updates or replaces new or existing batch production record and/or it’s sub documents.

  • Access to the equipment model is required.

  • HTTP methods supported: POST.

Description

The update batch production records endpoint allows update, replace or insert a new Batch Production Record (BRP). The endpoint logic makes use of the Lua function isa88.db.update().

Parameters

Name Type Optional Description

body

body

no

A list of BPR update items. Each item in the list should represent one 'update' operation.

wait_for_completion

boolean

yes

Option to force the server to just queue the MongoDB operations and return as quickly as possible. In this case the outcome of the annotate operations will not be part of the response.

insights

boolean

yes

Indicates application insights should be included in the response, by default false.

BPR update item

Should be a valid JSON document representing a single 'update' operation to perform. The following fields are supported:

  • doc
    Doc is a mandatory argument, which must represent a valid S88 document (a BatchProductionRecord, Comment, Sample, etc.).

  • doc_type
    Specifies the S88 document type of the doc argument. Optional, by default 'BatchProductionrecord'.

  • filter
    Filter used to match documents for 'update' and 'replace operations'.

  • filter_type
    Specifies the S88 document type of the filter argument. Optional, by default 'BatchProductionrecord'.

  • bpr
    Specifies a filter for the attributes of a Batch Production Record. This option can be used to further constrain the parent or filter option to the set of matched documents.

  • Operation
    Supported operations are insert (0 or 'insert'), replace (1 or 'replace') and update (2 or 'update') Optional, default operation is insert.

  • parent
    Used to match the parent documents for 'insert' operation'.

  • parent_type
    Specifies the S88 document type of the parent argument. Optional, by default 'BatchProductionrecord'.

  • validate_refs
    If true, DataReference attributes in Change and Comment documents are validated. The validation is performed in memory if a new stand-alone BPR with Embedded Change or Comment sub-documents is inserted. Otherwise, DataReference attributes are validated by checking the existence of the referenced document attribute in the database. Optional, by default false.

  • wait_for_completion
    Option to force the server to just queue the MongoDB operations and return as quickly as possible. If set to false the outcome of the update operations will not be part of the response. Optional, by default true.

Response structure

The response structure is the same as the response structure of the mass endpoint. The items in the response contain an update_id field, which can be matched later with the results published by the BPR Publisher class.

Examples

Insert BatchProduction Record example

HTTP POST

Request body
{
    "items": [
        {
            "doc": {
                "BatchID": "insert-bpr-01",
                "EquipmentID": "/A/B",
                "ControlRecipes": {
                    "ID": "CR-01"
                }
            },
            "doc_type": "BatchProductionRecord",
            "operation": 0,
            "wait_for_completion": true
        }
    ]
}
Response body
{
  "data": {
    "items": [
      {
        "n": "CREATED",
        "update_id": "89d318c4-3e6a-43fa-8ef3-244994dcca58"
      }
    ],
    "stats": {
      "failure": 0,
      "success": 1,
      "total": 1
    }
  }
}

Update a Batch Production Record example by adding a Lot ID.

HTTP POST

Request body
{
    "items": [
        {
            "doc": {
                "LotID": "lot-0001"
            },
            "doc_type": "BatchProductionRecord",
            "filter": {
                "BatchID": "insert-bpr-01"
            },
            "operation": "update",
            "wait_for_completion": true
        }
    ]
}
Response body
{
  "data": {
    "items": [
      {
        "n": "UPDATED",
        "update_id": "3c2216df-499b-490a-ac59-c7e166d93736"
      }
    ],
    "stats": {
      "failure": 0,
      "success": 1,
      "total": 1
    }
  }
}