Hi I want to check patient class in multiple rules, since the message structure is different to reach out to patient class value, i created a method to get the patient class and put it in a variable. This variable i can use in multiple rules. But somehow function is not able to read the HL7 message. Any tips. In rules i have this assign line. ![](/sites/default/files/inline/images/images/image(960).png) Function code looks like this, but in the msg pHL7 dont contain any. I tried getPatientClass(HL7) as well as getPatientClass(HL7.Source) ClassMethod getPatientClass(pHL7 As EnsLib.HL7.Message) As %String
{ try{
SET msgType = pHL7.GetValueAt("MSH:9") //MSH:MessageType.TriggerEvent</p>

IF msgType="A39"||msgType="A40"//checing merge msgs
 return pHL7.GetValueAt("PIDgrp(1).PV1:PatientClass")}

IF msgType="A45"{
 return pHL7.GetValueAt("MRGgrp(1).PV1:PatientClass")}

IF msgType="A20"||msgType="A30"||msgType="A47"//checking merge msgs
 return "U"}

IF msgType="O01"||msgType="O11"||msgType="O09"//checking medication msgs
 return pHL7.GetValueAt("PIDgrp.PV1grp.PV1:PatientClass")}

IF msgType="R01"//checking lab msgs
 return pHL7.GetValueAt("PIDgrpgrp(1).PIDgrp.PV1grp.PV1:PatientClass")}
 
IF msgType="T11"||msgType="T02"||msgType="T04"||msgType="T08"//checking document msgs
 return pHL7.GetValueAt("PV1:PatientClass")}

return pHL7.GetValueAt("PV1:PatientClass")
}
Catch {
return "U" //return unknown in case of error so validation will be ignore
}
}
 

</body></html>