mirror of
https://dev.azure.com/globalhealthx/EMR/_git/helix-engage-server
synced 2026-05-18 20:08:19 +00:00
fix: extract datetime from slot selection ID before booking
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
scheduledAt was passed as raw "slot:{id}:{datetime}" — platform rejected
it. Added extract_datetime expression to pull the ISO datetime from the
third segment. Updated flow JSON with SetVariableBlock after slot input.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -21,7 +21,8 @@
|
|||||||
{ "id": "v13", "name": "docListResult", "type": "object" },
|
{ "id": "v13", "name": "docListResult", "type": "object" },
|
||||||
{ "id": "v14", "name": "slotListResult", "type": "object" },
|
{ "id": "v14", "name": "slotListResult", "type": "object" },
|
||||||
{ "id": "v15", "name": "aiGreeting", "type": "string" },
|
{ "id": "v15", "name": "aiGreeting", "type": "string" },
|
||||||
{ "id": "v16", "name": "reason", "type": "string" }
|
{ "id": "v16", "name": "reason", "type": "string" },
|
||||||
|
{ "id": "v17", "name": "scheduledDateTime", "type": "string" }
|
||||||
],
|
],
|
||||||
"groups": [
|
"groups": [
|
||||||
{
|
{
|
||||||
@@ -189,6 +190,13 @@
|
|||||||
"type": "input",
|
"type": "input",
|
||||||
"inputType": "any",
|
"inputType": "any",
|
||||||
"variableId": "selectedSlot"
|
"variableId": "selectedSlot"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "b17a",
|
||||||
|
"type": "set_variable",
|
||||||
|
"variableId": "scheduledDateTime",
|
||||||
|
"value": "selectedSlot",
|
||||||
|
"expression": "extract_datetime"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
@@ -253,7 +261,7 @@
|
|||||||
"phoneNumber": "{{_phone}}",
|
"phoneNumber": "{{_phone}}",
|
||||||
"department": "{{selectedDepartmentTitle}}",
|
"department": "{{selectedDepartmentTitle}}",
|
||||||
"doctorName": "{{selectedDoctor_title}}",
|
"doctorName": "{{selectedDoctor_title}}",
|
||||||
"scheduledAt": "{{selectedSlot}}",
|
"scheduledAt": "{{scheduledDateTime}}",
|
||||||
"reason": "{{reason}}"
|
"reason": "{{reason}}"
|
||||||
},
|
},
|
||||||
"outputVariableId": "bookingResult"
|
"outputVariableId": "bookingResult"
|
||||||
@@ -312,7 +320,7 @@
|
|||||||
{ "id": "e6", "from": { "blockId": "b13", "conditionId": "c4" }, "to": { "groupId": "g4a" } },
|
{ "id": "e6", "from": { "blockId": "b13", "conditionId": "c4" }, "to": { "groupId": "g4a" } },
|
||||||
{ "id": "e7", "from": { "blockId": "b14" }, "to": { "groupId": "g5" } },
|
{ "id": "e7", "from": { "blockId": "b14" }, "to": { "groupId": "g5" } },
|
||||||
{ "id": "e8", "from": { "blockId": "b15" }, "to": { "groupId": "g5" } },
|
{ "id": "e8", "from": { "blockId": "b15" }, "to": { "groupId": "g5" } },
|
||||||
{ "id": "e9", "from": { "blockId": "b17" }, "to": { "groupId": "g6" } },
|
{ "id": "e9", "from": { "blockId": "b17a" }, "to": { "groupId": "g6" } },
|
||||||
{ "id": "e10", "from": { "blockId": "b19" }, "to": { "groupId": "g7" } },
|
{ "id": "e10", "from": { "blockId": "b19" }, "to": { "groupId": "g7" } },
|
||||||
{ "id": "e11", "from": { "blockId": "b22", "conditionId": "c5" }, "to": { "groupId": "g8" } },
|
{ "id": "e11", "from": { "blockId": "b22", "conditionId": "c5" }, "to": { "groupId": "g8" } },
|
||||||
{ "id": "e12", "from": { "blockId": "b22", "conditionId": "c6" }, "to": { "groupId": "g9" } }
|
{ "id": "e12", "from": { "blockId": "b22", "conditionId": "c6" }, "to": { "groupId": "g9" } }
|
||||||
|
|||||||
@@ -81,7 +81,7 @@ export type SetVariableBlock = {
|
|||||||
type: 'set_variable';
|
type: 'set_variable';
|
||||||
variableId: string;
|
variableId: string;
|
||||||
value: string;
|
value: string;
|
||||||
expression?: 'extract_id' | 'date_tomorrow' | 'date_day_after';
|
expression?: 'extract_id' | 'extract_datetime' | 'date_tomorrow' | 'date_day_after';
|
||||||
};
|
};
|
||||||
|
|
||||||
export type ToolCallBlock = {
|
export type ToolCallBlock = {
|
||||||
|
|||||||
@@ -25,10 +25,16 @@ export class FlowVariableService {
|
|||||||
evaluateExpression(expression: string, value: string, variables: Record<string, any>): any {
|
evaluateExpression(expression: string, value: string, variables: Record<string, any>): any {
|
||||||
switch (expression) {
|
switch (expression) {
|
||||||
case 'extract_id': {
|
case 'extract_id': {
|
||||||
// Extract UUID from "doc:{uuid}:{name}" or "dept:{name}" or "slot:{id}:{datetime}"
|
// Extract second segment: "doc:{uuid}:{name}" → uuid, "dept:{name}" → name
|
||||||
const parts = value.split(':');
|
const parts = value.split(':');
|
||||||
return parts.length >= 2 ? parts[1] : value;
|
return parts.length >= 2 ? parts[1] : value;
|
||||||
}
|
}
|
||||||
|
case 'extract_datetime': {
|
||||||
|
// Extract datetime from "slot:{doctorId}:{datetime}" → "2026-04-21T14:00:00"
|
||||||
|
const parts = value.split(':');
|
||||||
|
// Rejoin from index 2 onwards (datetime contains colons: 2026-04-21T14:00:00)
|
||||||
|
return parts.length >= 3 ? parts.slice(2).join(':') : value;
|
||||||
|
}
|
||||||
case 'date_tomorrow': {
|
case 'date_tomorrow': {
|
||||||
const d = new Date(Date.now() + 86400000);
|
const d = new Date(Date.now() + 86400000);
|
||||||
return d.toISOString().split('T')[0];
|
return d.toISOString().split('T')[0];
|
||||||
|
|||||||
Reference in New Issue
Block a user