Oy!
SQL Server 2008 R2
EPIC Clarity 2010
I have a table with flowsheet IDs called Clarity.dbo.IP_FLWSHT_MEAS. The associated value names are in another table Clarity.dbo.IP_FLO_GP_DATA liked via FLO_MEAS_ID. The value names I'm concerned with are vitals like 'HEIGHT', 'WEIGHT', 'PULSE', 'TEMP', 'RESP', 'CVP', and 'BP'.
The project I'm on calls for the BP to be split out into BP_SYSTOLIC and BP_DIASTOLIC. So the data are like so:
FLO_DIS_NAME MEAS_VALUE
HEIGHT 235
WEIGHT 165
PULSE 100
PULSE 90
PULSE 95
BP 120/80
BP 130/90
RESP 89
But they need to be like so:
FLO_DIS_NAME HEIGHT WEIGHT PULSE BP_SYSTOLIC BP_DIASTOLIC RESP
MEAS_VALUE 235
MEAS_VALUE 165
MEAS_VALUE 100
MEAS_VALUE 90
MEAS_VALUE 95
MEAS_VALUE 120 80
MEAS_VALUE 130 90
MEAS_VALUE 89
It feels like I need a PIVOT, but I don't know how to set it up with the split that needs to happen with BP. Here is what I'm using to parse them into their own fields, but again I don't know how to incorporate this into a PIVOT so the data will display like I need them to.
Any help is appreciated.
SQL Server 2008 R2
EPIC Clarity 2010
I have a table with flowsheet IDs called Clarity.dbo.IP_FLWSHT_MEAS. The associated value names are in another table Clarity.dbo.IP_FLO_GP_DATA liked via FLO_MEAS_ID. The value names I'm concerned with are vitals like 'HEIGHT', 'WEIGHT', 'PULSE', 'TEMP', 'RESP', 'CVP', and 'BP'.
The project I'm on calls for the BP to be split out into BP_SYSTOLIC and BP_DIASTOLIC. So the data are like so:
FLO_DIS_NAME MEAS_VALUE
HEIGHT 235
WEIGHT 165
PULSE 100
PULSE 90
PULSE 95
BP 120/80
BP 130/90
RESP 89
But they need to be like so:
FLO_DIS_NAME HEIGHT WEIGHT PULSE BP_SYSTOLIC BP_DIASTOLIC RESP
MEAS_VALUE 235
MEAS_VALUE 165
MEAS_VALUE 100
MEAS_VALUE 90
MEAS_VALUE 95
MEAS_VALUE 120 80
MEAS_VALUE 130 90
MEAS_VALUE 89
It feels like I need a PIVOT, but I don't know how to set it up with the split that needs to happen with BP. Here is what I'm using to parse them into their own fields, but again I don't know how to incorporate this into a PIVOT so the data will display like I need them to.
Code:
SUBSTRING(flomeas.MEAS_VALUE, 1, ISNULL(NULLIF(CHARINDEX('/', flomeas.MEAS_VALUE) -1, -1), 0) ) as 'BP_SYSTOLIC'
ISNULL(SUBSTRING(flomeas.MEAS_VALUE, NULLIF(CHARINDEX('/', flomeas.MEAS_VALUE) +1, 1), 3), '') as 'BP_DIASTOLIC'
Any help is appreciated.