Sunteți pe pagina 1din 4

SQL Writing Technique –

Total Duration – 1 hour

Part 1-

You are the new data analyst for Westborough Medical Associates. They have the data available for
March but are looking for some analysis. Based on the data available below, represent in sql queries how
you would provide them the data they are looking for. You can either use mysql or MSSQL query format.

Enc - List of all appointments

encounterid patientid doctorid date visittype status

26350 10085 122 3/1/2014 NOB PEN


26356 9795 122 3/2/2014 AV - PEN
Femal
26301 9985 122 3/3/2014 CON ARR
26306 10031 122 3/5/2014 F/U PEN
26304 10031 122 3/6/2014 F/U PEN
26305 10031 9124 3/7/2014 Procedure ARR
26302 9975 9123 3/7/2014 NOB ARR
26342 10082 122 3/8/2014 NOB PEN
26364 10089 122 3/9/2014 NOB PEN
26357 10034 122 3/9/2014 OV PEN
26309 10068 9123 3/10/2014 CON CHK
26313 10072 122 3/10/2014 F/U PEN
26315 10073 122 3/11/2014 NP PEN
26312 10072 122 3/11/2014 NP ARR
26326 10077 9124 3/20/2014 NP ARR
26327 10039 9123 3/20/2014 ESTOB ARR
26369 9963 122 3/23/2014 F/U ARR
26371 9374 122 3/25/2014 CON PEN
26362 10088 122 3/26/2014 ESTPT PEN
26260 10059 122 3/26/2014 NP ARR
26370 10077 9124 3/27/2014 NP ARR

Patients – Patient info

uid ufname ulname dob sex


10085 Sona Shah 7/8/1986 female
9795 3rd Prenatal 10/10/1985 female
condition
9985 Baby 3A 6/1/2011 male
10031 alex 9D 10/8/1995 male
10031 alex 9D 10/8/1995 male
10031 alex 9D 10/8/1995 male
9975 Prenatal Test 8/9/1980 female
10082 Catherian Shah 4/8/1984 female
10089 Sani Shah 8/5/1986 female
10034 John 9D 10/6/1970 male
10068 Nishant Bacchav 11/4/1990 male
10072 CAD Table 10/10/1985 male
10073 Cancer Table 10/10/1950 male
10072 CAD Table 10/10/1985 male
10077 Manish Waikiki 4/13/2000 male
10039 alisha 9D 10/6/1975 female
9963 Aro Diabetes 10/10/1985 male
9374 Isha Li- 1/1/1991 female
Martin
10088 Sanika Shah 9/4/1986 female
10059 Test 3A 1/1/1987 female
10077 Manish Waikiki 4/13/2000 male

Visit Type description

NOB – New OB
AV – Annual Visit
CON – Consult
F/U – Follow Up
ESTOB – Established OB
NP – New Patient
EST – Established Patient
Procedure – Procedure

Diagnosis -

encounterid primaryasmt Diagnosis


26350 1 Asthma, unspecified, unspecified status
26350 0 Routine infant or child health check
26356 1 Diabetes mellitus without mention of complication, type II or unspecified type, not
stated as uncontrolled
26356 0 Abdominal actinomycotic infection
26356 0 Other specified hypoglycemia
26301 1 Panhypopituitarism
26301 0 Pituitary dwarfism
26301 0 Coxsackievirus infection in conditions classified elsewhere and of unspecified site
26302 1 Abdominal or pelvic swelling, mass or lump, periumbilic
26302 0 Abdominal aneurysm, ruptured
26302 0 Abdominal actinomycotic infection
26342 1 Abdominal aneurysm without mention of rupture
26342 0 Abdominal aorta injury
26309 1 Asthma, unspecified, unspecified status
26312 1 Unspecified retrovirus in conditions classified elsewhere and of unspecified site
26312 0 Coxsackievirus infection in conditions classified elsewhere and of unspecified site
26371 1 Diabetes mellitus without mention of complication, type I [juvenile type], not
stated as uncontrolled
26362 1 Diabetes mellitus without mention of complication, type II or unspecified type,
uncontrolled
26260 1 Diabetes mellitus without mention of complication, type II or unspecified type, not
stated as uncontrolled
26260 0 Twin, mate liveborn, born in hospital, delivered by cesarean delivery
26260 0 Twin birth, mate liveborn, born outside hospital and not hospitalized
26370 1 Primary tuberculous complex, bacteriological or histological examination not done
26370 0 Primary tuberculous complex, tubercle bacilli found (in sputum) by microscopy
26370 0 Primary tuberculous complex, tubercle bacilli not found (in sputum) by
microscopy, but found by bacterial culture
26370 0 Primary tuberculous complex, tubercle bacilli not found by bacteriological
examination, but tuberculosis confirmed histologically
26370 0 Primary tuberculous complex, tubercle bacilli not found by bacteriological or
histological examination, but tuberculosis confirmed by other methods
[inoculation of animals]
26370 0 Tuberculous pleurisy in primary progressive tuberculosis, bacteriological or
histological examinatio

1) Practice wants a list of all unique patients with their most recent appointments. Represent this in
a query.
2) A) The clinic manager needs an overall encounter count for her month end numbers. What
query would get her this information?

B) The doctors are compensated based on the number of visits they have had for the reporting
time. Based on the information available provide the clinic manager a distinct count of
encounters for each doctor.

3) The OB/GYN staff is interested to get a list of all OB patients and have a follow up with them.
Provide this to them through your query.

4) The clinic is interested to know how many new patients they have had in the month. How would
you get them this data, along with the patient information?

5) Dr. Sam Willis (doctor Id 122) is looking to talk to all his patients who had an appointment
between March 1 and March 10. What query would you give him to fetch this list?

Note : the date field is a varchar, you will have to convert it to a suitable format at the query level
to bring in this information.

6) The Head Nurse is looking for all patients who have been diagnosed with chronic conditions like
Asthma and Diabetes. Can you provide her this info through your query? Note – The diagnosis
must be a primary assessment for each patient denoted by primaryasmt=1

S-ar putea să vă placă și