Bio-LIMS (v2.0)
A skill for calling Bio-LIMS backend APIs. All API calls are made through scripts/biolims.mjs, with automatic token management.
Module Features:
- - Order Management
- Sample Receive
- Sample Type Query
- Experiment Template Management
Quick Start
CODEBLOCK0
Common Usage Scenarios
Scenario 1: User asks about order information
User: "Help me check order ORDER202401180001"
AI Actions:
- 1. Call: INLINECODE1
- Parse the returned JSON, extract key information
- Reply to user in a clear list format
Reply Example (strictly follow field mapping):
CODEBLOCK1
Important Reminders:
- - Use English field display names (e.g., "Patient Name", not Chinese equivalents)
- Patient name is a single field
name, do not split it for display - Display by field groups (Patient Information, Product Information, etc.)
- Only show fields that have values
- This system does not use firstName/lastName, only the
name field
Scenario 2: Query order list
User: "What are the recent orders?"
AI Actions:
- 1. Call: INLINECODE4
- Parse the returned list
- Display recent orders
Reply Example (list mode, simplified display):
CODEBLOCK2
Important: List mode only shows key fields, uses English display names, patient name uses single name field
Scenario 3: View order samples
User: "What samples does order ORDER202401180001 have?"
AI Actions:
- 1. Call: INLINECODE6
- Display sample list
Reply Example:
CODEBLOCK3
Scenario 4: Query sample types
User: "What sample types are available?" or "I need the type ID for blood samples"
AI Actions:
- 1. If user provided a specific name (e.g., "Blood"), call: INLINECODE7
- If user did not provide a name, call: INLINECODE8
- Display sample type list including ID, name, and code
Reply Example:
CODEBLOCK4
Scenario 5: Create order
User: "Help me create an order, patient name is John Smith, test item is LymphDetect, need one blood sample"
AI Actions:
- 1. Collect required info: name (patient name), productId, productName
- If user mentions sample type, use
search-sample-type to query sample type ID - Build complete JSON (must use correct field names)
- Use file method to pass large JSON (avoid command line escaping issues)
- Call create order command
Key Notes for Creating Orders:
- 1. Use file method to pass JSON (strongly recommended):
- Windows PowerShell has issues with command line JSON escaping
- Write JSON to a temp file, then pass using
@filepath
CODEBLOCK5
- 2. productId must be a system ID:
- Wrong:
"productId": "LymphDetect" (using product name directly)
- Correct:
"productId": "CP2511240001" (system product ID)
- If you don't know the productId, first query existing orders to get the correct ID
- 3. Samples must also include productId and productName:
- Each sampleOrderItem must include productId and productName
- Otherwise the server will return a 400 error
Critically Important - Field Names:
CODEBLOCK6
Complete JSON Example:
CODEBLOCK7
Common Product ID Mapping:
| Product Name | productId |
|---|
| LymphDetect | CP2511240001 |
(Other product IDs can be obtained by querying existing orders)
Reply Example:
CODEBLOCK8
Response Handling
Key Rules:
- 1. Must check status field: Only
status === 200 indicates success - order-list response structure: INLINECODE14
- Order list is in
data.result, not directly in
data
- 3. Single order response structure: INLINECODE17
- Error response: INLINECODE18
Response Handling Steps:
CODEBLOCK9
Display Rules (Very Important):
- 1. Use English field display names:
- Strictly follow the field mapping table using English names
- Example:
name -> "Patient Name: John Smith"
- Example:
gender -> "Gender: Female"
- Reference
references/field-mapping-quick-reference.md for field mapping table
- 2. Correct use of name field:
- This system uses a single
name field for patient name, display as "Patient Name: John Smith"
- Do NOT look for firstName / lastName (these fields do not exist in this system)
- Do NOT split the name field into first and last name
- 3. Format Requirements:
- Do not paste raw JSON directly
- Use list format for display (WhatsApp does not support markdown tables)
- Display by groups (Patient Information, Product Information, etc.)
- Only show fields with values (do not show null or empty strings)
- 4. Enum Value Conversion:
- gender: 0->Female, 1->Male, 2->Unknown
- state: 0->Cancelled, 1->Complete, 3->NEW, 15->To Be Modified, 20->Submitted
- Sample status: 0->Cancel, 1->New, 2->To be received, 3->Received, 4->Scanned
- 5. Time Format:
- Keep original format or convert to readable format
- Example: "2024-01-18 10:30:00"
Order Status Description
- -
0 - Cancelled - INLINECODE24 - Complete
- INLINECODE25 - New
- INLINECODE26 - To Be Modified
- INLINECODE27 - Submitted
Gender Codes
- -
0 - Female - INLINECODE29 - Male
- INLINECODE30 - Unknown
Important Notes
- 1. Token Management: The script automatically handles login and token refresh; no manual intervention needed
- Error Handling: If the API returns an error, explain the specific issue to the user (e.g., "order does not exist", "insufficient permissions", etc.)
- Data Format: Creating/updating orders requires a complete JSON structure; refer to INLINECODE31
- Privacy Protection: Be careful to protect privacy when displaying patient information; do not over-expose sensitive data
Field Mapping Reference
Fixed Field Mapping
The JSON data returned by orders uses API internal field names (e.g., name, productId), which need to be mapped to page display names (e.g., "Patient Name", "Test Item ID").
Main Field Mapping:
- -
id -> Order ID - INLINECODE35 -> Patient Name (single field, NOT firstName/lastName)
- INLINECODE36 -> Gender (0=Female, 1=Male, 2=Unknown)
- INLINECODE37 -> Age
- INLINECODE38 -> Date of Birth
- INLINECODE39 -> Ethnicity
- INLINECODE40 -> ID Card No.
- INLINECODE41 -> Phone Number
- INLINECODE42 -> Email
- INLINECODE43 -> EMR ID
- INLINECODE44 -> Bed No.
- INLINECODE45 -> Inpatient/Outpatient No.
- INLINECODE46 -> Test Item ID
- INLINECODE47 -> Test Item(s)
- INLINECODE48 -> Barcode
- INLINECODE49 -> Clinical Diagnosis
- INLINECODE50 -> Health Condition
- INLINECODE51 -> Disease
- INLINECODE52 -> Status
- INLINECODE53 -> Order Progress
- INLINECODE54 -> Created by
- INLINECODE55 -> Created at
- INLINECODE56 -> Approved by
- INLINECODE57 -> Completed at
- INLINECODE58 -> Sales
- INLINECODE59 -> Medical Institutions
- INLINECODE60 -> Clinical Department
- INLINECODE61 -> Attending Physician
- INLINECODE62 -> Physician Contact No.
- INLINECODE63 -> Province
- INLINECODE64 -> Contract Name
- INLINECODE65 -> Contract Price
- INLINECODE66 -> Remarks
For the complete mapping table, refer to references/field-mapping-quick-reference.md.
Custom Field Handling
Order data contains two types of custom fields:
- 1. Order main table custom fields (
customFieldValue)
- Storage location:
order.customFieldValue (JSON string)
- Field mapping API: INLINECODE70
- 2. Sample sub-table custom fields (
customFieldValue)
- Storage location:
sampleOrderItem[n].customFieldValue (JSON string)
- Field mapping API: INLINECODE73
Processing Steps:
- 1. Call field mapping API to get
{"Display Name": "apiFieldName"} mapping - INLINECODE75 to parse the
customFieldValue string in the order - Use the mapping to convert API field names to display names
- Display to user
Example:
// 1. Get field mapping
const mapping = await getCustomFields('104-mainTable');
// Returns: {"Patient Note": "patientNote", "Urgency Level": "urgencyLevel"}
// 2. Parse custom fields
const customValues = JSON.parse(order.customFieldValue);
// customValues = {"patientNote": "Urgent case", "urgencyLevel": "High"}
// 3. Convert to display names
// "Patient Note": "Urgent case"
// "Urgency Level": "High"
Sample Receive Usage Scenarios
Scenario 6: Query receive order list
User: "What are the recent sample receive orders?"
AI Actions:
- 1. Call: INLINECODE77
- Parse the returned list
- Display recent receive orders
Reply Example (list mode, simplified display):
CODEBLOCK11
Scenario 7: Query receive order details
User: "Help me check receive order SR202401180001"
AI Actions:
- 1. Call: INLINECODE78
- Parse the returned JSON, extract key information
- Reply in a clear list format
Reply Example (strictly follow field mapping, do not merge fields):
CODEBLOCK12
Important Reminders:
- - Use English field display names (e.g., "Registration ID", not Chinese equivalents)
- Do not merge fields (display each field separately)
- Display by field groups (Sample Receive Information, Express Information, etc.)
- Only show fields that have values
Scenario 8: Query receive order sample details
User: "What samples does receive order SR202401180001 have?"
AI Actions:
- 1. Call: INLINECODE79
- Display sample list
Reply Example:
CODEBLOCK13
Scenario 9: Scan barcode to receive sample
User: "Scan barcode BC20240118001"
Important: The scan-barcode command's receive_id is a required parameter; you must create a receive order first!
AI Actions:
- 1. First check if a receive order exists:
- If user already provided a receive order ID -> use it directly
- If no receive order -> first call
create-receive to create a new one
- 2. Call: INLINECODE83
- Parse the returned sample information
- Display sample details
API Input Format:
CODEBLOCK14
Reply Example:
CODEBLOCK15
If barcode has already been received:
CODEBLOCK16
If no receive order ID provided:
CODEBLOCK17
Scenario 10: Scan order number for batch receiving
User: "Scan order ORD202401180001"
AI Actions:
- 1. Call: INLINECODE84
- Parse the returned sample list
- Display receivable samples
Reply Example:
CODEBLOCK18
Scenario 11: Create sample receive order
User: "Create a sample receive order, receive time is today at 10am, express number SF1234567890, needs plating"
AI Actions:
- 1. Collect required info: acceptDate (receive time), isBoard (whether to plate)
- Build complete JSON (must use correct field names)
- Call create receive order command
Critically Important - Field Names:
CODEBLOCK19
Complete JSON Example:
CODEBLOCK20
Reply Example:
Receive order created successfully!
Registration ID: SR202401180001
Description: Clinical Sample Receive
Received At: 2024-01-18 10:00:00
Express Bill No.: SF1234567890
Courier: SF Express
In Plate: Yes
Status: New
Sample Details:
- Sample ID: S001, Barcode: BC001, Whole Blood, 5ml
Receive order has been saved to the system.
Scenario 12: Query receive order with custom fields
User: "Query complete information for receive order SR202401180001, including custom fields"
AI Actions:
- 1. Call
get-custom-fields 121-mainTable to get main table custom field mapping - Call
get-custom-fields 121-receiveTable to get sub-table custom field mapping - Call
receive SR202401180001 to query receive order data - Parse fixed fields (using field mapping table from TOOLS.md)
- Parse enum values (Gender, Status, isGood, method, isBoard)
- Parse
customFieldValue JSON fields (main table and sub-table) - Format display (all fields use English display names)
Complete Workflow Example:
CODEBLOCK22
Parsing Logic (pseudocode):
CODEBLOCK23
Reply Example:
CODEBLOCK24
Important Tips:
- - Custom field mappings may change dynamically; it is recommended to re-fetch them with each query
- INLINECODE89 is a JSON string that must be parsed with
JSON.parse() first - All fields must use English display names
- Only display fields with values; do not show empty fields
Scenario 13: Query next step flow list
User: "Query next step flow for product PROD001" or "Where does this sample go next?"
AI Actions:
Key: This API requires a product ID; it will error without one
Step 1: Confirm product ID
- - If user already provided product ID -> use it directly
- If user did not provide product ID -> must ask or query first
Step 2: Call API
CODEBLOCK25
Step 3: Parse response
CODEBLOCK26
Reply Example 1 (with product ID):
CODEBLOCK27
Reply Example 2 (no product ID - must ask first):
CODEBLOCK28
Common Errors (must avoid):
CODEBLOCK29
Business Logic:
- - Single product ID: Returns all available next step flows for that product
- Multiple product IDs: Returns flows supported by all products (intersection)
- Example: PROD001 supports [A,B,C], PROD002 supports [B,C,D] -> Returns [B,C]
Rules AI Must Follow:
- 1. Never call
get-next-flows without a product ID - If user did not provide a product ID, must ask first: "Please provide the test item product ID"
- Or proactively offer help: "I can first help you query the available test item list, would you like that?"
- Only call the API after obtaining the product ID
Scenario 14: Required field validation before completing receive order
User: "Complete receive order SR202401180001"
AI Actions:
Key: Must validate all required fields before completing
Step 1: Query current receive order data
CODEBLOCK30
Step 2: Validate required fields
Main table required fields (2):
- -
acceptDate (Received At) - Receive time - INLINECODE93 (In Plate) - Whether to plate
Sample detail required fields (9 per sample):
- -
orderCode (Order ID) - INLINECODE95 (Barcode)
- INLINECODE96 (Test Item(s))
- INLINECODE97 (Sample Type ID)
- INLINECODE98 (Sampling Volume)
- INLINECODE99 (Unit)
- INLINECODE100 (Normal)
- INLINECODE101 (Result)
- INLINECODE102 (Next Step)
Step 3: Decide whether to complete based on validation results
Case A - All fields present:
CODEBLOCK31
Reply:
CODEBLOCK32
Case B - Missing fields (must list specific missing fields):
Reply:
CODEBLOCK33
Things AI Must Never Do:
- 1. Call
complete-receive directly without validation - Assume fields are filled and skip validation
- Only say "fields are missing" without listing specific fields
Scenario 15: Duplicate barcode error handling
User: "Create receive order with samples BC001 and BC001"
AI Actions:
- 1. Build JSON
- Call INLINECODE104
- Receive error response: INLINECODE105
AI should reply like this:
CODEBLOCK34
Common barcode error scenarios:
Scenario A - Duplicate within same receive order:
{
"sampleReceiveItems": [
{"barCode": "BC001", ...},
{"barCode": "BC001", ...} // Duplicate
]
}
Error: INLINECODE106
Scenario B - Already received by another receive order:
- - Barcode BC001 is already in another receive order
- Scanning will indicate the sample has been received
AI Handling:
- - Parse error message
- Identify the specific duplicate barcode
- Provide clear resolution suggestions
Scenario 16: Unified handling of API error responses
After all API calls, AI must check the status field:
CODEBLOCK36
Error response examples and AI replies:
| API Response | AI Reply |
|---|
| INLINECODE107 | Save failed: duplicate barcode. Duplicate barcode detected... Please modify and try again. |
| INLINECODE108 |
Save failed: missing required field - Received At (acceptDate). Please fill in and try again. |
|
{"status":500,"msg":"Internal error"} | Server error, please try again later. |
Principles AI Must Follow:
- 1. Always check the status field - Do not assume the call succeeded
- Display errors in a friendly manner - Do not return raw error messages directly
- Provide resolution suggestions - Tell the user how to fix the error
- List specific details - Which field is missing? Which barcode is duplicated?
Sample Receive Status Description
Receive Order Status
- -
3 - New - Editable, saveable, completable - INLINECODE111 - Complete - Read-only, not editable
Sample Qualification Status
- -
1 - Qualified - INLINECODE113 - Unqualified
In Plate
- -
1 - Yes - INLINECODE115 - No
Experiment Template Usage Scenarios
Scenario 17: Query experiment template list
User: "View experiment templates" / "Check latest experiment templates" / "What experiment templates are there"
AI Actions:
- 1. Call: INLINECODE116
- Parse the returned
data.result array, display key fields
Reply Example:
CODEBLOCK37
Status Value Conversion:
- -
3 -> New (editable) - INLINECODE119 -> In Workflow
- INLINECODE120 -> To Be Modified
- INLINECODE121 -> Complete
- INLINECODE122 -> Cancelled (excluded from queries automatically)
Scenario 18: Query experiment template details
User: "View details of template ET2024000001" / "What steps does ET2024000001 have"
AI Actions:
- 1. Call: INLINECODE123
- Parse three-layer nested structure, display by step -> component hierarchy
Reply Example:
Template Details: ET2024000001
=== Basic Information ===
Template Name: PCR Testing Experiment Template
Experiment Type: PCR Amplification
Status: Complete
Created by: admin
Created at: 2024-01-15 10:30:00
Version: 1.0
=== Step Structure (2 steps total) ===
Step 1: Sample Preparation
- [detailTable] Sample Detail Table
- [input] Extraction Concentration (number)
- [input] Extraction Date (date)
- [attachment] Extraction Record
Step 2: PCR Amplification
- [detailTable] Sample Detail Table
- [equipment] Instruments & Equipment
- [material] Reagents & Consumables
- [resultTable] Test Result Table
Scenario 19: Create experiment template
User: "Help me create an XXX testing template"
AI Actions:
- 1. First query experiment types: INLINECODE124
- First query experiment groups: INLINECODE125
- Collect required info: templateName, experimentType, experimentGroup, auditor
- Build JSON and write to temp file (avoid escaping issues)
- Call: INLINECODE126
Create JSON Structure (templateName required, stepDetails required):
{
"templateName": "Template Name",
"experimentType": "Experiment Type ID",
"experimentTypeName": "Experiment Type Name",
"experimentGroup": "Experiment Group ID",
"experimentGroupName": "Experiment Group Name",
"auditor": "Approver ID",
"auditorName": "Approver Name",
"stepDetails": [
{
"name": "Step Name",
"keyId": 0,
"jsonDatas": [
{
"label": "Field Name",
"type": "input",
"size": "8",
"inputType": "text",
"exclusiveShow": "0"
}
]
}
]
}
Scenario 20: Copy experiment template
User: "Copy template ET2024000001" / "Create a new one based on template ET001"
AI Actions:
- 1. Call: INLINECODE127
- Display new template ID (auto-generated by system, status is New and editable)
Scenario 21: Cancel experiment template
User: "Cancel template ET2024000001"
AI Actions:
- 1. Must confirm first: "Are you sure you want to cancel template ET2024000001? This action cannot be undone."
- After user confirms: INLINECODE128
Detailed API Information
Order Module
- - Complete API documentation: INLINECODE129
- Field mapping quick reference:
references/field-mapping-quick-reference.md <- Must read when querying orders!
Sample Receive Module
- - Complete API documentation: INLINECODE131
- Field mapping quick reference:
references/field-mapping-sample-receive-quick-reference.md <- Must read when querying receive orders!
Experiment Template Module
- - Complete API documentation:
references/api-experiment-template.md <- Must read for experiment template operations!
Bio-LIMS (v2.0)
用于调用Bio-LIMS后端API的技能。所有API调用均通过scripts/biolims.mjs进行,并自动管理令牌。
模块功能:
快速开始
bash
脚本路径(绝对路径)
SCRIPT=/home/biolims/.openclaw/workspace/skills/biolims/scripts/biolims.mjs
查询订单详情
node $SCRIPT order ORDER202401180001
分页查询订单列表(默认第1页,每页10条)
bash $SCRIPT order-list
bash $SCRIPT order-list 1 20 # 第1页,每页20条
查询订单样本列表
bash $SCRIPT order-samples ORDER202401180001
查询订单费用信息
bash $SCRIPT order-fees ORDER202401180001
创建新订单(注意:字段名称必须准确!)
sampleOrderItem 不能写成 samples!
crmConsumeRmarkets 不能写成 fees!
bash $SCRIPT create-order {
order: {
name: John Smith,
productId: PROD001,
productName: Genetic Testing
},
sampleOrderItem: [
{
slideCode: BC123,
sampleTypeId: T250724002,
sampleType: Whole Blood,
productId: PROD001,
productName: Genetic Testing
}
],
crmConsumeRmarkets: [
{
fee: 3500.00,
feeWay: Bank Transfer,
isFee: 1
}
]
}
更新订单
bash $SCRIPT update-order {order:{id:ORDER123,name:Jane Smith,...}}
完成订单
bash $SCRIPT complete-order ORDER202401180001
取消订单
bash $SCRIPT cancel-order ORDER202401180001
查询所有样本类型
bash $SCRIPT sample-types
搜索样本类型(按名称模糊匹配)
bash $SCRIPT search-sample-type Blood
==================== 样本接收命令 ====================
查询接收单列表
bash $SCRIPT receive-list
bash $SCRIPT receive-list 1 20 # 第1页,每页20条
查询单个接收单详情
bash $SCRIPT receive SR202401180001
查询接收单样本明细列表
bash $SCRIPT receive-samples SR202401180001
bash $SCRIPT receive-samples SR202401180001 1 50 # 第1页,每页50条
扫描条码获取样本信息(receive_id 为必填参数,必须先创建接收单)
输入格式:{ sampleReceive: { id: ..., name: ..., acceptDate: ..., isBoard: ... }, barCode: ... }
bash $SCRIPT scan-barcode BC20240118001 SR202401180001
扫描订单号获取未接收样本
bash $SCRIPT scan-order ORD202401180001
bash $SCRIPT scan-order ORD202401180001 SR202401180001 # 指定接收单ID
创建接收单(注意:字段名称必须准确!)
sampleReceiveItems 不能写成 samples!
addBoardInfo 不能写成 boardInfo!
bash $SCRIPT create-receive {
sampleReceive: {
name: Clinical Sample Receive,
acceptDate: 2024-01-18 10:00,
expressNum: SF1234567890,
expressCompanyId: EC001,
expressCompanyName: SF Express,
transportTypeId: TT001,
transportTypeName: Cold Chain Transport,
isBoard: 1
},
sampleReceiveItems: [
{
sampleCode: S001,
barCode: BC001,
orderCode: ORD001,
patientName: John Smith,
gender: 1,
dicSampleType: Whole Blood,
dicSampleTypeId: T250724002,
productName: Genetic Testing,
sampleNum: 5,
unit: ml,
isGood: 1,
nextFlow: Warehousing
}
],
addBoardInfo: {\banHao\:\P001\,\rowNum\:8,\colNum\:12}
}
更新接收单(使用与 create-receive 相同的API)
bash $SCRIPT update-receive {sampleReceive:{id:SR202401180001,...},...}
完成接收单
bash $SCRIPT complete-receive SR202401180001
删除样本接收明细项
bash $SCRIPT delete-receive-item SR202401180001 ITEM001,ITEM002
获取可用订单列表(用于订单号模式选择)
bash $SCRIPT get-orders-for-receive
bash $SCRIPT get-orders-for-receive 1 10 # 第1页,每页10条
==================== 实验模板命令 ====================
查询实验模板列表
bash $SCRIPT et-list
bash $SCRIPT et-list 1 20 # 第1页,每页20条
bash $SCRIPT et-list 1 10 PCR # 按模板名称模糊搜索
查询模板详情(三层结构:模板 -> 步骤 -> 组件)
bash $SCRIPT et-detail ET2024000001
bash $SCRIPT et-detail ET2024000001 edit # 编辑模式
创建模板(直接传递JSON或从文件读取)
bash $SCRIPT et-create {templateName:...,stepDetails:[...]}
bash $SCRIPT et-create @/tmp/template.json
复制模板(深拷贝,包含附件)
bash $SCRIPT et-copy ET2024000001
取消模板(支持多个ID)
bash $SCRIPT et-cancel ET2024000001
bash $SCRIPT et-cancel ET001 ET002 ET003
完成模板(工作流回调,状态 -> 1)
bash $SCRIPT et-complete ET2024000001
查询所有已完成的模板(供其他模块选择)
bash $SCRIPT et-all-completed
查询实验类型(创建模板前查询可用类型)
bash $SCRIPT et-exp-types
bash $SCRIPT et-exp-types-search PCR
查询审批人列表
bash $SCRIPT et-approvers
查询实验组列表
bash $SCRIPT et-groups
常见使用场景
场景1:用户询问订单信息
用户:帮我查一下订单 ORDER202401180001
AI操作:
- 1. 调用:bash $SCRIPT order ORDER202401180001
- 解析返回的JSON,提取关键信息
- 以清晰的列表格式回复用户
回复示例(严格遵循字段映射):
好的,已查到订单 ORDER202401180001 的信息:
=== 患者信息 ===
订单ID:ORDER202401180001
患者姓名:John Smith
性别:男
年龄:35
出生日期:1989-05-15
电话号码:[phone_number]
邮箱:[email]
邮政编码:200000
=== 产品与检测信息 ===
检测项目ID