PC Review


Reply
Thread Tools Rate Thread

Counting Patient visits

 
 
johngl
Guest
Posts: n/a
 
      8th Sep 2006
This is another question about eliminating accounting entries in a
clinical database, yet retaining the valid record. Latest wrinkle is
being able to sum the visits to the doctor, and the units of services
received. Here's the problem: If a visit is wrongly coded, then a
reverse entry is made as follows.
PTID CODE UNITS
1 100 2
1 100 -2
1 110 2

This is actually one visit for code 110 and the patient received 2
units of service. Thanks to a member's advice, I used:

SELECT ptid, code, sum(units) AS unit
FROM PTDB
GROUP BY ptid, code
HAVING (((sum(units))<>0));

This gives me a correct unit of service (I checked manually), but I
still need a field with a count of 1 for the visit. Most reports focus
on the number of visits taken, not how long much time you spent in the
office. Is there a way to get both sum of units and count of visits?
This is pretty basic stuff to most people, but it's killing me. Thks.

 
Reply With Quote
 
 
 
 
James A. Fortune
Guest
Posts: n/a
 
      8th Sep 2006
johngl wrote:
> This is another question about eliminating accounting entries in a
> clinical database, yet retaining the valid record. Latest wrinkle is
> being able to sum the visits to the doctor, and the units of services
> received. Here's the problem: If a visit is wrongly coded, then a
> reverse entry is made as follows.
> PTID CODE UNITS
> 1 100 2
> 1 100 -2
> 1 110 2
>
> This is actually one visit for code 110 and the patient received 2
> units of service. Thanks to a member's advice, I used:
>
> SELECT ptid, code, sum(units) AS unit
> FROM PTDB
> GROUP BY ptid, code
> HAVING (((sum(units))<>0));
>
> This gives me a correct unit of service (I checked manually), but I
> still need a field with a count of 1 for the visit. Most reports focus
> on the number of visits taken, not how long much time you spent in the
> office. Is there a way to get both sum of units and count of visits?
> This is pretty basic stuff to most people, but it's killing me. Thks.
>


Air SQL:

SELECT sum(1) AS visits, ptid, code, sum(units) AS unit FROM PTDB GROUP
BY ptid, code HAVING (((sum(units))<>0));

Only records that have not been cancelled will show up so the number of
visits should be the same as the number of records returned by the query.

James A. Fortune
(E-Mail Removed)

Wisconsin produces more cranberries than any other state. --
http://www.wiscran.org/
 
Reply With Quote
 
johngl
Guest
Posts: n/a
 
      8th Sep 2006
I just ran your code, here is an actual set of 6 records, same patient:
PTID CODE UNITS
1 100 1
1 100 1
1 100 -1
1 100 1
1 100 -1
1 100 1

These are all the same code, if it works on one, it will work on all
codes. The correct result is 2 units and 2 visits, the bottom four are
a wash, leaving the top two. Your code produced 6 visits and 2 units. I
would be happy just to get the visits. Not sure why your code did not
work, it looks correct.

Any suggestions? Thanks again.

James A. Fortune wrote:
> johngl wrote:
> > This is another question about eliminating accounting entries in a
> > clinical database, yet retaining the valid record. Latest wrinkle is
> > being able to sum the visits to the doctor, and the units of services
> > received. Here's the problem: If a visit is wrongly coded, then a
> > reverse entry is made as follows.
> > PTID CODE UNITS
> > 1 100 2
> > 1 100 -2
> > 1 110 2
> >
> > This is actually one visit for code 110 and the patient received 2
> > units of service. Thanks to a member's advice, I used:
> >
> > SELECT ptid, code, sum(units) AS unit
> > FROM PTDB
> > GROUP BY ptid, code
> > HAVING (((sum(units))<>0));
> >
> > This gives me a correct unit of service (I checked manually), but I
> > still need a field with a count of 1 for the visit. Most reports focus
> > on the number of visits taken, not how long much time you spent in the
> > office. Is there a way to get both sum of units and count of visits?
> > This is pretty basic stuff to most people, but it's killing me. Thks.
> >

