简体   繁体   中英

Iterating through HL7 message using Segment Iterator Object of Chameleon Python API

I am generating HL7 messages using Interfaceware Iguana and Chameleon. This is my first experience with Python, so this question may be immature. I am trying to iterate through message using Segment Iterator Object.

current_segment = environment.input_segment_iterator()  
current_segment.apply_transform()
output = current_segment.output()
if current_segment.move_next('OBX'):
    log('OBX setId is ' + current_segment.field(1).value );

I have written this script in global post process equation window, but it always gives me an error saying

RuntimeError: Invalid iterator must be reset before being used while calling apply_transform
while executing the outgoing post process equation for the project.

I have seen many examples of using iterator, and all follow same pattern. How do I reset this iterator, and why is this invalid?

After doing some research work, I discovered that I cannot use input_segment_iterator in the post process equation window, but in transformation window. Now I am able to see changes I make to script using the Test Mapping feature of Chameleon. But how can I configure this change to be implemented on each message which I generate using this vmd ?

I think someone working with INTERFACEWARE Chameleon and Iguana products could easily help me out.

Not much of an Iguana person, But what I believe is you are missing this

current_segment.reset() after you are done iterating through OBX, so that it sets the current segment to MSH.

You can see sample usage on this page .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM