Closed tschnibo closed 5 years ago
Hello tschinibo, to support version 2.1 we should have the schemes of all the messages of that version and create the internal representation of that messages as in other versions (e.g., here there is the internal representation of v2.2 structures). We have a script that parses the official XML and creates the structures but we haven't found the v2.1.
Dear svituz, thanks for the quick reply!
I guess you did look for it and therefore there is probably no such XML. Too bad. I'll think about how to solve this problem.
Maybe I'll consult you again. Thank you!
Well, of course the other way is to write all the structures manually without generating them. An idea is to copy the version 2.2 files and change the structures according to the 2.1 specification. If you look at HAPI structures for 2.1 and 2.2 it should be easy to check the differences and reply them on hl7apy. Kinda boring actually, but easy :)
Ok, thats at least a possibility! I'll have a look at this tomorrow.
Many thanks!
Hi @tschnibo, I created the structures for version 2.1 in the develop branch. Probably some structures are not completely correct, for example the CM datatype. That said, can you try that version or send some example messages before I push a release? Thank you, Vittorio
Hi @svituz thank you! That's very kind! I was parsing messages with just copying the 2.2 folder, and no problems so far. But I just parsed some data-fields, for testing, not quantitatively. Can it be, that the parsing is completely downward compatible? Until now I am not sending any messages, I am just building a 'consuming' application. Can the parsing of messages be helpful for the tests too? Sorry for the confusion, I'm totally new to hl7. Kind regards, Julian
The parsing, just like the message creation from scratch, follow the structures of the messages taken from the correct version. If the message doesn't adhere to the structure, the parsing can fail. It can happen that just changing the version of the message in the MSH doesn't break the parsing, but in this way you are not using the correct structure. For example, the version 2.2 may have different segments for a message or different fields. So, the parsing is totally helpful.
Dear Vittorio, sorry for the delay. Then I am going to test the new version. I'll be able to work on the project in two days. I'll keep you posted!
Dear Vittorio, already in the first file I tried I get the following error:
What do you think causes this?
###########
` File "...lib\site-packages\hl7apy\parser.py", line 88, in parse_message children = parse_segments(message, m.version, encoding_chars, validation_level, m.reference, find_groups) File "...\lib\site-packages\hl7apy\core.py", line 842, in getattr raise AttributeError(name) AttributeError: reference
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File "...\lib\site-packages\hl7apy\v2_1__init__.py", line 41, in get return ELEMENTS[element_type][name] KeyError: 'ID_1'
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File "...\lib\site-packages\hl7apy\core.py", line 546, in get_structure reference = load_reference(element.name, element.classname, element.version)
File "...\lib\site-packages\hl7apy__init__.py", line 280, in load_reference ref = lib.get(name, element_type) File "...\lib\site-packages\hl7apy\v2_1__init__.py", line 43, in get raise ChildNotFound(name) hl7apy.exceptions.ChildNotFound: No child named ID_1
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "c:\virtualizedpython\Lib\runpy.py", line 183, in _run_module_as_main
mod_name, mod_spec, code = _get_module_details(mod_name, _Error)
File "c:\virtualizedpython\Lib\runpy.py", line 109, in _get_module_details
import(pkg_name)
File "...\hl7_parser.py", line 49, in
The shortened message is: `MSH|^~\&|LDS-LAB|LAB1|SC-MED|MED1|2011332112001||ORU|4554543|P|2.1||XLAB PID|1|4554d43|4554543|002344234455|test^michii||4554543|M||||||||W|RK
`
It was a problem with the ID datatypes that I've just fixed. I tried to parse the message but I noticed that it is missing the escape character (): is it a problem with your example or version 2.1 is actually missing it? (I hope for the first option :) )
Perfect thanks! I'll retest. I had to do something like .replace( "\r\n" , "\r" ) before parsing the files, in order to make the parsing work. Do you mean this "segment" escape?
The encoding characters are the MSH.1, which is usually |, and MSH.2 which are the first 4 characters after that and usually are ^~\&. In your message the \ char is missing. I wonder it is because 2.1 doesn't have that character. You can find some info here
EDIT: I noticed it is probably a problem with GitHub using the same encoding char :relaxed:
OK, yes, I looked at the first line again. And voila, there is a "^~\&" contained :) - so seemst to be ok then, right?
I parsed some informations out of 7000 files now. It works smooth. When I just copied the 2.2 folder earlier I run into some errors, so until now your 2.1 version works better than the 2.2 version for parsing 2.1 files ;)
Maybe I'll find more issues proceeding, till now my test-case is not very thorough.
@svituz - Are there any plans to release this officially via pypi? We integrate with some very old clients and might have to grab what you all have been working on for 2_1 from the develop branch
@tuckeryatesjvion I'm preparing a new release, it should be ready today
Release 1.3.3 with version 2.1 support has been released
Thank you so much!
Good day and thanks for sharing this package!
Do you know what sort of changes there would be needed to use the package with Hl7 v2.1? It seems our software is using this quite an old version.
Kind regards and many thanks four your suggestions.