Jeff,
Well, I'm embarassed. In my first post in this thread, I wasn't fully awake and my scope examples were a combination of scope and filter syntax which, of course, can't be done. So please ignore my earlier post.
For complete data, i.e. complete last name and complete first name, you could do something this simple:
index on upper(last)+upper(first) to whatever
set scope to upper(cLast+cFirst)
go top
And this would show all people with the given first and last name.
But with only partial matches finding the records you want gets complicated. Since you can't use syntax similar to filters with scopes, then you have to scope on one field only then filter the rest. Determining which field to use as a scope can be complicated. You could build four indexes, one for each piece of data. Then you have to pick which index to use as the scope. I guess just using the first non-empty field, something like this:
- Code: Select all Expand view
cLast:= upper(rtrim(cLast))
cFirst:= upper(rtrim(cFirst))
cID:= rtrim(cID)
cMRN:= rtrim(cMRN)
do case
case ! empty(cLast)
set index to last
set scope to cLast
set filter to FIRST=cFirst .and. ID=cID .and. MRN=cMRN
go top
case ! empty(cFirst)
set index to first
set scope to rtrim(upper(cFirst))
set filter to LAST=cLast .and. ID=cID .and. MRN=cMRN
go top
case ! empty(cID)
set index to id
set scope to rtrim(cID)
set filter to LAST=cLast .and. FIRST=cFirst .and. MRN=cMRN
go top
case ! empty(cMRN)
set index to mrn
set scope to rtrim(cMRN)
set filter to LAST=cLast .and. FIRST=cFirst .and. ID=cID
go top
endcase
This should still be quite fast--way faster than a filter on the entire database. Even if you just enter a name (first or last) you should only get a few dozen records in the scope (depending on the database's size), then you filter those.
Let's digress for a minute. The problem seems to be how to find a patient's record. Let's consider this in generalities.
Most common last name in the USA is Smith. It is 1 percent of the population.
http://names.mongabay.com/most_common_surnames.htmSo out of a million records, 1 percent, or 10000 records, will be Smith. But if you add the most common first name, James at 3.318% (
http://names.mongabay.com/male_names.htm), you would get only:
10000 * .03318 = 331 records of James Smith's
OK, 331 names is still a lot for a user to browse through looking for one record. And without the ID or MRN, how would they determine this?
Let's consider DOB (date of birth). Assuming everyone lives to be 100 or less, we have:
1/365 * 100 = 0.0000274 or, 0.00274% chance of having any given DOB
So out of 1 million records, there will be 311 James Smith's, and 331 * .00274 = 0.906 James Smith's will have any given DOB. Now we have narrowed it down to 1 person out of a million. With a larger database, say 10 million, you will still have 9 people named James Smith with a given DOB so you will have to narrow those down using additional data, such as street address, phone, etc.
So, last name plus first name plus DOB seems to be a good set of information to find any given record out of 1 million records. Every patient will know these bits of information. However, the chance of a patient knowing their ID or MRN is probably slim to none. If the ID or MRN is known to the user these may be useful and they should be unique numbers so either one should be the only information needed. Actually, I am not sure of the difference between ID and MRN?
Anyhow, using my above scopes and filters, the user should be able to find anyone using either last, first, and DOB, or ID, or MRN. If they are entering ID or MRN, then that is the only field needed. This is assuming they have the entire ID or MRN.
Note that my above example of a DO CASE with scopes and filters will have to be modified to add DOB.
I am not sure how often the user doesn't have the patient's full name so I don't know how much of an issue it is to provide partial matching. Perhaps you could get even more sophisticated and try something like this:
- Code: Select all Expand view
index on upper(last)+upper(first) to ...
set scope to upper(cLast+cFirst) // assume complete full name
go top
if eof() // then must not be complete full name
// add the DO CASE in my example above
else
// set ID and MRN filters here
endif
Another idea. Once the user starts typing in either ID or MRN all the other fields are disabled. Then you don't need to program for all the different possibilities. If they have the ID or MRN they don't need anything else to find the record.
So many possiblities. Like I said, it can get complicated, but you could really improve the speed by programming for all the possibilities.
You might want to create some use cases before programming.
Regards,
James