>
> Air SQL:
>
> SELECT sum(1) AS visits, ptid, code, sum(units) AS unit FROM PTDB GROUP
> BY ptid, code HAVING (((sum(units))<>0));
>
> Only records that have not been cancelled will show up so the number of
> visits should be the same as the number of records returned by the query.
>
> James A. Fortune
> (E-Mail Removed)
>
> Wisconsin produces more cranberries than any other state. --
> http://www.wiscran.org/


 
Reply With Quote
 
johngl
Guest
Posts: n/a
 
      9th Sep 2006
I just realized the problem. The sum of units is greater than zero, so
all are counted, problem is four of the records have to be deleted. I
should have added that there is a date field and all the adjustments
are made on the same day. I added this below for reference. Even if I
group by date, I still get a positive value for August, and the 3
visits for that day when in fact there is only one (why they do this is
beyond me).

johngl wrote:
> I just ran your code, here is an actual set of 6 records, same patient:
> PTID CODE UNITS DATE
> 1 100 1 Aug 20
> 1 100 1 Aug 20
> 1 100 -1 Aug 20
> 1 100 1 Sept 9
> 1 100 -1 Sept 9
> 1 100 1 Sept 9
>
> These are all the same code, if it works on one, it will work on all
> codes. The correct result is 2 units and 2 visits, the bottom four are
> a wash, leaving the top two. Your code produced 6 visits and 2 units. I
> would be happy just to get the visits. Not sure why your code did not
> work, it looks correct.
>
> Any suggestions? Thanks again.
>
> James A. Fortune wrote:
> > johngl wrote:
> > > This is another question about eliminating accounting entries in a
> > > clinical database, yet retaining the valid record. Latest wrinkle is
> > > being able to sum the visits to the doctor, and the units of services
> > > received. Here's the problem: If a visit is wrongly coded, then a
> > > reverse entry is made as follows.
> > > PTID CODE UNITS
> > > 1 100 2
> > > 1 100 -2
> > > 1 110 2
> > >
> > > This is actually one visit for code 110 and the patient received 2
> > > units of service. Thanks to a member's advice, I used:
> > >
> > > SELECT ptid, code, sum(units) AS unit
> > > FROM PTDB
> > > GROUP BY ptid, code
> > > HAVING (((sum(units))<>0));
> > >
> > > This gives me a correct unit of service (I checked manually), but I
> > > still need a field with a count of 1 for the visit. Most reports focus
> > > on the number of visits taken, not how long much time you spent in the
> > > office. Is there a way to get both sum of units and count of visits?
> > > This is pretty basic stuff to most people, but it's killing me. Thks.
> > >

> >
> > Air SQL:
> >
> > SELECT sum(1) AS visits, ptid, code, sum(units) AS unit FROM PTDB GROUP
> > BY ptid, code HAVING (((sum(units))<>0));
> >
> > Only records that have not been cancelled will show up so the number of
> > visits should be the same as the number of records returned by the query.
> >
> > James A. Fortune
> > (E-Mail Removed)
> >
> > Wisconsin produces more cranberries than any other state. --
> > http://www.wiscran.org/


 
Reply With Quote
 
James A. Fortune
Guest
Posts: n/a
 
      9th Sep 2006
