NamssoB
Board Regular
- Joined
- Jul 8, 2005
- Messages
- 76
- Office Version
- 365
- 2016
- Platform
- Windows
This is more of a coding logic problem than it is Excel (I think!), but since it's in Excel VBA and will be running from a Click even on a button we have inside of a Worksheet, I'm hoping for some help. Here is the deal:
1) User enters a number of minutes spent with a patient.
2) My code calculates the correct billing codes to use based on the time spent, in minutes.
Here is how it breaks down: (detailed grid also provided below, along with the code I've written so far):
There are only FOUR (4) codes, total. But they get appended/added onto each other as time progresses.
95978: Code for first hour
95978-52 (Modifier added if 30 minutes or less)
95979: Subsequent 30 minutes
95979-52: If only 15 minutes are used in the subsequent 30 minutes
For example:
00-30: 95978-52
31-60: 95978
61-75: 95978 + 95979-52
76-90: 95978 + 95979
91-105: 95978 + 95979 + 95979-52
106-120: 95978 + 95979 + 95979
121-135: 95978 + 95979 + 95979 + 95979-52
136-150: 95978 + 95979 + 95979 + 95979
151-165: 95978 + 95979 + 95979 + 95979 + 95979-52
166-180: 95978 + 95979 + 95979 + 95979 + 95979
And so on...my issue is, I can't hard code the specific time frames. I need to use an algorithm to fill in the codes. Can someone help? Below is the code I tried that "mostly" works up until about 90, then there are some major logic issues.
1) User enters a number of minutes spent with a patient.
2) My code calculates the correct billing codes to use based on the time spent, in minutes.
Here is how it breaks down: (detailed grid also provided below, along with the code I've written so far):
There are only FOUR (4) codes, total. But they get appended/added onto each other as time progresses.
95978: Code for first hour
95978-52 (Modifier added if 30 minutes or less)
95979: Subsequent 30 minutes
95979-52: If only 15 minutes are used in the subsequent 30 minutes
For example:
00-30: 95978-52
31-60: 95978
61-75: 95978 + 95979-52
76-90: 95978 + 95979
91-105: 95978 + 95979 + 95979-52
106-120: 95978 + 95979 + 95979
121-135: 95978 + 95979 + 95979 + 95979-52
136-150: 95978 + 95979 + 95979 + 95979
151-165: 95978 + 95979 + 95979 + 95979 + 95979-52
166-180: 95978 + 95979 + 95979 + 95979 + 95979
And so on...my issue is, I can't hard code the specific time frames. I need to use an algorithm to fill in the codes. Can someone help? Below is the code I tried that "mostly" works up until about 90, then there are some major logic issues.
Code:
Private Sub GetBillingCode_Click()
Dim sglTotalTime As Single
Dim sglExtraTime As Single
Dim intHours As Integer
Dim intHalfHours As Integer
Const strCodeBase As String = "95978"
Const strCodeModifier As String = "-52"
Const strCodeAdded As String = "95979"
Dim strFinalCode As String
sglTotalTime = Range("B3").Value
sglExtraTime = (sglTotalTime Mod 60) / 60
intHours = Int((sglTotalTime - sglExtraTime) / 60)
strFinalCode = strCodeBase
If sglTotalTime < 31 Then
strFinalCode = strFinalCode & strCodeModifier
End If
If sglTotalTime > 60 Then
strFinalCode = strFinalCode & " + " & strCodeAdded
' LOOP here for the number of hours there are?
For x = 1 To intHours
strFinalCode = strFinalCode & " + " & strCodeAdded
' First 15 minutes (0 to .25, 61-75) adds a modifier
If (sglExtraTime > 0 And sglExtraTime <= 0.25) And (x = intHours) Then
strFinalCode = strFinalCode & strCodeModifier
' Second 15 minutes (.25 to .50, 76-90) adds nothing, leave it alone!
' Last HALF (.5+, 91-120) adds another added code, so add it here
ElseIf sglExtraTime > 0.5 Then
strFinalCode = strFinalCode & " + " & strCodeAdded
' 3rd "quarter" (.50 to .75, 90-105) adds a modifier
If sglExtraTime <= 0.75 And x = intHours Then
strFinalCode = strFinalCode & strCodeModifier
End If
Else
'strFinalCode = strFinalCode & " + " & strCodeAdded
End If
Next x
For x = 1 To intHours
If x < intHours Then
End If
Range("G7").Value = strFinalCode
End Sub