THIN DB Patient Enrollment
The PATIENT table of the THIN database contains the patient registration date (REGDATE = date registered with a practice) and the transferred out date (XFERDATE = date a patient left the practice if the transferred to another practice). All patients have a populated registration date. Those who do not transfer (currently still in the practice) will have a missing date for the transferred out date. The goal is to build a period for each patient that shows the valid enrollment in the practice within the database. We calculate this period by overlapping the patient’s registration date with the practice’s computerization start and end dates. These dates exist on the THINPRAC table supplied by EPIC.
The first step is to attach the practice computerization start date (COMP_DT) and last collection date (LASTCOLL_DT) to the patient table:
proc sql;
create table PATIENT as
select a.*, b.COMP_DT, b.LASTCOLL_DT
from thin.PATIENT as a join ancil.THINPRAC0701 as b
on ( trim(a.PRACID) = trim(b.Thin_PracID) );
quit;
Next, initialize the patient enrollment start and end dates to the practice start and end dates:
ENROLL_START_COMPUTER = COMP_DT;
ENROLL_END_COMPUTER = LASTCOLL_DT;
If a patient’s registration date is before the practice computerization date and the patient is currently enrolled in the practice or transfers out of the practice after the practice computerization dates, then the patient’s enrollment dates remain as the the practice computer dates. Graphically, this is:
If the patient registers after the practice is live using a computer system, then adjust the enrollment start date forward to the registration date. Set the enrollment start date to null if a patient registers after the practice computer dates (this should never occur). In this step, patient’s transfer out of the practice after the practice collection date or are currently still enrolled at the practice.
if REGISTRATION_DATE > ENROLL_START_COMPUTER and
REGISTRATION_DATE <= ENROLL_END_COMPUTER
then ENROLL_START_COMPUTER = REGISTRATION_DATE;
else if REGISTRATION_DATE > ENROLL_END_COMPUTER
then ENROLL_START_COMPUTER = . ;
Graphically, this step looks like:
If a patient transfers prior to the practice last collection date, then set the enrollment end date to the transfer date. I had set the transfer date to the year “2500″ for patient’s having a registration status (REGSTAT) not equal to “5″ which indicates “transferred out” status. Patient’s that transfer prior to a practice becoming live in the computer system have an enrollment end date set to null – these patients will eventually be ignored from analyses.
if TRANSFER_DATE >= ENROLL_START_COMPUTER and
TRANSFER_DATE <= ENROLL_END_COMPUTER
then ENROLL_END_COMPUTER = TRANSFER_DATE;
else if TRANSFER_DATE < ENROLL_START_COMPUTER and year(TRANSFER_DATE) ^= 2500
then ENROLL_END_COMPUTER = . ;
Graphically, this step looks like:
Patient’s that register to the practice and transfer out of the practice within the practice’s computerization start and end dates will have the enrollment dates equal to the patient registration and transfer dates. The above SAS code handles this situation and this graphically is seen as:



