Question
· Aug 23, 2023

ERROR #6232 Data type validation error while using %Date Property

Hi Community ,

I am using %Date Property for defining one csv source message class .Please refer below class

Class CSVtoHL7. Inputfile.Record  Extends  ,(%XML.Adaptor, Ens.Request, EnsLib.RecordMap.Base) [ Inheritance = right, ProcedureBlock ]

{

Property ID As %Integer;

Property LastName As %String;

Property FirstName As %String;

Property MiddleName As %String;

Property DOB As %Date;

Property Gender As %String;
}

Please refer to data transformation class

XData DTL [ XMLNamespace = "http://www.intersystems.com/dtl]
{
<transform sourceClass='CSVtoHL7.Inputfile.RecordtargetClass='EnsLib.HL7.Message' targetDocType='2.5:ADT_A01' create='new' language='objectscript' >
<assign value='source.ID' property='target.{PID:SetIDPID}' action='set' />
<assign value='source.FirstName' property='target.{PID:PatientName().FamilyName}' action='set' />
<assign value='source.MiddleName' property='target.{PID:PatientName().GivenName}' action='set' />
<assign value='source.Gender' property='target.{PID:AdministrativeSex}' action='set' />
<assign value='$zdatetime($zdatetimeh(source.DOB,7,,,,,,,,""),3)' property='target.{PID:DateTimeofBirth.Time}' action='set' />
</transform>
}

Property source.DOB Is throwing ERROR #6232 Datatype validation failed for tag ,DOB

Input value i am giving for DOB is  MM/DD/YYYY

If i using other format of dates it is giving 1840-12-31 Which is default date 

Can anyone help me how to resolve this error

 

Thanks,

Smythee

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

Your transformation produces  a YYYY-MM-DD HH:mm:SS string
in contradiction 
Property DOB As %Date;   expects an Integer similar to +$h 
The error is reported during Validation before %Save() of  your record

  • either you change  Property DOB As %String;
  • or use '$zdateh(source.DOB,7,,,,,,,,"")'   then ##class(%Date).IsValid(...)  is happy

Hello Smythe,

I agree with @Robert Cemper points. The %Date datatype is for +$H which means numeric date value. Not an string. You should modify the datatype of the property or use string functions.

IRISMYDEV>s obj = ##Class(CSVtoHL7.Inputfile.Record).%New()
IRISMYDEV>s obj.DOB="12/12/1993"
IRISMYDEV>zw ##Class(%Date).IsValid(obj.DOB)
"0 "_$lb($lb(7207,"12/12/1993",,,,,,,,$lb(,"IRISMYDEV",$lb("e^IsValid+1^%Library.Date.1^1","e^^^0"))))/* ERROR #7207: Datatype value '12/12/1993' is not a valid number */
 
IRISMYDEV>w $SYSTEM.OBJ.DisplayError()
ERROR #7207: Datatype value '12/12/1993' is not a valid number1
IRISMYDEV>s obj = ##Class(CSVtoHL7.Inputfile.Record).%New()
IRISMYDEV>s obj.DOB=$ZDateH("12/12/1993")
IRISMYDEV>zw ##Class(%Date).IsValid(obj.DOB)
1

As we mentioned above the DOB should have +$H value instead of MM/DD/YYYY. However you can try the below

If DOB is date format

IRISMYDEV>set dob="12/01/1993"
IRISMYDEV>write $translate($ZDT($ZDTH(dob),3)," ","T")_"Z"
1993-12-01T00:00:00Z

If DOB is +$H value

IRISMYDEV>set dob=+$H
IRISMYDEV>write $translate($ZDT(d_",00000",3)," ","T")_"Z"
2023-08-24T00:00:00Z

Hi ,

I am able to execute this code in terminal but not able use the same conversion in Data transformation still for me it is throwing Datatype validation error 

The reason why cannot change property of DOB to %String the many classes are dependent on the Source message class

Is there any other way  i can convert DOB form MM/DD/YYYY to YYYY-MM-DDT00:00:00Z ?

I'm not sure why the request class CSVtoHL7.Inputfile.Record inherits from right. All the request and response are required persistent object. This will be used to display the entire flow in the visual trace section. I have attached some sample below.

You can add a property setter method for property DOB and modify the value from MM/DD/YYYY to +$H value. This will keep the internal date format in database.

Class CSVtoHL7.Inputfile.Record Extends (Ens.Request, %XML.Adaptor, EnsLib.RecordMap.Base) [ ProcedureBlock ]
{
Property ID As %Integer;
Property LastName As %String;
Property FirstName As %String;
Property MiddleName As %String;
Property DOB As %Date;
Method DOBSet(pDate) As %Status
{
    Set i%DOB= $ZDH(pDate)
    Quit $$$OK
}
Property Gender As %String;
ClassMethod createObj() As CSVtoHL7.Inputfile.Record
{
    Set obj = ##class(CSVtoHL7.Inputfile.Record).%New()
    Set obj.DOB="12/30/2001"
    Set obj.FirstName="Test"
    Set obj.ID=12345
    Set obj.MiddleName = "middle"
    Set obj.Gender="M"
    return obj
}
}

Create a object for the request class and send to Transformation. you can use the logic $translate($ZDT(source.DOB_",0",3)," ","T")_"Z" in DTL to convert the internal date format to required output 2023-08-24T00:00:00Z. You can refer the DTL sample below

Class CSVtoHL7.DTL.Record Extends Ens.DataTransformDTL [ DependsOn = (CSVtoHL7.Inputfile.Record, EnsLib.HL7.Message) ]
{

Parameter IGNOREMISSINGSOURCE = 1;

Parameter REPORTERRORS = 1;

Parameter TREATEMPTYREPEATINGFIELDASNULL = 0;

XData DTL [ XMLNamespace = "http://www.intersystems.com/dtl" ]
{
<transform sourceClass='CSVtoHL7.Inputfile.Record' targetClass='EnsLib.HL7.Message' targetDocType='2.5:ADT_A01' create='new' language='objectscript' >
<assign value='source.ID' property='target.{PID:SetIDPID}' action='set' />
<assign value='source.FirstName' property='target.{PID:PatientName().FamilyName}' action='set' />
<assign value='source.MiddleName' property='target.{PID:PatientName().GivenName}' action='set' />
<assign value='source.Gender' property='target.{PID:AdministrativeSex}' action='set' />
<assign value='$translate($ZDT(source.DOB_",0",3)," ","T")_"Z"' property='target.{PID:DateTimeofBirth.Time}' action='set' />
</transform>
}

}

output

Hi ,

I am able to execute the above date conversion in Ensemble data transformation 

when i am trying to do the same in IRIS i am only getting output upto 1974-11-01T00:00:00

Please refer to the below code i am using

<assign value='$translate($ZDT($ZDTH(source.MemberDOB),3)," ","T")_"Z"' property='target.Patient.BirthTime' action='set' />

Is there any difference i need to know in IRIS date and time conversions?

Hello @Smythe Smythee 

There is no difference between ensemble and IRIS instance. In your case, the source.MemberDOB is an date( ex 01/01/2000) and the conversion is working perfectly. Can you check the input of the memberDOB before conversion and just take a quick look of the previous samples.

USER>write $ZV
IRIS for Windows (x86-64) 2023.1 (Build 229) Fri Apr 14 2023 17:36:18 EDT
USER>set DOB="01/01/1999"
 
USER>write $translate($ZDT($ZDTH(DOB),3)," ","T")_"Z"
1999-01-01T00:00:00Z

The same code is works in IRIS Interoperability DTL as well.

<assign value='$translate($ZDT($ZDTH(source.DOB),3)," ","T")_"Z"' property='target.{PID:DateTimeofBirth}' action='set' />

 

The HS.SDA3.TimeStamp datatype class  accepts both YYYY-MM-DDT00:00:00Z and YYYY-MM-DDT00:00:00 values but truncates the additional date values if the length is more than 19 in some system methods such as IsValid, LogicalToXSD methods while performing exports. I have verified and This changes happened whenever it converts to XML. However the actual entire value is persist YYYY-MM-DDT00:00:00Z in the container object. Container object have capability to export both XML and JSON as a stream by using ToJSON() method. You can run the DTL programmatically to get the container object to verify. 

SAMPLES> write container
2@HS.SDA3.Container
SAMPLES> write container.Patient
3@HS.SDA3.Patient
SAMPLES> write container.Patient.BirthTime
1993-12-12T00:00:00Z

I used the DTL generated container object value for another DTL source to generate a FHIR discrete resource. It works. The BirthTime is same as the expected value

{
  "resourceType": "Patient",
  "birthDate": "1993-12-12T00:00:00Z"
}