// api/record-detail.prg — Format single record detail (with full ADC data) // ctx: row (JSON of record row) FUNCTION Main() LOCAL hRow hRow := hb_jsonDecode(ctx_get("row", "{}")) IF ! HB_ISHASH(hRow) .OR. Empty(hRow) AP_JSONRESPONSE({ "error" => { "code" => "RECORD_NOT_FOUND", "message" => "record not found", "status" => 404 } }, 404) RETURN NIL ENDIF AP_JSONRESPONSE({ ; "rowIndex" => fn_HGet(hRow, "row_index"), ; "timestamp" => fn_HGet(hRow, "timestamp"), ; "commandType" => fn_HGet(hRow, "command_type"), ; "raaStatus" => fn_HGet(hRow, "raa_status"), ; "sensor" => fn_HGet(hRow, "sensor"), ; "channels" => fn_HGet(hRow, "channels"), ; "rawHex" => fn_HGet(hRow, "raw_hex") ; }) RETURN NIL STATIC FUNCTION fn_HGet(h, k) IF HB_ISHASH(h) .AND. hb_HHasKey(h, k) ; RETURN h[k] ; ENDIF RETURN ""