mirror of
https://gitlab.com/signalytic/client-external/streamline/streamline-emr.git
synced 2026-09-12 19:21:33 +00:00
resolved conflicts
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
import socket
|
||||
import hl7
|
||||
import requests
|
||||
import json
|
||||
from datetime import datetime
|
||||
|
||||
# get the hostname
|
||||
host = "10.23.14.97"
|
||||
port = 5050
|
||||
|
||||
server_socket = socket.socket() # get instance
|
||||
server_socket.bind((host, port)) # bind host address and port together
|
||||
|
||||
# configure how many client the server can listen simultaneously
|
||||
server_socket.listen(2)
|
||||
conn, address = server_socket.accept() # accept new connection
|
||||
bytes_to_decode = b''
|
||||
|
||||
with conn:
|
||||
while True:
|
||||
data = conn.recv(1024)
|
||||
|
||||
if data and data != b'\x02':
|
||||
bytes_to_decode += data
|
||||
|
||||
if data.decode('utf-8')[-2] == '\x1c':
|
||||
# this is the end of the line hence we can begin decoding
|
||||
try:
|
||||
results_parameter_list = []
|
||||
hl7_data = hl7.parse(bytes_to_decode.decode().strip())
|
||||
sample_id = hl7_data[3][3]
|
||||
|
||||
for row in hl7_data[10:38]:
|
||||
test_code = row[3][0][1][0]
|
||||
test_result = row[5][0]
|
||||
test_flag = row[8][0][0]
|
||||
results_parameter_list.append([test_code, test_result, test_flag])
|
||||
|
||||
requests.post('http://127.0.0.1:8000/lab_machines/receive_results_mindray', {
|
||||
'test_id': hl7_data[1][5][0],
|
||||
'parameters': json.dumps(results_parameter_list),
|
||||
'time': hl7_data[0][6][0]
|
||||
})
|
||||
|
||||
except Exception as e:
|
||||
print(e)
|
||||
|
||||
bytes_to_decode = b''
|
||||
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
from subprocess import check_output, Popen, PIPE, STDOUT
|
||||
import os
|
||||
|
||||
file_path = "/var/www/streamline/public/uploads/lab_machine_scripts/kisiizi/dymind/main.py"
|
||||
|
||||
try:
|
||||
# get the pid of the last process running with python3
|
||||
pid_list = check_output(["pidof", "python3"]).split()
|
||||
|
||||
# iterate over the list of related pids
|
||||
for pid in pid_list:
|
||||
decoded_pid = pid.decode("utf-8")
|
||||
file_path_from_pid = check_output(["ps", "-o", "cmd", decoded_pid]).split()[2].decode("utf-8")
|
||||
|
||||
if file_path_from_pid == file_path:
|
||||
# kill the process with this path
|
||||
delete_pid = check_output(["kill", "-9", decoded_pid])
|
||||
break
|
||||
|
||||
# start a new process
|
||||
os.system("nohup python3 " + file_path + " >/dev/null 2>&1 & ")
|
||||
print(1)
|
||||
|
||||
except Exception as e:
|
||||
print(e)
|
||||
Reference in New Issue
Block a user