@awell-health/awell-extensions 2.0.211 ā 2.0.213
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/extensions/awell/v1/actions/updatePatient/config/getTimezones.js +37 -4
- package/dist/extensions/awell/v1/actions/updatePatient/config/getTimezones.js.map +1 -1
- package/dist/extensions/mailgun/settings.d.ts +2 -2
- package/dist/extensions/math/v1/actions/generateRandomNumber/config/fields.d.ts +2 -2
- package/dist/extensions/shelly/actions/summarizeForm/summarizeForm.js +13 -17
- package/dist/extensions/shelly/actions/summarizeForm/summarizeForm.js.map +1 -1
- package/dist/extensions/shelly/actions/summarizeTrackOutcome/lib/summarizeTrackOutcomeWithLLM/prompt.d.ts +1 -1
- package/dist/extensions/shelly/actions/summarizeTrackOutcome/lib/summarizeTrackOutcomeWithLLM/prompt.js +98 -48
- package/dist/extensions/shelly/actions/summarizeTrackOutcome/lib/summarizeTrackOutcomeWithLLM/prompt.js.map +1 -1
- package/dist/extensions/shelly/actions/summarizeTrackOutcome/lib/summarizeTrackOutcomeWithLLM/summarizeTrackOutcomeWithLLM.evaluate.d.ts +1 -0
- package/dist/extensions/shelly/actions/summarizeTrackOutcome/lib/summarizeTrackOutcomeWithLLM/summarizeTrackOutcomeWithLLM.evaluate.js +151 -0
- package/dist/extensions/shelly/actions/summarizeTrackOutcome/lib/summarizeTrackOutcomeWithLLM/summarizeTrackOutcomeWithLLM.evaluate.js.map +1 -0
- package/dist/extensions/shelly/actions/summarizeTrackOutcome/summarizeTrackOutcome.js +14 -19
- package/dist/extensions/shelly/actions/summarizeTrackOutcome/summarizeTrackOutcome.js.map +1 -1
- package/dist/extensions/shelly/lib/getCareFlowDetails/getCareFlowDetails.d.ts +15 -0
- package/dist/extensions/shelly/lib/getCareFlowDetails/getCareFlowDetails.js +98 -0
- package/dist/extensions/shelly/lib/getCareFlowDetails/getCareFlowDetails.js.map +1 -0
- package/dist/extensions/shelly/lib/getCareFlowDetails/index.d.ts +1 -0
- package/dist/extensions/shelly/lib/getCareFlowDetails/index.js +18 -0
- package/dist/extensions/shelly/lib/getCareFlowDetails/index.js.map +1 -0
- package/dist/extensions/shelly/lib/getTrackData/getTrackData.d.ts +6 -53
- package/dist/extensions/shelly/lib/getTrackData/getTrackData.js +557 -372
- package/dist/extensions/shelly/lib/getTrackData/getTrackData.js.map +1 -1
- package/dist/extensions/shelly/lib/getTrackData/index.d.ts +1 -1
- package/dist/extensions/shelly/lib/getTrackData/index.js +15 -3
- package/dist/extensions/shelly/lib/getTrackData/index.js.map +1 -1
- package/dist/extensions/shelly/lib/getTrackData/types.d.ts +193 -0
- package/dist/extensions/shelly/lib/getTrackData/types.js +3 -0
- package/dist/extensions/shelly/lib/getTrackData/types.js.map +1 -0
- package/dist/extensions/talkDesk/settings.d.ts +2 -2
- package/package.json +2 -1
@@ -1,11 +1,44 @@
|
|
1
1
|
"use strict";
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
3
|
+
if (k2 === undefined) k2 = k;
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
7
|
+
}
|
8
|
+
Object.defineProperty(o, k2, desc);
|
9
|
+
}) : (function(o, m, k, k2) {
|
10
|
+
if (k2 === undefined) k2 = k;
|
11
|
+
o[k2] = m[k];
|
12
|
+
}));
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
15
|
+
}) : function(o, v) {
|
16
|
+
o["default"] = v;
|
17
|
+
});
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
19
|
+
var ownKeys = function(o) {
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
21
|
+
var ar = [];
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
23
|
+
return ar;
|
24
|
+
};
|
25
|
+
return ownKeys(o);
|
26
|
+
};
|
27
|
+
return function (mod) {
|
28
|
+
if (mod && mod.__esModule) return mod;
|
29
|
+
var result = {};
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
31
|
+
__setModuleDefault(result, mod);
|
32
|
+
return result;
|
33
|
+
};
|
34
|
+
})();
|
2
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
36
|
exports.getTimezoneOptions = void 0;
|
37
|
+
const tzdata = __importStar(require("tzdata"));
|
4
38
|
const getTimezoneOptions = () => {
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
value: timezone,
|
39
|
+
return Object.keys(tzdata.zones).map((tz) => ({
|
40
|
+
label: tz,
|
41
|
+
value: tz,
|
9
42
|
}));
|
10
43
|
};
|
11
44
|
exports.getTimezoneOptions = getTimezoneOptions;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"getTimezones.js","sourceRoot":"","sources":["../../../../../../../extensions/awell/v1/actions/updatePatient/config/getTimezones.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"getTimezones.js","sourceRoot":"","sources":["../../../../../../../extensions/awell/v1/actions/updatePatient/config/getTimezones.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+CAAgC;AAMzB,MAAM,kBAAkB,GAAG,GAAkB,EAAE;IACpD,OAAO,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;QAC5C,KAAK,EAAE,EAAE;QACT,KAAK,EAAE,EAAE;KACV,CAAC,CAAC,CAAA;AACL,CAAC,CAAA;AALY,QAAA,kBAAkB,sBAK9B"}
|
@@ -57,13 +57,13 @@ export declare const SettingsValidationSchema: z.ZodObject<{
|
|
57
57
|
testMode: boolean;
|
58
58
|
domain: string;
|
59
59
|
fromEmail?: any;
|
60
|
-
region?: "
|
60
|
+
region?: "EU" | "US" | "eu" | "us" | undefined;
|
61
61
|
}, {
|
62
62
|
apiKey: string;
|
63
63
|
fromName: string;
|
64
64
|
domain: string;
|
65
65
|
testMode?: "Yes" | "No" | "yes" | "no" | undefined;
|
66
66
|
fromEmail?: any;
|
67
|
-
region?: "
|
67
|
+
region?: "EU" | "US" | "eu" | "us" | undefined;
|
68
68
|
}>;
|
69
69
|
export declare const validateSettings: (settings: unknown) => z.infer<typeof SettingsValidationSchema>;
|
@@ -9,6 +9,8 @@ const config_1 = require("./config");
|
|
9
9
|
const getFormResponseText_1 = require("../../lib/getFormResponseText");
|
10
10
|
const awell_1 = require("../../../../src/lib/awell");
|
11
11
|
const utils_1 = require("../../../../src/utils");
|
12
|
+
const getCareFlowDetails_1 = require("../../lib/getCareFlowDetails");
|
13
|
+
const lodash_1 = require("lodash");
|
12
14
|
/**
|
13
15
|
* Awell Action: Form Summarization
|
14
16
|
*
|
@@ -27,7 +29,6 @@ exports.summarizeForm = {
|
|
27
29
|
previewable: false,
|
28
30
|
dataPoints: config_1.dataPoints,
|
29
31
|
onEvent: async ({ payload, onComplete, onError, helpers }) => {
|
30
|
-
var _a, _b, _c, _d, _e, _f;
|
31
32
|
// 1. Validate input fields
|
32
33
|
const { summaryFormat, language, additionalInstructions } = config_1.FieldsValidationSchema.parse(payload.fields);
|
33
34
|
// 2. Initialize OpenAI model with metadata
|
@@ -39,21 +40,8 @@ exports.summarizeForm = {
|
|
39
40
|
hideDataForTracing: true, // Hide input and output data when tracing
|
40
41
|
});
|
41
42
|
const awellSdk = await helpers.awellSdk();
|
42
|
-
// Get
|
43
|
-
const
|
44
|
-
pathway: {
|
45
|
-
__args: {
|
46
|
-
id: payload.pathway.id,
|
47
|
-
},
|
48
|
-
code: true,
|
49
|
-
success: true,
|
50
|
-
pathway: {
|
51
|
-
id: true,
|
52
|
-
title: true,
|
53
|
-
pathway_definition_id: true,
|
54
|
-
},
|
55
|
-
},
|
56
|
-
});
|
43
|
+
// Get care flow details for the disclaimer
|
44
|
+
const careFlowDetails = await (0, getCareFlowDetails_1.getCareFlowDetails)(awellSdk, payload.pathway.id);
|
57
45
|
// 3. Get form data
|
58
46
|
const { formDefinition, formResponse } = await (0, awell_1.getLatestFormInCurrentStep)({
|
59
47
|
awellSdk,
|
@@ -64,13 +52,21 @@ exports.summarizeForm = {
|
|
64
52
|
formDefinition,
|
65
53
|
formResponse,
|
66
54
|
});
|
55
|
+
// Create disclaimer message based on version availability
|
56
|
+
let disclaimerMessage = '';
|
57
|
+
if (!(0, lodash_1.isNil)(careFlowDetails.version)) {
|
58
|
+
disclaimerMessage = `Important Notice: The content provided is an AI-generated summary of form responses of version ${careFlowDetails.version} of Care Flow "${careFlowDetails.title}" (ID: ${careFlowDetails.id}).`;
|
59
|
+
}
|
60
|
+
else {
|
61
|
+
disclaimerMessage = `Important Notice: The content provided is an AI-generated summary of form responses of Care Flow "${careFlowDetails.title}" (ID: ${careFlowDetails.id}).`;
|
62
|
+
}
|
67
63
|
// 4. Generate summary
|
68
64
|
const summary = await (0, summarizeFormWithLLM_1.summarizeFormWithLLM)({
|
69
65
|
model,
|
70
66
|
formData,
|
71
67
|
summaryFormat,
|
72
68
|
language,
|
73
|
-
disclaimerMessage
|
69
|
+
disclaimerMessage,
|
74
70
|
additionalInstructions,
|
75
71
|
metadata,
|
76
72
|
callbacks,
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"summarizeForm.js","sourceRoot":"","sources":["../../../../../extensions/shelly/actions/summarizeForm/summarizeForm.ts"],"names":[],"mappings":";;;AAAA,mEAAqE;AACrE,yEAAqE;AACrE,wFAAoF;AACpF,wEAAwE;AACxE,qCAAqE;AACrE,uEAAmE;AACnE,qDAAsE;AACtE,iDAAsD;
|
1
|
+
{"version":3,"file":"summarizeForm.js","sourceRoot":"","sources":["../../../../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OAAO,CAAC,OAAO,CAAC,EAAE;YAC7B,UAAU,EAAE,OAAO,CAAC,QAAQ,CAAC,EAAE;SAChC,CAAC,CAAA;QAEF,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,GAAG,IAAA,yCAAmB,EAAC;YAC/C,cAAc;YACd,YAAY;SACb,CAAC,CAAA;QAEF,0DAA0D;QAC1D,IAAI,iBAAiB,GAAG,EAAE,CAAC;QAC3B,IAAI,CAAC,IAAA,cAAK,EAAC,eAAe,CAAC,OAAO,CAAC,EAAE,CAAC;YACpC,iBAAiB,GAAG,kGAAkG,eAAe,CAAC,OAAO,kBAAkB,eAAe,CAAC,KAAK,UAAU,eAAe,CAAC,EAAE,IAAI,CAAC;QACvN,CAAC;aAAM,CAAC;YACN,iBAAiB,GAAG,qGAAqG,eAAe,CAAC,KAAK,UAAU,eAAe,CAAC,EAAE,IAAI,CAAC;QACjL,CAAC;QAED,sBAAsB;QACtB,MAAM,OAAO,GAAG,MAAM,IAAA,2CAAoB,EAAC;YACzC,KAAK;YACL,QAAQ;YACR,aAAa;YACb,QAAQ;YACR,iBAAiB;YACjB,sBAAsB;YACtB,QAAQ;YACR,SAAS;SACV,CAAC,CAAA;QAEF,+BAA+B;QAC/B,MAAM,WAAW,GAAG,MAAM,IAAA,sBAAc,EAAC,OAAO,CAAC,CAAA;QACjD,MAAM,UAAU,CAAC;YACf,WAAW,EAAE;gBACX,OAAO,EAAE,WAAW;aACrB;SACF,CAAC,CAAA;IACJ,CAAC;CACF,CAAA"}
|
@@ -1,2 +1,2 @@
|
|
1
1
|
import { ChatPromptTemplate } from '@langchain/core/prompts';
|
2
|
-
export declare const systemPrompt: ChatPromptTemplate<import("@langchain/core/prompts").ParamsFromFString<"# Role\nYou are a specialized healthcare AI assistant tasked with analyzing and summarizing clinical care
|
2
|
+
export declare const systemPrompt: ChatPromptTemplate<import("@langchain/core/prompts").ParamsFromFString<"# Role\nYou are a specialized healthcare AI assistant tasked with analyzing and summarizing clinical care outcomes and decision paths for healthcare professionals. Your summary must use **clear, concise, and clinically appropriate** languageāavoiding any internal or Awell-specific terminology.\n\n----------\n# Context\nIn healthcare systems, a care flow represents a patient's journey through a clinical process. In the Awell platform, this is structured into four levels:\n- **Care Flow:** The overall clinical pathway.\n- **Track:** A phase of the care process that can occur sequentially (e.g., Diagnosis > Treatment > Follow-up) or in parallel (e.g., daily metrics alongside monthly appointments).\n- **Step:** A container that holds all events (actions) occurring at a given moment for a specific patient group.\n- **Action/Activity:** Individual events within a step, such as forms, messages, or automated system events (e.g., calculations, API calls). \n *Note:* When an action like a **message or form** is assigned to a stakeholder, interpret it as **\"presented\"** in standard language. Avoid using \"sent,\" as it implies asynchronous communication.\n\n### **Important:**\nAlthough the input data uses Awell-specific terms (e.g., care flow, track, step, action, activity), **your summary must not use these exact terms**. Instead, use alternative language such as:\n- **Care process**, **phase**, **procedure**, **event**, **step in the process**, or similar.\n- You **may** use \"forms\" and \"messages\" and mention their content, as clinical care teams are familiar with those.\n\n----------\n# Task\nAnalyze the provided structured data and generate a **clear, concise** summary that includes:\n1. **The final outcome** of the care process. \n - **Only describe what has been done ā do not include planned or future steps.** \n2. **The decision path and reasoning** that led to this outcome.\n3. **Key events and decision points** that influenced the outcome.\n\n----------\n# Input Data Structure\nYou will receive structured data containing information about a track:\n- **Care Process Information:** Title, status, start/end dates of steps.\n- **Events:** Activities within each segment, including:\n * **Timestamps** (when events occurred)\n * **Actors** (who performed the eventsāpatients, clinicians, etc.)\n * **Event types** (e.g., forms, messages, system events)\n * **Form responses** (questions and answers)\n * **Data points** (clinical measurements, observations, or responses)\n\n### **Additional Guidance:**\n- **Discarded Steps & Activities:** \n - **Steps marked as \"discarded\" were not executed** but should be used for reasoning about what did or did not happen. \n - **Never mention discarded steps in the final summary unless explicitly instructed.** \n - Avoid mentioning things like: \n **Incorrect:** \"The alternative treatment proposal (ATP) was not pursued, as indicated by the discarded 'Hernia Post-Op NOT Supported' phase.\"\n - This is **critical**āyour summary must only focus on what actually happened.\n\n- **Handling Documentation or Finalization Steps:** \n - If a step involves **documentation, record submission, or finalization**, it must be **consistently included** as part of the summary. \n - If the next step **is not explicitly documented as completed in the input data**, **it must not be mentioned at all**. \n\n- **Data Integrity:** \n - Base your analysis **solely** on the provided data. \n - Absolutely refrain from inventing details or making clinical assumptions beyond what is explicitly given. \n\n----------\n# Instructions for Analysis:\n1. **Carefully review** all provided information to understand the context.\n2. **Analyze the events in chronological order** to trace the decision-making process.\n3. **Identify key decision points and their outcomes.**\n4. **Determine the final outcome** (e.g., approved treatment, alternative pathway, pre-certification).\n5. **Extract logical reasoning strictly supported by the data.**\n6. **Ensure the outcome and supporting details are perfectly aligned.**\n7. **Organize your findings** into a coherent narrative that flows like a concise story.\n\n----------\n# Output Guidelines\nStructure your summary as follows:\n\n## **Outcome**\n- Start with a **clear, precise** statement of the final outcome. \n- **Only describe completed actions**ādo not include planned future steps or what happens next. \n - **Correct:** \n ```\n ## Outcome:\n The alternate treatment plan (ATP) was not accepted.\n ```\n - **Incorrect:** \n ```\n ## Outcome:\n The alternate treatment plan (ATP) was not accepted, and the case was directed toward pre-certification.\n ```\n- **Avoid mentioning the patient unless explicitly necessary.** Instead, focus on what occurred: \n - **Incorrect:** The patient's initial surgical evaluation for hernia was supported. \n - **Correct:** The initial surgical evaluation for hernia was supported. \n\n## **Details Supporting the Outcome:** \n- Provide a **brief paragraph** or a **list of 3ā5 bullet points** that explicitly outline the key evidence and logical steps leading to the outcome. \n- **The supporting details must be unambiguous, leaving no room for misinterpretation.** \n- Any reader should **immediately understand** how the outcome was reached.\n- Use **proper markdown formatting** with clear section headers.\n- Maintain **brevity and clarity**āclinical professionals prefer concise summaries that are easy to read.\n\n----------\n# Important Constraints\n- **Language:** \n - Use **clinical terminology** suitable for healthcare professionals. \n - **Avoid Awell-specific terms** (e.g., \"track,\" \"step,\" \"action\"). Instead, use: \n - **Care process, phase, procedure, or event.**\n- **Focus:** \n - Only include **events that actually occurred** (activated, done, completed, etc.). \n - **Never include discarded steps (paths not taken) unless explicitly specified in the instructions.**\n- **Accuracy:** \n - Ensure your summary **strictly reflects the provided data**. \n - Absolutely refrain from making assumptions or clinical conclusions that are not directly supported by the input. \n- **Phrasing Rules:** \n - **Messages and forms should be described as \"presented\" rather than \"sent\"** to avoid implying asynchronous communication. \n - Instead of **\"determined\"** or **\"confirmed,\"** use **\"indicated\"** when describing assessments or findings.\n - ā
**Correct:** \"During the initial hernia triage, it was indicated that the hernia was reducible...\"\n - ā **Incorrect:** \"During the initial hernia triage, it was determined that the hernia was reducible...\" \n\n----------\n# Example Output Format\n## **Outcome:**\nThe alternate treatment plan (ATP) was not accepted.\n\n## **Details Supporting the Outcome:**\n- During the initial hernia triage, it was indicated that the hernia was reducible and did not affect the patient's activities of daily living (ADLs).\n- A physician was presented with a form to accept an Alternate Treatment Plan (ATP).\n- The physician declined the ATP, as indicated by the form response.\n- The process concluded with the rejection of the ATP.\n\n----------\nInstructions:\n{instructions}\n\n----------\nTrack Data:\n{input}">, any>;
|
@@ -2,74 +2,124 @@
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.systemPrompt = void 0;
|
4
4
|
const prompts_1 = require("@langchain/core/prompts");
|
5
|
-
// TODO prompt will be tuned/improved after we collect real world data
|
6
5
|
exports.systemPrompt = prompts_1.ChatPromptTemplate.fromTemplate(`# Role
|
7
|
-
You are a specialized healthcare AI assistant tasked with analyzing and summarizing clinical care
|
6
|
+
You are a specialized healthcare AI assistant tasked with analyzing and summarizing clinical care outcomes and decision paths for healthcare professionals. Your summary must use **clear, concise, and clinically appropriate** languageāavoiding any internal or Awell-specific terminology.
|
8
7
|
|
9
8
|
----------
|
10
9
|
# Context
|
11
|
-
In healthcare systems, a care flow represents a patient's journey through a clinical process:
|
12
|
-
- Care
|
13
|
-
- Track
|
14
|
-
- Step
|
15
|
-
- Action
|
16
|
-
|
10
|
+
In healthcare systems, a care flow represents a patient's journey through a clinical process. In the Awell platform, this is structured into four levels:
|
11
|
+
- **Care Flow:** The overall clinical pathway.
|
12
|
+
- **Track:** A phase of the care process that can occur sequentially (e.g., Diagnosis > Treatment > Follow-up) or in parallel (e.g., daily metrics alongside monthly appointments).
|
13
|
+
- **Step:** A container that holds all events (actions) occurring at a given moment for a specific patient group.
|
14
|
+
- **Action/Activity:** Individual events within a step, such as forms, messages, or automated system events (e.g., calculations, API calls).
|
15
|
+
*Note:* When an action like a **message or form** is assigned to a stakeholder, interpret it as **"presented"** in standard language. Avoid using "sent," as it implies asynchronous communication.
|
16
|
+
|
17
|
+
### **Important:**
|
18
|
+
Although the input data uses Awell-specific terms (e.g., care flow, track, step, action, activity), **your summary must not use these exact terms**. Instead, use alternative language such as:
|
19
|
+
- **Care process**, **phase**, **procedure**, **event**, **step in the process**, or similar.
|
20
|
+
- You **may** use "forms" and "messages" and mention their content, as clinical care teams are familiar with those.
|
17
21
|
|
18
22
|
----------
|
19
23
|
# Task
|
20
|
-
|
21
|
-
1. The final outcome of the
|
22
|
-
|
23
|
-
|
24
|
+
Analyze the provided structured data and generate a **clear, concise** summary that includes:
|
25
|
+
1. **The final outcome** of the care process.
|
26
|
+
- **Only describe what has been done ā do not include planned or future steps.**
|
27
|
+
2. **The decision path and reasoning** that led to this outcome.
|
28
|
+
3. **Key events and decision points** that influenced the outcome.
|
24
29
|
|
25
30
|
----------
|
26
31
|
# Input Data Structure
|
27
|
-
You will receive structured data containing:
|
28
|
-
-
|
29
|
-
-
|
30
|
-
|
31
|
-
*
|
32
|
-
*
|
33
|
-
*
|
34
|
-
*
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
32
|
+
You will receive structured data containing information about a track:
|
33
|
+
- **Care Process Information:** Title, status, start/end dates of steps.
|
34
|
+
- **Events:** Activities within each segment, including:
|
35
|
+
* **Timestamps** (when events occurred)
|
36
|
+
* **Actors** (who performed the eventsāpatients, clinicians, etc.)
|
37
|
+
* **Event types** (e.g., forms, messages, system events)
|
38
|
+
* **Form responses** (questions and answers)
|
39
|
+
* **Data points** (clinical measurements, observations, or responses)
|
40
|
+
|
41
|
+
### **Additional Guidance:**
|
42
|
+
- **Discarded Steps & Activities:**
|
43
|
+
- **Steps marked as "discarded" were not executed** but should be used for reasoning about what did or did not happen.
|
44
|
+
- **Never mention discarded steps in the final summary unless explicitly instructed.**
|
45
|
+
- Avoid mentioning things like:
|
46
|
+
**Incorrect:** "The alternative treatment proposal (ATP) was not pursued, as indicated by the discarded 'Hernia Post-Op NOT Supported' phase."
|
47
|
+
- This is **critical**āyour summary must only focus on what actually happened.
|
48
|
+
|
49
|
+
- **Handling Documentation or Finalization Steps:**
|
50
|
+
- If a step involves **documentation, record submission, or finalization**, it must be **consistently included** as part of the summary.
|
51
|
+
- If the next step **is not explicitly documented as completed in the input data**, **it must not be mentioned at all**.
|
52
|
+
|
53
|
+
- **Data Integrity:**
|
54
|
+
- Base your analysis **solely** on the provided data.
|
55
|
+
- Absolutely refrain from inventing details or making clinical assumptions beyond what is explicitly given.
|
56
|
+
|
57
|
+
----------
|
58
|
+
# Instructions for Analysis:
|
59
|
+
1. **Carefully review** all provided information to understand the context.
|
60
|
+
2. **Analyze the events in chronological order** to trace the decision-making process.
|
61
|
+
3. **Identify key decision points and their outcomes.**
|
62
|
+
4. **Determine the final outcome** (e.g., approved treatment, alternative pathway, pre-certification).
|
63
|
+
5. **Extract logical reasoning strictly supported by the data.**
|
64
|
+
6. **Ensure the outcome and supporting details are perfectly aligned.**
|
65
|
+
7. **Organize your findings** into a coherent narrative that flows like a concise story.
|
45
66
|
|
46
67
|
----------
|
47
68
|
# Output Guidelines
|
48
69
|
Structure your summary as follows:
|
49
|
-
- Begin with a clear outcome statement
|
50
|
-
- Follow with 3-5 bullet points explaining the supporting evidence and reasoning
|
51
|
-
- Present information chronologically to show progression
|
52
|
-
- Use clinical terminology appropriate for healthcare professionals
|
53
|
-
- Maintain brevity while preserving critical details
|
54
70
|
|
71
|
+
## **Outcome**
|
72
|
+
- Start with a **clear, precise** statement of the final outcome.
|
73
|
+
- **Only describe completed actions**ādo not include planned future steps or what happens next.
|
74
|
+
- **Correct:**
|
75
|
+
\`\`\`
|
76
|
+
## Outcome:
|
77
|
+
The alternate treatment plan (ATP) was not accepted.
|
78
|
+
\`\`\`
|
79
|
+
- **Incorrect:**
|
80
|
+
\`\`\`
|
81
|
+
## Outcome:
|
82
|
+
The alternate treatment plan (ATP) was not accepted, and the case was directed toward pre-certification.
|
83
|
+
\`\`\`
|
84
|
+
- **Avoid mentioning the patient unless explicitly necessary.** Instead, focus on what occurred:
|
85
|
+
- **Incorrect:** The patient's initial surgical evaluation for hernia was supported.
|
86
|
+
- **Correct:** The initial surgical evaluation for hernia was supported.
|
87
|
+
|
88
|
+
## **Details Supporting the Outcome:**
|
89
|
+
- Provide a **brief paragraph** or a **list of 3ā5 bullet points** that explicitly outline the key evidence and logical steps leading to the outcome.
|
90
|
+
- **The supporting details must be unambiguous, leaving no room for misinterpretation.**
|
91
|
+
- Any reader should **immediately understand** how the outcome was reached.
|
92
|
+
- Use **proper markdown formatting** with clear section headers.
|
93
|
+
- Maintain **brevity and clarity**āclinical professionals prefer concise summaries that are easy to read.
|
94
|
+
|
95
|
+
----------
|
55
96
|
# Important Constraints
|
56
|
-
-
|
57
|
-
-
|
58
|
-
-
|
59
|
-
-
|
60
|
-
-
|
61
|
-
-
|
62
|
-
-
|
63
|
-
-
|
97
|
+
- **Language:**
|
98
|
+
- Use **clinical terminology** suitable for healthcare professionals.
|
99
|
+
- **Avoid Awell-specific terms** (e.g., "track," "step," "action"). Instead, use:
|
100
|
+
- **Care process, phase, procedure, or event.**
|
101
|
+
- **Focus:**
|
102
|
+
- Only include **events that actually occurred** (activated, done, completed, etc.).
|
103
|
+
- **Never include discarded steps (paths not taken) unless explicitly specified in the instructions.**
|
104
|
+
- **Accuracy:**
|
105
|
+
- Ensure your summary **strictly reflects the provided data**.
|
106
|
+
- Absolutely refrain from making assumptions or clinical conclusions that are not directly supported by the input.
|
107
|
+
- **Phrasing Rules:**
|
108
|
+
- **Messages and forms should be described as "presented" rather than "sent"** to avoid implying asynchronous communication.
|
109
|
+
- Instead of **"determined"** or **"confirmed,"** use **"indicated"** when describing assessments or findings.
|
110
|
+
- ā
**Correct:** "During the initial hernia triage, it was indicated that the hernia was reducible..."
|
111
|
+
- ā **Incorrect:** "During the initial hernia triage, it was determined that the hernia was reducible..."
|
64
112
|
|
65
113
|
----------
|
66
114
|
# Example Output Format
|
67
|
-
## Outcome
|
68
|
-
The
|
115
|
+
## **Outcome:**
|
116
|
+
The alternate treatment plan (ATP) was not accepted.
|
69
117
|
|
70
|
-
## Details
|
71
|
-
-
|
72
|
-
-
|
118
|
+
## **Details Supporting the Outcome:**
|
119
|
+
- During the initial hernia triage, it was indicated that the hernia was reducible and did not affect the patient's activities of daily living (ADLs).
|
120
|
+
- A physician was presented with a form to accept an Alternate Treatment Plan (ATP).
|
121
|
+
- The physician declined the ATP, as indicated by the form response.
|
122
|
+
- The process concluded with the rejection of the ATP.
|
73
123
|
|
74
124
|
----------
|
75
125
|
Instructions:
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"prompt.js","sourceRoot":"","sources":["../../../../../../../extensions/shelly/actions/summarizeTrackOutcome/lib/summarizeTrackOutcomeWithLLM/prompt.ts"],"names":[],"mappings":";;;AAAA,qDAA4D;
|
1
|
+
{"version":3,"file":"prompt.js","sourceRoot":"","sources":["../../../../../../../extensions/shelly/actions/summarizeTrackOutcome/lib/summarizeTrackOutcomeWithLLM/prompt.ts"],"names":[],"mappings":";;;AAAA,qDAA4D;AAE/C,QAAA,YAAY,GAAG,4BAAkB,CAAC,YAAY,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QA6HpD,CAAC,CAAA"}
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
@@ -0,0 +1,151 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
|
+
};
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
+
/**
|
7
|
+
* LangSmith Evaluation Script for summarizeTrackOutcomeWithLLM
|
8
|
+
*
|
9
|
+
* Evaluates the summarizeTrackOutcomeWithLLM function by:
|
10
|
+
* - Running test cases from LangSmith dataset
|
11
|
+
* - Checking if a summary is provided
|
12
|
+
* - Generating evaluation reports
|
13
|
+
*
|
14
|
+
* Requirements:
|
15
|
+
* - Set environment variables in .env:
|
16
|
+
* - OPENAI_API_KEY
|
17
|
+
* - LANGSMITH_API_KEY
|
18
|
+
* - LANGSMITH_TRACING=true
|
19
|
+
* - LANGSMITH_PROJECT=ai-actions-local
|
20
|
+
*
|
21
|
+
* Usage:
|
22
|
+
* yarn ts-node extensions/shelly/actions/summarizeTrackOutcome/lib/summarizeTrackOutcomeWithLLM/summarizeTrackOutcomeWithLLM.evaluate.ts
|
23
|
+
*
|
24
|
+
* Results can be viewed in LangSmith dashboard
|
25
|
+
*
|
26
|
+
* ā ļø **Note:** This script does NOT run in CI/CD. It is meant for **manual evaluation** before merging PRs (for now)
|
27
|
+
*/
|
28
|
+
const langsmith_1 = require("langsmith");
|
29
|
+
const evaluation_1 = require("langsmith/evaluation");
|
30
|
+
const createOpenAIModel_1 = require("../../../../../../src/lib/llm/openai/createOpenAIModel");
|
31
|
+
const summarizeTrackOutcomeWithLLM_1 = require("./summarizeTrackOutcomeWithLLM");
|
32
|
+
const constants_1 = require("../../../../../../src/lib/llm/openai/constants");
|
33
|
+
const lodash_1 = require("lodash");
|
34
|
+
const dotenv_1 = __importDefault(require("dotenv"));
|
35
|
+
dotenv_1.default.config();
|
36
|
+
const langsmith = new langsmith_1.Client({
|
37
|
+
apiKey: process.env.LANGSMITH_API_KEY,
|
38
|
+
apiUrl: process.env.LANGSMITH_ENDPOINT,
|
39
|
+
});
|
40
|
+
// Define the dataset name
|
41
|
+
const datasetName = 'ai-actions-summarize-track_outcome-shelly';
|
42
|
+
// Fetch the 'test' split examples from the dataset
|
43
|
+
const fetchTestExamples = async () => {
|
44
|
+
try {
|
45
|
+
const testExamples = langsmith.listExamples({
|
46
|
+
datasetName,
|
47
|
+
splits: ['test'],
|
48
|
+
});
|
49
|
+
const examples = [];
|
50
|
+
for await (const example of testExamples) {
|
51
|
+
if (!(0, lodash_1.isNil)(example.inputs)) {
|
52
|
+
// Explicit null check
|
53
|
+
examples.push(example);
|
54
|
+
}
|
55
|
+
}
|
56
|
+
return examples;
|
57
|
+
}
|
58
|
+
catch (error) {
|
59
|
+
console.error('ā Error fetching test examples:', error);
|
60
|
+
throw error;
|
61
|
+
}
|
62
|
+
};
|
63
|
+
// Custom evaluator to check if a summary is provided
|
64
|
+
// Actual evaluation will be run automatically in LangSmith by LLM as a judge
|
65
|
+
// TODO: right now we are usign gpt4o as a judge as well - not problematic but not great either - same models tend to prefer each other styles
|
66
|
+
// once o3 supported (issue with temperature resolved and reasoning type enabled) we should use o3 as a judge
|
67
|
+
const summaryProvidedEvaluator = async ({ outputs, }) => {
|
68
|
+
const summary = outputs === null || outputs === void 0 ? void 0 : outputs.summary;
|
69
|
+
// Check if summary is provided and not empty
|
70
|
+
const isProvided = typeof summary === 'string' && summary.trim().length > 0;
|
71
|
+
return {
|
72
|
+
key: 'summary_provided',
|
73
|
+
score: isProvided ? 1 : 0,
|
74
|
+
metadata: {
|
75
|
+
summaryLength: typeof summary === 'string' ? summary.length : 0,
|
76
|
+
hasSummary: isProvided
|
77
|
+
}
|
78
|
+
};
|
79
|
+
};
|
80
|
+
// Wrapper function to adapt summarizeTrackOutcomeWithLLM for evaluation
|
81
|
+
const summarizeTrackOutcomeWithLLMWrapper = async (input) => {
|
82
|
+
const payload = {
|
83
|
+
activity: {
|
84
|
+
id: 'test-activity-id',
|
85
|
+
},
|
86
|
+
pathway: {
|
87
|
+
tenant_id: 'test-tenant',
|
88
|
+
definition_id: 'test-definition',
|
89
|
+
id: 'test-pathway',
|
90
|
+
org_slug: 'test-org',
|
91
|
+
org_id: 'test-org-id',
|
92
|
+
},
|
93
|
+
fields: {
|
94
|
+
instructions: input.instruction,
|
95
|
+
},
|
96
|
+
settings: {
|
97
|
+
openAiApiKey: process.env.OPENAI_API_KEY,
|
98
|
+
},
|
99
|
+
};
|
100
|
+
const helpers = {
|
101
|
+
getOpenAIConfig: () => {
|
102
|
+
const apiKey = process.env.OPENAI_API_KEY;
|
103
|
+
if ((0, lodash_1.isNil)(apiKey) || apiKey.trim() === '') {
|
104
|
+
throw new Error('OPENAI_API_KEY is required but not set');
|
105
|
+
}
|
106
|
+
return { apiKey };
|
107
|
+
},
|
108
|
+
};
|
109
|
+
const { model, metadata, callbacks } = await (0, createOpenAIModel_1.createOpenAIModel)({
|
110
|
+
settings: payload.settings,
|
111
|
+
helpers,
|
112
|
+
payload,
|
113
|
+
modelType: constants_1.OPENAI_MODELS.GPT4o,
|
114
|
+
});
|
115
|
+
const summary = await (0, summarizeTrackOutcomeWithLLM_1.summarizeTrackOutcomeWithLLM)({
|
116
|
+
model,
|
117
|
+
trackActivities: input.track_data,
|
118
|
+
instructions: input.instruction,
|
119
|
+
metadata,
|
120
|
+
callbacks,
|
121
|
+
});
|
122
|
+
return { summary };
|
123
|
+
};
|
124
|
+
// Main function to run the evaluation and print results
|
125
|
+
const runEvaluation = async () => {
|
126
|
+
var _a, _b;
|
127
|
+
try {
|
128
|
+
console.log('š” Fetching test dataset from LangSmith...');
|
129
|
+
const testExamples = await fetchTestExamples();
|
130
|
+
console.log(`ā
Loaded ${testExamples.length} test examples\n`);
|
131
|
+
console.log('š Running evaluation...\n');
|
132
|
+
const results = await (0, evaluation_1.evaluate)(summarizeTrackOutcomeWithLLMWrapper, {
|
133
|
+
data: testExamples,
|
134
|
+
evaluators: [summaryProvidedEvaluator],
|
135
|
+
experimentPrefix: 'SummarizeTrackOutcomeWithLLM Evaluation',
|
136
|
+
maxConcurrency: 4,
|
137
|
+
});
|
138
|
+
const resultsArray = Array.isArray(results) ? results : [results];
|
139
|
+
const experimentId = (_b = (_a = resultsArray[0]) === null || _a === void 0 ? void 0 : _a.run) === null || _b === void 0 ? void 0 : _b.run_id;
|
140
|
+
console.log('\n⨠Evaluation Complete!');
|
141
|
+
console.log('View detailed results in LangSmith:');
|
142
|
+
console.log(`https://smith.langchain.com/runs/${experimentId}`);
|
143
|
+
}
|
144
|
+
catch (error) {
|
145
|
+
console.error('ā Error during evaluation:', error);
|
146
|
+
throw error;
|
147
|
+
}
|
148
|
+
};
|
149
|
+
// Execute the evaluation
|
150
|
+
void runEvaluation();
|
151
|
+
//# sourceMappingURL=summarizeTrackOutcomeWithLLM.evaluate.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"summarizeTrackOutcomeWithLLM.evaluate.js","sourceRoot":"","sources":["../../../../../../../extensions/shelly/actions/summarizeTrackOutcome/lib/summarizeTrackOutcomeWithLLM/summarizeTrackOutcomeWithLLM.evaluate.ts"],"names":[],"mappings":";;;;;AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,yCAAgD;AAChD,qDAA+C;AAC/C,8FAA0F;AAC1F,iFAA6E;AAC7E,8EAA8E;AAC9E,mCAA8B;AAE9B,oDAA2B;AAC3B,gBAAM,CAAC,MAAM,EAAE,CAAA;AAEf,MAAM,SAAS,GAAG,IAAI,kBAAM,CAAC;IAC3B,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,iBAAiB;IACrC,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,kBAAkB;CACvC,CAAC,CAAA;AAEF,0BAA0B;AAC1B,MAAM,WAAW,GAAG,2CAA2C,CAAA;AAiB/D,mDAAmD;AACnD,MAAM,iBAAiB,GAAG,KAAK,IAAwB,EAAE;IACvD,IAAI,CAAC;QACH,M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G,CAAC,4CAA4C,CAAC,CAAA;QACzD,MAAM,YAAY,GAAG,MAAM,iBAAiB,EAAE,CAAA;QAC9C,OAAO,CAAC,GAAG,CAAC,YAAY,YAAY,CAAC,MAAM,kBAAkB,CAAC,CAAA;QAE9D,OAAO,CAAC,GAAG,CAAC,4BAA4B,CAAC,CAAA;QACzC,MAAM,OAAO,GAAG,MAAM,IAAA,qBAAQ,EAAC,mCAAmC,EAAE;YAClE,IAAI,EAAE,YAAY;YAClB,UAAU,EAAE,CAAC,wBAAwB,CAAC;YACtC,gBAAgB,EAAE,yCAAyC;YAC3D,cAAc,EAAE,CAAC;SAClB,CAAC,CAAA;QAEF,MAAM,YAAY,GAAG,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAA;QACjE,MAAM,YAAY,GAAG,MAAA,MAAA,YAAY,CAAC,CAAC,CAAC,0CAAE,GAAG,0CAAE,MAAgB,CAAA;QAE3D,OAAO,CAAC,GAAG,CAAC,0BAA0B,CAAC,CAAA;QACvC,OAAO,CAAC,GAAG,CAAC,qCAAqC,CAAC,CAAA;QAClD,OAAO,CAAC,GAAG,CAAC,oCAAoC,YAAY,EAAE,CAAC,CAAA;IACjE,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CAAC,4BAA4B,EAAE,KAAK,CAAC,CAAA;QAClD,MAAM,KAAK,CAAA;IACb,CAAC;AACH,CAAC,CAAA;AAED,yBAAyB;AACzB,KAAK,aAAa,EAAE,CAAA"}
|
@@ -8,17 +8,18 @@ const summarizeTrackOutcomeWithLLM_1 = require("./lib/summarizeTrackOutcomeWithL
|
|
8
8
|
const openai_1 = require("../../../../src/lib/llm/openai");
|
9
9
|
const constants_1 = require("../../../../src/lib/llm/openai/constants");
|
10
10
|
const index_1 = require("../../lib/getTrackData/index");
|
11
|
+
const getCareFlowDetails_1 = require("../../lib/getCareFlowDetails");
|
11
12
|
const lodash_1 = require("lodash");
|
12
13
|
exports.summarizeTrackOutcome = {
|
13
14
|
key: 'summarizeTrackOutcome',
|
14
15
|
category: extensions_core_1.Category.WORKFLOW,
|
15
|
-
title: 'Summarize Track Outcome
|
16
|
+
title: 'Summarize Track Outcome',
|
16
17
|
description: 'Summarize the care flow track outcome and activities that led to the outcome',
|
17
18
|
fields: config_1.fields,
|
18
19
|
previewable: false,
|
19
20
|
dataPoints: config_1.dataPoints,
|
20
21
|
onEvent: async ({ payload, onComplete, onError, helpers }) => {
|
21
|
-
var _a, _b
|
22
|
+
var _a, _b;
|
22
23
|
// 1. Validate input fields
|
23
24
|
const { instructions } = config_1.FieldsValidationSchema.parse(payload.fields);
|
24
25
|
const pathway = payload.pathway;
|
@@ -28,24 +29,9 @@ exports.summarizeTrackOutcome = {
|
|
28
29
|
helpers,
|
29
30
|
payload,
|
30
31
|
modelType: constants_1.OPENAI_MODELS.GPT4o,
|
31
|
-
hideDataForTracing: false, //
|
32
|
+
hideDataForTracing: false, // IMPORTANT: set to true if there is a use case that might include PHI
|
32
33
|
});
|
33
34
|
const awellSdk = await helpers.awellSdk();
|
34
|
-
// Get pathway details for the disclaimer
|
35
|
-
const pathwayDetails = await awellSdk.orchestration.query({
|
36
|
-
pathway: {
|
37
|
-
__args: {
|
38
|
-
id: pathway.id,
|
39
|
-
},
|
40
|
-
code: true,
|
41
|
-
success: true,
|
42
|
-
pathway: {
|
43
|
-
id: true,
|
44
|
-
title: true,
|
45
|
-
pathway_definition_id: true,
|
46
|
-
},
|
47
|
-
},
|
48
|
-
});
|
49
35
|
// Get activity details to find track_id
|
50
36
|
const activityId = payload.activity.id;
|
51
37
|
const activityDetails = await awellSdk.orchestration
|
@@ -86,7 +72,16 @@ exports.summarizeTrackOutcome = {
|
|
86
72
|
metadata,
|
87
73
|
callbacks,
|
88
74
|
});
|
89
|
-
|
75
|
+
// Get care flow details for the disclaimer
|
76
|
+
const careFlowDetails = await (0, getCareFlowDetails_1.getCareFlowDetails)(awellSdk, pathway.id);
|
77
|
+
// Create version string if version is available
|
78
|
+
let disclaimerMsg = '';
|
79
|
+
if (!(0, lodash_1.isNil)(careFlowDetails.version)) {
|
80
|
+
disclaimerMsg = `Important Notice: The content provided is an AI-generated summary of version ${careFlowDetails.version} of Care Flow "${careFlowDetails.title}" (ID: ${careFlowDetails.id}).`;
|
81
|
+
}
|
82
|
+
else {
|
83
|
+
disclaimerMsg = `Important Notice: The content provided is an AI-generated summary of Care Flow "${careFlowDetails.title}" (ID: ${careFlowDetails.id}).`;
|
84
|
+
}
|
90
85
|
const htmlSummary = await (0, utils_1.markdownToHtml)(`${disclaimerMsg}\n\n${summary}`);
|
91
86
|
await onComplete({
|
92
87
|
data_points: {
|