Code: Select all
{
"meta": {
"instanceId": "c5bbe0e4dd0c2a71ee01ba0477f0fe876e4ef1ddb06022d07739fda528d4f9f1"
},
"nodes": [
{
"parameters": {},
"id": "606d42e8-c133-44e0-90f1-cc1a02d70ac6",
"name": "Start",
"type": "n8n-nodes-base.start",
"typeVersion": 1,
"position": [
180,
80
]
},
{
"parameters": {
"path": "GetSteriBatchbyPatient",
"responseMode": "lastNode",
"options": {}
},
"id": "275420a3-6458-4b94-a485-154c08386dfe",
"name": "GetSteriBatchbyPatient",
"type": "n8n-nodes-base.webhook",
"typeVersion": 1,
"position": [
180,
300
],
"webhookId": "49734ee3-6f88-4908-a958-f0d26ffb9f25"
},
{
"parameters": {
"path": "GetSteriBatchbyTimeframe",
"responseMode": "lastNode",
"options": {}
},
"id": "b7a11fb0-91e7-44ef-8325-ce301418d645",
"name": "GetSteriBatchbyTimeframe",
"type": "n8n-nodes-base.webhook",
"typeVersion": 1,
"position": [
180,
560
],
"webhookId": "49734ee3-6f88-4908-a958-f0d26ffb9f25"
},
{
"parameters": {
"conditions": {
"string": [
{
"value1": "={{$json[\"FieldValue\"]}}",
"operation": "isEmpty"
}
]
}
},
"id": "46b1776c-90f6-4baa-853d-6142217f9e82",
"name": "Remove empty batch Nr (A)",
"type": "n8n-nodes-base.if",
"typeVersion": 1,
"position": [
1020,
300
]
},
{
"parameters": {
"conditions": {
"string": [
{
"value1": "={{$json[\"FieldValue\"]}}",
"operation": "isEmpty"
}
]
}
},
"id": "c5800291-ac1c-41ed-9bb0-48581819c032",
"name": "Remove empty batch Nr (B)",
"type": "n8n-nodes-base.if",
"typeVersion": 1,
"position": [
1020,
560
]
},
{
"parameters": {
"functionCode": "let myValues = [];\n\nfor (item of items) {\n myValues.push(...item.json.FieldValue.split(','));\n}\n\nreturn myValues.map(e => {\n return {\n json: {\n Batch: e.trim()\n }\n };\n});"
},
"name": "Split String (A)",
"type": "n8n-nodes-base.function",
"typeVersion": 1,
"position": [
1300,
320
],
"id": "9fd8aa64-dfec-4463-bb47-7d0c39974ad1"
},
{
"parameters": {
"functionCode": "let myValues = [];\n\nfor (item of items) {\n myValues.push(...item.json.FieldValue.split(','));\n}\n\nreturn myValues.map(e => {\n return {\n json: {\n Batch: e.trim()\n }\n };\n});"
},
"name": "Split String (B)",
"type": "n8n-nodes-base.function",
"typeVersion": 1,
"position": [
1300,
580
],
"id": "25681b5f-ca5d-473c-a866-90e2168c8ae8"
},
{
"parameters": {
"mode": "multiplex",
"options": {}
},
"id": "bd36c169-99ad-4487-bd13-3c478a713f99",
"name": "Merge Bad Batch Number",
"type": "n8n-nodes-base.merge",
"typeVersion": 2,
"position": [
1300,
860
]
},
{
"parameters": {
"operation": "removeDuplicates"
},
"id": "54853902-4f77-4a6e-bbe6-e3eb28aacaa1",
"name": "Remove duplicate Patients",
"type": "n8n-nodes-base.itemLists",
"typeVersion": 1,
"position": [
2380,
820
]
},
{
"parameters": {
"path": "GetPatientbyTimeframeSteriBatch",
"responseMode": "lastNode",
"options": {
"responsePropertyName": "data"
}
},
"id": "bc404b08-cd1b-4e68-a415-6fef71bdf482",
"name": "GetPatientbyTimeframeSteriBatch",
"type": "n8n-nodes-base.webhook",
"typeVersion": 1,
"position": [
180,
820
],
"webhookId": "49734ee3-6f88-4908-a958-f0d26ffb9f25"
},
{
"parameters": {
"authentication": "genericCredentialType",
"genericAuthType": "httpHeaderAuth",
"url": "http://192.168.1.60:30223/api/v1/appointments",
"options": {
"splitIntoItems": true
},
"queryParametersUi": {
"parameter": [
{
"name": "dateStart",
"value": "={{$json[\"DateStart\"]}}"
},
{
"name": "dateEnd",
"value": "={{$json[\"DateEnd\"]}}"
}
]
}
},
"id": "518d74f6-63c6-4873-8b8f-7cabc0e76783",
"name": "Get all appointments in timeframe (B)",
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 2,
"position": [
480,
560
],
"credentials": {
"httpHeaderAuth": {
"id": "5",
"name": "Header Auth KL Office"
}
}
},
{
"parameters": {
"authentication": "genericCredentialType",
"genericAuthType": "httpHeaderAuth",
"url": "http://192.168.1.60:30223/api/v1/appointments",
"options": {
"splitIntoItems": true
},
"queryParametersUi": {
"parameter": [
{
"name": "dateStart",
"value": "={{$json[\"query\"][\"dateStart\"]}}"
},
{
"name": "dateEnd",
"value": "={{$json[\"query\"][\"dateEnd\"]}}"
}
]
}
},
"id": "ef57dda4-9b2b-4fb5-afe4-367e1d028139",
"name": "Get all appointments in timeframe (C)",
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 2,
"position": [
480,
820
],
"credentials": {
"httpHeaderAuth": {
"id": "5",
"name": "Header Auth KL Office"
}
}
},
{
"parameters": {
"authentication": "genericCredentialType",
"genericAuthType": "httpHeaderAuth",
"url": "http://192.168.1.60:30223/api/v1/appointments",
"options": {
"splitIntoItems": true
},
"queryParametersUi": {
"parameter": [
{
"name": "PatNum",
"value": "={{$json[\"query\"][\"PatNum\"]}}"
}
]
}
},
"id": "3dbee8a0-c939-4de5-9a55-f13b5f35c2e4",
"name": "Get Appointments for Patient",
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 2,
"position": [
480,
300
],
"credentials": {
"httpHeaderAuth": {
"id": "5",
"name": "Header Auth KL Office"
}
}
},
{
"parameters": {
"authentication": "genericCredentialType",
"genericAuthType": "httpHeaderAuth",
"url": "http://192.168.1.60:30223/api/v1/apptfields",
"options": {},
"queryParametersUi": {
"parameter": [
{
"name": "AptNum",
"value": "={{$json[\"AptNum\"]}}"
},
{
"name": "FieldName",
"value": "S-batch-Nr"
}
]
}
},
"id": "127ca7c5-66c0-4e81-b20a-8dd06f1566fd",
"name": "Get ApptFields",
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 2,
"position": [
760,
300
],
"credentials": {
"httpHeaderAuth": {
"id": "5",
"name": "Header Auth KL Office"
}
}
},
{
"parameters": {
"operation": "aggregateItems",
"fieldsToAggregate": {
"fieldToAggregate": [
{
"fieldToAggregate": "Batch"
}
]
},
"options": {}
},
"id": "7c268367-8167-47b4-86f5-8019bf6d850f",
"name": "Create Array (A)",
"type": "n8n-nodes-base.itemLists",
"typeVersion": 1,
"position": [
1860,
320
]
},
{
"parameters": {
"operation": "removeDuplicates",
"compare": "selectedFields",
"fieldsToCompare": {
"fields": [
{
"fieldName": "Batch"
}
]
},
"options": {}
},
"id": "95898967-78b4-4a77-b821-80b7162b2689",
"name": "Remove Duplicate Batch Nr. (A)",
"type": "n8n-nodes-base.itemLists",
"typeVersion": 1,
"position": [
1580,
320
]
},
{
"parameters": {
"operation": "removeDuplicates",
"compare": "selectedFields",
"fieldsToCompare": {
"fields": [
{
"fieldName": "Batch"
}
]
},
"options": {}
},
"id": "605d9822-26e9-402e-aef0-1228374628bb",
"name": "Remove Duplicate Batch Nr. (B)",
"type": "n8n-nodes-base.itemLists",
"typeVersion": 1,
"position": [
1580,
580
]
},
{
"parameters": {
"operation": "aggregateItems",
"fieldsToAggregate": {
"fieldToAggregate": [
{
"fieldToAggregate": "Batch"
}
]
},
"options": {}
},
"id": "e47d079f-5e20-4a4e-a4d8-500e088b0c60",
"name": "Create Array (B)",
"type": "n8n-nodes-base.itemLists",
"typeVersion": 1,
"position": [
1860,
580
]
},
{
"parameters": {
"authentication": "genericCredentialType",
"genericAuthType": "httpHeaderAuth",
"url": "http://192.168.1.60:30223/api/v1/apptfields",
"options": {},
"queryParametersUi": {
"parameter": [
{
"name": "AptNum",
"value": "={{$json[\"AptNum\"]}}"
},
{
"name": "FieldName",
"value": "S-batch-Nr"
}
]
}
},
"id": "7ea75939-d7d8-482f-be9f-55e5db9d8f6a",
"name": "Get S-batch-Nr (B)",
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 2,
"position": [
760,
560
],
"credentials": {
"httpHeaderAuth": {
"id": "5",
"name": "Header Auth KL Office"
}
}
},
{
"parameters": {
"authentication": "genericCredentialType",
"genericAuthType": "httpHeaderAuth",
"url": "http://192.168.1.60:30223/api/v1/apptfields",
"options": {},
"queryParametersUi": {
"parameter": [
{
"name": "AptNum",
"value": "={{$json[\"AptNum\"]}}"
},
{
"name": "FieldName",
"value": "S-batch-Nr"
}
]
}
},
"id": "70052272-7f9c-48fa-9876-2f4fbb111502",
"name": "Get S-batch-Nr (C)",
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 2,
"position": [
760,
940
],
"credentials": {
"httpHeaderAuth": {
"id": "5",
"name": "Header Auth KL Office"
}
}
},
{
"parameters": {
"mode": "mergeByPosition",
"options": {}
},
"id": "35bcb3a9-84aa-40e9-bd2a-e67f1617f8d9",
"name": "Merge Appointments and Batch-Nr.",
"type": "n8n-nodes-base.merge",
"typeVersion": 2,
"position": [
1020,
840
]
},
{
"parameters": {
"authentication": "genericCredentialType",
"genericAuthType": "httpHeaderAuth",
"url": "=http://192.168.1.60:30223/api/v1/patients/{{$json[\"PatNum\"]}}",
"options": {},
"queryParametersUi": {
"parameter": [
{
"name": "AptNum",
"value": "={{$json[\"AptNum\"]}}"
},
{
"name": "FieldName",
"value": "S-batch-Nr"
}
]
}
},
"id": "bfcc8d11-a3af-437d-b9d7-4933e5ad67d6",
"name": "Get Patient Names",
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 2,
"position": [
2140,
820
],
"credentials": {
"httpHeaderAuth": {
"id": "5",
"name": "Header Auth KL Office"
}
}
},
{
"parameters": {
"operation": "aggregateItems",
"aggregate": "aggregateAllItemData"
},
"id": "87abbe39-740d-4b34-bc80-2df4c80b5bfc",
"name": "Create Array (C)",
"type": "n8n-nodes-base.itemLists",
"typeVersion": 1,
"position": [
2860,
820
]
},
{
"parameters": {
"functionCode": "return [\n {\n \"PatNum\": 0,\n \"LName\": \"nobody\",\n \"FName\": \"nobody\",\n \"MiddleI\": \"\",\n \"Preferred\": \"\",\n \"Birthdate\": \"1990-07-11\",\n \"DateTStamp\": \"2022-11-29 13:06:37\"\n }\n]\n"
},
"id": "bc6613ea-1b42-4813-96ea-d039df5ddd7c",
"name": "Test Data",
"type": "n8n-nodes-base.function",
"typeVersion": 1,
"position": [
2380,
1040
],
"notes": "Only Test parameter needed is PatNum"
},
{
"parameters": {},
"id": "40cc45b1-8823-4175-94c5-60ec55d29c94",
"name": "NoOp",
"type": "n8n-nodes-base.noOp",
"typeVersion": 1,
"position": [
760,
1140
]
},
{
"parameters": {
"keepOnlySet": true,
"values": {
"number": [
{
"name": "PatNum",
"value": "={{$json[\"PatNum\"]}}"
}
],
"string": [
{
"name": "LName",
"value": "={{$json[\"LName\"]}}"
},
{
"name": "FName",
"value": "={{$json[\"FName\"]}}"
},
{
"name": "Birthdate",
"value": "={{$json[\"Birthdate\"]}}"
}
]
},
"options": {}
},
"id": "3c93b93c-1400-4699-9321-9d31a0bf8e7a",
"name": "Set",
"type": "n8n-nodes-base.set",
"typeVersion": 1,
"position": [
2620,
820
]
},
{
"parameters": {
"conditions": {
"string": [
{
"value1": "={{$json[\"FieldValue\"]}}",
"operation": "contains",
"value2": "={{$json[\"query\"][\"BadBatch\"]}}"
},
{
"value1": "={{$json[\"FieldValue\"]}}",
"operation": "isEmpty"
}
]
},
"combineOperation": "any"
},
"id": "a9f80fea-78c5-4260-8f4c-1132d8ba7481",
"name": "Select Items that contain BadBatch or Empty",
"type": "n8n-nodes-base.if",
"typeVersion": 1,
"position": [
1860,
840
]
},
{
"parameters": {
"conditions": {
"string": [
{
"value1": "={{$json[\"AptStatus\"]}}",
"value2": "Complete"
}
]
}
},
"id": "3ac72651-e2f3-4790-a6a2-3b551ce4a822",
"name": "IF",
"type": "n8n-nodes-base.if",
"typeVersion": 1,
"position": [
1580,
860
]
}
],
"connections": {
"GetSteriBatchbyPatient": {
"main": [
[
{
"node": "Get Appointments for Patient",
"type": "main",
"index": 0
}
]
]
},
"GetSteriBatchbyTimeframe": {
"main": [
[
{
"node": "Get all appointments in timeframe (B)",
"type": "main",
"index": 0
}
]
]
},
"Remove empty batch Nr (A)": {
"main": [
null,
[
{
"node": "Split String (A)",
"type": "main",
"index": 0
}
]
]
},
"Remove empty batch Nr (B)": {
"main": [
null,
[
{
"node": "Split String (B)",
"type": "main",
"index": 0
}
]
]
},
"Split String (A)": {
"main": [
[
{
"node": "Remove Duplicate Batch Nr. (A)",
"type": "main",
"index": 0
}
]
]
},
"Split String (B)": {
"main": [
[
{
"node": "Remove Duplicate Batch Nr. (B)",
"type": "main",
"index": 0
}
]
]
},
"Merge Bad Batch Number": {
"main": [
[
{
"node": "IF",
"type": "main",
"index": 0
}
]
]
},
"Remove duplicate Patients": {
"main": [
[
{
"node": "Set",
"type": "main",
"index": 0
}
]
]
},
"GetPatientbyTimeframeSteriBatch": {
"main": [
[
{
"node": "Get all appointments in timeframe (C)",
"type": "main",
"index": 0
},
{
"node": "NoOp",
"type": "main",
"index": 0
}
]
]
},
"Get all appointments in timeframe (B)": {
"main": [
[
{
"node": "Get S-batch-Nr (B)",
"type": "main",
"index": 0
}
]
]
},
"Get all appointments in timeframe (C)": {
"main": [
[
{
"node": "Get S-batch-Nr (C)",
"type": "main",
"index": 0
},
{
"node": "Merge Appointments and Batch-Nr.",
"type": "main",
"index": 0
}
]
]
},
"Get Appointments for Patient": {
"main": [
[
{
"node": "Get ApptFields",
"type": "main",
"index": 0
}
]
]
},
"Get ApptFields": {
"main": [
[
{
"node": "Remove empty batch Nr (A)",
"type": "main",
"index": 0
}
]
]
},
"Remove Duplicate Batch Nr. (A)": {
"main": [
[
{
"node": "Create Array (A)",
"type": "main",
"index": 0
}
]
]
},
"Remove Duplicate Batch Nr. (B)": {
"main": [
[
{
"node": "Create Array (B)",
"type": "main",
"index": 0
}
]
]
},
"Get S-batch-Nr (B)": {
"main": [
[
{
"node": "Remove empty batch Nr (B)",
"type": "main",
"index": 0
}
]
]
},
"Get S-batch-Nr (C)": {
"main": [
[
{
"node": "Merge Appointments and Batch-Nr.",
"type": "main",
"index": 1
}
]
]
},
"Merge Appointments and Batch-Nr.": {
"main": [
[
{
"node": "Merge Bad Batch Number",
"type": "main",
"index": 0
}
]
]
},
"Get Patient Names": {
"main": [
[
{
"node": "Remove duplicate Patients",
"type": "main",
"index": 0
}
]
]
},
"Test Data": {
"main": [
[
{
"node": "Set",
"type": "main",
"index": 0
}
]
]
},
"NoOp": {
"main": [
[
{
"node": "Merge Bad Batch Number",
"type": "main",
"index": 1
}
]
]
},
"Set": {
"main": [
[
{
"node": "Create Array (C)",
"type": "main",
"index": 0
}
]
]
},
"Select Items that contain BadBatch or Empty": {
"main": [
[
{
"node": "Get Patient Names",
"type": "main",
"index": 0
}
],
[
{
"node": "Test Data",
"type": "main",
"index": 0
}
]
]
},
"IF": {
"main": [
[
{
"node": "Select Items that contain BadBatch or Empty",
"type": "main",
"index": 0
}
]
]
}
}
}