johngl wrote:
> I just realized the problem. The sum of units is greater than zero, so
> all are counted, problem is four of the records have to be deleted. I
> should have added that there is a date field and all the adjustments
> are made on the same day. I added this below for reference. Even if I
> group by date, I still get a positive value for August, and the 3
> visits for that day when in fact there is only one (why they do this is
> beyond me).
>
> johngl wrote:
>
>>I just ran your code, here is an actual set of 6 records, same patient:
>>PTID CODE UNITS DATE
>>1 100 1 Aug 20
>>1 100 1 Aug 20
>>1 100 -1 Aug 20
>>1 100 1 Sept 9
>>1 100 -1 Sept 9
>>1 100 1 Sept 9
>>
>>These are all the same code, if it works on one, it will work on all
>>codes. The correct result is 2 units and 2 visits, the bottom four are
>>a wash, leaving the top two. Your code produced 6 visits and 2 units. I
>>would be happy just to get the visits. Not sure why your code did not
>>work, it looks correct.
>>
>>Any suggestions? Thanks again.
>>
>>James A. Fortune wrote:
>>
>>>johngl wrote:
>>>
>>>>This is another question about eliminating accounting entries in a
>>>>clinical database, yet retaining the valid record. Latest wrinkle is
>>>>being able to sum the visits to the doctor, and the units of services
>>>>received. Here's the problem: If a visit is wrongly coded, then a
>>>>reverse entry is made as follows.
>>>>PTID CODE UNITS
>>>>1 100 2
>>>>1 100 -2
>>>>1 110 2
>>>>
>>>>This is actually one visit for code 110 and the patient received 2
>>>>units of service. Thanks to a member's advice, I used:
>>>>
>>>>SELECT ptid, code, sum(units) AS unit
>>>>FROM PTDB
>>>>GROUP BY ptid, code
>>>>HAVING (((sum(units))<>0));
>>>>
>>>>This gives me a correct unit of service (I checked manually), but I
>>>>still need a field with a count of 1 for the visit. Most reports focus
>>>>on the number of visits taken, not how long much time you spent in the
>>>>office. Is there a way to get both sum of units and count of visits?
>>>>This is pretty basic stuff to most people, but it's killing me. Thks.
>>>>
>>>
>>>Air SQL:
>>>
>>>SELECT sum(1) AS visits, ptid, code, sum(units) AS unit FROM PTDB GROUP
>>>BY ptid, code HAVING (((sum(units))<>0));
>>>
>>>Only records that have not been cancelled will show up so the number of
>>>visits should be the same as the number of records returned by the query.
>>>
>>>James A. Fortune
>>>(E-Mail Removed)
>>>
>>>Wisconsin produces more cranberries than any other state. --
>>>http://www.wiscran.org/

>
>


I see that I made a poor guess about what your data looks like because
of the small sample. I'll try to take a look at it again tomorrow night.

James A. Fortune
(E-Mail Removed)
 
Reply With Quote
 
johngl
Guest
Posts: n/a
 
      9th Sep 2006
Thanks, really appreciate it. The file has over 10 million records,
there is no way I can do the excel thing.
James A. Fortune wrote:
> johngl wrote:
> > I just realized the problem. The sum of units is greater than zero, so
> > all are counted, problem is four of the records have to be deleted. I
> > should have added that there is a date field and all the adjustments
> > are made on the same day. I added this below for reference. Even if I
> > group by date, I still get a positive value for August, and the 3
> > visits for that day when in fact there is only one (why they do this is
> > beyond me).
> >
> > johngl wrote:
> >
> >>I just ran your code, here is an actual set of 6 records, same patient:
> >>PTID CODE UNITS DATE
> >>1 100 1 Aug 20
> >>1 100 1 Aug 20
> >>1 100 -1 Aug 20
> >>1 100 1 Sept 9
> >>1 100 -1 Sept 9
> >>1 100 1 Sept 9
> >>
> >>These are all the same code, if it works on one, it will work on all
> >>codes. The correct result is 2 units and 2 visits, the bottom four are
> >>a wash, leaving the top two. Your code produced 6 visits and 2 units. I
> >>would be happy just to get the visits. Not sure why your code did not
> >>work, it looks correct.
> >>
> >>Any suggestions? Thanks again.
> >>
> >>James A. Fortune wrote:
> >>
> >>>johngl wrote:
> >>>
> >>>>This is another question about eliminating accounting entries in a
> >>>>clinical database, yet retaining the valid record. Latest wrinkle is
> >>>>being able to sum the visits to the doctor, and the units of services
> >>>>received. Here's the problem: If a visit is wrongly coded, then a
> >>>>reverse entry is made as follows.
> >>>>PTID CODE UNITS
> >>>>1 100 2
> >>>>1 100 -2
> >>>>1 110 2
> >>>>
> >>>>This is actually one visit for code 110 and the patient received 2
> >>>>units of service. Thanks to a member's advice, I used:
> >>>>
> >>>>SELECT ptid, code, sum(units) AS unit
> >>>>FROM PTDB
> >>>>GROUP BY ptid, code
> >>>>HAVING (((sum(units))<>0));
> >>>>
> >>>>This gives me a correct unit of service (I checked manually), but I
> >>>>still need a field with a count of 1 for the visit. Most reports focus
> >>>>on the number of visits taken, not how long much time you spent in the
> >>>>office. Is there a way to get both sum of units and count of visits?
> >>>>This is pretty basic stuff to most people, but it's killing me. Thks.
> >>>>
> >>>
> >>>Air SQL:
> >>>
> >>>SELECT sum(1) AS visits, ptid, code, sum(units) AS unit FROM PTDB GROUP
> >>>BY ptid, code HAVING (((sum(units))<>0));
> >>>
> >>>Only records that have not been cancelled will show up so the number of
> >>>visits should be the same as the number of records returned by the query.
> >>>
> >>>James A. Fortune
> >>>(E-Mail Removed)
> >>>
> >>>Wisconsin produces more cranberries than any other state. --
> >>>http://www.wiscran.org/

