TruWomen’s Health PCR Report API

Validates a submitted case with the same database-backed clinical engine the Report Generator page uses client-side, renders the approved report design, and saves a PDF. This product line has a single report mode - no MAST/culture-plate workflow, no preliminary/pending state.

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/generator-app.js to match.

POST api/generate-report.php

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

{
  "study": {"code": "WOMENS", "name": "TruWomen’s Health Panel"},
  "patient": {"name": "Sally Sicko", "id": "WH-100245", "dob": "1986-04-14", "sex": "Female"},
  "physician": {"provider": "Scott M. Sweazy, M.D.", "npi": "", "practiceFacility": "", "officePhone": "", "officeFax": ""},
  "order": {"specimen": "Vaginal swab", "testFacility": "TruPath Labs", "accession": "WH260816-01", "collected": "2026-08-16", "received": "2026-08-16", "reported": "2026-08-16"},
  "detected": [
    {"name": "Atopobium vaginae", "load": "High", "cls": "BACTERIA"},
    {"name": "Candida albicans", "load": "Moderate", "cls": "FUNGAL"}
  ],
  "genes": ["ermB"],
  "empiric": {"name": "Metronidazole", "strength": "500 mg", "dosing": "Take 1 tablet by mouth twice daily"},
  "allergies": [],
  "pregnancy": "NO",
  "renalDysfunction": false,
  "liverDysfunction": false,
  "alternatives": [],
  "showSampleBanner": true
}

Field notes

FieldNotes
detected[].nameMust match a pathogen's display_name exactly (Pathogens dashboard page).
detected[].loadQualitative: "High", "Moderate", or "Low" - not a numeric PCR copy count. Low is excluded from the significance/coverage calculation.
detected[].clsOne of BACTERIA / VIRUS / FUNGAL / PROTOZOA.
genes[]Resistance-gene IDs (TetM, blaTEM, mefA, ermB by default). A detected gene can exclude an otherwise-matched drug (e.g. ermB excludes macrolides and clindamycin) from both the coverage calculation and alternatives ranking.
alternatives[]Optional, up to 3 antimicrobial generic names. If omitted, the server auto-ranks from the master mapping (same as the page's "Reload from Master Mapping" button), filtered for genes/allergies/pregnancy/renal/hepatic.
pregnancy"YES", "NO", or "UNKNOWN".
showSampleBannerDefault true - shows the red "SAMPLE - NOT FOR CLINICAL USE" footer banner on the printed report.

Response

{
  "success": true,
  "message": "Report generated successfully",
  "renderer": "chrome",
  "reportId": "20260816120000_a1b2c3d4",
  "pdfUrl": "https://.../uploads/pdf/20260816120000_a1b2c3d4.pdf",
  "htmlUrl": "https://.../uploads/html/20260816120000_a1b2c3d4.html",
  "getApi": "https://.../api/get-report.php?reportId=20260816120000_a1b2c3d4"
}

renderer is "chrome" when the primary headless-Chrome-print pipeline produced the PDF (pixel-identical to the browser's own "Print / Save PDF"), or "dompdf-fallback" when Chrome wasn't available on the host. 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 by reportId. Same auth as above.

GET api/reference-data.php

Returns the current pathogens/resistance genes/antimicrobials/recommendations straight from the database - what the admin dashboard's Pathogens, Resistance Genes, Antimicrobials, and Recommendations pages manage. Useful for keeping an external system's copy of the panel in sync. Same auth as above.

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-womens-health/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-womens-health/api/generate-report (and the same pattern for get-report / reference-data).

← Back to Report Generator