I'm working with an EMR that has a proprietary query designer so I'm somewhat limited in what I can do as far as SQL commands.
I have one field (PTC_BASIC.MENTAL_STATUS) that puts a 1 if the field is checked and 0 if it is not. For instance if box 1 and box 6 are both checked it will return 1000010.
I need to write a report that will return the values that are checked so if the first character is a 1 return 'Oriented', if character 2 = 1 then return 'Forgetful'. If 2 boxes are checked then both values should be returned.
Here is what I have, but I'm only getting data returned if all fields are checked.
Case WHEN SUBSTRING(PTC_BASIC.MENTAL_STATUS,1,1) = 1 then 'Oriented' end + ' ' + Case WHEN SUBSTRING(PTC_BASIC.MENTAL_STATUS,2,1) = 1 then 'Comatose' end + ' ' + Case WHEN SUBSTRING(PTC_BASIC.MENTAL_STATUS,3,1) = 1 then 'Forgetful' End + ' ' + Case WHEN SUBSTRING(PTC_BASIC.MENTAL_STATUS,4,1) = 1 then 'Depressed' End + ' ' + Case WHEN SUBSTRING(PTC_BASIC.MENTAL_STATUS,5,1) = 1 then 'Disoriented' End + ' ' + Case WHEN SUBSTRING(PTC_BASIC.MENTAL_STATUS,6,1) = 1 then 'Lethargic' End + ' ' + Case WHEN SUBSTRING(PTC_BASIC.MENTAL_STATUS,7,1) = 1 then 'Agitated' End
So based on a value of 1000010 I would like the output to be Oriented Lethargic