> >
> >

>
> I see that I made a poor guess about what your data looks like because
> of the small sample. I'll try to take a look at it again tomorrow night.
>
> James A. Fortune
> (E-Mail Removed)


 
Reply With Quote
 
Jeff Boyce
Guest
Posts: n/a
 
      9th Sep 2006
This is just a passing thought...

There's no easy way to tell, in your example, that the Code=100 was, in
fact, an invalid entry.

What if, instead of adding in a counter/reversing entry, you added a single
Yes/No field to the table. The purpose of the Yes/No field is to indicate
"Disregard This Row". Any invalid entries have the value in this field set
to "Yes" (via a checkbox on a form).

Now, all you need to do to get a count of (valid) visits is to use the
Totals query and count the rows where the checkbox/field is NOT "Yes".

Just a thought...

Regards

Jeff Boyce
Microsoft Office/Access MVP

"johngl" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> This is another question about eliminating accounting entries in a
> clinical database, yet retaining the valid record. Latest wrinkle is
> being able to sum the visits to the doctor, and the units of services
> received. Here's the problem: If a visit is wrongly coded, then a
> reverse entry is made as follows.
> PTID CODE UNITS
> 1 100 2
> 1 100 -2
> 1 110 2
>
> This is actually one visit for code 110 and the patient received 2
> units of service. Thanks to a member's advice, I used:
>
> SELECT ptid, code, sum(units) AS unit
> FROM PTDB
> GROUP BY ptid, code
> HAVING (((sum(units))<>0));
>
> This gives me a correct unit of service (I checked manually), but I
> still need a field with a count of 1 for the visit. Most reports focus
> on the number of visits taken, not how long much time you spent in the
> office. Is there a way to get both sum of units and count of visits?
> This is pretty basic stuff to most people, but it's killing me. Thks.
>



 
Reply With Quote
 
johngl
Guest
Posts: n/a
 
      9th Sep 2006
Well, I think there is two potential problems there....
1. If I eliminate all the negative entries, I still have an invalid
positive record, I have to eliminate the two records, when the only
difference is the negative value of the unit. Real problem is combining
an accounting and clinical database in the first place, but that is
another story.
2. I could create an adjustment table of the sums of all negative
values by code, and deduct that from the subtotals of visits by code.
However, that process destroys the integrity of the record, so I cannot
look at variances between codes and age and sex, for example. Can't
analyze aggregated data.

Simple but difficult problem. The total negative records is only a
small percentage of total cases, I could just eliminate the negative
cases, leaving one positive wrong record for 100K wrong vists out of 2
million.


