Question
· Jun 11, 2018

How to splice a segment with a DTL? (in a BPL)

Hi, 

I want to splice a PID segement returned from a query, so I can use it in a DTL:

<assign value='context.pidSegment' property='target.{PIDgrp.PID}' action='set' />

I need to set the value of 'context.pidSegment' to something I can use in the DTL objectscript expression

but I'm not sure what method (or property) to use to get the class EnsLib.HL7.Segment segment into a datatype that can be used in the DTL?

I've tried the following to no avail;

  • context.K21response.GetSegmentAt("PIDgrp.PID")
  • context.K21response.FindSegment("PIDgrp.PID")
  • context.K21response.GetSegmentAt("PIDgrp.PID").RawContent
  • context.K21response.FindSegment("PIDgrp.PID").RawContent

(using <assign> to set context.pidSegment)

What method should I use?

Kind regards, 


Stephen

Discussion (1)0
Log in or sign up to continue

Suriya at WRC solved this for me

Where I went wrong: 

  1. I created context.pidSegment as EnsLib.HL7.Segment - which fails as an argument to the DTL <assign> statement)
  2. I forgot the (1) in {PIDgrp(1).PID}

The right way to copy a segment from one message to another is;

  1. create context variable as a string:  e.g. context.pidSegment as %String(MAXLEN=2500) 
  2. extract the segment as a string: context.k22.GetValueAt("PIDgrp(1).PID")
  3. use the DTL to set the right field: <assign value='context.pidSegment' property='target.{PIDgrp(1).PID}' action='set' />

Thanks go to Suriya at WRC

Stephen