Sei sulla pagina 1di 2

July 27th 2018 1

Discussion 3.1: Computed Fields


In order to prepare for this discussion, read pages 83 through 85 of Concepts in Database Management,
which discuss Structured Query Language (SQL) and calculated fields.
SQL can be written to generate a field that is not in the database, but whose values can be computed from
existing database fields. A field whose values are derived from existing fields is called a computed field,
or calculated field. Computed fields can involve arithmetic operations such as addition (+), subtraction (-
), multiplication (*), or division (/).
For an example of a computed field, review Example 12 on page 83 of Concepts in Database
Management. In this example, available credit is a computed field. There are fields that store customers’
names and numbers; however, there is no field in the database that stores available credit. Available credit
can be computed by using two fields that are present in the database: CreditLimit and Balance. In this
case, subtract the value in the Balance field from that in the CreditLimit field to calculate available credit.
The SQL for this query would be written as:
SELECT CustomerNum, CustomerName, CreditLimit-Balance AS AvailableCredit
FROM Customer
;
For your initial post, you will use your knowledge of a healthcare, work, or school environment, or create
your own environment, to consider the computed fields that could be created from your selected database.
Then:
 Identify the database (i.e., setting) you are addressing,
 Discuss one field that should be computed, not stored, in that database.
 Provide an approach to compute the field (i.e., What data should be stored, and how would you
compute the field from the stored data?).

Proportion of Days Covered (PDC) is a method of calculating medication adherence


endorsed by the Pharmacy Quality Alliance (PQA). It is calculated by using the
following formula

For example, Rx 123456 is a 30-day prescription with 5 refills. Hence total number of
days’ supply is 30 + (30*5) = 180 days. Each 30 days’ fill can be viewed as an ‘array’ of
days supplied. The FillNumber has an unnormalized relation as it has multiple entries.
FillNumber 00 (Jan 1st 2018), 01 (Feb 14th 2018), 02 (April 1st 2018), 03 (May 4th 2018)
PatientID RxNumber DaysSupply FillNumber Fill Date PeriodStartDate PeriodEndDate
000001 123456 30 -00 - Jan 1st 2018 Jan 1st 2018 Jun 30th 2018
-01 - Feb 14th 2018
-02 - April 1st 2018
-03 - May 4th 2018
July 27th 2018 1

I am not sure if this is the correct way of calculating PDC and would really like to get
feedback on this
SELECT PatientID, PrescriptionNumber, DaysSupply, PeriodStartDate-PeriodEndDate
AS NumberOfDaysinPeriod, sum(FillNumber)*30 AS NumberofDaysinPeriodCovered,
NumberOfDaysin PeriodCovered/NumberOfDaysinPeriod*100 AS
ProportionDaysCovered
FROM Prescriptions

Potrebbero piacerti anche