so here goes, and thanks Tom for enlightening us.
regards, ganesh seshadri, indiana regional
-----Original Message-----
From: Thomas Stephen Laxar [mailto:tsl...@mail.cho.org]
Sent: Tuesday, October 14, 2008 12:13 PM
To: tsl...@mail.cho.org; Ganesh Seshadri
Subject: RE: SQL Query Examples
Ganesh:
One more thing. If you are able to send attachments to Meditech-L, it
is okay to post my samples. Others might be interested.
My Meditech-L account is MOX and we have attachment options turned off.
Thomas Stephen Laxar
Coordinator, Hospital Information Systems Children's Hospital Oakland
tsl...@mail.cho.org
phone: 510-428-3833
The email message (and any attachments) is for the sole use of the
intended
recipient(s) and may contain confidential information. Any unauthorized
review, use, disclosure or distribution is prohibited. If you are not
the intended recipient, please contact the sender by reply email and
destroy all copies of the original message (and any attachments).
-----Original Message-----
From: Thomas Stephen Laxar [mailto:tsl...@mail.cho.org]
Sent: Monday, October 13, 2008 10:10 AM
To: 'Ganesh Seshadri'
Subject: RE: SQL Query Examples
Ganesh:
I haven't figured out how to handle that problem either. Your idea of
unions sounds pretty good.
One strategy I have used is to start in AbstractData. All accounts have
an AdmitDateTime value in that table. The only downside is if you need
to pick up accounts in B/AR that have been cancelled. They won't exist
in ABS, but they stay in B/AR, especially if there are charges posted to
them.
I haven't been able go to MUSE in some time. We have a $0.00 education
and travel budget. I did go to the Regional meeting in San Jose
Regional a few years ago because it was close enough to commute. I was
going to pay my own fees as well, but a budget exception happened to
take care of that.
So an educational session sounds fun, but maybe not feasible in these
difficult financial times. It doesn't help that our case load is 67%
Medi-Cal (our version of Medicaid). That could put our operations
seriously at risk as the economy contracts.
As for paradigm shifts, I thought that SQL was going to be the be all
and end all in 1988. I began to study it then. Next thing I knew, I
was programming in Magic and didn't see any SQL until maybe 1998 if that
is when DR came to be. We were the second DR hospital. So it turned
out to be a lucky, if belated, guess at what would come to pass.
Thomas Stephen Laxar
Coordinator, Hospital Information Systems Children's Hospital Oakland
tsl...@mail.cho.org
phone: 510-428-3833
The email message (and any attachments) is for the sole use of the
intended
recipient(s) and may contain confidential information. Any unauthorized
review, use, disclosure or distribution is prohibited. If you are not
the intended recipient, please contact the sender by reply email and
destroy all copies of the original message (and any attachments).
-----Original Message-----
From: Ganesh Seshadri [mailto:gses...@indianarmc.org]
Sent: Monday, October 13, 2008 6:07 AM
To: tsl...@mail.cho.org
Subject: RE: SQL Query Examples
thanks a lot; it's logic like this that I typically need and have never
taken the time to properly learn.
Same goes for basic things like the equivalent of going through BAR.PAT
bar.acct using the adm.ser or dis.ser index - in NPR you can do it with
your eyes closed. in DR, since there isn't a field for bar.adm.ser or
bar.dis.ser that can be indexed (at least I don't know how to), what
I've done is indexed specific individual fields such as Admit.date,
Discharge.date & Service.date, select on them and then try to union the
results. Again, I don't have the faintest idea if this is a reasonable
way or if there are far more straightforward approaches.
If you haven't already, you ought to do a session at MUSE specific to
SQL as it applies to the DR. There'll be dinosaurs like me who'll
benefit greatly - perhaps those of us who thought that relational DB
will never make it because its performance in 16KB/32KB systems was too
slow to be useful in real life didn't take note when the paradigm
shifted.
As always, thanks for your help. regards, ganesh
-----Original Message-----
From: Thomas Stephen Laxar [mailto:tsl...@mail.cho.org]
Sent: Friday, October 10, 2008 5:34 PM
To: Ganesh Seshadri
Subject: RE: SQL Query Examples
Ganesh:
The tricky part here is B/AR uses different dates for inpatients and
outpatients. I would avoid that issue by using the charge service date.
The altcode really does relate to the charge, not the visit.
So, you could try something like this:
Cpt4 = ISNULL((
SELECT AltCode.Code
FROM LiveDb.dbo.DBarProcAltCodeEffectDates AltCode
WHERE Chgs.SourceID = AltCode.SourceID
AND Chgs.TransactionProcedureID =
AltCode.ProcedureID
AND AltCode.TypeID = 'CPT-4'
AND AltCode.EffectiveDateTime = (
SELECT MAX(AltCode.EffectiveDateTime)
FROM LiveDb.dbo.DBarProcAltCodeEffectDates
AltCode
WHERE Chgs.SourceID = AltCode.SourceID
AND Chgs.TransactionProcedureID =
AltCode.ProcedureID
AND AltCode.TypeID = 'CPT-4'
AND AltCode.EffectiveDateTime <=
Chgs.ServiceDateTime
)
The additional code is the last line:
AND AltCode.EffectiveDateTime <= Chgs.ServiceDateTime
Sorry about the funny indents. Email isn't the greatest for formatting
code.
Thomas Stephen Laxar
Coordinator, Hospital Information Systems Children's Hospital Oakland
tsl...@mail.cho.org
phone: 510-428-3833
The email message (and any attachments) is for the sole use of the
intended
recipient(s) and may contain confidential information. Any unauthorized
review, use, disclosure or distribution is prohibited. If you are not
the intended recipient, please contact the sender by reply email and
destroy all copies of the original message (and any attachments).
-----Original Message-----
From: Ganesh Seshadri [mailto:gses...@indianarmc.org]
Sent: Friday, October 10, 2008 1:19 PM
To: tsl...@mail.cho.org
Subject: RE: SQL Query Examples
Tom, hate to bug you, but just one question - if you can think of it
without wasting any of your time - instead of "SELECT
MAX(AltCode.EffectiveDateTime)" that you have listed in one of your
procedures, what would you put if you needed the most recent date not
later than service/discharge date of the account?
Again, thanks a million. regards, ganesh -----Original Message-----
From: Thomas Stephen Laxar [mailto:tsl...@mail.cho.org]
Sent: Friday, October 10, 2008 3:05 PM
To: Ganesh Seshadri
Subject: SQL Query Examples
Ganesh:
My Meditech-L account is for MOX and I can't attach files. So I am
sending you a couple of examples rather than posting them. They were
done years apart and show a transformation in my approach to coding SQL
queries.
The demographic example uses lots of JOINS. I have found that JOINS are
very time and resource intensive. So I currently will use many
subselects in the SELECT part of the query instead. This means a lot
more coding, but the performance is way better.
By the way, the WHERE statement in the example is a dummy. The real
WHERE statement references a table our own database of accounts that
have already been sent as a way of filtering out duplicates. You
wouldn't be able to run that version. This one should run as it is more
generic.
The transaction file is for a completely different profee vendor. It
references a group response that has a list of GL departments that are
using that vendor. It does list a CPT code and takes effective date
into consideration.
Let me know if you have any questions about these examples.
Thomas Stephen Laxar
Coordinator, Hospital Information Systems Children's Hospital Oakland
tsl...@mail.cho.org
phone: 510-428-3833
The email message (and any attachments) is for the sole use of the
intended
recipient(s) and may contain confidential information. Any unauthorized
review, use, disclosure or distribution is prohibited. If you are not
the intended recipient, please contact the sender by reply email and
destroy all copies of the original message (and any attachments).
Ganesh:
tsl...@mail.cho.org
phone: 510-428-3833
Ganesh:
tsl...@mail.cho.org
phone: 510-428-3833
Ganesh:
AND AltCode.EffectiveDateTime <= Chgs.ServiceDateTime
tsl...@mail.cho.org
phone: 510-428-3833
Ganesh:
tsl...@mail.cho.org
phone: 510-428-3833
CONFIDENTIALITY NOTICE
Information contained in this transmission, together with any other documents or attachments, is privileged and confidential, and is intended only for the use of the individual or entity to which it is addressed. This transmission may contain information or materials protected by the applicable laws of the State of Connecticut, and /or protected health information as defined by the Health Insurance Portability and Accountability Act of 1996 (HIPAA). This information is intended exclusively for the use of the individual or entity named as addressee(s). The authorized recipient of this information is STRICTLY PROHIBITED from disclosing this information after its stated need has been fulfilled. Misuse or distribution of the information contained in this transmission is punishable by civil and/or criminal penalties under state or federal law.
If you are not the intended recipient, you are hereby notified that any disclosure, dissemination, saving, printing, copying, or action taken in reliance on the contents of these documents of this message, or any attachment, is strictly prohibited. Please notify the original sender (only) immediately by telephone or by reply e-mail and delete this message, along with any attachments from your computer immediately.
====================================
Don't forget to visit the meditech-l web site at MTUsers.net. Check out the vendors who have donated to the meditech-l. Make sure to support them for supporting you.
If you appreciate the benefits of the meditech-l, be sure to make a donation to help keep it going. The form is at MTUsers.net. Skip that next latte, fast food burger, or milk shake and donate $7, $5, or even $3 to the meditech-l today.
The meditech-l archives (and other tips) can be found at
http://mtusers.net/zarchives
Job opportunites in the Meditech community can be found at
http://mtusers.net/zjobs
Some of that SQL source code looks pretty ugly.
Uglier than NPR in my humble opinion.
I will stick with NPR until it dies...
James Purvins
Inland Northwest Health Services
(509) 232-8384
This e-mail and any attachments are confidential and may also be
privileged. If you are not the named recipient, or have otherwise
received this communication in error, please delete it from your inbox,
notify the sender immediately by replying to the message, and do not
disclose its contents to any other person, use the information for any
purpose or store or copy the information in any medium. Thank you for
your cooperation
-----Original Message-----
From: meditech-...@mtusers.com
[mailto:meditech-...@mtusers.com] On Behalf Of Ganesh Seshadri
Sent: Tuesday, October 14, 2008 10:31 AM
To: medit...@MTUsers.com
Subject: [MEDITECH-L] DR SQL Query Examples
Ganesh:
tsl...@mail.cho.org
phone: 510-428-3833
Ganesh:
tsl...@mail.cho.org
phone: 510-428-3833
Ganesh:
AND AltCode.EffectiveDateTime <= Chgs.ServiceDateTime
tsl...@mail.cho.org
phone: 510-428-3833
Ganesh:
tsl...@mail.cho.org
phone: 510-428-3833
I think the best overall use of the DR is to use along with the
Medisolve solutions(or other similar tools). They're pretty much taken
the guess work out of writing the SQL for you.. Making it much more user
friendly.
Jim Joyner - Quality Svcs.
St. Patrick Hospital
406-327-1918
-----Original Message-----
From: Purvins, James A. [mailto:Pur...@inhs.org]
Sent: Wednesday, October 15, 2008 11:43 AM
To: Ganesh Seshadri; medit...@MTUsers.com
I once saw a $T macro written in COBOL...kinda scarey actually...
So what $T lacks in readability is made up for the fact that its pretty
easy to write self documenting code in Magic .... if the programmer is
up to it that is...