19.1.20. camcops_server.cc_modules.cc_hl7


Copyright (C) 2012-2018 Rudolf Cardinal (rudolf@pobox.com).

This file is part of CamCOPS.

CamCOPS is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

CamCOPS is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with CamCOPS. If not, see <http://www.gnu.org/licenses/>.


class camcops_server.cc_modules.cc_hl7.HL7Message(task=None, recipient_def=None, hl7run=None, show_queue_only=False, *args, **kwargs)[source]
divert_to_file(f: TextIO) → None[source]

Write an HL7 message to a file.

make_hl7_message(req: camcops_server.cc_modules.cc_request.CamcopsRequest) → None[source]

Stores HL7 message in self.msg.

May also store it in self.message (which is saved to the database), if we’re saving HL7 messages.

send(req: camcops_server.cc_modules.cc_request.CamcopsRequest, queue_file: TextIO = None, divert_file: TextIO = None) → Tuple[bool, bool][source]

Send an outbound HL7/file message, by the appropriate method.

send_to_filestore(req: camcops_server.cc_modules.cc_request.CamcopsRequest) → None[source]

Send a file to a filestore.

transmit_hl7() → None[source]

Sends HL7 message over TCP/IP.

valid(req: camcops_server.cc_modules.cc_request.CamcopsRequest) → bool[source]

Checks for internal validity; returns Boolean.

class camcops_server.cc_modules.cc_hl7.HL7Run(recipdef=None, *args, **kwargs)[source]

Class representing an HL7/file run for a specific recipient.

May be associated with multiple HL7/file messages.

class camcops_server.cc_modules.cc_hl7.MLLPTimeoutClient(host: str, port: int, timeout_ms: int = None)[source]

Class for MLLP TCP/IP transmission that implements timeouts.

close()[source]

Release the socket connection

send(data: bytes) → Tuple[bool, Union[str, NoneType]][source]

Low-level, direct access to the socket.send (data must be already wrapped in an MLLP container). Blocks until the server returns.

send_message(message: Union[str, hl7.containers.Message]) → Tuple[bool, Union[str, NoneType]][source]

Wraps a str, unicode, or hl7.Message in a MLLP container and send the message to the server

camcops_server.cc_modules.cc_hl7.make_sure_path_exists(path: str) → None[source]

Creates a directory/directories if the path doesn’t already exist.

camcops_server.cc_modules.cc_hl7.send_all_pending_hl7_messages(cfg: camcops_server.cc_modules.cc_config.CamcopsConfig, show_queue_only: bool = False) → None[source]

Sends all pending HL7 or file messages.

Obtains a file lock, then iterates through all recipients.

camcops_server.cc_modules.cc_hl7.send_pending_hl7_messages(req: camcops_server.cc_modules.cc_request.CamcopsRequest, recipient_def: camcops_server.cc_modules.cc_recipdef.RecipientDefinition, show_queue_only: bool, queue_stdout: TextIO) → None[source]

Pings recipient if necessary, opens any files required, creates an HL7Run, then sends all pending HL7/file messages to a specific recipient.

camcops_server.cc_modules.cc_hl7.send_pending_hl7_messages_2(req: camcops_server.cc_modules.cc_request.CamcopsRequest, recipient_def: camcops_server.cc_modules.cc_recipdef.RecipientDefinition, show_queue_only: bool, queue_stdout: TextIO, hl7run: camcops_server.cc_modules.cc_hl7.HL7Run, divert_file: Union[TextIO, NoneType]) → None[source]

Sends all pending HL7/file messages to a specific recipient.

Also called once per recipient, but after diversion files safely opened and recipient pinged successfully (if desired).