Jeff Boyce wrote:
> This is just a passing thought...
>
> There's no easy way to tell, in your example, that the Code=100 was, in
> fact, an invalid entry.
>
> What if, instead of adding in a counter/reversing entry, you added a single
> Yes/No field to the table. The purpose of the Yes/No field is to indicate
> "Disregard This Row". Any invalid entries have the value in this field set
> to "Yes" (via a checkbox on a form).
>
> Now, all you need to do to get a count of (valid) visits is to use the
> Totals query and count the rows where the checkbox/field is NOT "Yes".
>
> Just a thought...
>
> Regards
>
> Jeff Boyce
> Microsoft Office/Access MVP
>
> "johngl" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > This is another question about eliminating accounting entries in a
> > clinical database, yet retaining the valid record. Latest wrinkle is
> > being able to sum the visits to the doctor, and the units of services
> > received. Here's the problem: If a visit is wrongly coded, then a
> > reverse entry is made as follows.
> > PTID CODE UNITS
> > 1 100 2
> > 1 100 -2
> > 1 110 2
> >
> > This is actually one visit for code 110 and the patient received 2
> > units of service. Thanks to a member's advice, I used:
> >
> > SELECT ptid, code, sum(units) AS unit
> > FROM PTDB
> > GROUP BY ptid, code
> > HAVING (((sum(units))<>0));
> >
> > This gives me a correct unit of service (I checked manually), but I
> > still need a field with a count of 1 for the visit. Most reports focus
> > on the number of visits taken, not how long much time you spent in the
> > office. Is there a way to get both sum of units and count of visits?
> > This is pretty basic stuff to most people, but it's killing me. Thks.
> >


 
Reply With Quote
 
=?Utf-8?B?RG91ZyBGLg==?=
Guest
Posts: n/a
 
      9th Sep 2006
Let's assume your 10M record table is table A.
Append all negatives in table A to a new table B.
Change all negatives in table B to positives (*-1).
Delete negatives from table A.
Join table A and table B deleting matches in table A.
What's left in table A is good stuff?

--
Doug F.


"johngl" wrote:

> Well, I think there is two potential problems there....
> 1. If I eliminate all the negative entries, I still have an invalid
> positive record, I have to eliminate the two records, when the only
> difference is the negative value of the unit. Real problem is combining
> an accounting and clinical database in the first place, but that is
> another story.
> 2. I could create an adjustment table of the sums of all negative
> values by code, and deduct that from the subtotals of visits by code.
> However, that process destroys the integrity of the record, so I cannot
> look at variances between codes and age and sex, for example. Can't
> analyze aggregated data.
>
> Simple but difficult problem. The total negative records is only a
> small percentage of total cases, I could just eliminate the negative
> cases, leaving one positive wrong record for 100K wrong vists out of 2
> million.
>
>
> Jeff Boyce wrote:
> > This is just a passing thought...
> >
> > There's no easy way to tell, in your example, that the Code=100 was, in
> > fact, an invalid entry.
> >
> > What if, instead of adding in a counter/reversing entry, you added a single
> > Yes/No field to the table. The purpose of the Yes/No field is to indicate
> > "Disregard This Row". Any invalid entries have the value in this field set
> > to "Yes" (via a checkbox on a form).
> >
> > Now, all you need to do to get a count of (valid) visits is to use the
> > Totals query and count the rows where the checkbox/field is NOT "Yes".
> >
> > Just a thought...
> >
> > Regards
> >
> > Jeff Boyce
> > Microsoft Office/Access MVP
> >
> > "johngl" <(E-Mail Removed)> wrote in message
> > news:(E-Mail Removed)...
> > > This is another question about eliminating accounting entries in a
> > > clinical database, yet retaining the valid record. Latest wrinkle is
> > > being able to sum the visits to the doctor, and the units of services
> > > received. Here's the problem: If a visit is wrongly coded, then a
> > > reverse entry is made as follows.
> > > PTID CODE UNITS
> > > 1 100 2
> > > 1 100 -2
> > > 1 110 2
> > >
> > > This is actually one visit for code 110 and the patient received 2
> > > units of service. Thanks to a member's advice, I used:
> > >
> > > SELECT ptid, code, sum(units) AS unit
> > > FROM PTDB
> > > GROUP BY ptid, code
> > > HAVING (((sum(units))<>0));
> > >
> > > This gives me a correct unit of service (I checked manually), but I
> > > still need a field with a count of 1 for the visit. Most reports focus
> > > on the number of visits taken, not how long much time you spent in the
> > > office. Is there a way to get both sum of units and count of visits?
> > > This is pretty basic stuff to most people, but it's killing me. Thks.
> > >

