We have a simple table called "patient list" representing patient visit records in a hospital system PatientApp, and we wrote a script to go down each row and automate some tasks within PatientApp for each patient visit record.
The problem is that we have some junk data in the table that messes up our script, so we want to clean up the patient list.
We need 4 new lists:
1. tblvisits - This is the patient list but with all "bad" patients removed.
2. tblpatients - This is a list of each unique patient and not the individual visits (basically query will only select some columns and remove duplicate rows)
3. tblvisits_bad - This is where all the "bad" patients' visits need to be
4. tblpatients_bad - This is the list of all "bad" patients
We have written out the rules for what makes a good patient and a bad one, and we just need an expert at writing SQL queries to be able to generate the lists we need.