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.
For the LabReportAPI to receive data, you will need to configure your lab machine's settings to send data to the IP address where LabReportAPI is running, on port 12377
.
The image below shows an example of the kind of configuration settings you might encounter on a lab machine to set up the host and protocol parameters:
Key settings to look for on your lab machine:
- IP Address/Host: Set this to the IP address of the machine running
LabReportAPI
. - Port: Set this to
12377
. - Protocol/Delimiter: Ensure the machine is configured to send data with
STX
(Start of Text,0x02
) andETX
(End of Text,0x03
) delimiters. You may also need to configure other protocol parameters likeBaud Rate
,Parity
,Data Length
, andStop Bits
to match the machine's default output or a standard configuration.
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.