Finnrick - Ensuring a Safer and More Transparent Supply ChainBETA

my JS analysis

Analysis set requiring 99% minimum purity, endotoxin-free results, and quantity within ±10% of reference

javascript860c49c9bd97
Created: Wed 3 Dec 2025 20:25
Updated: Wed 3 Dec 2025 20:26

Analysis Rules (4)

purity

Purity percentage measurement

Created Wed 3 Dec 2025 20:26
JavaScript Code:
function analyze(result, sample, test) {
  // Purity test: ≥99% Pass, <95% Catastrophic, between is Fail
  const value = result.measure_value;
  if (value === null || value === undefined) {
    return "Neutral";
  }
  if (value >= 99) {
    return "Pass";
  }
  if (value < 95) {
    return "Catastrophic";
  }
  return "Fail";
}

endotoxins

Endotoxin test

Created Wed 3 Dec 2025 20:26
JavaScript Code:
function analyze(result, sample, test) {
  // Endotoxins test: Pass if measure_flag is 'Pass' or 'Below LOQ', else Catastrophic
  const flag = result.measure_flag;
  if (flag === "Pass" || flag === "Below LOQ") {
    return "Pass";
  }
  return "Catastrophic";
}

quantity

Quantity measurement in mg

Created Wed 3 Dec 2025 20:26
JavaScript Code:
function analyze(result, sample, test) {
  // Quantity test: within ±10% Pass, ±30% Fail, beyond Catastrophic
  const value = result.measure_value;
  if (value === null || value === undefined) {
    return "Neutral";
  }
  
  let refQty = sample.batch_quantity;
  if (refQty === null || refQty === undefined) {
    refQty = sample.label_quantity;
  }
  
  if (refQty === null || refQty === undefined) {
    return "Neutral";
  }
  
  const lowerPass = refQty * 0.9;
  const upperPass = refQty * 1.1;
  const lowerFail = refQty * 0.7;
  const upperFail = refQty * 1.3;
  
  if (value >= lowerPass && value <= upperPass) {
    return "Pass";
  }
  if (value >= lowerFail && value <= upperFail) {
    return "Fail";
  }
  return "Catastrophic";
}

identity

Identity confirmation test

Created Wed 3 Dec 2025 20:26
JavaScript Code:
function analyze(result, sample, test) {
  // Identity test: Pass if measure_flag is 'Pass', else Catastrophic
  if (result.measure_flag === "Pass") {
    return "Pass";
  }
  return "Catastrophic";
}

JavaScript Data Context

The analyze(result, sample, test) function receives these objects:

result

.measure_value (number | null)
.measure_flag (string | null)
.result_date (string)
.unit (string | null)
.notes (string | null)
.exception (string | null)
.loq (number | null)
.method (string | null)

sample

.batch_quantity (number | null)
.label_quantity (number | null)
.registered_date (string)
.batch_id (string | null)
.batch_source (string | null)
.storage_location (string | null)

test

.tested_date (string | null)
.coa_date (string | null)
.coa_url (string | null)
.coa_id (string | null)

Valid Return Values

• "Pass"
• "Fail"
• "Catastrophic"
• "Neutral"

JavaScript runs in an isolated V8 sandbox. Must define function analyze(result, sample, test).