crs4 / hl7apy

Python library to parse, create and handle HL7 v2 messages.
http://crs4.github.io/hl7apy/
MIT License
215 stars 85 forks source link

Invalid date formats, other factory errors write to standard-out -- suggest using the warning library instead. #97

Closed gbtimmon closed 2 years ago

gbtimmon commented 2 years ago

At line 102 of factories.py inside datatype_factory(), there is a print(e) line that causes the warning messages such as {} is not an HL7 valid date value to be written to standard out when invalid data is included in a parsed message.

It is a useful message in many cases but for my particular application, the parsing error message is not needed and is polluting the stdout.

It is easy enough to work around by redirecting the stdout handles, but I think in general this message should be passed to a python warning so that the user could have more control over how to handle them. (Ignore, write to stdout, treat it as an exception, etc.)

If implementing warnings is too much change, maybe VALIDATION_LEVEL.QUIET should suppress these prints?

svituz commented 2 years ago

That is most likely a debugging message we forgot to delete :grimacing: I'll delete it in the next release