applicationLogic
Class SQLStatement

java.lang.Object
  extended by applicationLogic.SQLStatement

public class SQLStatement
extends java.lang.Object

SQLStatement handles the querying and updating of information in the database.

Author:
02leungi

Constructor Summary
SQLStatement()
           
 
Method Summary
static KeyValuePair genQuery(java.lang.String queryCommand, java.lang.String queryType, java.lang.String userType, java.util.Map data, java.util.Map filterData)
          Uses 'queryCommand' and 'queryType' to determine what type of database query to use.
static KeyValuePair getPhysiciansWhoPerformedProcedure(java.sql.Connection con, java.util.Map data)
          Helper method for getting the info on doctors who performed a particular procedure instance (MedicalProcedure)
static void setDataAccessAcquiringMode(boolean useEnv)
          Change the setting of whether SQLStatement will get connections to the database using the J2EE environnment.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SQLStatement

public SQLStatement()
Method Detail

setDataAccessAcquiringMode

public static void setDataAccessAcquiringMode(boolean useEnv)
Change the setting of whether SQLStatement will get connections to the database using the J2EE environnment.

Parameters:
useEnvironment - The new setting for 'useEnvironment'.

genQuery

public static KeyValuePair genQuery(java.lang.String queryCommand,
                                    java.lang.String queryType,
                                    java.lang.String userType,
                                    java.util.Map data,
                                    java.util.Map filterData)
Uses 'queryCommand' and 'queryType' to determine what type of database query to use. Uses 'queryData' for query parameters, and 'filterData' for filtering information. This method uses the Filter class to do the filtering in the query. This table shows all possible combinations of queryCommands and queryTypes, as well as their meanings:

Query Name

Meaning

Inputs (<Key>:<value_type>)

Output KeyValuePair Keys

get patientList

Get all the Patients in the system

null

“OHIP”, “First Name”, “Last Name”, “Date of Birth”, “Sex”, “Physician OHIP”, "Physician First Name", "Physician Last Name"

get PhysicianList

Get all the Physicians in the system

null

“OHIP”, “First Name”, “Last Name”, “Specialization”, “Address”

get patient

Get Patient information for a particular Patient

“patient_ohip”:int

“OHIP”, “First Name”, “Last Name”, “ Date of Birth”, “Address", "Sex”, "Physician OHIP", "Physician First Name", "Physician Last Name"

insert patient

Insert a Patient into the database

first_name”:String, “last_name”:String, “dob”:util.Date, “address”:String, “sex”:String, “physician_ohip”:int

“OHIP”

update patient

Update Patient information for a particular Patient

first_name”:String, “last_name”:String, “dob”:util.Date, “address”:String, “sex”:String, “physician_ohip”:int, “patient_ohip”:int

null

update patientStatus

Update the system status for a particular Patient

“status”:int, “patient_ohip”:int

null

get proceduresForPatient

Get all MedicalProcedures that have been performed on a particular Patient. This DOES NOT includes helper Physicians.

“patient_ohip”:int

“Procedure ID”, “Physician OHIP”, “First Name”, “Last Name”, “Date”, “Description”, “Procedure OHIP”

get physiciansForPatient

Get all Physicians who have performeded a medical procedure on a particular Patient

“patient_ohip”:int

“OHIP”, “First Name”, “Last Name”, “
“Address”, “Specialization”

get physician

Get Physician information for a particular Physician

“physician_ohip”:int

“OHIP”, “First Name”, “Last Name”, “Specialization”, “Address”

update physician

Update Physician info for a particular Physician

first_name”:String, “last_name”:String, “specialization”:String, “address”:String, “status”:int, “physician_ohip”:int

null

update physicianStatus

Update the system status for a particular Physician

“status”:int,

“physician_ohip”:int

null

get patientsForPhysician

Get all Patients who have had a MedicalProcedure from a particular Physician. Includes if Physician was a helper doctor.

“physician_ohip”:int

“OHIP”, “First Name”, “Last Name”, “Sex”, “Primary Physician OHIP”,

“Primary Physician First Name”, “Primary Physician Last Name”

get procedureTypesForPhysician

Get all the ProcedureTypes a particular Physician has worked one

“physician_ohip”:int

“OHIP”, “Description”

