Page 1 of 1

Sterilization Monitoring using n8n and Appsmith 1/2

Posted: Wed Nov 30, 2022 2:35 am
by joergzastrau
Dear all,

we have introduced an Appt Field to record the batch numbers for autoclave runs used during treatment to support sterilization monitoring (screenshot attached).

The n8n workflow provides 3 webhooks to look up

- all batch numbers used on all patients during a specific time period
- all patients affected by a specific batch number during a specific time period
- all batch numbers that have ever been used during the treatment of one patient

The Appsmith low code GUI application provides the user interface (default time period previous 14 days, screenshot attached).

Drawback: Changes to Appt Fields don't seem to appear in the Audit Trail.

Requirements:

.) OD version 21.1 or later with RO API access (tested with 22.2.52.0)
.) n8n (tested with version 0.195.5, port 5678)
.) Appsmith (tested with version 1.8.8 )

We use Docker images for n8n and Appsmith. Setup see http://opendentalsoft.com/forum/viewtop ... f=9&t=7749 (similar).

Code in subsequent post.

Please ask.

Joerg

Sterilization Monitoring using n8n and Appsmith 2/2

Posted: Wed Nov 30, 2022 2:37 am
by joergzastrau
Code for n8n:

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": {
        "conditions": {
          "string": [
            {
              "value1": "={{$json[\"FieldValue\"]}}",
              "operation": "contains",
              "value2": "={{$json[\"query\"][\"BadBatch\"]}}"
            }
          ]
        }
      },
      "id": "a9f80fea-78c5-4260-8f4c-1132d8ba7481",
      "name": "Remove empty batch Nr (C)",
      "type": "n8n-nodes-base.if",
      "typeVersion": 1,
      "position": [
        1580,
        860
      ]
    },
    {
      "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": [
        2100,
        840
      ]
    },
    {
      "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": [
        1860,
        840
      ],
      "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": [
        2580,
        840
      ]
    },
    {
      "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": [
        2100,
        1060
      ],
      "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": [
        2340,
        840
      ]
    }
  ],
  "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
          }
        ]
      ]
    },
    "Remove empty batch Nr (C)": {
      "main": [
        [
          {
            "node": "Get Patient Names",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Test Data",
            "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": "Remove empty batch Nr (C)",
            "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
          }
        ]
      ]
    }
  }
}
Code for Appsmith (see attachment).

Re: Sterilization Monitoring using n8n and Appsmith 1/2

Posted: Tue Dec 20, 2022 4:26 am
by joergzastrau
Changes:

- return patients with missing sterilization information
- return only patients with completed appointments
- fixed spelling mistakes

Updated Code for n8n:

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
          }
        ]
      ]
    }
  }
}

Sterilization Monitoring using n8n and Appsmith V2.0

Posted: Sun Aug 18, 2024 1:03 am
by joergzastrau
Dear all,

the workflow has been updated with current nodes for new versions of n8n (tested with version 1.50.1). The Appsmith application is unchanged.

Code: Select all

