RCheesley
Registered User.
- Local time
- Today, 17:38
- Joined
- Aug 12, 2008
- Messages
- 243
Hi all,
I have a query I'm using which I want to do something funky with but I'm not sure how!
Basically I am currently using a very complex excel spreadsheet to maintain a line listing of patients with a certain condition, which automagically calculates certain fields.
I'm attempting to incorporate this into an access database with varying levels of success, as I'm quite new to Access and databases in general.
I have a query pulling from a table with the following fields:
SpecimenID (PK)
PatientDetailsID (FK from tblPatientDetails)
SpecimenDate (date of sample)
SpecimenOrganism (because this db will manage several organisms in the future)
SpecimenLocation (which lab it came from)
SpecimenPreviousDischarge (patient's most recent discharge date)
SpecimenCurrentAdmission (patient's admission date if admitted this episode)
I've got this query working perfectly in a number of situations, however I want to be able to automagically calculate as my spreadsheet does, whether the sample is classified as:
Acute (taken day of admission + 2 days or greater)
Pre-48h (taken on day of admission or following 2 days)
Community (taken by GP hence no admission date for this episode, or admission date is after sample date)
The way I accomplish this on the spreadsheet is using the following formula:
=IF(AND((G2-I2)<=2,G2>=I2),"PRE-48h",IF((AND((G2-I2)>2,G2>=I2,I2<>"")),"ACUTE","COMMUNITY"))
Where
G2 = Specimen Date
I2 = Admission Date
I then have a separate field which identified in further detail the hospital association:
=IF(AND(G2<=(I2+2),(K2>31)),"CO-HAP",IF(AND(OR(K2>=63,(AND(ISBLANK(J2),N2=1))),N2=1),"CO-CA",IF(AND(K2>=32,K2<=64,N2=1),"INDETERMINATE",IF(AND(G2>=I2+2,N2=3),"HO-HA",IF(AND(OR(ISBLANK(I2),K2>=1,K2<=31,)),"CO-HA")))))
Where
G2 = Specimen Date
I2 = Admission Date
K2 = Calculated field of days since discharge using =IF(ISBLANK(J2),"N/A",(DATEDIF(J2,G2,dcell)))
J2 = Previous Discharge Date
N2 = Automatically populated location code using =IF( M2="Community", 1, IF( M2="Pre-48h", 2, IF( M2="Acute",3)))
My question is (well done for making it this far!) what is the best way to calculate these fields in Access? The Spec/Admission/Discharge dates are all input via a form frmAddSpecimens so is it possible to have a field which calculates the appropriate values somehow based on the above equations?
Ruth
I have a query I'm using which I want to do something funky with but I'm not sure how!
Basically I am currently using a very complex excel spreadsheet to maintain a line listing of patients with a certain condition, which automagically calculates certain fields.
I'm attempting to incorporate this into an access database with varying levels of success, as I'm quite new to Access and databases in general.
I have a query pulling from a table with the following fields:
SpecimenID (PK)
PatientDetailsID (FK from tblPatientDetails)
SpecimenDate (date of sample)
SpecimenOrganism (because this db will manage several organisms in the future)
SpecimenLocation (which lab it came from)
SpecimenPreviousDischarge (patient's most recent discharge date)
SpecimenCurrentAdmission (patient's admission date if admitted this episode)
I've got this query working perfectly in a number of situations, however I want to be able to automagically calculate as my spreadsheet does, whether the sample is classified as:
Acute (taken day of admission + 2 days or greater)
Pre-48h (taken on day of admission or following 2 days)
Community (taken by GP hence no admission date for this episode, or admission date is after sample date)
The way I accomplish this on the spreadsheet is using the following formula:
=IF(AND((G2-I2)<=2,G2>=I2),"PRE-48h",IF((AND((G2-I2)>2,G2>=I2,I2<>"")),"ACUTE","COMMUNITY"))
Where
G2 = Specimen Date
I2 = Admission Date
I then have a separate field which identified in further detail the hospital association:
=IF(AND(G2<=(I2+2),(K2>31)),"CO-HAP",IF(AND(OR(K2>=63,(AND(ISBLANK(J2),N2=1))),N2=1),"CO-CA",IF(AND(K2>=32,K2<=64,N2=1),"INDETERMINATE",IF(AND(G2>=I2+2,N2=3),"HO-HA",IF(AND(OR(ISBLANK(I2),K2>=1,K2<=31,)),"CO-HA")))))
Where
G2 = Specimen Date
I2 = Admission Date
K2 = Calculated field of days since discharge using =IF(ISBLANK(J2),"N/A",(DATEDIF(J2,G2,dcell)))
J2 = Previous Discharge Date
N2 = Automatically populated location code using =IF( M2="Community", 1, IF( M2="Pre-48h", 2, IF( M2="Acute",3)))
My question is (well done for making it this far!) what is the best way to calculate these fields in Access? The Spec/Admission/Discharge dates are all input via a form frmAddSpecimens so is it possible to have a field which calculates the appropriate values somehow based on the above equations?
Ruth