-
Notifications
You must be signed in to change notification settings - Fork 90
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Child limit exceeded ORU_R01_OBSERVATION.OBX #90
Comments
The specification allows for 1 OBX segment per OBSERVATION group. You'll need to add a new OBSERVATION group for each OBX segment you would like to add. |
@kwiechen @rileyschack Do you have an code example? I do not understand. |
@kwiechen @perjer4675 As @rileyschack suggested, OBX segment is part of the ORU_R01_OBSERVATION group which, in turn, is part of ORU_R01_ORDER_OBSERVATION group. It means that you need to create both groups and attach them to ORU_R01_PATIENT_RESULT group. This will add the OBX: from hl7apy import core
hl7 = core.Message("ORU_R01", version="2.2")
hl7.msh.msh_3 = "SendingApp"
hl7.msh.msh_4 = "SendingFac"
hl7.msh.msh_5 = "ReceivingApp"
hl7.msh.msh_6 = "ReceivingFac"
hl7.msh.msh_9 = "ORU^R01"
hl7.msh.msh_10 = "168715"
hl7.msh.msh_11 = "P"
hl7.ORU_R01_PATIENT_RESULT.ORU_R01_PATIENT.PID.pid_3 = "1"
hl7.ORU_R01_PATIENT_RESULT.ORU_R01_PATIENT.PID.pid_5 = "Patient^Test"
hl7.ORU_R01_PATIENT_RESULT.ORU_R01_ORDER_OBSERVATION.OBR.obr_4 = "10000"
hl7.ORU_R01_PATIENT_RESULT.ORU_R01_ORDER_OBSERVATION.ORU_R01_OBSERVATION.OBX.obx_1 = "1"
hl7.ORU_R01_PATIENT_RESULT.ORU_R01_ORDER_OBSERVATION.ORU_R01_OBSERVATION.OBX.obx_2 = "ST"
hl7.ORU_R01_PATIENT_RESULT.ORU_R01_ORDER_OBSERVATION.ORU_R01_OBSERVATION.OBX.obx_3 = "PDF"
hl7.ORU_R01_PATIENT_RESULT.ORU_R01_ORDER_OBSERVATION.ORU_R01_OBSERVATION.OBX.obx_5 = "Test"
hl7.ORU_R01_PATIENT_RESULT.ORU_R01_ORDER_OBSERVATION.ORU_R01_OBSERVATION.OBX.obx_11 = "F" # Observ Result Status -- "F" meaning 'Final result'
obx = core.Segment("OBX", version="2.2")
obx.obx_1 = "2"
obx.obx_2 = "ST"
obx.obx_5 = "Test2"
obx.obx_11 = "F"
order_observation_group = core.Group("ORU_R01_ORDER_OBSERVATION", version="2.2")
observation_group = core.Group("ORU_R01_OBSERVATION", version="2.2")
observation_group.add(obx)
order_observation_group.add(observation_group)
hl7.ORU_R01_PATIENT_RESULT.add(order_observation_group)
print(repr(hl7.to_er7())) Resulting in
You can access the second instance by index. hl7.ORU_R01_PATIENT_RESULT.ORU_R01_ORDER_OBSERVATION[1].ORU_R01_OBSERVATION.OBX More about accessing elements here Notice that validation still fails due to your ORU_R01_OBSERVATIONs missing ORU segment but this is one step forward :) |
@svituz thank you very much. ^_^ |
I have tried adding an additional OBX segment to an ORU_R01 message using a slightly modified code from Michael Sarfati
from hl7apy import core
hl7 = core.Message("ORU_R01", version="2.2")
hl7.msh.msh_3 = "SendingApp"
hl7.msh.msh_4 = "SendingFac"
hl7.msh.msh_5 = "ReceivingApp"
hl7.msh.msh_6 = "ReceivingFac"
hl7.msh.msh_9 = "ORU^R01"
hl7.msh.msh_10 = "168715"
hl7.msh.msh_11 = "P"
hl7.ORU_R01_PATIENT_RESULT.ORU_R01_PATIENT.PID.pid_3 = "1"
hl7.ORU_R01_PATIENT_RESULT.ORU_R01_PATIENT.PID.pid_5 = "Patient^Test"
hl7.ORU_R01_PATIENT_RESULT.ORU_R01_ORDER_OBSERVATION.OBR.obr_4 = "10000"
hl7.ORU_R01_PATIENT_RESULT.ORU_R01_ORDER_OBSERVATION.ORU_R01_OBSERVATION.OBX.obx_1 = "1"
hl7.ORU_R01_PATIENT_RESULT.ORU_R01_ORDER_OBSERVATION.ORU_R01_OBSERVATION.OBX.obx_2 = "ST"
hl7.ORU_R01_PATIENT_RESULT.ORU_R01_ORDER_OBSERVATION.ORU_R01_OBSERVATION.OBX.obx_3 = "PDF"
hl7.ORU_R01_PATIENT_RESULT.ORU_R01_ORDER_OBSERVATION.ORU_R01_OBSERVATION.OBX.obx_5 = "Test"
hl7.ORU_R01_PATIENT_RESULT.ORU_R01_ORDER_OBSERVATION.ORU_R01_OBSERVATION.OBX.obx_11 = "F" # Observ Result Status -- "F" meaning 'Final result'
obx = core.Segment("OBX", version="2.2")
obx.obx_1 = "2"
obx.obx_2 = "ST"
obx.obx_5 = "Test2"
obx.obx_11 = "F"
hl7.ORU_R01_PATIENT_RESULT.ORU_R01_ORDER_OBSERVATION.ORU_R01_OBSERVATION.add(obx)
assert hl7.validate() is True
-> gives exception: Child limit exceeded ORU_R01_OBSERVATION.OBX
As far as I understand the specification one or more OBX segments are allowed?
Best regards,
Kai
The text was updated successfully, but these errors were encountered: