Annotate Production Records

  • Allows adding textual comments to existing batch production records.

  • Access to the equipment model is required.

  • HTTP methods supported: POST.

Description

The annotate batch production record endpoint allows adding textual comments to an existing Batch Production Records (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 annotation items. Each annotation will be added into the BPR as a "Comment" document type.

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 annotation item

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

  • bpr
    Used to specify the parent Batch Production Record to insert the annotation.

  • annotation
    Annotation to insert as a S88 'Comment' document to the provided Batch Production Record.

  • validate_refs
    If true, DataReference attributes in the Comment document will be 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

Annotation example without data reference

HTTP POST

Request body
{
    "items": [
        {
            "bpr": {
                    "BatchID": "13"
            },
            "annotation" : {
            	"Comment" : "My First comment.",
            	"PersonID" : {
            		"#" : "My Name"
            	}
            }
        }
    ]
}
Response body
{
    "items": [
        {
            "bpr": {
                    "BatchID": "13"
            },
            "annotation" : {
            	"Comment" : "My First comment.",
            	"PersonID" : {
            		"#" : "My Name"
            	}
            }
        }
    ]
}

Annotation example with data reference and data reference validation

HTTP POST

Request body
{
    "items": [
        {
            "bpr": {
            	"BatchProductionRecord" : {
                  "BatchID": "13"
            	}
            },
            "annotation" : {
            	"Comment" : "My First comment.",
            	"PersonID" : "My Name",
            	"DataReference" : {
            		"ReferenceObjectType" : 21,
            		"ReferenceEntryID" : "64703f65-b4f9-11e9-b77c-6c2b59d68f72"
            	}
            },
             "validate_refs" : true
        }
    ]
}

The value (21) of the field ReferenceObjectType points to the object type 'Batch Production Record' as defined in the S88ProductionRecordEntryType coding group.

Response body
{
  "data": {
    "items": [
      {
        "n": "CREATED",
        "update_id": "9cedf3b8-64d6-4be7-a775-8a6ed395b8cc"
      }
    ],
    "stats": {
      "failure": 0,
      "success": 1,
      "total": 1
    }
  }
}
Response body in case the data reference validation fails
{
  "data": {
    "items": [
      {
        "error": {
          "code": 15,
          "msg": "a data reference failed validation: resolve failed"
        },
        "n": "FAILED_DENIED"
      }
    ],
    "stats": {
      "failure": 1,
      "success": 0,
      "total": 1
    }
  }
}