I am looking for a way to inactivate patients who have never been seen. The active report in GE only looks at last office visit. When we migrated to GE, we brought across 2 years of patient data and many of these patients never came in. Anyone have anything like this? I would like to be able to do by date created.
thanks in advance
Here you go, this script will set patients the Inactive status if they are currently active but do not have a document in their Chart.
UPDATE PatientProfile
SET pstatus = 'I', PatientStatusMId = -901
WHERE pstatus = 'A' AND (SELECT COUNT(*) FROM DOCUMENT WHERE PID = PatientProfile.PID) = 0
AND (SELECT COUNT(*) FROM Appointments WHERE OwnerId = PatientProfile.PatientProfileId) = 0
If you want to see which patients will be inactivated, you can run this script below before you do the one above:
SELECT *
FROM PatientProfile
WHERE pstatus = 'A' AND (SELECT COUNT(*) FROM DOCUMENT WHERE PID = PatientProfile.PID) = 0
AND (SELECT COUNT(*) FROM Appointments WHERE OwnerId = PatientProfile.PatientProfileId) = 0
Thanks, but wont that remove all the new patients who have not come in yet?
I updated the script to look to see if they have any appointments as well.
Nice solution.
Here is another approach. Identified HDID for Obs term used in all encounters which for our practice was "cardio HPI", left join PatientProfile on Obs by PID, listed pts with null value in obs term.
SELECT PatientProfile.Last, PatientProfile.First, PatientProfile.PatientId
FROM PatientProfile LEFT JOIN OBS ON PatientProfile.PId = OBS.PID
WHERE ((OBS.OBSVALU) Is Null) AND (OBS.HDID)=25317)
If you want by date created, add a date condition to the where clause:
BEGIN TRANSACTION
UPDATE PatientProfile
SET pstatus = 'I'
WHERE pstatus = 'A'
AND (SELECT COUNT(*) FROM DOCUMENT WHERE PID = PatientProfile.PID) = 0
AND (SELECT COUNT(*) FROM Appointments WHERE OwnerId = PatientProfile.PatientProfileId) = 0
AND Created < '01/01/2013'
-- COMMIT
- Make you you have at least two backups before doing a mass-delete like this.
- As recommended above, run a SELECT query first to verify which patients will be affected.
- Add a BEGIN TRANSACTION at the first statement, when the update is done and the row count is correct run the COMMIT statement (highlight COMMIT then click Execute).
- Note that using BEGIN TRANSACTION will lock out other users until the changes are committed, so it's best to run this after hours.
don't think you would need a begin transaction and commit, you are not deleting anything, just changing the patients status from Active to Inactive. But, i do agree, you do need to make sure you have a backup of the table just in case you need to rollback the changes. But recommended to run the select script first to view which records are going to be changed.
thanks for all the answers!