[ { "id": "c35879532d354a78", "type": "group", "z": "28d13c3ea2339426", "style": { "stroke": "#999999", "stroke-opacity": "1", "fill": "none", "fill-opacity": "1", "label": true, "label-position": "nw", "color": "#a4a4a4" }, "nodes": [ "c52260086c3d435c", "c3fa464e1978340d", "42d06109b4a63480", "9b09f19914b8bca1", "99237b7ad0153eb1" ], "x": 74, "y": 1759, "w": 852, "h": 122 }, { "id": "c52260086c3d435c", "type": "ctrlx-datalayer-request", "z": "28d13c3ea2339426", "g": "c35879532d354a78", "device": "7b877229.678964", "method": "READ", "path": "diagnosis/get/actual/list", "payloadFormat": "value", "name": "", "x": 410, "y": 1840, "wires": [ [ "42d06109b4a63480" ] ] }, { "id": "c3fa464e1978340d", "type": "inject", "z": "28d13c3ea2339426", "g": "c35879532d354a78", "name": "", "props": [], "repeat": "60", "crontab": "", "once": false, "onceDelay": 0.1, "topic": "", "x": 170, "y": 1840, "wires": [ [ "c52260086c3d435c" ] ] }, { "id": "42d06109b4a63480", "type": "function", "z": "28d13c3ea2339426", "g": "c35879532d354a78", "name": "check target error", "func": "var newMsg = {};\n\n// extract the payload object of diagnosis messages\nvar diagnosis_messages = msg.payload.listDiagnosisIdentificationWithTimestamp;\n\n// find out the diagnosis messages array length\nvar array_length = diagnosis_messages.length;\n\n// iterate over the messages array to find the potential error\nfor ( var i=0; i<= array_length-1; i++){\n var obj = diagnosis_messages[i];\n var mainNumber = obj.diagnosisIdentification.mainDiagnosisNumber;\n var detailedNumber;\n var entity_name;\n\n // check if required error is present in messages\n if (mainNumber == \"081F2001\"){\n detailedNumber = obj.diagnosisIdentification.detailedDiagnosisNumber;\n entity_name = obj.diagnosisIdentification.entity;\n\n // prepare the new message payload to confirm the error\n newMsg.payload = {\n \"type\": \"object\",\n \"value\": {\n \"mainDiagnosisNumber\": mainNumber,\n \"detailedDiagnosisNumber\": detailedNumber,\n \"entity\": entity_name\n }\n }\n return newMsg;\n }\n}\n\nreturn;", "outputs": 1, "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 650, "y": 1840, "wires": [ [ "9b09f19914b8bca1" ] ] }, { "id": "9b09f19914b8bca1", "type": "ctrlx-datalayer-request", "z": "28d13c3ea2339426", "g": "c35879532d354a78", "device": "7b877229.678964", "method": "WRITE", "path": "diagnosis/confirm/error", "payloadFormat": "value_type", "name": "Confirm error", "x": 830, "y": 1840, "wires": [ [] ] }, { "id": "99237b7ad0153eb1", "type": "comment", "z": "28d13c3ea2339426", "g": "c35879532d354a78", "name": "clear non-required errors from pending diagnostics", "info": "", "x": 310, "y": 1800, "wires": [] }, { "id": "7b877229.678964", "type": "ctrlx-config", "name": "localhost", "hostname": "localhost", "debug": false } ]