Question
· Jun 1, 2020

How could we iterate on a segment list, to get a needed field which is present in each one of the list's elements?

Hello,

 

We are wondering how could we iterate over a segments list,

 

The use case is that we are sending from Process X to process Y a message, only if at the OBR4 CE1 there is a certain code.  We were getting this field as follows:

set context.studyReason = request.GetValueAt("ORCgrp(1).OBRuniongrp.OBRunion.OBR:UniversalServiceIdentifier.Identifier")

 

How could we iterate over the following message and get both OBR4 CE1 (1 and 2):

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
    <SOAP-ENV:Header/>
    <SOAP-ENV:Body>
        <ORM_O01>
            <MSH>
                <MSH.1>|</MSH.1>
                <MSH.2>^~\&amp;</MSH.2>
                <MSH.3>
                    <HD.1>sistemaExterno</HD.1>
                </MSH.3>
                <MSH.4>
                    <HD.1>27</HD.1>
                    <HD.2>PRUEBAS</HD.2>
                </MSH.4>
                <MSH.5>
                    <HD.1>380316</HD.1>
                </MSH.5>
                <MSH.6>
                    <HD.1>EXTHL7</HD.1>
                </MSH.6>
                <MSH.7>
                    <TS.1>20200429114820</TS.1>
                </MSH.7>
                <MSH.8></MSH.8>
                <MSH.9>
                    <MSG.1>ORM</MSG.1>
                    <MSG.2>O01</MSG.2>
                    <MSG.3>ORM_O01</MSG.3>
                </MSH.9>
                <MSH.10>65636</MSH.10>
                <MSH.11>
                    <PT.1>E</PT.1>
                </MSH.11>
                <MSH.12>
                    <VID.1>2.5</VID.1>
                </MSH.12>
                <MSH.13>1</MSH.13>
                <MSH.16>AL</MSH.16>
                <MSH.18>ASCII</MSH.18>
            </MSH>
            <ORM_O01.PATIENT>
                <PID>
                    <PID.1>1</PID.1>
                    <PID.2>
                        <CX.1>FCCT540403904019</CX.1>
                    </PID.2>
                    <PID.3>
                        <CX.1>11645069</CX.1>
                        <CX.4>
                            <HD.1>MPI</HD.1>
                        </CX.4>
                        <CX.5>11645069</CX.5>
                    </PID.3>
                    <PID.3>
                        <CX.1>FCCT540403904019</CX.1>
                        <CX.4>
                            <HD.1>TISR</HD.1>
                        </CX.4>
                        <CX.5>FCCT540403904019</CX.5>
                    </PID.3>
                    <PID.3>
                        <CX.1>92920000T</CX.1>
                        <CX.4>
                            <HD.1>DNI</HD.1>
                        </CX.4>
                        <CX.5>92920000T</CX.5>
                    </PID.3>
                    <PID.4>
                        <CX.1>11645069</CX.1>
                    </PID.4>
                    <PID.5>
                        <XPN.1>
                            <FN.1>CIUDADANO</FN.1>
                        </XPN.1>
                        <XPN.2>FICTICIO</XPN.2>
                        <XPN.3>ACTIVO</XPN.3>
                    </PID.5>
                    <PID.7>
                        <TS.1>19540403000000</TS.1>
                    </PID.7>
                    <PID.8>M</PID.8>
                    <PID.11>
                        <XAD.1>
                            <SAD.1>C/</SAD.1>
                            <SAD.2>ABREU Y GALINDO, 5</SAD.2>
                            <SAD.3>6</SAD.3>
                        </XAD.1>
                        <XAD.2>87</XAD.2>
                        <XAD.4>28</XAD.4>
                        <XAD.5>35001</XAD.5>
                    </PID.11>
                    <PID.13>
                        <XTN.1>922000000</XTN.1>
                    </PID.13>
                    <PID.19>380000012304</PID.19>
                    <PID.30>N</PID.30>
                    <PID.31>N</PID.31>
                </PID>
                <PD1>
                    <PD1.1>1</PD1.1>
                </PD1>
                <ORM_O01.PATIENT_VISIT>
                    <PV1>
                        <PV1.1>1</PV1.1>
                        <PV1.2>1</PV1.2>
                        <PV1.7>
                            <XCN.1>DAMIAN ALVAREZ PEREZ</XCN.1>
                        </PV1.7>
                        <PV1.8>
                            <XCN.8>27950104</XCN.8>
                        </PV1.8>
                        <PV1.10>APLP</PV1.10>
                        <PV1.11>
                            <PL.1>27</PL.1>
                        </PV1.11>
                        <PV1.15>27</PV1.15>
                        <PV1.30>20200429</PV1.30>
                        <PV1.35>20200429</PV1.35>
                        <PV1.50>
                            <CX.1>11645069</CX.1>
                            <CX.2>LABAP</CX.2>
                        </PV1.50>
                    </PV1>
                </ORM_O01.PATIENT_VISIT>
            </ORM_O01.PATIENT>
            <ORM_O01.ORDER>
                <ORC>
                    <ORC.1>HD</ORC.1>
                    <ORC.3>
                        <EI.1>11111</EI.1>
                    </ORC.3>
                    <ORC.7>
                        <TQ.6>1</TQ.6>
                    </ORC.7>
                    <ORC.8>
                        <EIP.1>
                            <EI.1>65639</EI.1>
                        </EIP.1>
                    </ORC.8>
                    <ORC.10>
                        <XCN.1>43794017Q</XCN.1>
                    </ORC.10>
                    <ORC.13>
                        <PL.1>CON</PL.1>
                    </ORC.13>
                    <ORC.16>
                        <CE.1>PC</CE.1>
                        <CE.2>Study</CE.2>
                    </ORC.16>
                </ORC>
                <ORM_O01.ORDER_DETAIL>
                    <ORM_O01.OBRRQDRQ1RXOODSODT_SUPPGRP>
                        <OBR>
                            <OBR.1></OBR.1>
                            <OBR.4>
                                <CE.1>1</CE.1>
                                <CE.2></CE.2>
                            </OBR.4>
                            <OBR.18>LAB</OBR.18>
                            <OBR.19>LAB</OBR.19>
                        </OBR>
                    </ORM_O01.OBRRQDRQ1RXOODSODT_SUPPGRP>
                    <NTE>
                        <NTE.3>Observations
                        </NTE.3>
                    </NTE>
                </ORM_O01.ORDER_DETAIL>
                <ORM_O01.ORDER_DETAIL>
                    <ORM_O01.OBRRQDRQ1RXOODSODT_SUPPGRP>
                        <OBR>
                            <OBR.1></OBR.1>
                            <OBR.4>
                                <CE.1>2</CE.1>
                                <CE.2></CE.2>
                            </OBR.4>
                            <OBR.18>LAB</OBR.18>
                            <OBR.19>LAB</OBR.19>
                        </OBR>
                    </ORM_O01.OBRRQDRQ1RXOODSODT_SUPPGRP>
                    <NTE>
                        <NTE.3>Observations
                        </NTE.3>
                    </NTE>
                </ORM_O01.ORDER_DETAIL>
            </ORM_O01.ORDER>
        </ORM_O01>
    </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

Would we need to use a Transform, or could we do it inside the Process itself with a code block? Would we need a foreach block inside the process?

Here is the picture showing the structure were we would need to iterate, as it is being shown by a transform:

Discussion (2)2
Log in or sign up to continue

The schema doesn't seem to match the structure of the message you've supplied; the OBRuniongrp group should be a repeating group and indicate such with parentheses (i.e. OBRuiniongrp()). Assuming that's fixed in the schema, you should be able to get at the fields in question in repeating OBR segments with something like:

Set tStudy = 0
// Get count of OBR segments
Set tOBRCnt = request.GetValueAt("ORCgrp(1).OBRuniongrp(*)")
// Loop through OBRs and evaluate field contents
For tIter = 1:1:tOBRCnt
{
   If request.GetValueAt("ORCgrp(1).OBRuniongrp("_tIter_").OBRunion.OBR:UniversalServiceIdentifier.Identifier") = "match_value"
   {
      Set tStudy = 1
   }
}
If tStudy
{
   ...insert action to take here...
}

The above may need to be modified to use context variables if it's being used in a BPL.