Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions api-server/src/lib/providers/__tests__/samGovQuality.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ describe("SAM.gov bid-ready query policy", () => {
);
});

it("uses one broad structured retrieval when no query is supplied", () => {
assert.deepEqual(buildSamGovTitleQueries(), []);
it("uses one focused occupational-health title request when no query is supplied", () => {
assert.deepEqual(buildSamGovTitleQueries(), ["occupational health"]);
});

it("accepts only active bid notices with a future response deadline", () => {
Expand Down Expand Up @@ -61,4 +61,4 @@ describe("SAM.gov bid-ready query policy", () => {
false,
);
});
});
});
89 changes: 89 additions & 0 deletions api-server/src/lib/providers/__tests__/tangoPrecision.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
import assert from "node:assert/strict";
import { describe, it } from "node:test";
import { passesTangoOccumedPrecisionGate } from "../tango";

describe("Tango Occu-Med precision gate", () => {
it("keeps core occupational-health scopes", () => {
assert.equal(
passesTangoOccumedPrecisionGate(
"RFP for occupational health services including employee physical examinations, drug testing, audiograms, spirometry, and medical surveillance.",
),
true,
);
assert.equal(
passesTangoOccumedPrecisionGate(
"NFPA 1582 firefighter medical examinations and annual fitness-for-duty services.",
),
true,
);
assert.equal(
passesTangoOccumedPrecisionGate(
"Respirator medical evaluation and fit testing for public works employees under the respiratory protection program.",
),
true,
);
assert.equal(
passesTangoOccumedPrecisionGate(
"Pre-employment physical examinations and DOT drug and alcohol testing for agency applicants and employees.",
),
true,
);
});

it("keeps generic clinical components only when tied to workforce context", () => {
assert.equal(
passesTangoOccumedPrecisionGate(
"Audiometric testing, spirometry and vaccinations for employees assigned to hazardous worksites.",
),
true,
);
assert.equal(
passesTangoOccumedPrecisionGate(
"TB testing and immunization services for contractor personnel before deployment.",
),
true,
);
});

it("rejects ordinary patient and community medical procurements", () => {
assert.equal(
passesTangoOccumedPrecisionGate(
"Community vaccination services for residents and the general public.",
),
false,
);
assert.equal(
passesTangoOccumedPrecisionGate(
"Hospital seeks laboratory testing and medical screening services for clinic patients.",
),
false,
);
assert.equal(
passesTangoOccumedPrecisionGate(
"Student health TB testing and immunization program for university students.",
),
false,
);
});

it("rejects unrelated federal solicitations containing incidental medical words", () => {
assert.equal(
passesTangoOccumedPrecisionGate(
"Construction contract. Contractor must maintain a drug testing policy for its own staff.",
),
false,
);
assert.equal(
passesTangoOccumedPrecisionGate(
"IT support services. Personnel must complete a medical screening before receiving site access.",
),
false,
);
assert.equal(
passesTangoOccumedPrecisionGate(
"Purchase of laboratory testing equipment and medical supplies.",
),
false,
);
});
});
10 changes: 6 additions & 4 deletions api-server/src/lib/providers/samGovQuality.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ const SAM_TITLE_PROFILES = [
const CUSTOM_QUERY_NOISE =
/\b(?:active|bid|bids|city|contract|contracts|county|due|federal|find|government|open|opportunities|opportunity|procurement|proposal|proposals|request|rfp|rfq|services?|solicitation|state)\b/gi;
const BID_READY_TYPE_RE = /^(?:solicitation|combined synopsis\/solicitation)$/i;
const DEFAULT_AUTONOMOUS_SAM_TITLE = "occupational health";

export function buildSamGovTitleQueries(keywords?: string): string[] {
const normalized = (keywords ?? "")
Expand All @@ -76,9 +77,10 @@ export function buildSamGovTitleQueries(keywords?: string): string[] {
.replace(/[^a-z0-9]+/g, " ")
.replace(/\s+/g, " ")
.trim();
// Blank autonomous runs retrieve broadly once; the Occu-Med ontology then
// classifies notices locally instead of spending a call per service title.
if (!normalized) return [];
// Keep autonomous SAM usage to one API call, but make that call useful.
// A broad blank search returns thin metadata for many unrelated notices and
// routinely produces zero usable Occu-Med records after local classification.
if (!normalized) return [DEFAULT_AUTONOMOUS_SAM_TITLE];

const matched = SAM_TITLE_PROFILES.filter((profile) =>
profile.aliases.some((alias) => normalized.includes(alias)),
Expand Down Expand Up @@ -111,4 +113,4 @@ export function isBidReadySamOpportunity(
: null;
if (!deadline || Number.isNaN(deadline.getTime())) return false;
return deadline.getTime() > now.getTime();
}
}
Loading
Loading