get proceduresPerformedForPhysician

Get all the MedicalProcedures (including as a helper) a particular Physician has worked on

“physician_ohip”:int

“Procedure ID”, “Physician OHIP”, “Patient OHIP”, “Physician First Name”, “Physician Last Name”, “Patient First Name”, “Patient Last Name”

get procedure

Get ProcedureType information for a particular ProcedureType

“proc_ohip”:int

"OHIP", “Description”, “Time”, “Cost”, “Status”

update procedure

Update information for a particular ProcedureType.

“proc_id”:int, “description”:String, “time”:float, “cost”:float, “status”:int

null

insert procedurePerformed

Insert a new MedicalProcedure and any necessary MedicalProcedureHelpers.

“ohip_type”:int, “date”:util.Date, “patient_ohip”:int, “physician_ohip”:int, “date_sub”:util.Date, “helper_physician_ohip”:applicationLogic.utility.IntArrayWrapper (this is an array of all helper ohip numbers wrapper in our utility class)

“Medical Procedure ID”

get physiciansWhoPerformedProcedure

Get all Physicians who worked on a particular MedicalProcedure

“proc_id”:int

“OHIP”, “First Name”, “Last Name”, “Procedure ID”, “Description”

get userType

Get the user type for a particular user name and password

“user_id”:String,

“password”:String

“Patient OHIP”, “Physician OHIP”, “Is Admin” (the non-null field contains the ohip number or “true”/”false” for is admin. if all three are null, then the user DNE)

get proceduresPerformedOnPatientByPhysician

Get all MedicalProcedures in which a particular Physician worked on a particular Patient

“patient_ohip”:int,

“physician_ohip”:int

“Patient OHIP”, “Physician OHIP”, “Patient First Name”, “Patient Last Name”, “Physician First Name”, “Physician Last Name”, “Procedure ID”, “Date”,“Procedure OHIP”, “Description”

get procedureNotes

Get all ProcedureNotes for a particular MedicalProcedure

“proc_id”:int

“Date”, “File”, “Text Notes”, “Filename”

get qualifications

Get all Qualifications for a particular Physician

“physician_ohip”:int

"Degree", "Institution", "Date"

get specificProcedurePerformedForPhysician

Get all Medical Procedures peformed by a particular Physician of a particular Procedure Type (ex get all stiches procedures performed by dr rick)

“physician_ohip”:int, “ohip_type”:int

"Procedure ID", "Physician OHIP", "Patient OHIP", "Physician First Name", "Physician Last Name", "Patient First Name", "Patient Last Name"

insert physician

Insert a Physician

“first_name”:String, “last_name”:String, “dob”:util.Date, “specialization”:String, “address”:String, “password”:String, “status”:int

OHIP”

This table shows the filter parameters that can be used for the filterable queries. If no filtering is required, either use no keys from this list in your Map, or leave filterData null

Query Name

Filter Parameters

get patientList

“first_name”:String, “last_name”:String, “sex”:String, “start_date”:util.Date, “end_date”:util.Date

get physicianList

“first_name”:String, “last_name”:String, “specialization”:String

get procedureList

“name”:String, “status_code”:int, “status”:String

Parameters:
queryCommand - 'queryCommand' can be "update", "get", "insert" but not all types of commands can be used for each 'queryType'.
queryType - See above table for queryTypes.
userType - Type of user who is making this query. Possible values can be "patient", "physician", and "admin". For most queries, this can be left null.
data - The data to be used as parameters to this query. A Map object containing query parameter names as keys, and values of the parameters as values. See the documentation
filterData - A Map object containing the types of filters to use, as keys, and the parameters to use in the filters, as values. A filter can only be used for queries returning multiple records. If null, no filtering is used.
Returns:
A KeyValuePair object containing the query result if 'isRetrieval' is true. Null if there is no such query, or if there is an error in the query. Update statements return a KeyValuePair that contains nothing (this is analogous to an empty result).

getPhysiciansWhoPerformedProcedure

public static KeyValuePair getPhysiciansWhoPerformedProcedure(java.sql.Connection con,
                                                              java.util.Map data)
Helper method for getting the info on doctors who performed a particular procedure instance (MedicalProcedure)

Parameters:
data -
Returns: