@awell-health/awell-extensions 2.0.236 → 2.0.238

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.
@@ -14,7 +14,7 @@
14
14
  * - LANGSMITH_PROJECT=ai-actions-local
15
15
  *
16
16
  * Usage:
17
- * node getTagsFromLLM/evaluateTags.ts
17
+ * * yarn ts-node extensions/elation/actions/updatePatientTags/lib/getTagsFromLLM/evaluateTags.ts
18
18
  *
19
19
  * Results can be viewed in LangSmith dashboard:
20
20
  * https://smith.langchain.com/o/3fffae83-70ff-4574-81ba-aaaedf0b4dc5/datasets/745cea13-3379-463f-9a8a-c6b10e29b8f6
@@ -15,7 +15,7 @@
15
15
  * - LANGSMITH_PROJECT=ai-actions-local
16
16
  *
17
17
  * Usage:
18
- * node getTagsFromLLM/evaluateTags.ts
18
+ * * yarn ts-node extensions/elation/actions/updatePatientTags/lib/getTagsFromLLM/evaluateTags.ts
19
19
  *
20
20
  * Results can be viewed in LangSmith dashboard:
21
21
  * https://smith.langchain.com/o/3fffae83-70ff-4574-81ba-aaaedf0b4dc5/datasets/745cea13-3379-463f-9a8a-c6b10e29b8f6
