Query Batch Production Records
-
Retrieves batch production record data.
-
For querying Batch Production Records stored in the default system Production Tracking data store, access to the equipment model is required.
-
For querying Batch Production Records stored in a custom Production Tracking data store, READ permission on the data store object is required.
-
HTTP methods supported: GET, POST.
Description
The query batch production records endpoint allows Batch Production Record (BRP) querying. The queries use a syntax similar to the MongoDB query language such as the $lte and $gte comparison operators.
Parameters
Name | Type | Optional | Description |
---|---|---|---|
data_store |
long / string |
depends |
Specifies a data store. If not specified, this defaults to the System Production Tracking Data Store for Master Cores. For Local Cores, this option is required.The value is an object ID or path, identifying the System object or a custom store object. |
query |
string |
no |
Batch production record query. Has to be a JSON document. In case of a HTTP GET the value of this URL query parameter must be Base64 encoded. |
project |
string |
yes |
A JSON dictionary which specifies the inclusion or exclusion of fields returned by the BPR query. In case of a HTTP GET the value of this URL query parameter must be Base64 encoded. By default not set. |
sort |
string |
yes |
Expression to order the Batch Production Records in the response. The syntax is identical to the MongoDB sort expression syntax. Has to be a JSON (dictionary). In case of a HTTP GET the value of this URL query parameter must be Base64 encoded. By default not set. |
group_by_root |
boolean |
yes |
Can be used to force the server not to group the documents by their root id and to return the documents as is. By default true. |
return_sub_documents |
boolean |
yes |
Indicates subdocuments should constructed recursively and included in the response, by default true. This can be switched-off if only the top-level fields are required. |
limit |
integer |
yes |
Limits the number of results in the response, ignored by default. |
skip |
integer |
yes |
Specifies the first number of results to skip, ignored by default. |
format |
string |
yes |
Can be used to force the server to return the response in a certain format. Supported formats are 'isa88' and 'batchtree', by default 'isa88'. |
timeout |
integer |
yes |
Time limit in milliseconds for processing the query, by default 10000 milliseconds. |
insights |
boolean |
yes |
Indicates application insights should be included in the response, by default false. |
Examples
The Batch Production Record find() function is called by requiring the isa88.db.find library. Read more about the lua logic behind the query batch production records endpoint here.
Querying Event type documents
This example demonstrates how to find documents of type Event whose TimeStamp is within a range of the specified time.
HTTP POST
Request body
{
"query": {
"Event": {
"TimeStamp": {
"$lte": {
"$date": "2019-07-19T16:30:00.0Z"
},
"$gte": {
"$date": "2019-07-18T12:00:00.0Z"
}
}
}
}
}
Response body
{
"data": {
"batch_production_record_data": [
{
"Events": [
{
"EntryID": "9a0a8330-a953-11e9-b77c-6c2b59d68f72",
"EquipmentID": {
"#": "/XI Pharma/Köln/Human Drugs/WSC/WSC-1"
},
"EventSubType": {
"#": 20
},
"EventType": {
"#": 3
},
"ObjectType": {
"#": 1
},
"TimeStamp": 1563451210155,
"Value": {
"#": 3
}
},
{
"EntryID": "9a0a8331-a953-11e9-b77c-6c2b59d68f72",
"EquipmentID": {
"#": "/XI Pharma/Köln/Human Drugs/WSC/WSC-1"
},
"EventSubType": {
"#": 20
},
"EventType": {
"#": 3
},
"ObjectType": {
"#": 1
},
"PreviousValue": {
"#": 3
},
"TimeStamp": 1563451215156,
"Value": {
"#": 17
}
}
],
"ID": "E41D3DC9-B4E0-4572-AE8A-ABAA5BD7D71A"
},
{
"Events": [
{
"EntryID": "9410a107-a953-11e9-b77c-6c2b59d68f72",
"EquipmentID": {
"#": "/XI Pharma/Köln/Human Drugs/WSC/WSC-1"
},
"EventSubType": {
"#": 20
},
"EventType": {
"#": 3
},
"ObjectType": {
"#": 1
},
"TimeStamp": 1563451200155,
"Value": {
"#": 3
}
},
{
"EntryID": "9410a108-a953-11e9-b77c-6c2b59d68f72",
"EquipmentID": {
"#": "/XI Pharma/Köln/Human Drugs/WSC/WSC-1"
},
"EventSubType": {
"#": 20
},
"EventType": {
"#": 3
},
"ObjectType": {
"#": 1
},
"PreviousValue": {
"#": 3
},
"TimeStamp": 1563451205156,
"Value": {
"#": 17
}
}
],
"ID": "A7811B7E-EA29-4F42-8643-3CEE941799D1"
}
]
}
}
Query conditions on multiple document types
This example demonstrates that user can also specify conditions on multiple document types at once. In that case, the full 'Batch Production Record' documents which match the criterion are returned regardless of the type of documents specified.
HTTP POST
Request body
{
"query": [
{
"BatchProductionRecord": {
"EquipmentID": "/XI Pharma/Köln/Human Drugs/WSC/WSC-1"
}
},
{
"Event": {
"TimeStamp": {
"$lte": {
"$date": "2019-07-18T12:30:00.0Z"
},
"$gte": {
"$date": "2019-07-18T12:00:00.0Z"
}
}
}
}
]
}
Response body
Note, due to the size of the response, the example displayed below is reduced.
{
"data": {
"batch_production_record_data": [
{
"BatchProductionRecords": [
{
"BatchID": [
{
"#": "14"
}
],
"ControlRecipes": [
{
...
}
],
"CreationDate": 1563451215327,
"DataSets": [
{
...
}
],
"EntryID": "9a0a832f-a953-11e9-b77c-6c2b59d68f72",
"EquipmentID": [
{
"#": "/XI Pharma/Köln/Human Drugs/WSC/WSC-1"
}
],
"Events": [
{
...
},
{
...
}
],
"ID": "E41D3DC9-B4E0-4572-AE8A-ABAA5BD7D71A",
"ObjectType": {
"#": 21
},
"TimeStamp": 1563451215327
}
],
"ID": "E41D3DC9-B4E0-4572-AE8A-ABAA5BD7D71A"
},
{
"BatchProductionRecords": [
{
"BatchID": [
{
"#": "13"
}
],
"ControlRecipes": [
{
...
}
],
"CreationDate": 1563451205301,
"DataSets": [
{
...
},
{
...
}
],
"EntryID": "9410a106-a953-11e9-b77c-6c2b59d68f72",
"EquipmentID": [
{
"#": "/XI Pharma/Köln/Human Drugs/WSC/WSC-1"
}
],
"Events": [
{
...
},
{
...
}
],
"ID": "A7811B7E-EA29-4F42-8643-3CEE941799D1",
"ObjectType": {
"#": 21
},
"TimeStamp": 1563451205301
}
],
"ID": "A7811B7E-EA29-4F42-8643-3CEE941799D1"
}
]
}
}
Querying BatchIDs within a time range
This example demonstrates how to find the BatchIDs of Batch Production records whose TimeStamp is within a range of the specified time. The project option is used to only include the 'BatchID' field in the response.
Querying BatchIDs within a time range
This example demonstrates how to find the BatchIDs of Batch Production records whose TimeStamp is within a certain time range. The project
option is used to only include the 'BatchID' and 'TimeStamp' fields in the response. The sort
option is used to order the records in the response in descending order based on the TimeStamp.
HTTP POST
Request body
{
"query": {
"BatchProductionRecord": {
"TimeStamp": {
"$gte": {
"$date": "2019-07-01T00:00:00.000Z"
},
"$lte": {
"$date": "2019-10-01T00:00:00.000Z"
}
}
}
},
"project" : {
"BatchProductionRecord" :{
"BatchID" : 1,
"TimeStamp" : 1
}
},
"sort" : {
"BatchProductionRecord" :{
"TimeStamp" : -1
}
}
}