TruSTI PCR Report API

Validates a submitted case with the same database-backed clinical engine the Report Generator page uses client-side, renders the approved 1102x1427 report design, and saves a PDF. This product has no MAST/culture workflow at all - render() always forces PCR_ONLY and always produces exactly one page, shrinking row heights/fonts to fit more detected pathogens instead of paginating.

Authentication

Every request must include one of:

Default key: DF@2026:DF@2026 (app/config/api_key.php, overridable via TRUPATH_API_KEY or api_key.local.php). If you rotate it, update the API_KEY constant in assets/sti-generator-app.js to match.

POST api/generate-report.php

Request body: {"case": { ... }} - exactly what the Report Generator's "Download Case JSON" button produces.

{
  "patient": {"name": "Sally Sicko", "patientId": "STI-260809-014", "dob": "04/12/1974", "sex": "F / Female"},
  "order": {
    "provider": "Scott M. Sweazy, M.D.",
    "specimen": "Vaginal swab",
    "facility": "TruPath Labs",
    "accession": "TP-STI-260809-014",
    "collected": "08/09/2026  9:15 a.m.",
    "received": "08/09/2026  1:42 p.m.",
    "reported": "08/09/2026  4:18 p.m."
  },
  "diagnoses": {"primary": ["Z20.2"], "screening": false, "risks": []},
  "detected": [{"id": "STI01"}, {"id": "STI06"}, {"id": "STI09"}],
  "empiric": {"name": "Doxycycline", "strength": "100 mg", "directions": "Take 1 capsule by mouth twice daily for 7 days"},
  "alternatives": [{"name": "Valacyclovir"}, {"name": "Clotrimazole"}, {"name": "Fluconazole"}],
  "allergies": [],
  "pregnancy": "NO",
  "pregnancyTrimester": "UNKNOWN",
  "kidneyDisease": false,
  "liverDisease": false,
  "showSampleBanner": true
}

Field notes

FieldNotes
detected[]{id} only - no load field at all. id is one of the 14 targets (STI01-STI15, STI10 reserved/skipped). No cap on the number of rows - shrinks row height/font (17.5px floor) instead of rejecting a 4th+ pathogen or paginating.
Pathogen classOne of VIRUS/BACTERIA/FUNGAL/PARASITE (labeled "Protozoa" - this panel includes Trichomonas vaginalis). No separate protozoal assessment function; PARASITE is evaluated the same way as BACTERIA/FUNGAL.
empiric.nameEmpty/omitted means no empiric therapy. With no empiric drug, every detected pathogen reads INAPPROPRIATE, not N/A - a deliberate, confirmed difference from tpl-rpp's equivalent function.
alternatives[]Optional {name, info?}, up to 3 used. info override aside, info/renalStatus/hepaticStatus always come from master_clinical_info - the only authoritative source. Omitted entirely → server auto-ranks from detected-pathogen recommendations.
allergiesArray of free-text strings. Keyword-matched against drug-class patterns including a Nitroimidazoles class (metronidazole/tinidazole) unique to this product.
pregnancyTrimesterUNKNOWN/FIRST/SECOND/THIRD - drives the four pregnancy rules below. The source's own shipped UI has no trimester selector (always submits UNKNOWN); this build's form adds one so the real capability is testable.
kidneyDisease / liverDiseaseEscalate an alternative's kidney/liver icon from baseline. Any amphotericin-B drug's kidney icon is YELLOW at baseline / RED with kidney disease, regardless of its own renalStatus.
diagnoses{primary[], screening, risks[]} ICD-10 - confirmed inert to clinical/report logic.
showSampleBannerDefault true - shows the orange "SAMPLE - NOT FOR CLINICAL USE" footer banner.

The four pregnancy-safety rules

  1. Influenza-antiviral substitution - Baloxavir/Zanamivir/Peramivir → Oseltamivir, caution:false.
  2. Doxycycline trimester-gating - kept only in FIRST trimester (caution:true); dropped for SECOND/THIRD/UNKNOWN.
  3. Unconditional Fluconazole/Tinidazole removal - the rule tpl-rpp/tpl-wound don't have: dropped regardless of trimester.
  4. Levofloxacin/Ciprofloxacin caution - kept, caution:true, fluoroquinolone pregnancy-caution note attached.

Response

{
  "success": true,
  "message": "Report generated successfully",
  "mode": "PCR_ONLY",
  "pageCount": 1,
  "renderer": "chrome",
  "reportId": "20260911092111_82950b59",
  "pdfUrl": "http://.../uploads/pdf/20260911092111_82950b59.pdf",
  "htmlUrl": "http://.../uploads/html/20260911092111_82950b59.html",
  "getApi": "http://.../api/get-report.php?reportId=20260911092111_82950b59"
}

renderer is "chrome" when the primary headless-Chrome-print pipeline produced the PDF, or "dompdf-fallback" when Chrome wasn't available on the host. pageCount is always 1. On failure: HTTP 4xx/5xx with {"success": false, "message": "..."}.

GET api/get-report.php?reportId=...

Looks up a previously generated report's PDF/HTML URLs and its saved case/resolved payload by reportId. Same auth as above.

GET api/reference-data.php

Returns the current 14-target panel, the fixed 14-name "Pathogens Assessed" list, medication names, allergy options, diagnosis codes, dosing profiles, and the shared general-instructions list straight from the database. Same auth as above. No mastDrugs, genePanel, or evolveMastDatabase keys - this product has none of those concepts.

Postman collection

⇩ Download TruPath_API.postman_collection.json - includes every request above with realistic sample bodies. Import it into Postman, then check the collection variables:

VariableValueNotes
baseUrlhttps://tpl.robbiekohli.comThe bare domain only, no trailing slash and no product subfolder - every request's own path already spells out /tpl-sti/api/..., so this same baseUrl value is shared as-is across every TruPath product on this domain.
apiKeyDF@2026:DF@2026Sent as the X-API-Key header on every request.
reportId(blank)Paste a reportId from a Generate Report response here to use with Get Report.

Full request path for this product: https://tpl.robbiekohli.com/tpl-sti/api/generate-report.php (and the same pattern for get-report.php / reference-data.php).

← Back to Report Generator