I am writing a database for a small scale research project, and there's a requirement that patients involved must be stripped of identifying data. The data will be stripped prior to data entry, and kept externally in an excel file.
I plan to have an external excel file which lists for each patient:
PatientHospital_ID (must not be stored in the database)
PatientAnon_ID (a random number which can be stored in the database)
PatientDOB etc
The main tables in the database will include:
tblEncounterDetails: Encounter_ID (primary key), Patient_ID, EncounterDate, EncounterType etc
tblPatientDetails: Patient_ID (primary key), PatientAnon_ID, PatientAge, PatientSex etc
Each patient can have multiple encounters.
I have two questions:
1)
I would like the main data input form to have a field for typing the patient's Patient_HospitalID (which is not stored in the database). Upon pressing enter/a button, I would like a query to compare this input to the PatientHospitalID in the external excel file, and return the corresponding PatientAnon_ID. If there is more than one matching PatientHospitalID (this is possible), I want only the first PatientAnon_ID returned
Then, I would like this PatientAnon_ID compared to records in tblPatientDetails. If there is a match, the corresponding Patient_ID should be recorded in tblEncounterDetails. Otherwise a new record should be created in tblPatientDetails and the new Patient_ID should be recorded in tblEncounterDetails
2)
Would a better approach be to just take the PatientAnon_IDs from the excel file, copy them into tblPatientDetails and use it as the primary key? I'm just uneasy about not using autonumber for a primary key.
Thanks very much, and sorry for the convoluted question!