Question
· Aug 27, 2020

How to compare value in global and add description to segment

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|||
Discussion (7)1
Log in or sign up to continue

This is typically handled by data lookup tables. Lookup table entries can be maintained through a provided GUI, imported from files or through custom code:
https://docs.intersystems.com/healthconnectlatest/csp/docbook/DocBook.UI...

DTL includes pre-built functions for looking up values in a lookup table:
https://docs.intersystems.com/healthconnectlatest/csp/docbook/Doc.View.c...

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

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