mirror of
https://gitlab.com/signalytic/client-external/streamline/streamline-emr.git
synced 2026-09-12 11:11:31 +00:00
resolved conflicts
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
import socket
|
||||
import hl7
|
||||
import requests
|
||||
import json
|
||||
from datetime import datetime
|
||||
|
||||
# Create a TCP/IP socket
|
||||
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||
|
||||
# Connect the socket to the port where the server is listening
|
||||
server_address = ('192.168.0.78', 5100)
|
||||
sock.connect(server_address)
|
||||
bytes_to_decode = b''
|
||||
|
||||
while True:
|
||||
data = sock.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:
|
||||
hl7_data = hl7.parse(bytes_to_decode.decode().strip())
|
||||
results_parameter_list = []
|
||||
|
||||
for row in hl7_data[8:32]:
|
||||
test_code = row[3][0][1][0]
|
||||
test_result = row[5][0]
|
||||
|
||||
if type(row[8][0]) == hl7.containers.Repetition:
|
||||
test_flag = row[8][0][0]
|
||||
else:
|
||||
test_flag = row[8][0]
|
||||
|
||||
results_parameter_list.append([test_code, test_result, test_flag])
|
||||
|
||||
return_str = "\x0bMSH|^~\\&|||||" + hl7_data[0][7][0] + "||ACK^R01|" + hl7_data[0][10][0]
|
||||
return_str += "|P|2.3.1||||||UNICODE\rMSA|AA|" + hl7_data[0][10][0] + "|okay|||0|\r\x1c\r"
|
||||
|
||||
sock.sendall(bytes(return_str, 'utf-8'))
|
||||
|
||||
requests.post('http://192.168.0.250/lab_machines/receive_results_mindray', data={
|
||||
'test_id': hl7_data[3][3][0],
|
||||
'parameters': json.dumps(results_parameter_list),
|
||||
'time': hl7_data[0][7][0]
|
||||
})
|
||||
except Exception as e:
|
||||
pass
|
||||
|
||||
bytes_to_decode = b''
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
from subprocess import check_output, Popen, PIPE, STDOUT
|
||||
import os
|
||||
|
||||
file_path = "/var/www/html/streamline/public/uploads/lab_machine_scripts/soft_power/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