code wiki / (root) / nx_chem_report_json.nx

nx_chem_report_json.nx

buildroot/runtime/nx_chem_report_json.nx

12925 B312 linesdepth 11pulls 18 transitivereach 7 importersview sourcekind librarytopic chem
docsdependenciesstructsconstsfunctions

about

nx_chem_report_json.nx -- C6.0 milestone: structured JSON report emitter for LIMS (Laboratory Information Management System) integration. Real lab workflow: 1. Lab runs adulterant-detection pipeline 2. Substrate emits JSON report to a file or stdout 3. LIMS ingests JSON, applies business rules: - banned_count > 0 -> auto-reject lot, alert QA - restricted_count > 0 + label_doesnt_mention -> escalate - unknown_count > threshold -> retest with method 2 4. Audit trail: JSON archived with sample record + citation Format (one-line; nx_chem_report_emit_json): {"sample_id":"...","method":"...","tolerance_ppm":N, "peaks_analyzed":N, "matches":[ {"mz":NNN.NNNN,"rt_seconds":N,"compound_id":N, "name":"...","regulatory":"...","delta_ppm":N, "citation":"..."}, ... ], "verdict":{"banned":N,"restricted":N,"approved":N, "unknown":N,"recommendation":"..."}} Bits-up emitter: - No JSON library; manual byte emission to caller-provided buffer - String escape: handles " and \ ; control chars not expected in citations or compound names - Q4 decimal -> "DDD.MMMM" zero-padded form - All emit_* functions return bytes written

dependencies 4 imports · 7 importers

nx_chem.nx nx_chem_molecule.nx nx_chem_adulterant_db.nx nx_chem_peak_list.nx nx_chem_report_json.nx nx_chem_report_csv.nx nx_chem_report_csv_test.nx nx_chem_report_json_test.nx nx_supplement.nx nx_supplement_batch.nx nx_supplement_check.nx nx_supplement_csv.nx

imports: nx_chem.nxnx_chem_molecule.nxnx_chem_adulterant_db.nxnx_chem_peak_list.nx

imported by: nx_chem_report_csv.nxnx_chem_report_csv_test.nxnx_chem_report_json_test.nxnx_supplement.nxnx_supplement_batch.nxnx_supplement_check.nxnx_supplement_csv.nx

structs

none

consts

none

functions

41func nx_chem_emit_str(buf: *u8, offset: nx_int, src: *u8) -> nx_int
60func nx_chem_emit_str_escaped(buf: *u8, offset: nx_int, src: *u8) -> nx_int
91func nx_chem_emit_int(buf: *u8, offset: nx_int, value: nx_int) -> nx_int
128func nx_chem_emit_q4(buf: *u8, offset: nx_int, value: nx_int) -> nx_int
154func nx_chem_emit_char(buf: *u8, offset: nx_int, ch: nx_int) -> nx_int
164func nx_chem_emit_regulatory(buf: *u8, offset: nx_int, reg: nx_int) -> nx_int
172func nx_chem_verdict_recommendation(n_banned: nx_int, n_restricted: nx_int, n_unknown: nx_int) -> *u8
189func nx_chem_emit_report_json(buf: *u8, peaks: *PeakList, db: *AdulterantDB, sample_id: *u8, tolerance_ppm: nx_int) -> nx_int
286func nx_chem_buf_find(haystack: *u8, len: nx_int, needle: *u8) -> nx_int