Hello All,
Well this is going to be a nightmare for a very basic newbie. I don't know what will be worse doing it or trying to explain it well enough to maybe get some help from the more expert experts here.
Here it goes.
I am working with Crystal 9.0 professional
I have two connections the first is an ODBC connection and the second is an Excel workbook.
The connection is no problem,
I work for a hospital and we have a database called the Discharge Abstract Database. In this database there are many fields but the only ones I need for this process is
(instito) (institfrom) (Age Group) (CaseMixGroup) (LengthofStay) (disp.)
In order to calculate the Weighted cases...this is just a term used to put a intensity amount to the types of cases seen in a hospital...the Ministry makes available this excel workbook that you can go into and dump all your data onto the sheet and it has this built in model that will calculate the PAC10riw. That PAc10riw is what I need, it is the Weighted case number I mentioned. Well it just seems silly to me to go to all the trouble of dumping the data 100,000 records into this sheet to get this calculation. But then I looked at the module behind the workbook, Oh my god, but if I could figure some way of getting crystal to look at the workbook and then just do the calculation looking at the live data...that just seems the best. I know I can't attach the workbook here but if you are into a challange it is at and is called Pac-10 Calculator for 2004/2005 and 2005/2006
Here is the module behind the sheets..it is written in visual basic...I am willing to work hard and learn but I just don't know where to begin but I really need this thing to work with crystal...
Function PAC10RIW(instto, instfrom, disp, cmg, los, age)
If age = 9 Then
age = 3
End If
instto = Application.WorksheetFunction.Trim(instto)
instfrom = Application.WorksheetFunction.Trim(instfrom)
disp = Application.WorksheetFunction.Trim(disp)
cmg = Application.WorksheetFunction.Trim(cmg)
Dim pac10Range As Range
Set pac10Range = Worksheets("PAC10").Range("A1:U479")
typriw = Application.WorksheetFunction.VLookup(cmg, pac10Range, Choose(age, 3, 7, 11), False)
bopdw = Application.WorksheetFunction.VLookup(cmg, pac10Range, Choose(age, 4, 8, 12), False)
rapdw = Application.WorksheetFunction.VLookup(cmg, pac10Range, Choose(age, 5, 9, 13), False)
cihipdw = Application.WorksheetFunction.VLookup(cmg, pac10Range, Choose(age, 6, 10, 14), False)
elos = Application.WorksheetFunction.VLookup(cmg, pac10Range, Choose(age, 15, 17, 19), False)
lostrim = Application.WorksheetFunction.VLookup(cmg, pac10Range, Choose(age, 16, 18, 20), False)
plxgrade = Application.WorksheetFunction.VLookup(cmg, pac10Range, 21, False)
If plxgrade = "1" Then
plxgradeN = 1
ElseIf plxgrade = "3" Then
plxgradeN = 2
Else
plxgradeN = 3
End If
If disp = "07" Then
riwexcl = 4
ElseIf disp = "06" Then
riwexcl = 3
ElseIf instfrom = "AT" Or instfrom = "AP" Or instfrom = "1" Or instto = "AT" Or instto = "AP" Or instto = "1" Then
riwexcl = 2
Else
riwexcl = 0
End If
If riwexcl = 0 And los > lostrim Then
riwexcl = 1
End If
If cmg = "996" Or cmg = "997" Then
riwexcl = 7
ElseIf cmg = "910" Or cmg = "912" Then
riwexcl = 5
ElseIf cmg = "999" Or cmg = "998" Then
riwexcl = 6
End If
If los = 0 Then
riwexcl = 7
End If
If los > 10 Then
los10 = 10
Else
los10 = los
End If
Dim pacccRange As Range
Set pacccRange = Worksheets("CostCurves").Range("B3:K13")
If riwexcl = 4 Then
pacCC = Application.WorksheetFunction.VLookup(los10, pacccRange, Choose(plxgradeN, 4, 7, 10), False)
End If
If riwexcl = 2 Then
If instfrom = "AT" Or instfrom = "AP" Or instfrom = "1" Then
pacCC = Application.WorksheetFunction.VLookup(los10, pacccRange, Choose(plxgradeN, 2, 5, 8), False)
ElseIf instto = "AT" Or instto = "AP" Or instto = "1" Then
pacCC = Application.WorksheetFunction.VLookup(los10, pacccRange, Choose(plxgradeN, 3, 6, 9), False)
End If
End If
If riwexcl = 0 Then
PAC10RIW = typriw
ElseIf riwexcl = 1 Then
PAC10RIW = typriw + (bopdw * (los - elos))
ElseIf riwexcl = 2 Or riwexcl = 4 Then
If los <= lostrim Then
PAC10RIW = cihipdw * los * pacCC
Else
PAC10RIW = typriw + (bopdw * (los - elos))
End If
ElseIf riwexcl = 3 Then
If los <= elos Then
PAC10RIW = cihipdw * los
ElseIf los > elos And los <= lostrim Then
PAC10RIW = cihipdw * elos
Else
PAC10RIW = typriw + (bopdw * (los - elos))
End If
ElseIf riwexcl = 7 Then
PAC10RIW = 0
Else
If los * bopdw < typriw Then
PAC10RIW = los * bopdw
Else
PAC10RIW = typriw
End If
End If
End Function
What a nightmare...any suggestions would be so appreciated...I have already tried pinching myself but I can't seem to wake up so I guess the nightmare continues.
Well this is going to be a nightmare for a very basic newbie. I don't know what will be worse doing it or trying to explain it well enough to maybe get some help from the more expert experts here.
Here it goes.
I am working with Crystal 9.0 professional
I have two connections the first is an ODBC connection and the second is an Excel workbook.
The connection is no problem,
I work for a hospital and we have a database called the Discharge Abstract Database. In this database there are many fields but the only ones I need for this process is
(instito) (institfrom) (Age Group) (CaseMixGroup) (LengthofStay) (disp.)
In order to calculate the Weighted cases...this is just a term used to put a intensity amount to the types of cases seen in a hospital...the Ministry makes available this excel workbook that you can go into and dump all your data onto the sheet and it has this built in model that will calculate the PAC10riw. That PAc10riw is what I need, it is the Weighted case number I mentioned. Well it just seems silly to me to go to all the trouble of dumping the data 100,000 records into this sheet to get this calculation. But then I looked at the module behind the workbook, Oh my god, but if I could figure some way of getting crystal to look at the workbook and then just do the calculation looking at the live data...that just seems the best. I know I can't attach the workbook here but if you are into a challange it is at and is called Pac-10 Calculator for 2004/2005 and 2005/2006
Here is the module behind the sheets..it is written in visual basic...I am willing to work hard and learn but I just don't know where to begin but I really need this thing to work with crystal...
Function PAC10RIW(instto, instfrom, disp, cmg, los, age)
If age = 9 Then
age = 3
End If
instto = Application.WorksheetFunction.Trim(instto)
instfrom = Application.WorksheetFunction.Trim(instfrom)
disp = Application.WorksheetFunction.Trim(disp)
cmg = Application.WorksheetFunction.Trim(cmg)
Dim pac10Range As Range
Set pac10Range = Worksheets("PAC10").Range("A1:U479")
typriw = Application.WorksheetFunction.VLookup(cmg, pac10Range, Choose(age, 3, 7, 11), False)
bopdw = Application.WorksheetFunction.VLookup(cmg, pac10Range, Choose(age, 4, 8, 12), False)
rapdw = Application.WorksheetFunction.VLookup(cmg, pac10Range, Choose(age, 5, 9, 13), False)
cihipdw = Application.WorksheetFunction.VLookup(cmg, pac10Range, Choose(age, 6, 10, 14), False)
elos = Application.WorksheetFunction.VLookup(cmg, pac10Range, Choose(age, 15, 17, 19), False)
lostrim = Application.WorksheetFunction.VLookup(cmg, pac10Range, Choose(age, 16, 18, 20), False)
plxgrade = Application.WorksheetFunction.VLookup(cmg, pac10Range, 21, False)
If plxgrade = "1" Then
plxgradeN = 1
ElseIf plxgrade = "3" Then
plxgradeN = 2
Else
plxgradeN = 3
End If
If disp = "07" Then
riwexcl = 4
ElseIf disp = "06" Then
riwexcl = 3
ElseIf instfrom = "AT" Or instfrom = "AP" Or instfrom = "1" Or instto = "AT" Or instto = "AP" Or instto = "1" Then
riwexcl = 2
Else
riwexcl = 0
End If
If riwexcl = 0 And los > lostrim Then
riwexcl = 1
End If
If cmg = "996" Or cmg = "997" Then
riwexcl = 7
ElseIf cmg = "910" Or cmg = "912" Then
riwexcl = 5
ElseIf cmg = "999" Or cmg = "998" Then
riwexcl = 6
End If
If los = 0 Then
riwexcl = 7
End If
If los > 10 Then
los10 = 10
Else
los10 = los
End If
Dim pacccRange As Range
Set pacccRange = Worksheets("CostCurves").Range("B3:K13")
If riwexcl = 4 Then
pacCC = Application.WorksheetFunction.VLookup(los10, pacccRange, Choose(plxgradeN, 4, 7, 10), False)
End If
If riwexcl = 2 Then
If instfrom = "AT" Or instfrom = "AP" Or instfrom = "1" Then
pacCC = Application.WorksheetFunction.VLookup(los10, pacccRange, Choose(plxgradeN, 2, 5, 8), False)
ElseIf instto = "AT" Or instto = "AP" Or instto = "1" Then
pacCC = Application.WorksheetFunction.VLookup(los10, pacccRange, Choose(plxgradeN, 3, 6, 9), False)
End If
End If
If riwexcl = 0 Then
PAC10RIW = typriw
ElseIf riwexcl = 1 Then
PAC10RIW = typriw + (bopdw * (los - elos))
ElseIf riwexcl = 2 Or riwexcl = 4 Then
If los <= lostrim Then
PAC10RIW = cihipdw * los * pacCC
Else
PAC10RIW = typriw + (bopdw * (los - elos))
End If
ElseIf riwexcl = 3 Then
If los <= elos Then
PAC10RIW = cihipdw * los
ElseIf los > elos And los <= lostrim Then
PAC10RIW = cihipdw * elos
Else
PAC10RIW = typriw + (bopdw * (los - elos))
End If
ElseIf riwexcl = 7 Then
PAC10RIW = 0
Else
If los * bopdw < typriw Then
PAC10RIW = los * bopdw
Else
PAC10RIW = typriw
End If
End If
End Function
What a nightmare...any suggestions would be so appreciated...I have already tried pinching myself but I can't seem to wake up so I guess the nightmare continues.