In these older versions, a predecessor of this class was used. The updated successor of that class that is documented on this page has new functionality and provides a more consistent interface than the old class. MD Link Jython code written using the old class will continue to work without alteration in MD Link 4.3.8 and above, but it is recommended that you convert your old code to use the new class when convenient. For help with this code conversion, contact MDI Solutions, or follow this guideline of code changes that will be required.
You must first make your code point at the new class. To do that, find any place in your code that creates an old HL7Message object. That was done in two lines; one that looks like this:
from com.mdisolutions.mdlink import HL7Message
and one that looks like this:
hl7msg = HL7Message(textvar)
Remove every instance of the first, and change every instance of the second to this:
hl7msg = util.makeHL7Message(textvar)
If your code includes a 1 argument, like this:
hl7msg = HL7Message(textvar,1)
then you can also replace that with hl7msg = util.makeHL7Message(textvar). If your code contains 0 instead of a 1, then contact MDI Solutions.
Then you must update certain method calls which are incompatible between versions. (Be aware that a single line of your Jython code may require several different modifications, due to falling under several different bullet points below.)
hl7msg.getField('MSH', 10)
must be changed to hl7msg.getField('MSH', 11)
Likewise with the field index arguments to all other methods: setField, getComponent, setComponent, getComponentRep, setComponentRep.
hl7msg.getField('EVN', 1) (for example) should not be changed; only those methods concerning 'MSH' segments.
hl7msg.getSegment(3)
must be changed to
hl7msg.getSegment(4)
Likewise with all segment index arguments to addSegment, and removeSegment, and also setField, getField, setComponent, setComponentRep, getComponent, getComponentRep, etc. (if the method call includes a segment repetition index).
hl7msg.getComponent('PID', 3, 0)
to
hl7msg.getComponent('PID', 3, 1)
hl7msg.getComponent('ZYX', 7, 3, 4)
to
hl7msg.getComponent(('ZYX', 8), 3, 4)
(Note that the segment index has been increased by one also, as per the second point above.) Do this wherever you deal with repeating segments.
hl7msg.setComponentRep('Adrian', 'PID', 5, 3, 2)
must be replaced with
hl7msg.setComponent('Adrian', 'PID', (5,4), 2)
(Note that the field repetition index has been increased by one also.) Likewise for all other versions of setComponentRep/ getComponentRep. The important part is to remove the Rep and put brackets around the field and repetition index, and add 1 to the field repetition argument.