>
>

 
Reply With Quote
 
johngl
Guest
Posts: n/a
 
      9th Sep 2006
That should work, will try now. I assumed this would require a select
statement. Your idea should run faster, other select statement takes 3
hours. Thanks, John

Doug F. wrote:
> Let's assume your 10M record table is table A.
> Append all negatives in table A to a new table B.
> Change all negatives in table B to positives (*-1).
> Delete negatives from table A.
> Join table A and table B deleting matches in table A.
> What's left in table A is good stuff?
>
> --
> Doug F.
>
>
> "johngl" wrote:
>
> > Well, I think there is two potential problems there....
> > 1. If I eliminate all the negative entries, I still have an invalid
> > positive record, I have to eliminate the two records, when the only
> > difference is the negative value of the unit. Real problem is combining
> > an accounting and clinical database in the first place, but that is
> > another story.
> > 2. I could create an adjustment table of the sums of all negative
> > values by code, and deduct that from the subtotals of visits by code.
> > However, that process destroys the integrity of the record, so I cannot
> > look at variances between codes and age and sex, for example. Can't
> > analyze aggregated data.
> >
> > Simple but difficult problem. The total negative records is only a
> > small percentage of total cases, I could just eliminate the negative
> > cases, leaving one positive wrong record for 100K wrong vists out of 2
> > million.
> >
> >
> > Jeff Boyce wrote:
> > > This is just a passing thought...
> > >
> > > There's no easy way to tell, in your example, that the Code=100 was, in
> > > fact, an invalid entry.
> > >
> > > What if, instead of adding in a counter/reversing entry, you added a single
> > > Yes/No field to the table. The purpose of the Yes/No field is to indicate
> > > "Disregard This Row". Any invalid entries have the value in this field set
> > > to "Yes" (via a checkbox on a form).
> > >
> > > Now, all you need to do to get a count of (valid) visits is to use the
> > > Totals query and count the rows where the checkbox/field is NOT "Yes".
> > >
> > > Just a thought...
> > >
> > > Regards
> > >
> > > Jeff Boyce
> > > Microsoft Office/Access MVP
> > >
> > > "johngl" <(E-Mail Removed)> wrote in message
> > > news:(E-Mail Removed)...
> > > > This is another question about eliminating accounting entries in a
> > > > clinical database, yet retaining the valid record. Latest wrinkle is
> > > > being able to sum the visits to the doctor, and the units of services
> > > > received. Here's the problem: If a visit is wrongly coded, then a
> > > > reverse entry is made as follows.
> > > > PTID CODE UNITS
> > > > 1 100 2
> > > > 1 100 -2
> > > > 1 110 2
> > > >
> > > > This is actually one visit for code 110 and the patient received 2
> > > > units of service. Thanks to a member's advice, I used:
> > > >
> > > > SELECT ptid, code, sum(units) AS unit
> > > > FROM PTDB
> > > > GROUP BY ptid, code
> > > > HAVING (((sum(units))<>0));
> > > >
> > > > This gives me a correct unit of service (I checked manually), but I
> > > > still need a field with a count of 1 for the visit. Most reports focus
> > > > on the number of visits taken, not how long much time you spent in the
> > > > office. Is there a way to get both sum of units and count of visits?
> > > > This is pretty basic stuff to most people, but it's killing me. Thks.
> > > >

> >
> >


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Counting patient check in Meebers Microsoft Excel Worksheet Functions 13 3rd Jun 2009 09:39 PM
COunting patients visits =?Utf-8?B?TmlyIE4=?= Microsoft Access Queries 2 26th Oct 2007 04:53 AM
counting visits Jackie L Preston Microsoft Access Queries 3 23rd Feb 2007 05:17 PM
Counting patient encounters by provider =?Utf-8?B?cmljaGFyZGI=?= Microsoft Access Queries 4 8th Mar 2005 11:32 PM
Tracking patient visits for different studies Kurt Microsoft Access Database Table Design 5 5th Feb 2004 06:06 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:14 PM.