Output Attribute Values to the view

Instead of just using SUM('fieldname') we call
PatientAttribute_GetFieldValue which may return 'SUM('fieldname')' but
also may return
'PatientAttribute_GetFormattedValue(PatientID,',_attributeid,')' which
gets the actual value