hl7apy not displaying data with multiple OBX fields
<p>I am trying to parse hl7 files using <strong>hl7apy</strong> i am having below hl7 sample</p>

<p><strong>sample :</strong></p>

<pre><code>MSH|^~\&amp;|XXXX|C|PRIORITYHEALTH|PRIORITYHEALTH|20080511103530||ORU^R01|Q335939501T337311002|P|2.3|||
PID|1||94000000000^^^Priority Health||LASTNAME^FIRSTNAME^INIT||19460101|M|||||
PD1|1|||1234567890^PCPLAST^PCPFIRST^M^^^^^NPI|
OBR|1||185L29839X64489JLPF~X64489^ACC_NUM|JLPF^Lipid Panel - C||||||||||||1694^DOCLAST^DOCFIRST^^MD||||||20080511103529|||
OBX|1|NM|JHDL^HDL Cholesterol (CAD)|1|62|CD:289^mg/dL|&gt;40^&gt;40|""||""|F|||20080511103500|||^^^""|
OBX|2|NM|JTRIG^Triglyceride (CAD)|1|72|CD:289^mg/dL|35-150^35^150|""||""|F|||20080511103500|||^^^""|
OBX|3|NM|JVLDL^VLDL-C (calc - CAD)|1|14|CD:289^mg/dL||""||""|F|||20080511103500|||^^^""|
OBX|4|NM|JLDL^LDL-C (calc - CAD)|1|134|CD:289^mg/dL|0-100^0^100|H||""|F|||20080511103500|||^^^""|
OBX|5|NM|JCHO^Cholesterol (CAD)|1|210|CD:289^mg/dL|90-200^90^200|H||""|F|||20080511103500|||^^^""|
</code></pre>

<p><strong>Code:</strong></p>

<pre><code>from hl7apy import parser
from hl7apy.exceptions import UnsupportedVersion

hl7 = open('sample.hl7', 'r').read()

try:
    m = parser.parse_message(hl7)
except UnsupportedVersion:
    m = parser.parse_message(hl7.replace("n", "r"))

  print(m.obx.obx_1.value)
</code></pre>

<p>but when i am trying to read OBX (Repeating segments) i am not getting any data, it is displaying nothing. What is am i doing wrong ?</p>

<p>You have an error in your code. It should be</p>

<pre><code>hl7.replace("\n", "\r")
</code></pre>

<p>You have to write all groups, if you want to access a field in (a) group(s)</p>

<p>try  <code>m.ORU_R01_RESPONSE.ORU_R01_ORDER_OBSERVATION.ORU_R01_OBSERVATION.OBX[0].obx_1.value</code>
for the first value of the first obx segment and so on.</p>

<p>I recommend to read <a href="https://github.com/crs4/hl7apy/issues/8" rel="nofollow">Improve hl7apy documentation</a></p>

python hl7 hl7-v2