How to compare value in global and add description to segment

#ObjectScript #Ensemble

I have a list of 300 code combinations in the following format, which I plan to load into a global

X123, Internal health

X234, external health

X345, Peripheral health etc..

I want to get the code from the DG1 segment, compare to the global, and add a description. Is there an easy way to do it?

So in my DG1 segment If I get the code X123, what I want to do is check if the code is in the global and if it does add the description in the field.

So DG1 will look like this:

DG1|1|CDS||X123^^^|20200827141200|Primary||||||||||Dr. Who|||

and needs to be transformed as below

DG1|1|CDS||X123^Internal Health^^|20200827141200|Primary||||||||||Dr. Who|||
  • 00
  • 0
  • 78
  • 7


"plan to load into a global"

in which way?  straight global, class, .. ??? pls. explain

Hi Robert, I am getting the list in an excel file, and thinking I could use a straight global to load the values and compare. Is that a good way?

^EDLIST("DIAG", "X123, internal health") = ""

^EDLIST("DIAG", "X234, External health") = ""

Hi Marc, thank you so much for that. This is a new thought process for me. 

This might make your task easier

^EDLIST("DIAG", "X123")=" internal health"
^EDLIST("DIAG", "X234")=" External health"
. . . 

So you will need this Function / Method to Update your segment:
The class is just a container for the method

Class ED.Update [abstract] {
/// assumption you have the full Segment already in a string
ClassMethod AddDescription(ByRef segment as %String) as %Boolean
{  set code=$piece(segment,"^")
   if $data(^EDLIST("DIAG",code),value)#10 set $piece(segment,"^",2)=value
        quit $test }

now all you have to do

/// ...  get the segment from DG1
    if  ##class(ED.Update).AddDescription(.segment)  {
          /// .....Update the segment in DG1

If the code is not defined you just skip the update

HI Robert,  thank you, I was able to use your advice on implementing the code. What does the #10 do? I was able to use your suggestion because I already had a Business Process defined, which I could just plug in your suggestion.

very quick:  $DATA() returns:

  • 0 no node, no data
  • 1 node exist and has data
  • 10 node exist has descendants but no data
  • 11  node exist has descendants and has data

# is the modulo operator and #10 means you just get the rightmost part of the $Data() result : 1 or 0 (true/false)
So $Data(^EDLIST("DIAG",code),value)#10 means: If the node has data than the content is in  value.
otherwise value is useless, skip it