Question
· Jul 14, 2020

How can I read a field from the second obx segment using objectscript

Hi, I am trying to read a field from the second obx segment but it keeps giving me an error.

Following is what I am trying:

detval = pRequest.FindSegment("OBX(2)")
dep = detval.GetValueAt(2)

but it doesnt read it. Is there a different way to read the value?

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

Hi Eric,

In ORM messages the property path is:

"ORCgrp(<indexORC>).OBRuniongrp.OBXgrp(<indexOBX>).OBX"

Where <indexORC> is the "line" of ORC segment, the <indexOBX> is the same to OBX segment, generally we iterate over a loop.

In ORU messages the property  path is:

"PIDgrpgrp(<indexPID>).ORCgrp(<indexORC>).OBXgrp(<indexOBX>).OBX"

Then indexes variables is analogous to the ORM messages.

The easy way to you "discover" the property  path is creating a DTL data transformation  and map the property that you need in a fake assign action, save, compile and change to the generated routine (in studio use the shortcut Ctrl+Shift+V, 2 times)

Eric,

The problem is that ensemble do not recognized your Message Type, then in this case you can only access properties by Index.

In your case is segment 9 field 6: 

pRequest.GetValueAt("9:6")

To see the problem call the method GetValueAt and log the status code:

Do pRequest.GetValueAt("PIDgrpgrp(1).ORCgrp(1).OBXgrp(2).OBX:6", , .statusCode)

$$$LOGSTATUS(statusCode)

See de documentation for mor detail about message schema:

https://docs.intersystems.com/irisforhealthlatest/csp/docbook/Doc.View.cls?KEY=EHL72_tools