- Print
- DarkLight
- PDF
While the System Message Types provide a substantial amount of functionality for your Tenant's processing network, in many cases you may want to augment those Message Types with ones that are specific to your processing needs.
For example:
- You have a specific format and want to audit messages of that format in custom ways as you process them.
- You have a message format that requires a Python package that you have built for processing, and wish to automatically include that package in every Node that uses the Message Type.
- You want to create Functions in your Tenant's Function library that perform specific message processing, and you want to enforce that only messages that conform to a specific format can be passed to that Function.
EchoStream allows you to create as many Tenant-specific Message Types as you wish to fulfill these types of use-cases.
Creating
To create a Tenant-specific Message Type, you must provide the following:
Name
The name of your Message Type must conform to the regular expression ^[A-Za-z][A-Za-z0-9-_\.]{3,24}$
and must be unique within your Tenant.
Description
A human-readable description of your Message Type.
Auditor
You must provide an auditor function that will provide audit fields specific to your Message Type.
This auditor is a Python function that has the following requirements:
- It must have the signature
def auditor(*, message, **kwargs):
- It must contain all code within the
def
statement, including any imports. - It must return a flat dictionary of key/value pairs.
For example, the echo.hl7
auditor:
def auditor(*, message, **kwargs):
from hl7 import Message, parse as hl7parse
if not isinstance(message, Message):
message = hl7parse(message)
return dict(
cntrl_id=message.extract_field("MSH", 1, 10),
code=message.extract_field("MSH", 1, 9, 1, 1),
date_time=message.extract_field("MSH", 1, 7),
rec_app=message.extract_field("MSH", 1, 5),
rec_fac=message.extract_field("MSH", 1, 6),
send_app=message.extract_field("MSH", 1, 3),
send_fac=message.extract_field("MSH", 1, 4),
struc=message.extract_field("MSH", 1, 9, 1, 3),
trigger=message.extract_field("MSH", 1, 9, 1, 2),
)
Bitmapper Template
You must provide a template for Bitmap Router Nodes that will be used when creating a custom bitmapper implementation in those Nodes.
Your template is a Python function that has the following requirements:
- It must have the signature:
def bitmapper(*, context, message, source, **kwargs):
- It must contain all code within the
def
statement, including any imports. - It must return an
int
.
For example, the echo.hl7
bitmapper template:
def bitmapper(*, context, message, source, **kwargs):
from hl7 import Message, parse as hl7parse
if not isinstance(message, Message):
message = hl7parse(message)
bitmap = 0x0
# TODO - Perform conditional bitmapping of the HL7 message here.
# The returned bitmap will be compared against the routes in the
# route table for route matching. This will be done by
# (message_bitmap & route) == route. If no routes match, the
# message will be filtered.
# Example:
# if message["MSH.4"] == "Glory Hospital":
# bitmap |= 1
# if message["MSH.4"] == "University Hosp":
# bitmap |= 2
# If we then wanted a route that fired on Glory or University
# the route bitmap would equal 3 (i.e. - '11').
return bitmap
Processor Template
You must provide a template for Processor Nodes that will be used when creating a custom processor implementation in those Nodes.
Your template is a Python function that has the following requirements:
- It must have the signature:
def processor(*, context, message, source, **kwargs):
- It must contain all code within the
def
statement, including any imports. - It must return a
str
,list[str]
orNone
.
For example, the echo.hl7
processor template:
def processor(*, context, message, source, **kwargs):
from hl7 import Message, parse as hl7parse
if not isinstance(message, Message):
message = hl7parse(message)
# TODO - Perform any transformations to the HL7 message here.
# This can include transforming the message to something that
# is no longer HL7. Remember, you MUST return a string or None.
# If None is returned, the message will be filtered.
return str(message)
Sample Message
You must provide a sample message that wil be used during validation of code that processes your Message Type. This must be a str
that contains the message in your Message Type's format.
For example, the echo.hl7
sample message:
MSH|^~\&|GHH LAB|ELAB-3|GHH OE|BLDG4|200202150930||ORU^R01|CNTRL-3456|P|2.4
PID|||555-44-4444||EVERYWOMAN^EVE^E^^^^L|JONES|196203520|F|||153 FERNWOOD DR.^^STATESVILLE^OH^35292||(206)3345232|(206)752-121||||AC555444444||67-A4335^OH^20030520
OBR|1|845439^GHH OE|1045813^GHH LAB|1554-5^GLUCOSE|||200202150730||||||||555-55-5555^PRIMARY^PATRICIA P^^^^MD^^LEVEL SEVEN HEALTHCARE, INC.|||||||||F||||||444-44-4444^HIPPOCRATES^HOWARD H^^^^MD
OBX|1|SN|1554-5^GLUCOSE^POST 12H CFST:MCNC:PT:SER/PLAS:QN||^182|mg/dl|70_105|H|||F
OBX|2|FN|1553-5^GLUCOSE^POST 12H CFST:MCNC:PT:SER/PLAS:QN||^182|mg/dl|70_105|H|||F
Requirements
If processing your Message Type requires third-party Python packages, you may provide a list of those packages in pip
requirement specifiers format.
For example, the echo.hl7
requirements:
hl7>=0.4.2
Readme
While is is not required, EchoStream strongly suggests that you provide a README in Markdown format that provides a more in-depth explanation of your Message Type and it's use to users of your Message Type.
Updating
You may update all attributes of your Message Type except the name. Updates are automatically applied to all Functions and Nodes that use your Message Type in near-real time.
Deleting
You may delete your Message Type if:
- There are no Nodes in your Tenant that use it.
- There are no Functions in your Tenant that use it.
- There are no Managed Node Types in your Tenant that use it.