Question
· Mar 30, 2022

Data transformation

Hi Team,

I am trying to call  Datetime in CUSTOM.Training.Functions class please refer the below line.

<assign value='##class(CUSTOM.Training.Functions).DateTime(source.{PIDgrpgrp().PIDgrp.PID:7.1})' property='target.{PID:7.1}' action='set' />

My Datetime method 

ClassMethod DateTime(DateTime As %Integer)
{
Set Year = msg.SetValueAt(,"PIDgrpgrp().PIDgrp.PID:7.1","set")
Q Year
}
 

But i am not able to get the value of date of birth into the Datetime method, Kindly help how to get data of date of birth value into the method.

Thanks in advance

Product version: Ensemble 2018.1
$ZV: Cache for Windows (x86-64) 2018.1.1 (Build 312_1_18937U) Fri Apr 26 2019 17:58:36 EDT
Discussion (3)2
Log in or sign up to continue

If you're trying to get the 4 digit year from an HL7-formatted time string (YYYYmmddHHMM), your method should look like this (using GetYear rather than DateTime as method name for clarity):

ClassMethod GetYear(pDate As %String) As %String
{
   If ($LENGTH(pDate) > 4)
   {
      Return $EXTRACT(pDate,1,4)
   }
   Return ""
}
}

You would then call that class as follows:

Set Year = ##class(CUSTSOM.Training.Functions).GetYear(source.GetValueAt("PIDgrpgrp(1).PIDgrp.PID:7.1"))

The variable Year should then contain the 4 digit year, or the empty string if the value in PID:7.1 is 4 characters or less.

I see two things here. First, in your Data Transformation, since PIDgrpgrp() repeats, you will need to specify a repetition in the parenthesis like PIDgrpgrp(1) for the first repetition.

<assign value='##class(CUSTOM.Training.Functions).DateTime(source.{PIDgrpgrp(1).PIDgrp.PID:7.1})' property='target.{PID:7.1}' action='set' />

Then, in your DateTime method, you will need to return the year. For example, if the DateTime was formatted YYYYMMDD:

ClassMethod DateTime(DateTime As %Integer)
 {
   Set Year = $EXTRACT(DateTime,1,4)
   Quit Year
 }