@@ -45,7 +45,7 @@ const fetchTestExamples = async () => {
45
45
  try {
46
46
  const testExamples = langsmith.listExamples({
47
47
  datasetName,
48
- splits: ['test'],
48
+ splits: ['test'], // change to ['validation'] to run on validation set
49
49
  });
50
50
  const examples = [];
51
51
  for await (const example of testExamples) {
@@ -63,10 +63,8 @@ const fetchTestExamples = async () => {
63
63
  };
64
64
  // Custom evaluator to compare generated tags with expected tags
65
65
  const tagsMatchEvaluator = async ({ outputs, referenceOutputs, }) => {
66
- console.log('Evaluator received:', { outputs, referenceOutputs }); // Debug log
67
66
  const generatedTags = outputs === null || outputs === void 0 ? void 0 : outputs.validatedTags;
68
67
  const expectedTags = referenceOutputs === null || referenceOutputs === void 0 ? void 0 : referenceOutputs.expected_updated_tags;
69
- // console.log('Comparing tags:', { generatedTags, expectedTags }); // Debug log
70
68
  const isEqual = Array.isArray(generatedTags) &&
71
69
  Array.isArray(expectedTags) &&
72
70
  generatedTags.length === expectedTags.length &&
@@ -129,7 +127,8 @@ const runEvaluation = async () => {
129
127
  data: testExamples,
130
128
  evaluators: [tagsMatchEvaluator],
131
129
  experimentPrefix: 'GetTagsFromLLM Evaluation',
132
- maxConcurrency: 4,
130
+ maxConcurrency: 16,
131
+ numRepetitions: 3,
133
132
  });
134
133
  const resultsArray = Array.isArray(results) ? results : [results];
135
134
  const experimentId = (_b = (_a = resultsArray[0]) === null || _a === void 0 ? void 0 : _a.run) === null || _b === void 0 ? void 0 : _b.run_id;
@@ -1 +1 @@
1
- {"version":3,"file":"evaluateTags.js","sourceRoot":"","sources":["../../../../../../../extensions/elation/actions/updatePatientTags/lib/getTagsFromLLM/evaluateTags.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;;;;;AAEH,yCAAgD;AAChD,qDAA+C;AAC/C,8FAA0F;AAC1F,qDAAiD;AACjD,8EAA8E;AAE9E,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,wCAAwC,CAAA;AAiB5D,mDAAmD;AACnD,MAAM,iBAAiB,GAAG,KAAK,IAAwB,EAAE;IACvD,IAAI,CAAC;QACH,MAAM,YAAY,GAAG,SAAS,CAAC,YAAY,CAAC;YAC1C,WAAW;YACX,MAAM,EAAE,CAAC,MAAM,CAAC;SACjB,CAAC,CAAA;QACF,MAAM,QAAQ,GAAc,EAAE,CAAA;QAC9B,IAAI,KAAK,EAAE,MAAM,OAAO,IAAI,YAAY,EAAE,CAAC;YACzC,IAA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AAC,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,qBAAqB,EAAE;YACpD,IAAI,EAAE,YAAY;YAClB,UAAU,EAAE,CAAC,kBAAkB,CAAC;YAChC,gBAAgB,EAAE,2BAA2B;YAC7C,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,IAAI,CAAC,IAAA,cAAK,EAAC,YAAY,CAAC,IAAI,YAAY,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC;YACvD,OAAO,CAAC,GAAG,CAAC,0BAA0B,CAAC,CAAA;YACvC,OAAO,CAAC,GAAG,CAAC,qCAAqC,CAAC,CAAA;YAClD,OAAO,CAAC,GAAG,CAAC,oCAAoC,YAAY,EAAE,CAAC,CAAA;QACjE,CAAC;IACH,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"}
1
+ {"version":3,"file":"evaluateTags.js","sourceRoot":"","sources":["../../../../../../../extensions/elation/actions/updatePatientTags/lib/getTagsFromLLM/evaluateTags.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;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cAAK,EAAC,YAAY,CAAC,IAAI,YAAY,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC;YACvD,OAAO,CAAC,GAAG,CAAC,0BAA0B,CAAC,CAAA;YACvC,OAAO,CAAC,GAAG,CAAC,qCAAqC,CAAC,CAAA;YAClD,OAAO,CAAC,GAAG,CAAC,oCAAoC,YAAY,EAAE,CAAC,CAAA;QACjE,CAAC;IACH,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"}
@@ -1,2 +1,2 @@
1
1
  import { ChatPromptTemplate } from '@langchain/core/prompts';
2
- export declare const systemPrompt: ChatPromptTemplate<import("@langchain/core/prompts").ParamsFromFString<"\n You are a clinical data manager with expert knowledge of Elation Patient Tags, which help care teams organize patient care (e.g., grouping, reporting, or identifying patients for care).\n\n Your task is to manage a single patient's tags based on the provided instructions.\n\n You will receive:\n - existing_tags: An array of the patient's current tags.\n - instruction: A directive specifying which tags to add, update, or remove. Ensure to follow them diligently.\n\n ### Step-by-Step Approach:\n 1. **Review the Instruction**\n - Identify the required tag modifications: additions, updates, or removals.\n\n 2. **Apply Modifications**\n - **Removing Tags:**\n - Only remove tags if explicitly stated in the instruction.\n - Match existing tags for removal, allowing minor variations (e.g., capitalization, spacing).\n - If unsure, do not remove the tag.\n\n - **Adding Tags:**\n - Use the exact wording and formatting provided in the instruction for new tags. Do not modify, reformat, or adjust them in any way. This is critical.\n - Ensure that the final list does not exceed **10 tags**. If adding a tag would exceed this limit, do not add it and clarify this in the \"explanation\".\n - If a tag exceeds **100 characters**, do not add it and state this in the \"explanation\".\n - Ensure all tags remain **unique** (no duplicates).\n - The updated list should first retain all unchanged tags, followed by any new additions.\n\n - **Unaffected Tags:**\n - Tags that are not affected by the modification instructions must remain unchanged, including spacing and formatting.\n\n 3. **Generate Output**\n - Return a JSON object containing:\n - \"updatedTags\": The final array of tags after modifications.\n - \"explanation\": A single, concise sentence summarizing all tag modifications, including the reasoning behind changes or lack thereof. Do not include statements about the total number of tags.\n\n ### Input\n existingTags: {existingTags}\n instructions: {instructions}\n">, any>;
2
+ export declare const systemPrompt: ChatPromptTemplate<import("@langchain/core/prompts").ParamsFromFString<"\n You are a clinical data manager with expert knowledge of Elation Patient Tags, which help care teams organize patient care (e.g., grouping, reporting, or identifying patients for care).\n\n Your task is to manage a single patient's tags based on the provided instructions.\n\n You will receive:\n - existing_tags: An array of the patient's current tags.\n - instruction: A directive specifying which tags to add, update, or remove. Ensure to follow them diligently.\n\n ### Step-by-Step Approach:\n 1. **Review the Instruction**\n - Identify the required tag modifications: additions, updates, or removals.\n\n 2. **Apply Modifications**\n - **Removing Tags:**\n - Only remove tags if explicitly stated in the instruction.\n - Match existing tags for removal, allowing minor variations (e.g., capitalization, spacing).\n - If unsure, do not remove the tag.\n\n - **Adding Tags:**\n - Use the exact wording and formatting provided in the instruction for new tags. Do not modify, reformat, or adjust them in any way. This is critical.\n - When extracting tag names from instructions:\n - If the tag is in quotes: use exactly what's in the quotes, but if the quoted text contains the word \"tag\" (e.g., 'MH-T tag', \"CCM 2 tag\"), remove the word \"tag\" and keep only the tag name ('MH-T', \"CCM 2\")\n - If there are no quotes but the word \"tag\" follows the intended tag name (e.g., \"add MH-T tag\"), extract only the tag name (\"MH-T\") without the word \"tag\"\n - Always preserve all spaces, punctuation, and capitalization exactly as specified\n - If a tag exceeds **100 characters**, do not add it and state this in the \"explanation\".\n - Ensure all tags remain **unique** (no duplicates).\n - The updated list should first retain all unchanged tags, followed by any new additions.\n\n - **Unaffected Tags:**\n - Tags that are not affected by the modification instructions must remain unchanged, including spacing and formatting.\n\n 3. **Generate Output**\n - Return a JSON object containing:\n - \"updatedTags\": The final array of tags after modifications.\n - \"explanation\": A single, concise sentence summarizing all tag modifications, including the reasoning behind changes or lack thereof. Refrain from including statements about the total number of tags.\n\n ### Input\n existingTags: {existingTags}\n instructions: {instructions}\n">, any>;
@@ -23,7 +23,10 @@ exports.systemPrompt = prompts_1.ChatPromptTemplate.fromTemplate(`
23
23
 
24
24
  - **Adding Tags:**
25
25
  - Use the exact wording and formatting provided in the instruction for new tags. Do not modify, reformat, or adjust them in any way. This is critical.
26
- - Ensure that the final list does not exceed **10 tags**. If adding a tag would exceed this limit, do not add it and clarify this in the "explanation".
26
+ - When extracting tag names from instructions:
27
+ - If the tag is in quotes: use exactly what's in the quotes, but if the quoted text contains the word "tag" (e.g., 'MH-T tag', "CCM 2 tag"), remove the word "tag" and keep only the tag name ('MH-T', "CCM 2")
28
+ - If there are no quotes but the word "tag" follows the intended tag name (e.g., "add MH-T tag"), extract only the tag name ("MH-T") without the word "tag"
29
+ - Always preserve all spaces, punctuation, and capitalization exactly as specified
27
30
  - If a tag exceeds **100 characters**, do not add it and state this in the "explanation".
28
31
  - Ensure all tags remain **unique** (no duplicates).
29
32
  - The updated list should first retain all unchanged tags, followed by any new additions.
@@ -34,7 +37,7 @@ exports.systemPrompt = prompts_1.ChatPromptTemplate.fromTemplate(`
34
37
  3. **Generate Output**
35
38
  - Return a JSON object containing:
36
39
  - "updatedTags": The final array of tags after modifications.
37
- - "explanation": A single, concise sentence summarizing all tag modifications, including the reasoning behind changes or lack thereof. Do not include statements about the total number of tags.
40
+ - "explanation": A single, concise sentence summarizing all tag modifications, including the reasoning behind changes or lack thereof. Refrain from including statements about the total number of tags.
38
41
 
39
42
  ### Input
40
43
  existingTags: {existingTags}
@@ -1 +1 @@
1
- {"version":3,"file":"prompt.js","sourceRoot":"","sources":["../../../../../../../extensions/elation/actions/updatePatientTags/lib/getTagsFromLLM/prompt.ts"],"names":[],"mappings":";;;AAAA,qDAA4D;AAE/C,QAAA,YAAY,GAAG,4BAAkB,CAAC,YAAY,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAqC3D,CAAC,CAAA"}
1
+ {"version":3,"file":"prompt.js","sourceRoot":"","sources":["../../../../../../../extensions/elation/actions/updatePatientTags/lib/getTagsFromLLM/prompt.ts"],"names":[],"mappings":";;;AAAA,qDAA4D;AAE/C,QAAA,YAAY,GAAG,4BAAkB,CAAC,YAAY,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAwC3D,CAAC,CAAA"}
@@ -45,7 +45,7 @@ const fetchTestExamples = async () => {
45
45
  try {
46
46
  const testExamples = langsmith.listExamples({
47
47
  datasetName,
48
- splits: ['test'],
48
+ splits: ['test'], // change to ['validation'] to run on validation set
49
49
  });
50
50
  const examples = [];
51
51
  for await (const example of testExamples) {
@@ -135,6 +135,7 @@ const runEvaluation = async () => {
135
135
  evaluators: [appointmentsMatchEvaluator],
136
136
  experimentPrefix: 'FindAppointmentsWithLLM Evaluation',
137
137
  maxConcurrency: 16,
138
+ numRepetitions: 3,
138
139
  });
139
140
  const resultsArray = Array.isArray(results) ? results : [results];
140
141
  const experimentId = (_b = (_a = resultsArray[0]) === null || _a === void 0 ? void 0 : _a.run) === null || _b === void 0 ? void 0 : _b.run_id;
@@ -1 +1 @@
1
- {"version":3,"file":"FindAppointmentsWithLLM.evaluate.js","sourceRoot":"","sources":["../../../../../extensions/elation/lib/findAppointmentsWithLLM/FindAppointmentsWithLLM.evaluate.ts"],"names":[],"mappings":";;;;;AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,yCAAgD;AAChD,qDAA+C;AAC/C,wFAAoF;AACpF,uEAAmE;AACnE,wEAAwE;AAExE,mCAA8B;AAG9B,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,MAA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;AAED,yBAAyB;AACzB,KAAK,aAAa,EAAE,CAAA"}
1
+ {"version":3,"file":"FindAppointmentsWithLLM.evaluate.js","sourceRoot":"","sources":["../../../../../extensions/elation/lib/findAppointmentsWithLLM/FindAppointmentsWithLLM.evaluate.ts"],"names":[],"mappings":";;;;;AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,yCAAgD;AAChD,qDAA+C;AAC/C,wFAAoF;AACpF,uEAAmE;AACnE,wEAAwE;AAExE,mCAA8B;AAG9B,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,sCAAsC,CAAA;AAkB1D,mDAAmD;AACnD,MAAM,iBAAiB,GAAG,KAAK,IAAwB,EAAE;IACvD,IAAI,CAAC;QACH,MAAM,YAAY,GAAG,SAAS,CAAC,YAAY,CAAC;YAC1C,WAAW;YACX,MAAM,EAAE,CAAC,MAAM,CAAC,EAAE,oDAAoD;SACvE,CAAC,CAAA;QACF,MAAM,QAAQ,GAAc,EAAE,CAAA;QAC9B,IAAI,KAAK,EAAE,MAAM,OAAO,IAAI,YAAY,EAAE,CAAC;YACzC,IAAI,CAAC,IAAA,cAAK,EAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,IAAA,cAAK,EAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;gBACtD,sBAAsB;gBACtB,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;YACxB,CAAC;QACH,CAAC;QACD,OAAO,QAAQ,CAAA;IACjB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CAAC,iCAAiC,EAAE,KAAK,CAAC,CAAA;QAC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AE,EAAE;YAClB,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"}
@@ -1,3 +1,3 @@
1
1
  import { ChatPromptTemplate } from '@langchain/core/prompts';
2
- export declare const systemPromptWithDates: ChatPromptTemplate<import("@langchain/core/prompts").ParamsFromFString<"\nYou are a **thorough and precise** medical assistant.\nYou will receive:\n1. A list (array) of **appointments** for a single patient (in JSON format).\n2. A set of **instructions** (written by a clinician, for a clinician) specifying which types of appointments to find.\n\n---\n### **Your Task**\nYour goal is to carefully analyze the provided instructions and the list of appointments to **identify only those that match the instructions**.\n\n- You must be **thorough** in your search but only return results when you are **certain** that they match.\n- If multiple appointments match, return **all** their IDs.\n- If no appointments match, return an empty array—this is a valid outcome.\n- Be **meticulous when evaluating time-based criteria**, ensuring all matches are **precise** relative to ${currentDateTime}.\n\n---\n### **Important Instructions**\n- **Interpret clinically**: Instructions are written by a clinician for a clinician. Understand medical terminology correctly.\n - Example: \"Rx\" relates to prescription or medication follow-up, \"PT\" refers to physical therapy, \"f/u\" means follow-up. 2x/wk means 2 times a week while 2:1 means two patients per one clinician.\n- **Only return matches when you are certain**:\n - Use your expertise for matching but do not assume connections—appointments must explicitly fit the given instructions.\n - If an instruction is vague or ambiguous, only match appointments if the data supports it directly.\n- **Evaluate time constraints precisely**:\n - If the instruction mentions \"past\" appointments, **only include** those scheduled **before** ${currentDateTime}.\n - If \"future\" appointments are requested, **only include** those scheduled **after** ${currentDateTime}.\n - If an exact date is specified, match it **precisely**.\n - For relative time windows (e.g., within the next 12 hours):\n - Calculate the exact time difference between an appointment's scheduled date/time and ${currentDateTime}.\n - Example: If an appointment is scheduled at a time such that the time difference from ${currentDateTime} is more than 0 but less than or equal to 12 hours, then it qualifies.\n - It is critical to ensure the accuracy of your time comparison. Double check your calculation and reasoning.\n- **Only include appointment IDs that exist in the provided input array**.\n- **Do not fabricate matches**—returning an empty array is preferable to an incorrect match.\n\n\n----------\nPatient Appointments:\n${appointments}\n----------\nInstructions:\n${prompt}\n\nYour output must be a valid JSON object with the following fields:\n\n- appointmentIds: An array containing the IDs of appointments that match the given criteria. If no appointments meet the criteria, this array must be empty.\n- explanation: A concise, human-readable explanation that clearly describes:\n - How and why the selected appointments match the input criteria.\n - Why any appointments were excluded, if relevant.\n - Any edge cases or specific reasoning behind your selection.\n\n## Critical Requirements\n### Ensure that the explanation strictly matches the appointmentIds:\n- If appointmentIds contains **selected appointments**, the explanation must accurately describe **why they were chosen**.\n- If appointmentIds is **empty**, the explanation must clearly state **why no matches were found**.\n\n### Be thorough and precise:\n- Carefully **analyze all appointments** before making a decision.\n- **Double-check** your reasoning to confirm that **only valid matches** are included.\n- Ensure that no appointments that **do not meet the criteria** are selected.\n- **Maintain strict consistency** between appointmentIds and explanation.\n- **Do not contradict yourself**: The explanation must always align with the selected appointments appointmentIds. Double check your explanation against the appointmentIds.\n">, any>;
3
- export declare const systemPromptWithoutDates: ChatPromptTemplate<import("@langchain/core/prompts").ParamsFromFString<"\nYou are a **thorough and precise** medical assistant.\nYou will receive:\n1. A list (array) of **appointments** for a single patient (in JSON format).\n2. A set of **instructions** (written by a clinician, for a clinician) specifying which types of appointments to find.\n\n---\n### **Your Task**\nYour goal is to carefully analyze the provided instructions and the list of appointments to **identify only those that match the instructions**.\nTranslate the instructions into a set of granular criteria, then go through the list of appointments and evaluate each criteria separately, and in a final pass keep only the appointments that meet all of the criteria.\n\n- You must be **thorough** in your search but only return results when you are **certain** that they match.\n- If multiple appointments match, return **all** their IDs.\n- If no appointments match, return an empty array—this is a valid outcome.\n- The current date is {currentDateTime}\n\n---\n### **Important Instructions**\n- **Interpret clinically**: Instructions are written by a clinician for a clinician. Understand medical terminology correctly.\n - Example: \"Rx\" relates to prescription or medication follow-up, \"PT\" refers to physical therapy, \"f/u\" means follow-up. 2x/wk means 2 times a week while 2:1 means two patients per one clinician.\n- **Only return matches when you are certain**:\n - Use your expertise for matching but do not assume connections—appointments must explicitly fit the given instructions.\n - If an instruction is vague or ambiguous, only match appointments if the data supports it directly.\n- **Do not exclude appointments based on their scheduled date**.\n- **Only include appointment IDs that exist in the provided input array**.\n- **Do not fabricate matches**—returning an empty array is preferable to an incorrect match.\n\n\n----------\nPatient Appointments:\n{appointments}\n----------\nInstructions:\n{prompt}\n\nYour output must be a valid JSON object with the following fields:\n\n- appointmentIds: An array containing the IDs of appointments that match the given criteria. If no appointments meet the criteria, this array must be empty.\n- explanation: A concise, human-readable explanation that clearly describes:\n - How and why the selected appointments match the input criteria.\n - Why any appointments were excluded, if relevant.\n - Any edge cases or specific reasoning behind your selection.\n\n## Critical Requirements\n### Ensure that the explanation strictly matches the appointmentIds:\n- If appointmentIds contains **selected appointments**, the explanation must accurately describe **why they were chosen**.\n- If appointmentIds is **empty**, the explanation must clearly state **why no matches were found**.\n\n### Be thorough and precise:\n- Carefully **analyze all appointments** before making a decision.\n- **Double-check** your reasoning to confirm that **only valid matches** are included.\n- **Maintain strict consistency** between appointmentIds and explanation.\n- **Do not contradict yourself**: The explanation must always align with the selected appointments appointmentIds. Double check your explanation against the appointmentIds.">, any>;
2
+ export declare const systemPromptWithDates: ChatPromptTemplate<import("@langchain/core/prompts").ParamsFromFString<"\nYou are a **thorough and precise** medical assistant.\nYou will receive:\n1. A list (array) of **appointments** for a single patient (in JSON format).\n2. A set of **instructions** (written by a clinician, for a clinician) specifying which types of appointments to find.\n\n---\n### **Your Task**\nYour goal is to carefully analyze the provided instructions and the list of appointments to **identify only those that match the instructions**.\n\n- You must be **thorough** in your search but only return results when you are **certain** that they match.\n- If multiple appointments match, return **all** their IDs.\n- If no appointments match, return an empty array—this is a valid outcome.\n- Be **meticulous when evaluating time-based criteria**, ensuring all matches are **precise** relative to ${currentDateTime}.\n\n---\n### **Important Instructions**\n- **Interpret clinically**: Instructions are written by a clinician for a clinician. Understand medical terminology correctly.\n - Example: \"Rx\" relates to prescription or medication follow-up, \"PT\" refers to physical therapy, \"f/u\" means follow-up. 2x/wk means 2 times a week while 2:1 means two patients per one clinician.\n- **Only return matches when you are certain**:\n - Use your expertise for matching but do not assume connections—appointments must explicitly fit the given instructions.\n - If an instruction is vague or ambiguous, only match appointments if the data supports it directly.\n- **Evaluate time constraints precisely**:\n - If the instruction mentions \"past\" appointments, **only include** those scheduled **before** ${currentDateTime}.\n - If \"future\" appointments are requested, **only include** those scheduled **after** ${currentDateTime}.\n - If an exact date is specified, match it **precisely**.\n - For relative time windows (e.g., \"within the next 12 hours\"):\n - Calculate the exact time difference between an appointment's scheduled date/time and ${currentDateTime}.\n - Example: If an appointment is scheduled at a time such that the time difference from ${currentDateTime} is more than 0 but less than or equal to 12 hours, then it qualifies.\n - It is critical to ensure the accuracy of your time comparison. Double check your calculation and reasoning.\n- **Only include appointment IDs that exist in the provided input array**.\n- **Do not fabricate matches**—returning an empty array is preferable to an incorrect match.\n- **Regardless of phrasing, always find ALL matching appointments**:\n - Even if the instruction says \"find one appointment\" or \"cancel an appointment,\" you must return ALL appointments that match the criteria.\n - Your job is always to identify every appointment that matches the specified criteria, not to limit results based on phrasing.\n- **Treat quoted terms as exact matches with only format variations**:\n - When terms appear in quotes (e.g., \"checked in\"), match only to that specific term and minor format variations.\n - Example: \"checked in\" would match \"Checked In\", \"checked in\", \"checked-in\", but NOT \"checked out\", \"not checked in\", or any semantically different status.\n - Do not assume semantic equivalence or infer relationships unless explicitly stated.\n\n----------\nPatient Appointments:\n${appointments}\n----------\nInstructions:\n${prompt}\n\nYour output must be a valid JSON object with the following fields:\n\n- appointmentIds: An array containing the IDs of appointments that match the given criteria. If no appointments meet the criteria, this array must be empty.\n- explanation: A concise, human-readable explanation that clearly describes:\n - How and why the selected appointments match the input criteria.\n - Why any appointments were excluded, if relevant.\n - Any edge cases or specific reasoning behind your selection.\n\n## Critical Requirements\n### Ensure that the explanation strictly matches the appointmentIds:\n- If appointmentIds contains **selected appointments**, the explanation must accurately describe **why they were chosen**.\n- If appointmentIds is **empty**, the explanation must clearly state **why no matches were found**.\n\n### Be thorough and precise:\n- Carefully **analyze all appointments** before making a decision.\n- **Double-check** your reasoning to confirm that **only valid matches** are included.\n- Ensure that no appointments that **do not meet the criteria** are selected.\n- **Maintain strict consistency** between appointmentIds and explanation.\n- **Do not contradict yourself**: The explanation must always align with the selected appointments appointmentIds. Double check your explanation against the appointmentIds.\n- **Final verification**: Before finalizing, verify that each appointment in appointmentIds meets **ALL** criteria specified in the instructions. Remove any appointment that fails to meet even a single criterion.\n">, any>;
3
+ export declare const systemPromptWithoutDates: ChatPromptTemplate<import("@langchain/core/prompts").ParamsFromFString<"\nYou are a **thorough and precise** medical assistant.\nYou will receive:\n1. A list (array) of **appointments** for a single patient (in JSON format).\n2. A set of **instructions** (written by a clinician, for a clinician) specifying which types of appointments to find.\n\n---\n### **Your Task**\nYour goal is to carefully analyze the provided instructions and the list of appointments to **identify only those that match the instructions**.\nTranslate the instructions into a set of granular criteria, then go through the list of appointments and evaluate each criteria separately, and in a final pass keep only the appointments that meet all of the criteria.\n\n- You must be **thorough** in your search but only return results when you are **certain** that they match.\n- If multiple appointments match, return **all** their IDs.\n- If no appointments match, return an empty array—this is a valid outcome.\n- The current date is {currentDateTime}\n\n---\n### **Important Instructions**\n- **Interpret clinically**: Instructions are written by a clinician for a clinician. Understand medical terminology correctly.\n - Example: \"Rx\" relates to prescription or medication follow-up, \"PT\" refers to physical therapy, \"f/u\" means follow-up. 2x/wk means 2 times a week while 2:1 means two patients per one clinician.\n- **Only return matches when you are certain**:\n - Use your expertise for matching but do not assume connections—appointments must explicitly fit the given instructions.\n - If an instruction is vague or ambiguous, only match appointments if the data supports it directly.\n- **Do not exclude appointments based on their scheduled date**.\n- **Only include appointment IDs that exist in the provided input array**.\n- **Do not fabricate matches**—returning an empty array is preferable to an incorrect match.\n- **Regardless of phrasing, always find ALL matching appointments**:\n - Even if the instruction says \"find one appointment\" or \"cancel an appointment,\" you must return ALL appointments that match the criteria.\n - Your job is always to identify every appointment that matches the specified criteria, not to limit results based on phrasing.\n- **Treat quoted terms as exact matches with only format variations**:\n - When terms appear in quotes (e.g., \"checked in\"), match only to that specific term and minor format variations.\n - Example: \"checked in\" would match \"Checked In\", \"checked in\", \"checked-in\", but NOT \"checked out\", \"not checked in\", or any semantically different status.\n - Do not assume semantic equivalence or infer relationships unless explicitly stated.\n\n----------\nPatient Appointments:\n{appointments}\n----------\nInstructions:\n{prompt}\n\nYour output must be a valid JSON object with the following fields:\n\n- appointmentIds: An array containing the IDs of appointments that match the given criteria. If no appointments meet the criteria, this array must be empty.\n- explanation: A concise, human-readable explanation that clearly describes:\n - How and why the selected appointments match the input criteria.\n - Why any appointments were excluded, if relevant.\n - Any edge cases or specific reasoning behind your selection.\n\n## Critical Requirements\n### Ensure that the explanation strictly matches the appointmentIds:\n- If appointmentIds contains **selected appointments**, the explanation must accurately describe **why they were chosen**.\n- If appointmentIds is **empty**, the explanation must clearly state **why no matches were found**.\n\n### Be thorough and precise:\n- Carefully **analyze all appointments** before making a decision.\n- **Double-check** your reasoning to confirm that **only valid matches** are included.\n- **Maintain strict consistency** between appointmentIds and explanation.\n- **Do not contradict yourself**: The explanation must always align with the selected appointments appointmentIds. Double check your explanation against the appointmentIds.\n- **Final verification**: Before finalizing, verify that each appointment in appointmentIds meets **ALL** criteria specified in the instructions. Remove any appointment that fails to meet even a single criterion.\n">, any>;
@@ -28,13 +28,19 @@ Your goal is to carefully analyze the provided instructions and the list of appo
28
28
  - If the instruction mentions "past" appointments, **only include** those scheduled **before** \${currentDateTime}.
29
29
  - If "future" appointments are requested, **only include** those scheduled **after** \${currentDateTime}.
30
30
  - If an exact date is specified, match it **precisely**.
31
- - For relative time windows (e.g., within the next 12 hours):
31
+ - For relative time windows (e.g., "within the next 12 hours"):
32
32
  - Calculate the exact time difference between an appointment's scheduled date/time and \${currentDateTime}.
33
33
  - Example: If an appointment is scheduled at a time such that the time difference from \${currentDateTime} is more than 0 but less than or equal to 12 hours, then it qualifies.
34
34
  - It is critical to ensure the accuracy of your time comparison. Double check your calculation and reasoning.
35
35
  - **Only include appointment IDs that exist in the provided input array**.
36
36
  - **Do not fabricate matches**—returning an empty array is preferable to an incorrect match.
37
-
37
+ - **Regardless of phrasing, always find ALL matching appointments**:
38
+ - Even if the instruction says "find one appointment" or "cancel an appointment," you must return ALL appointments that match the criteria.
39
+ - Your job is always to identify every appointment that matches the specified criteria, not to limit results based on phrasing.
40
+ - **Treat quoted terms as exact matches with only format variations**:
41
+ - When terms appear in quotes (e.g., "checked in"), match only to that specific term and minor format variations.
42
+ - Example: "checked in" would match "Checked In", "checked in", "checked-in", but NOT "checked out", "not checked in", or any semantically different status.
43
+ - Do not assume semantic equivalence or infer relationships unless explicitly stated.
38
44
 
39
45
  ----------
40
46
  Patient Appointments:
@@ -62,6 +68,7 @@ Your output must be a valid JSON object with the following fields:
62
68
  - Ensure that no appointments that **do not meet the criteria** are selected.
63
69
  - **Maintain strict consistency** between appointmentIds and explanation.
64
70
  - **Do not contradict yourself**: The explanation must always align with the selected appointments appointmentIds. Double check your explanation against the appointmentIds.
71
+ - **Final verification**: Before finalizing, verify that each appointment in appointmentIds meets **ALL** criteria specified in the instructions. Remove any appointment that fails to meet even a single criterion.
65
72
  `);
66
73
  exports.systemPromptWithoutDates = prompts_1.ChatPromptTemplate.fromTemplate(`
67
74
  You are a **thorough and precise** medical assistant.
@@ -89,7 +96,13 @@ Translate the instructions into a set of granular criteria, then go through the
89
96
  - **Do not exclude appointments based on their scheduled date**.
90
97
  - **Only include appointment IDs that exist in the provided input array**.
91
98
  - **Do not fabricate matches**—returning an empty array is preferable to an incorrect match.
92
-
99
+ - **Regardless of phrasing, always find ALL matching appointments**:
100
+ - Even if the instruction says "find one appointment" or "cancel an appointment," you must return ALL appointments that match the criteria.
101
+ - Your job is always to identify every appointment that matches the specified criteria, not to limit results based on phrasing.
102
+ - **Treat quoted terms as exact matches with only format variations**:
103
+ - When terms appear in quotes (e.g., "checked in"), match only to that specific term and minor format variations.
104
+ - Example: "checked in" would match "Checked In", "checked in", "checked-in", but NOT "checked out", "not checked in", or any semantically different status.
105
+ - Do not assume semantic equivalence or infer relationships unless explicitly stated.
93
106
 
94
107
  ----------
95
108
  Patient Appointments:
@@ -115,5 +128,7 @@ Your output must be a valid JSON object with the following fields:
115
128
  - Carefully **analyze all appointments** before making a decision.
116
129
  - **Double-check** your reasoning to confirm that **only valid matches** are included.
117
130
  - **Maintain strict consistency** between appointmentIds and explanation.
118
- - **Do not contradict yourself**: The explanation must always align with the selected appointments appointmentIds. Double check your explanation against the appointmentIds.`);
131
+ - **Do not contradict yourself**: The explanation must always align with the selected appointments appointmentIds. Double check your explanation against the appointmentIds.
132
+ - **Final verification**: Before finalizing, verify that each appointment in appointmentIds meets **ALL** criteria specified in the instructions. Remove any appointment that fails to meet even a single criterion.
133
+ `);
119
134
  //# sourceMappingURL=prompt.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"prompt.js","sourceRoot":"","sources":["../../../../../extensions/elation/lib/findAppointmentsWithLLM/prompt.ts"],"names":[],"mappings":";;;AAAA,qDAA4D;AAE/C,QAAA,qBAAqB,GAAG,4BAAkB,CAAC,YAAY,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4DpE,CAAC,CAAA;AAEW,QAAA,wBAAwB,GAAG,4BAAkB,CAAC,YAAY,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;6KAoDqG,CAAC,CAAA"}
1
+ {"version":3,"file":"prompt.js","sourceRoot":"","sources":["../../../../../extensions/elation/lib/findAppointmentsWithLLM/prompt.ts"],"names":[],"mappings":";;;AAAA,qDAA4D;AAE/C,QAAA,qBAAqB,GAAG,4BAAkB,CAAC,YAAY,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAmEpE,CAAC,CAAA;AAEW,QAAA,wBAAwB,GAAG,4BAAkB,CAAC,YAAY,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4DvE,CAAC,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@awell-health/awell-extensions",
3
- "version": "2.0.236",
3
+ "version": "2.0.238",
4
4
  "packageManager": "yarn@4.5.3",
5
5
  "main": "dist/src/index.js",
6
6
  "repository": {