{
  "meta": {
    "instanceId": "c5bbe0e4dd0c2a71ee01ba0477f0fe876e4ef1ddb06022d07739fda528d4f9f1"
  },
  "nodes": [
    {
      "parameters": {
        "path": "GetSteriBatchbyPatient",
        "responseMode": "lastNode",
        "options": {}
      },
      "id": "28a96fe3-2404-4577-8cb5-8fc78b9d7c6d",
      "name": "GetSteriBatchbyPatient",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 1,
      "position": [
        460,
        460
      ],
      "webhookId": "49734ee3-6f88-4908-a958-f0d26ffb9f25"
    },
    {
      "parameters": {
        "conditions": {
          "string": [
            {
              "value1": "={{$json[\"FieldValue\"]}}",
              "operation": "isEmpty"
            }
          ]
        }
      },
      "id": "8dd0e1ea-c56c-4f0d-acb7-d4df856e2266",
      "name": "Remove empty batch Nr (A)",
      "type": "n8n-nodes-base.if",
      "typeVersion": 1,
      "position": [
        1300,
        460
      ]
    },
    {
      "parameters": {
        "conditions": {
          "string": [
            {
              "value1": "={{$json[\"FieldValue\"]}}",
              "operation": "isEmpty"
            }
          ]
        }
      },
      "id": "83649962-705a-4c61-b0d3-57b65eff98ac",
      "name": "Remove empty batch Nr (B)",
      "type": "n8n-nodes-base.if",
      "typeVersion": 1,
      "position": [
        1300,
        720
      ]
    },
    {
      "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": [
        1580,
        480
      ],
      "id": "0e9ef6c2-63fc-4275-b5a3-2e534c95d43c"
    },
    {
      "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": [
        1580,
        740
      ],
      "id": "656bea51-d7ca-480e-a809-522d7ed2f9c7"
    },
    {
      "parameters": {
        "mode": "combine",
        "combinationMode": "multiplex",
        "options": {}
      },
      "id": "adde7ae8-ac7e-493a-8432-f22e3e1404dd",
      "name": "Merge Bad Batch Number",
      "type": "n8n-nodes-base.merge",
      "typeVersion": 2,
      "position": [
        1580,
        1020
      ]
    },
    {
      "parameters": {
        "operation": "removeDuplicates"
      },
      "id": "a543d2a0-eecb-4945-a7b4-5240bf85ec29",
      "name": "Remove duplicate Patients",
      "type": "n8n-nodes-base.itemLists",
      "typeVersion": 1,
      "position": [
        2660,
        980
      ]
    },
    {
      "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": "2d1ec21c-f152-40f3-bce3-4b7b970edc40",
      "name": "Get all appointments in timeframe (B)",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 2,
      "position": [
        760,
        720
      ],
      "credentials": {
        "httpHeaderAuth": {
          "id": "c8ZCHq07tFc7C8sw",
          "name": "Header Auth account 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": "b6c63999-d314-4586-b654-4e5ff9af5155",
      "name": "Get all appointments in timeframe (C)",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 2,
      "position": [
        760,
        980
      ],
      "credentials": {
        "httpHeaderAuth": {
          "id": "c8ZCHq07tFc7C8sw",
          "name": "Header Auth account 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": "68507b43-9da9-4998-a702-15686e6c6399",
      "name": "Get Appointments for Patient",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 2,
      "position": [
        760,
        460
      ],
      "credentials": {
        "httpHeaderAuth": {
          "id": "c8ZCHq07tFc7C8sw",
          "name": "Header Auth account 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": "8dc7c99d-d8c6-4d2a-9d07-3c9a1f3bfede",
      "name": "Get ApptFields",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 2,
      "position": [
        1040,
        460
      ],
      "credentials": {
        "httpHeaderAuth": {
          "id": "c8ZCHq07tFc7C8sw",
          "name": "Header Auth account KL Office"
        }
      }
    },
    {
      "parameters": {
        "operation": "aggregateItems",
        "fieldsToAggregate": {
          "fieldToAggregate": [
            {
              "fieldToAggregate": "Batch"
            }
          ]
        },
        "options": {}
      },
      "id": "a946987b-64e1-4c7a-a9db-0a2360f43e8e",
      "name": "Create Array (A)",
      "type": "n8n-nodes-base.itemLists",
      "typeVersion": 1,
      "position": [
        2140,
        480
      ]
    },
    {
      "parameters": {
        "operation": "removeDuplicates",
        "compare": "selectedFields",
        "fieldsToCompare": {
          "fields": [
            {
              "fieldName": "Batch"
            }
          ]
        },
        "options": {}
      },
      "id": "51f5427e-88ea-4a0e-8dc9-5eeeb9373389",
      "name": "Remove Duplicate Batch Nr. (A)",
      "type": "n8n-nodes-base.itemLists",
      "typeVersion": 1,
      "position": [
        1860,
        480
      ]
    },
    {
      "parameters": {
        "operation": "removeDuplicates",
        "compare": "selectedFields",
        "fieldsToCompare": {
          "fields": [
            {
              "fieldName": "Batch"
            }
          ]
        },
        "options": {}
      },
      "id": "a583044c-95bd-4713-8539-a08fec52b2ff",
      "name": "Remove Duplicate Batch Nr. (B)",
      "type": "n8n-nodes-base.itemLists",
      "typeVersion": 1,
      "position": [
        1860,
        740
      ]
    },
    {
      "parameters": {
        "operation": "aggregateItems",
        "fieldsToAggregate": {
          "fieldToAggregate": [
            {
              "fieldToAggregate": "Batch"
            }
          ]
        },
        "options": {}
      },
      "id": "3c4b9f6e-29fb-4496-a15a-3655d97db8f2",
      "name": "Create Array (B)",
      "type": "n8n-nodes-base.itemLists",
      "typeVersion": 1,
      "position": [
        2140,
        740
      ]
    },
    {
      "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": "0bc06a69-9eb8-4d7b-b61f-6a05d299b40e",
      "name": "Get S-batch-Nr (B)",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 2,
      "position": [
        1040,
        720
      ],
      "credentials": {
        "httpHeaderAuth": {
          "id": "c8ZCHq07tFc7C8sw",
          "name": "Header Auth account 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": "d8042c94-0ab0-4265-803c-8cf88309fe38",
      "name": "Get S-batch-Nr (C)",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 2,
      "position": [
        1040,
        1100
      ],
      "credentials": {
        "httpHeaderAuth": {
          "id": "c8ZCHq07tFc7C8sw",
          "name": "Header Auth account KL Office"
        }
      }
    },
    {
      "parameters": {
        "mode": "combine",
        "combinationMode": "mergeByPosition",
        "options": {}
      },
      "id": "f1261634-866b-45ac-aafc-7bbc8a407136",
      "name": "Merge Appointments and Batch-Nr.",
      "type": "n8n-nodes-base.merge",
      "typeVersion": 2,
      "position": [
        1300,
        1000
      ]
    },
    {
      "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": "f4dd5133-c81e-4a71-b2ce-21525e035bf6",
      "name": "Get Patient Names",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 2,
      "position": [
        2420,
        980
      ],
      "credentials": {
        "httpHeaderAuth": {
          "id": "c8ZCHq07tFc7C8sw",
          "name": "Header Auth account KL Office"
        }
      }
    },
    {
      "parameters": {
        "operation": "aggregateItems",
        "aggregate": "aggregateAllItemData"
      },
      "id": "cd8c0cd6-f2e3-4c91-a54b-4b6ee4e89999",
      "name": "Create Array (C)",
      "type": "n8n-nodes-base.itemLists",
      "typeVersion": 1,
      "position": [
        3220,
        980
      ]
    },
    {
      "parameters": {},
      "id": "43c53c4f-4878-452a-8cd1-20c9820d76aa",
      "name": "NoOp",
      "type": "n8n-nodes-base.noOp",
      "typeVersion": 1,
      "position": [
        1040,
        1300
      ]
    },
    {
      "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": "b5ee92d3-749e-45bd-91eb-b0c27a205760",
      "name": "Set",
      "type": "n8n-nodes-base.set",
      "typeVersion": 1,
      "position": [
        2940,
        980
      ]
    },
    {
      "parameters": {
        "conditions": {
          "string": [
            {
              "value1": "={{$json[\"FieldValue\"]}}",
              "operation": "contains",
              "value2": "={{$json[\"query\"][\"BadBatch\"]}}"
            },
            {
              "value1": "={{$json[\"FieldValue\"]}}",
              "operation": "isEmpty"
            }
          ]
        },
        "combineOperation": "any"
      },
      "id": "3de3a09c-4418-49b6-86ed-ab2fb623a074",
      "name": "Select Items that contain BadBatch or Empty",
      "type": "n8n-nodes-base.if",
      "typeVersion": 1,
      "position": [
        2140,
        1000
      ]
    },
    {
      "parameters": {
        "conditions": {
          "string": [
            {
              "value1": "={{$json[\"AptStatus\"]}}",
              "value2": "Complete"
            }
          ]
        }
      },
      "id": "3cb7cfb1-a400-4818-9272-9f6b39aa4d60",
      "name": "IF",
      "type": "n8n-nodes-base.if",
      "typeVersion": 1,
      "position": [
        1860,
        1020
      ]
    },
    {
      "parameters": {
        "path": "GetSteriBatchbyTimeframe",
        "responseMode": "lastNode",
        "options": {}
      },
      "id": "c6287ed6-8cb0-477f-b516-a0e8c14dad89",
      "name": "GetSteriBatchbyTimeframe",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 1,
      "position": [
        460,
        720
      ],
      "webhookId": "49734ee3-6f88-4908-a958-f0d26ffb9f25"
    },
    {
      "parameters": {
        "path": "GetPatientbyTimeframeSteriBatch",
        "responseMode": "lastNode",
        "options": {
          "responsePropertyName": "data"
        }
      },
      "id": "c8ec94a8-0195-4b8f-a24c-b7a88e8d0aa0",
      "name": "Webhook",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2,
      "position": [
        460,
        980
      ],
      "webhookId": "5eab5023-3753-400b-8d8b-060579a10e8e"
    }
  ],
  "connections": {
    "GetSteriBatchbyPatient": {
      "main": [
        [
          {
            "node": "Get Appointments for Patient",
            "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
          }
        ]
      ]
    },
    "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
          }
        ]
      ]
    },
    "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
          }
        ]
      ]
    },
    "IF": {
      "main": [
        [
          {
            "node": "Select Items that contain BadBatch or Empty",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "GetSteriBatchbyTimeframe": {
      "main": [
        [
          {
            "node": "Get all appointments in timeframe (B)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Webhook": {
      "main": [
        [
          {
            "node": "Get all appointments in timeframe (C)",
            "type": "main",
            "index": 0
          },
          {
            "node": "NoOp",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "pinData": {}
}
With best regards

Joerg