Try the Sample Commands
Explore recorded sample responses in this browser demo. Choose a command or type 'help' to see what’s available.
The problem
Clinical form specifications often begin in Excel. CRF.xl works from that starting point, turning workbook grids into form definitions and ODM-XML while checking the dependencies between calculation rules.
The approach: Office.js reads the workbook, a dependency graph checks formula relationships, and Web Workers generate the clinical form exports.
Reported project measurements: Sub-10ms UI thread responsiveness during 10,000+ item parsing via asynchronous chunking workers; 100% strict compliance verification against CDISC ODM 1.3.2 foundation schemas; automated 21 CFR Part 11 audit trails with cryptographic state digests.
The fields a CRF collects decide which metrics a study can report later. The platform demo's study metrics explorer groups and filters governed metrics built from that kind of collected data, on synthetic studies.
How it works
The Office.js taskpane's React components sit apart from the domain layer (src/taskpane/core/). Transformations and validation gates run as a chain of composable middleware.
Parsing, AST construction and XML serialization run in Web Workers (engine.worker.ts, customxml-worker.ts), so the taskpane stays responsive in the limited Office Webview.
Conditional logic and skip rules are parsed into an AST and checked with a topological DAG traversal (dag-validator.ts, rules-parser.ts), which finds circular dependencies and references to missing items while the form is being written.
How the pieces connect
flowchart TD
subgraph IngestionLayer [Office.js Client Ingestion]
A[Excel Taskpane UI / React] -->|Trigger Ingestion/Sync| B[App Orchestrator]
B --> C[Office.js Chunking Ingestion Layer]
end
subgraph WebWorkerPipeline [Web Worker Processing Engine]
C -->|Transfer ArrayBuffer/Chunks| D[Web Worker Engine]
D --> E[Excel/Rules Parser & AST Generator]
E --> F[DAG Dependency & Circular Ref Validator]
F --> G[CDISC Controlled Terminology Resolver]
G --> H[Serialization Pipeline]
end
H -->|Emits ODM-XML / aCRF| I[Office.js CustomXML / Blob Exporter]
H -->|Validation Errors| J[Interactive Grid Error Annotator]
Implementation notes
DAG Circular Dependency Detection Solver (src/taskpane/core/dag-validator.ts)
// Topological DAG Validation Solver for Clinical Skip & Derivation Logic
interface RuleNode {
id: string;
dependsOn: string[];
}
function detectCircularLogicDependencies(nodes: RuleNode[]): string[][] {
const adjList = new Map<string, string[]>();
nodes.forEach((n) => adjList.set(n.id, n.dependsOn || []));
const visited = new Set<string>();
const recStack = new Set<string>();
const cycles: string[][] = [];
function dfs(current: string, path: string[]) {
visited.add(current);
recStack.add(current);
const neighbors = adjList.get(current) || [];
for (const neighbor of neighbors) {
if (!visited.has(neighbor)) {
dfs(neighbor, [...path, neighbor]);
} else if (recStack.has(neighbor)) {
const cycleStartIndex = path.indexOf(neighbor);
cycles.push([...path.slice(cycleStartIndex), neighbor]);
}
}
recStack.delete(current);
}
for (const node of nodes) {
if (!visited.has(node.id)) {
dfs(node.id, [node.id]);
}
}
return cycles;
}
Office.js Memory-Efficient Range Chunking (src/taskpane/office/excel-reader.ts)
// Non-blocking chunked reading of large clinical protocol worksheets in Office.js
async function readWorkbookInChunks(
context: Excel.RequestContext,
sheetName: string,
chunkSize: number = 500,
onChunk: (rows: any[][], progress: number) => Promise<void>
): Promise<void> {
const sheet = context.workbook.worksheets.getItem(sheetName);
const usedRange = sheet.getUsedRange();
usedRange.load(["rowCount", "columnCount", "values"]);
await context.sync();
const totalRows = usedRange.rowCount;
for (let offset = 0; offset < totalRows; offset += chunkSize) {
const end = Math.min(offset + chunkSize, totalRows);
const chunkValues = usedRange.values.slice(offset, end);
const progress = Math.round((end / totalRows) * 100);
await onChunk(chunkValues, progress);
}
}
CDISC ODM-XML v1.3.2 Serializer (src/taskpane/export/odm-serializer.ts)
// Regulatory-grade CDISC ODM-XML 1.3.2 Snapshot Serializer
function serializeODMStudy(study: {
oid: string;
name: string;
protocolId: string;
forms: Array<{ oid: string; name: string; itemGroups: Array<{ oid: string }> }>;
}): string {
const formsXml = study.forms
.map(
(f) =>
`<FormDef OID="${f.oid}" Name="${f.name}" Repeating="No">` +
f.itemGroups.map((g) => `<ItemGroupRef ItemGroupOID="${g.oid}" Mandatory="Yes"/>`).join("") +
`</FormDef>`
)
.join("");
return (
`<?xml version="1.0" encoding="UTF-8"?>\n` +
`<ODM xmlns="http://www.cdisc.org/ns/odm/v1.3" ODMVersion="1.3.2" FileType="Snapshot">\n` +
` <Study OID="${study.oid}">\n` +
` <GlobalVariables>\n` +
` <StudyName>${study.name}</StudyName>\n` +
` <ProtocolName>${study.protocolId}</ProtocolName>\n` +
` </GlobalVariables>\n` +
` <MetaDataVersion OID="MDV.1" Name="CDASH 2.2 Specification">\n` +
` ${formsXml}\n` +
` </MetaDataVersion>\n` +
` </Study>\n` +
`</ODM>`
);
}
Tradeoffs and lessons
- Reading 10,000+ rows on the main Office.js thread made Office Webview stutter badly. Passing the raw data to Web Workers in chunked ArrayBuffers brought the UI back to 60fps.
- Checking skip conditions for cycles on blur stops a circular rule from setting off an endless validation cascade while the protocol is being written.
- Writing strict XML and validating against CDASH 2.2 controlled terminology prevents data migration failures in the EDC downstream.