LabReportAPI is a .NET 9 WebAPI application that listens for lab machine data over TCP using a custom STX/ETX protocol. Valid lab data is parsed and saved to a USB drive as a JSON file. The Web API provides endpoints to monitor status and trigger data saving.
- Listens on
0.0.0.0:12377
for incoming TCP messages. - Each message must be wrapped in
STX
(0x02
) andETX
(0x03
) characters. - Valid messages are in the format:
PATIENT123|GLUCOSE|120|mg/dL
- Parsed data is stored in-memory as
LabMessage
objects. If the system has been idle (no TCP messages) for 30+ seconds, it saves data. - Data is appended to
LabData.json
on the USB drive. - Works even if the USB path is not explicitly configured (
auto-detects removable drives
).
/api/labdata/status
: Shows the server IP, port, last message time, and write status./api/labdata/save
: Manually triggers a save to USB.
You can build using the .NET CLI:
dotnet publish -c Release -r win-x64 --self-contained true
Edit appsettings.json
:
{
"LabSettings": {
"UsbPath": "E:\"
}
}
If left empty, the app will try to auto-detect the first available removable USB drive.
If you're unsure how to send TCP messages or need help testing, please reach out to me.