Files
streamline-emr/docker/streamline-src/public/uploads/lab_machine_scripts/kisiizi/main.py
T
alec.turner a424394109 Build modified streamline images
The official image from streamline does not currently work for the arm64
platform. As a temporary measure, the source code and docker build scripts
have been lifted from the official images and are used to build locally.

Some additional modifications are made to reduce overall image size, these
are documented in docker/README.md
2024-03-10 16:17:50 -07:00

56 lines
1.9 KiB
Python
Executable File

import json
import socket
import requests
HOST = "192.168.1.215" # Standard loopback interface address (localhost)
PORT = 5100 # Port to listen on (non-privileged ports are > 1023)
bytes_to_decode = b''
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
s.bind((HOST, PORT))
s.listen()
conn, addr = s.accept()
with conn:
# print(f"Connected by {addr}")
while True:
data = conn.recv(1024)
if data:
bytes_to_decode += data
if 'END_RESULT' in data.decode():
results_dict = {}
decoded_data = bytes_to_decode.decode()
data_lists = [line.split(";") for line in decoded_data.split("\r\n")]
data_list = []
for row in data_lists:
if row[0] in ['SID', 'PID', 'ID']:
results_dict[row[0]] = row[1]
elif row[0] in ['WBC', 'LYMP', 'MONP', 'NEUP', 'EOSP', 'BASP', 'IMMP', 'ALYP', 'LYM', 'RDW-SD',
'MON', 'NEU', 'EOS', 'BAS', 'IMM', 'ALY', 'RBC', 'HGB', 'HCT', 'MCV', 'MCH',
'MCHC', 'RDW-CV', 'PLCR', 'PDW', 'PCT', 'MPV', 'PLT']:
try:
flag = row[3]
except:
flag = ''
try:
result = row[1]
except:
result = ''
data_list.append([row[0], result, flag])
results_dict["results"] = json.dumps(data_list)
requests.post('http://192.168.1.215/lab_machines/receive_results_mispa', data=results_dict)
bytes_to_decode = b''