I am trying to update a temp table with patient weight, BP and BMI using their HDID but it is only picking up a random result. I am new and still learning so thank you for all of your help
HDID weight-61 bmi-2788 and BP is 54/53
Update #tmpDiabetes
SET PatientWeight = ro.obsvalue
from patientprofile as pp
join RPTOBS as ro on ro.pid=pp.pid and ro.hdid=61
Take a look at the LASTLABS view. It has one row for the most recent value of every obs term for each patient. It just has the PID, HDID, and MAXLABDATE columns. You can join to patientprofile on PID and OBS to get the OBSVALUE on PID to PID and HDID to HDID and MAXLABDATE on OBSDATE.
It gives me the first value for all patients
Update #tmpDiabetes
SET PatientWeight = ro.obsvalue
from patientprofile as pp
JOIN rptobs as ro ON pp.pid = ro.PId
JOIN lastlabs as ll ON ro.hdid = ll.hdid AND ro.obsdate = ll.maxlabdate AND pp.pid = ll.pid
where ro.hdid = 61
PatientWeight
185 with shoes
185 with shoes
185 with shoes
185 with shoes
185 with shoes
185 with shoes
185 with shoes
185 with shoes
185 with shoes
185 with shoes
185 with shoes