From 79da34a3e38d51bb0a1b1b251c176e6835ca0d2f Mon Sep 17 00:00:00 2001 From: servdal Date: Thu, 31 Jul 2025 11:36:52 +0700 Subject: [PATCH] Update Port --- .gitignore | 1 + docker-compose.yml | 3 + htdocs/listenerlis/app.py | 2 + htdocs/listenerlis/listener.log | 114 ++++++++++++++++++++++++++++ htdocs/listenerlis/tcp_raw_data.bin | 21 ++++- 5 files changed, 140 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 0722fe68..cd5d3ebb 100644 --- a/.gitignore +++ b/.gitignore @@ -9,5 +9,6 @@ mergekemain.sh # Ignore bootstrap cache /htdocs/bootstrap/cache/* /htdocs/listenerlis/listener.log +/htdocs/listenerlis/tcp_raw_data.bin !/htdocs/bootstrap/cache/.gitignore diff --git a/docker-compose.yml b/docker-compose.yml index 1570873b..20c769c3 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -49,6 +49,9 @@ services: restart: unless-stopped volumes: - ./htdocs/listenerlis:/app + ports: + - "5000:5000" + - "6001:6001" depends_on: postgresql: condition: service_healthy diff --git a/htdocs/listenerlis/app.py b/htdocs/listenerlis/app.py index 2ba0d190..62299ef9 100644 --- a/htdocs/listenerlis/app.py +++ b/htdocs/listenerlis/app.py @@ -7,6 +7,7 @@ from sqlalchemy import create_engine, Column, Integer, String, Text, ForeignKey, from sqlalchemy.orm import declarative_base, sessionmaker import datetime import time +import traceback from sqlalchemy.exc import OperationalError # Konfigurasi logging logging.basicConfig( @@ -76,6 +77,7 @@ def process_and_save_to_db(hl7_message): logging.info("Data successfully saved to the database.") except Exception as e: logging.error(f"Error processing and saving data: {e}") + logging.error(traceback.format_exc()) raise def is_astm_format(data): # ASTM biasanya menggunakan karakter STX (\x02) sebagai awal dan ETX (\x03) sebagai akhir diff --git a/htdocs/listenerlis/listener.log b/htdocs/listenerlis/listener.log index df244075..2ed318eb 100644 --- a/htdocs/listenerlis/listener.log +++ b/htdocs/listenerlis/listener.log @@ -1657,3 +1657,117 @@ OBR|||1|TEST123^Exa 2025-07-17 01:31:44,028 - ERROR - Failed to bind to port 6001: [Errno 98] Address already in use 2025-07-17 01:31:44,108 - WARNING - * Debugger is active! 2025-07-17 01:31:44,110 - INFO - * Debugger PIN: 135-554-149 +2025-07-31 03:54:40,581 - INFO - Listening on TCP port 6001... +2025-07-31 03:54:40,647 - INFO - WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead. + * Running on all addresses (0.0.0.0) + * Running on http://127.0.0.1:5000 + * Running on http://172.18.0.3:5000 +2025-07-31 03:54:40,647 - INFO - Press CTRL+C to quit +2025-07-31 03:54:40,648 - INFO - * Restarting with stat +2025-07-31 03:54:41,259 - ERROR - Failed to bind to port 6001: [Errno 98] Address already in use +2025-07-31 03:54:41,273 - WARNING - * Debugger is active! +2025-07-31 03:54:41,276 - INFO - * Debugger PIN: 128-029-017 +2025-07-31 03:55:15,330 - INFO - Listening on TCP port 6001... +2025-07-31 03:55:15,351 - INFO - WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead. + * Running on all addresses (0.0.0.0) + * Running on http://127.0.0.1:5000 + * Running on http://172.18.0.3:5000 +2025-07-31 03:55:15,352 - INFO - Press CTRL+C to quit +2025-07-31 03:55:15,354 - INFO - * Restarting with stat +2025-07-31 03:55:15,830 - ERROR - Failed to bind to port 6001: [Errno 98] Address already in use +2025-07-31 03:55:15,848 - WARNING - * Debugger is active! +2025-07-31 03:55:15,849 - INFO - * Debugger PIN: 117-557-421 +2025-07-31 03:58:14,623 - INFO - Listening on TCP port 6001... +2025-07-31 03:58:14,684 - INFO - WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead. + * Running on all addresses (0.0.0.0) + * Running on http://127.0.0.1:5000 + * Running on http://172.18.0.4:5000 +2025-07-31 03:58:14,685 - INFO - Press CTRL+C to quit +2025-07-31 03:58:14,686 - INFO - * Restarting with stat +2025-07-31 03:58:15,367 - ERROR - Failed to bind to port 6001: [Errno 98] Address already in use +2025-07-31 03:58:15,390 - WARNING - * Debugger is active! +2025-07-31 03:58:15,392 - INFO - * Debugger PIN: 454-857-589 +2025-07-31 04:26:26,758 - INFO - Processing HL7 message: MSH|^~\&|SendingApp|SendingFac|ReceivingApp|ReceivingFac|20231130120000||ORU^R01|MSGID1234|P|2.3 +PID|||12345||John^Doe||19800101|M +OBR|||1|TEST123^Example Test +OBX|||POSITIVE + +2025-07-31 04:26:26,789 - INFO - Data successfully saved to the database. +2025-07-31 04:26:26,790 - INFO - 192.168.65.1 - - [31/Jul/2025 04:26:26] "POST /listener HTTP/1.1" 201 - +2025-07-31 04:26:44,980 - INFO - New connection from ('192.168.65.1', 45962) +2025-07-31 04:26:44,981 - INFO - Handling client from ('192.168.65.1', 45962) +2025-07-31 04:26:44,982 - INFO - Raw binary data saved: 504f5354202f6c697374656e657220485454502f312e310d0a486f73743a206c6f63616c686f73743a363030310d0a557365722d4167656e743a206375726c2f382e372e310d0a4163636570743a202a2f2a0d0a436f6e74656e742d547970653a20746578742f706c61696e0d0a436f6e74656e742d4c656e6774683a203137350d0a0d0a4d53487c5e7e5c267c53656e64696e674170707c53656e64696e674661637c526563656976696e674170707c526563656976696e674661637c32303233313133303132303030307c7c4f52555e5230317c4d53474944313233347c507c322e330a5049447c7c7c31323334357c7c4a6f686e5e446f657c7c31393830303130317c4d0a4f42527c7c7c317c544553543132335e4578616d706c6520546573740a4f42587c7c7c504f5349544956450a +2025-07-31 04:26:44,983 - INFO - Data is not in HL7 or ASTM format, skipping. +2025-07-31 04:26:44,984 - INFO - Connection closed by client ('192.168.65.1', 45962) +2025-07-31 04:27:48,808 - INFO - New connection from ('192.168.65.1', 28125) +2025-07-31 04:27:48,809 - INFO - Handling client from ('192.168.65.1', 28125) +2025-07-31 04:27:56,578 - INFO - Raw binary data saved: 4d53487c5e7e5c267c53656e64696e674170707c53656e64696e674661637c526563656976696e674170707c526563656976696e674661637c32303233313133303132303030307c7c4f52555e5230317c4d53474944313233347c507c322e330a +2025-07-31 04:27:56,579 - INFO - Received HL7 message: MSH|^~\&|SendingApp|SendingFac|ReceivingApp|ReceivingFac|20231130120000||ORU^R01|MSGID1234|P|2.3 + +2025-07-31 04:27:56,583 - INFO - Processing HL7 message: MSH|^~\&|SendingApp|SendingFac|ReceivingApp|ReceivingFac|20231130120000||ORU^R01|MSGID1234|P|2.3 + +2025-07-31 04:27:56,633 - INFO - Data successfully saved to the database. +2025-07-31 04:27:56,635 - INFO - Raw binary data saved: 5049447c7c7c31323334357c7c4a6f686e5e446f657c7c31393830303130317c4d0a4f42527c7c7c317c544553543132335e4578616d706c6520546573740a +2025-07-31 04:27:56,636 - INFO - Received HL7 message: PID|||12345||John^Doe||19800101|M +OBR|||1|TEST123^Example Test + +2025-07-31 04:27:56,636 - INFO - Processing HL7 message: PID|||12345||John^Doe||19800101|M +OBR|||1|TEST123^Example Test + +2025-07-31 04:27:56,636 - ERROR - Error processing and saving data: First segment is PID, must be one of MHS, FHS or BHS +2025-07-31 04:27:56,636 - ERROR - Error processing data: First segment is PID, must be one of MHS, FHS or BHS +2025-07-31 04:29:51,996 - INFO - * Detected change in '/app/app.py', reloading +2025-07-31 04:29:52,204 - INFO - * Restarting with stat +2025-07-31 04:29:52,966 - ERROR - Failed to bind to port 6001: [Errno 98] Address already in use +2025-07-31 04:29:52,985 - WARNING - * Debugger is active! +2025-07-31 04:29:52,986 - INFO - * Debugger PIN: 454-857-589 +2025-07-31 04:29:54,122 - INFO - Connection closed by client ('192.168.65.1', 28125) +2025-07-31 04:30:20,134 - INFO - Listening on TCP port 6001... +2025-07-31 04:30:20,207 - INFO - WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead. + * Running on all addresses (0.0.0.0) + * Running on http://127.0.0.1:5000 + * Running on http://172.18.0.4:5000 +2025-07-31 04:30:20,207 - INFO - Press CTRL+C to quit +2025-07-31 04:30:20,209 - INFO - * Restarting with stat +2025-07-31 04:30:21,252 - ERROR - Failed to bind to port 6001: [Errno 98] Address already in use +2025-07-31 04:30:21,273 - WARNING - * Debugger is active! +2025-07-31 04:30:21,274 - INFO - * Debugger PIN: 919-933-610 +2025-07-31 04:32:50,618 - INFO - New connection from ('192.168.65.1', 59039) +2025-07-31 04:32:50,619 - INFO - Handling client from ('192.168.65.1', 59039) +2025-07-31 04:33:10,684 - INFO - Raw binary data saved: 4d53487c5e7e5c267c53656e64696e674170707c53656e64696e674661637c526563656976696e674170707c526563656976696e674661637c32303233313133303132303030307c7c4f52555e5230317c4d53474944313233347c507c322e330a +2025-07-31 04:33:10,685 - INFO - Received HL7 message: MSH|^~\&|SendingApp|SendingFac|ReceivingApp|ReceivingFac|20231130120000||ORU^R01|MSGID1234|P|2.3 + +2025-07-31 04:33:10,688 - INFO - Processing HL7 message: MSH|^~\&|SendingApp|SendingFac|ReceivingApp|ReceivingFac|20231130120000||ORU^R01|MSGID1234|P|2.3 + +2025-07-31 04:33:10,736 - INFO - Data successfully saved to the database. +2025-07-31 04:33:10,737 - INFO - Raw binary data saved: 5049447c7c7c31323334357c7c4a6f686e5e446f657c7c31393830303130317c4d0a4f42527c7c7c317c544553543132335e4578616d706c6520546573740a4f42587c7c7c504f5349544956450a +2025-07-31 04:33:10,738 - INFO - Received HL7 message: PID|||12345||John^Doe||19800101|M +OBR|||1|TEST123^Example Test +OBX|||POSITIVE + +2025-07-31 04:33:10,738 - INFO - Processing HL7 message: PID|||12345||John^Doe||19800101|M +OBR|||1|TEST123^Example Test +OBX|||POSITIVE + +2025-07-31 04:33:10,738 - ERROR - Error processing and saving data: First segment is PID, must be one of MHS, FHS or BHS +2025-07-31 04:33:10,740 - ERROR - Traceback (most recent call last): + File "/app/app.py", line 66, in process_and_save_to_db + message = hl7.parse(hl7_message) + ^^^^^^^^^^^^^^^^^^^^^^ + File "/usr/local/lib/python3.11/site-packages/hl7/parser.py", line 98, in parse + plan = create_parse_plan(strmsg, factory) + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + File "/usr/local/lib/python3.11/site-packages/hl7/parser.py", line 348, in create_parse_plan + raise ParseException( +hl7.exceptions.ParseException: First segment is PID, must be one of MHS, FHS or BHS + +2025-07-31 04:33:10,741 - ERROR - Error processing data: First segment is PID, must be one of MHS, FHS or BHS +2025-07-31 04:33:11,645 - INFO - Raw binary data saved: 0a +2025-07-31 04:33:11,645 - INFO - Data is not in HL7 or ASTM format, skipping. +2025-07-31 04:33:20,965 - INFO - Raw binary data saved: 4d53487c5e7e5c267c53656e64696e674170707c53656e64696e674661637c526563656976696e674170707c526563656976696e674661637c32303233313133303132303030307c7c4f52555e5230317c4d53474944313233347c507c322e335049447c7c7c31323334357c7c4a6f686e5e446f657c7c31393830303130317c4d4f42527c7c7c317c544553543132335e4578616d706c6520546573744f42587c7c7c504f5349544956450a +2025-07-31 04:33:20,965 - INFO - Received HL7 message: MSH|^~\&|SendingApp|SendingFac|ReceivingApp|ReceivingFac|20231130120000||ORU^R01|MSGID1234|P|2.3PID|||12345||John^Doe||19800101|MOBR|||1|TEST123^Example TestOBX|||POSITIVE + +2025-07-31 04:33:20,965 - INFO - Processing HL7 message: MSH|^~\&|SendingApp|SendingFac|ReceivingApp|ReceivingFac|20231130120000||ORU^R01|MSGID1234|P|2.3PID|||12345||John^Doe||19800101|MOBR|||1|TEST123^Example TestOBX|||POSITIVE + +2025-07-31 04:33:20,972 - INFO - Data successfully saved to the database. +2025-07-31 04:35:43,445 - INFO - Connection closed by client ('192.168.65.1', 59039) diff --git a/htdocs/listenerlis/tcp_raw_data.bin b/htdocs/listenerlis/tcp_raw_data.bin index 353b33df..5a5f4c6f 100644 --- a/htdocs/listenerlis/tcp_raw_data.bin +++ b/htdocs/listenerlis/tcp_raw_data.bin @@ -6,4 +6,23 @@ MSH|^~\&|SendingApp|SendingFac|... MSH|^~\&|SendingApp|SendingFac|... MSH|^~\&|SendingApp|SendingFac|... MSH|^~\&|SendingApp|SendingFac|... - \ No newline at end of file +POST /listener HTTP/1.1 +Host: localhost:6001 +User-Agent: curl/8.7.1 +Accept: */* +Content-Type: text/plain +Content-Length: 175 + +MSH|^~\&|SendingApp|SendingFac|ReceivingApp|ReceivingFac|20231130120000||ORU^R01|MSGID1234|P|2.3 +PID|||12345||John^Doe||19800101|M +OBR|||1|TEST123^Example Test +OBX|||POSITIVE +MSH|^~\&|SendingApp|SendingFac|ReceivingApp|ReceivingFac|20231130120000||ORU^R01|MSGID1234|P|2.3 +PID|||12345||John^Doe||19800101|M +OBR|||1|TEST123^Example Test +MSH|^~\&|SendingApp|SendingFac|ReceivingApp|ReceivingFac|20231130120000||ORU^R01|MSGID1234|P|2.3 +PID|||12345||John^Doe||19800101|M +OBR|||1|TEST123^Example Test +OBX|||POSITIVE + +MSH|^~\&|SendingApp|SendingFac|ReceivingApp|ReceivingFac|20231130120000||ORU^R01|MSGID1234|P|2.3PID|||12345||John^Doe||19800101|MOBR|||1|TEST123^Example TestOBX|||POSITIVE