testmeout

Adding "and" before last word in group of words

4 posts in this topic

I have the following checkbox items with the following text:
Diagnostic results
Prognosis
Risks and benefits of treatment options
Impressions
Importance of compliance with chosen treatment options
Risk factor reductions
Patient and family education

If the checkbox is checked I am wanting to combine all the words with a "," and before the last word in the group add an "and" to produce something like:

During this (Total Time) minute face-to-face visit more than 50 percent of the time with the patient was dedicated to counseling or coordinating care discussing, Diagnostic results, Prognosis, Risks and benefits of treatment options, Impressions, Importance of compliance with chosen treatment options, Risk factor reductions, (code an and) Patient and family education on the following issues:

Any help is greatly appreciated

Here is my code so far

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <MsgBoxConstants.au3>
#include <Date.au3>
#include <GuiEdit.au3>


#Region ### START Koda GUI section ### Form=C:\Users\Eric\Documents\AutoitScript\Form1.kxf
$Form1 = GUICreate("Office Visit Timer", 479, 324, 192, 124)
$cStart = GUICtrlCreateButton("Start", 152, 24, 89, 41)
$cStop = GUICtrlCreateButton("Stop", 258, 24, 89, 41)
$cReset = GUICtrlCreateButton("Reset", 361, 24, 89, 41)
$Checkbox1 = GUICtrlCreateCheckbox("Diagnostic results", 16, 32, 121, 17)
GUICtrlSetState(-1, $GUI_CHECKED)
$Checkbox2 = GUICtrlCreateCheckbox("Prognosis", 16, 69, 121, 17)
$Label1 = GUICtrlCreateLabel("New Patient Suggested Code:", 192, 264, 147, 17)
$Label2 = GUICtrlCreateLabel("Established Patient Suggested Code:", 160, 288, 179, 17)
$Checkbox3 = GUICtrlCreateCheckbox("Risks and benefits of treatment options", 16, 91, 129, 41, BitOR($GUI_SS_DEFAULT_CHECKBOX,$BS_MULTILINE))
GUICtrlSetState(-1, $GUI_CHECKED)
$Checkbox4 = GUICtrlCreateCheckbox("Impressions", 16, 136, 97, 17)
GUICtrlSetState(-1, $GUI_CHECKED)
$Checkbox5 = GUICtrlCreateCheckbox("Importance of compliance with chosen treatment options", 16, 157, 121, 57, BitOR($GUI_SS_DEFAULT_CHECKBOX,$BS_MULTILINE))
$Checkbox6 = GUICtrlCreateCheckbox("Risk factor reductions", 16, 219, 129, 17)
GUICtrlSetState(-1, $GUI_CHECKED)
$Checkbox7 = GUICtrlCreateCheckbox("Patient and family education", 16, 248, 161, 17)
GUICtrlSetState(-1, $GUI_CHECKED)
$Edit1 = GUICtrlCreateEdit("", 152, 72, 297, 169, BitOR($ES_READONLY,$ES_WANTRETURN))
$NPCode = GUICtrlCreateLabel("99205", 360, 264, 34, 17)
$EPCode = GUICtrlCreateLabel("99215", 360, 288, 34, 17)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

GUICtrlSetState($cStop, $GUI_DISABLE)

GUISetState()

Global $Init0, $PausedTimer, $iHours, $iMins, $iSecs, $Starttime, $Endtime
Global $sStart, $sStop

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $cStart
            ;start_timer()
            $sStart = _NowTime()
            $Init0 = TimerInit()
            ConsoleWrite($sStart & @CRLF)
            _GUICtrlEdit_SetText( $Edit1, "" )
            GUICtrlSetState($cStart, $GUI_DISABLE)
            GUICtrlSetState($cStop, $GUI_ENABLE)
            AdlibRegister("show_timer", 60)
            GUISetState(@SW_MINIMIZE)
        Case $cStop
            $sStop = _NowTime()
            GUICtrlSetState($cStop, $GUI_DISABLE)
            GUICtrlSetState($cStart, $GUI_ENABLE)
            $iSecs = _DateDiff("s", $sStart, $sStop)
            $starttime = "Provider Face to Face Start Time: " & $sStart & @CRLF
            $endtime = "Provider Face to Face  End Time: " & $sStop & @CRLF
            _TicksToTime(Int(TimerDiff($Init0)), $iHours, $iMins, $iSecs)
            $Dxresults = GUICtrlRead($Checkbox1)

            $timespent = "Total Time of Face to Face visit: " & $iHours & ":" & $iMins & ":" & $iSecs & @CRLF
            $totalmins = $iHours*60 + $iMins
            $checkboxtext = "Diagnostic results"
            $discussed = "During this " & $totalmins & " minute face-to-face visit more than 50 percent of the time with the patient was dedicated to counseling or coordinating care discussing, "&$checkboxtext&" on the following issues:"
            $text = $starttime & $endtime & $timespent & $discussed
            If $totalmins < 10 Then
                $NPEM = "99201"
                $EPEM = "99211"
            ElseIf $totalmins < 15 Then
                $NPEM = "99201"
                $EPEM = "99212"
            ElseIf $totalmins < 20 Then
                $NPEM = "99201"
                $EPEM = "99213"
            ElseIf $totalmins < 25 Then
                $NPEM = "99201"
                $EPEM = "99213"
            ElseIf $totalmins < 30 Then
                $NPEM = "99201"
                $EPEM = "99213"
            ElseIf $totalmins < 40 Then
                $NPEM = "99202"
                $EPEM = "99214"
            ElseIf $totalmins < 45 Then
                $NPEM = "99203"
                $EPEM = "99214"
            ElseIf $totalmins < 60 Then
                $NPEM = "99204"
                $EPEM = "99214"
            ElseIf $totalmins < 70 Then
                $NPEM = "99205"
                $EPEM = "99215"
            ElseIf $totalmins < 90 Then
                $NPEM = "99201"
                $EPEM = "99214"
            ElseIf $totalmins < 115 Then
                $NPEM = "99201"
                $EPEM = "99215"
            EndIf
            GUICtrlSetData($NPCode, $NPEM)
            GUICtrlSetData($EPCode, $EPEM)
            GUICtrlSetData($Edit1, $text, 1)
            AdlibUnRegister()
        Case $cReset
            _GUICtrlEdit_SetText ( $Edit1, "" )
            GUICtrlSetState($cStart, $GUI_ENABLE)
            GUICtrlSetState($cStop, $GUI_DiSABLE)
            ToolTip("HH:MM:SS = " & "00:00:00", 0, 0, "Timer")
    EndSwitch

WEnd

Func show_timer()     ; _TicksToTime to get hours, mins, seconds
   _TicksToTime(Int(TimerDiff($Init0)), $iHours, $iMins, $iSecs)

   ;StringFormat to display the time as HH:MM:SS
   ToolTip("HH:MM:SS = " & StringFormat("%02i:%02i:%02i", $iHours, $iMins, $iSecs), 0, 0, "Timer")
EndFunc   ;==>show_timer

 

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Have a look at this small example:

#include <GUIConstantsEx.au3>
;#include <Array.au3>

Opt('MustDeclareVars', 1)

Global $aChkIDs[9][2]
$aChkIDs[0][1] = "func1"
$aChkIDs[1][1] = "func2"
$aChkIDs[2][1] = "func3"
$aChkIDs[3][1] = "func4"
$aChkIDs[4][1] = "func5"
$aChkIDs[5][1] = "func6"
$aChkIDs[6][1] = "func7"
$aChkIDs[7][1] = "func8"
$aChkIDs[8][1] = "func9"

Global $iSeg, $iMsg

Global $hGui = GUICreate('CheckBoxtest', 105, 175)
Global $msg

For $i = 0 To 8
    $aChkIDs[$i][0] = GUICtrlCreateCheckBox($i + 1, 10 + Mod($i, 3) * 30, 10 + Int($i / 3) * 30, 25, 25)
    ConsoleWrite($i + 1 & ': ' & $aChkIDs[$i][0] & @CRLF)
Next

Global $idBtnSubmit = GUICtrlCreateButton('OK', 10, 110, 90, 25)
ConsoleWrite('OK: ' & $idBtnSubmit & @CRLF)
;GUICtrlSetState(-1, $GUI_DISABLE)
Global $idProgress=GUICtrlCreateProgress(10,140,85,25)
GUISetState()

While 1
    $iMsg=GUIGetMsg()
    Switch $iMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $aChkIDs[0][0] to $aChkIDs[8][0]
            _click($iMsg-$aChkIDs[0][0])

            #cs
            If GUICtrlRead($iID) Then
                GUICtrlSetState($iID,$GUI_UNCHECKED)    ;ist gechecked also uncheck
            Else
                GUICtrlSetState($iID,$GUI_CHECKED)  ;ist nicht gechecked also check
            EndIf
            #ce
        Case $idBtnSubmit
            _Submit()
    EndSwitch
WEnd

Func _Click($iID)
    ConsoleWrite($iID&@CRLF)
    Return
    Local $bAtLeastOneCheckBoxChecked
    For $i = 0 To 8
        If BitAND(GUICtrlRead($aChkIDs[$i][0]),$GUI_checked)=$GUI_checked Then
            $bAtLeastOneCheckBoxChecked = True
            ExitLoop
        EndIf
    Next
    If $bAtLeastOneCheckBoxChecked Then
        GUICtrlSetState($idBtnSubmit, $GUI_ENABLE)
    Else
        GUICtrlSetState($idBtnSubmit, $GUI_DISABLE)
    EndIf
EndFunc   ;==>_Click

Func _Submit()
    Local $sFunc='', $iCount
    GUICtrlSetData($idProgress,0)
    For $i = 0 To 8
        If BitAND(GUICtrlRead($aChkIDs[$i][0]),$GUI_checked)=$GUI_checked Then $iCount+=1
    Next
    $iSeg=Int(100/$iCount)
    For $i = 0 To 8
        If BitAND(GUICtrlRead($aChkIDs[$i][0]),$GUI_checked)=$GUI_checked Then
            Call($aChkIDs[$i][1])
            $sFunc&=$aChkIDs[$i][1]&', '
        EndIf
    Next
    $sFunc=StringTrimRight($sFunc,2)
    $sFunc=StringReplace($sFunc,',',' and',-1)
    GUICtrlSetData($idProgress,100)
    ConsoleWrite('Funcs are called: '&$sFunc&@CRLF&@CRLF)
EndFunc   ;==>_Submit

Func Func1()
    Sleep(Random(100,1000,1))
    GUICtrlSetData($idProgress,GUICtrlRead($idProgress)+$iSeg)
EndFunc
Func Func2()
    Sleep(Random(100,1000,1))
    GUICtrlSetData($idProgress,GUICtrlRead($idProgress)+$iSeg)
EndFunc
Func Func3()
    Sleep(Random(100,1000,1))
    GUICtrlSetData($idProgress,GUICtrlRead($idProgress)+$iSeg)
EndFunc
Func Func4()
    Sleep(Random(100,1000,1))
    GUICtrlSetData($idProgress,GUICtrlRead($idProgress)+$iSeg)
EndFunc
Func Func5()
    Sleep(Random(100,1000,1))
    GUICtrlSetData($idProgress,GUICtrlRead($idProgress)+$iSeg)
EndFunc
Func Func6()
    Sleep(Random(100,1000,1))
    GUICtrlSetData($idProgress,GUICtrlRead($idProgress)+$iSeg)
EndFunc
Func Func7()
    Sleep(Random(100,1000,1))
    GUICtrlSetData($idProgress,GUICtrlRead($idProgress)+$iSeg)
EndFunc
Func Func8()
    Sleep(Random(100,1000,1))
    GUICtrlSetData($idProgress,GUICtrlRead($idProgress)+$iSeg)
EndFunc
Func Func9()
    Sleep(Random(100,1000,1))
    GUICtrlSetData($idProgress,GUICtrlRead($idProgress)+$iSeg)
EndFunc

specially the func _Submit. Run the script and have a look at console pane.

Edited by AutoBert

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

I suggest to put the checkboxes IDs in an array an then use this way to populate $checkboxtext

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <MsgBoxConstants.au3>
#include <Date.au3>
#include <GuiEdit.au3>

Local $Checkbox[8] = [7]

#Region ### START Koda GUI section ### Form=C:\Users\Eric\Documents\AutoitScript\Form1.kxf
$Form1 = GUICreate("Office Visit Timer", 479, 324, 192, 124)
$cStart = GUICtrlCreateButton("Start", 152, 24, 89, 41)
$cStop = GUICtrlCreateButton("Stop", 258, 24, 89, 41)
$cReset = GUICtrlCreateButton("Reset", 361, 24, 89, 41)
$Checkbox[1] = GUICtrlCreateCheckbox("Diagnostic results", 16, 32, 121, 17)
GUICtrlSetState(-1, $GUI_CHECKED)
$Checkbox[2] = GUICtrlCreateCheckbox("Prognosis", 16, 69, 121, 17)
$Label1 = GUICtrlCreateLabel("New Patient Suggested Code:", 192, 264, 147, 17)
$Label2 = GUICtrlCreateLabel("Established Patient Suggested Code:", 160, 288, 179, 17)
$Checkbox[3] = GUICtrlCreateCheckbox("Risks and benefits of treatment options", 16, 91, 129, 41, BitOR($GUI_SS_DEFAULT_CHECKBOX,$BS_MULTILINE))
GUICtrlSetState(-1, $GUI_CHECKED)
$Checkbox[4] = GUICtrlCreateCheckbox("Impressions", 16, 136, 97, 17)
GUICtrlSetState(-1, $GUI_CHECKED)
$Checkbox[5] = GUICtrlCreateCheckbox("Importance of compliance with chosen treatment options", 16, 157, 121, 57, BitOR($GUI_SS_DEFAULT_CHECKBOX,$BS_MULTILINE))
$Checkbox[6] = GUICtrlCreateCheckbox("Risk factor reductions", 16, 219, 129, 17)
GUICtrlSetState(-1, $GUI_CHECKED)
$Checkbox[7] = GUICtrlCreateCheckbox("Patient and family education", 16, 248, 161, 17)
GUICtrlSetState(-1, $GUI_CHECKED)
$Edit1 = GUICtrlCreateEdit("", 152, 72, 297, 169, BitOR($ES_READONLY,$ES_WANTRETURN))
$NPCode = GUICtrlCreateLabel("99205", 360, 264, 34, 17)
$EPCode = GUICtrlCreateLabel("99215", 360, 288, 34, 17)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

GUICtrlSetState($cStop, $GUI_DISABLE)

GUISetState()

Global $Init0, $PausedTimer, $iHours, $iMins, $iSecs, $Starttime, $Endtime
Global $sStart, $sStop

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $cStart
            ;start_timer()
            $sStart = _NowTime()
            $Init0 = TimerInit()
            ConsoleWrite($sStart & @CRLF)
            _GUICtrlEdit_SetText( $Edit1, "" )
            GUICtrlSetState($cStart, $GUI_DISABLE)
            GUICtrlSetState($cStop, $GUI_ENABLE)
            AdlibRegister("show_timer", 60)
            GUISetState(@SW_MINIMIZE)
        Case $cStop
            $sStop = _NowTime()
            GUICtrlSetState($cStop, $GUI_DISABLE)
            GUICtrlSetState($cStart, $GUI_ENABLE)
            $iSecs = _DateDiff("s", $sStart, $sStop)
            $starttime = "Provider Face to Face Start Time: " & $sStart & @CRLF
            $endtime = "Provider Face to Face  End Time: " & $sStop & @CRLF
            _TicksToTime(Int(TimerDiff($Init0)), $iHours, $iMins, $iSecs)
            $Dxresults = GUICtrlRead($Checkbox[1])

            $timespent = "Total Time of Face to Face visit: " & $iHours & ":" & $iMins & ":" & $iSecs & @CRLF
            $totalmins = $iHours*60 + $iMins

;=====================================
$checkboxtext = ""
For $i = 1 to $Checkbox[0]
  If GUICtrlRead($Checkbox[$i]) = $GUI_CHECKED Then $checkboxtext &= GUICtrlRead($Checkbox[$i], 1) & ", "
Next
$checkboxtext = StringReplace (StringTrimRight($checkboxtext, 2), ",", " and", -1)
;=====================================

            $discussed = "During this " & $totalmins & " minute face-to-face visit more than 50 percent of the time with the patient was dedicated to counseling or coordinating care discussing, "&$checkboxtext&" on the following issues:"
            $text = $starttime & $endtime & $timespent & $discussed
            If $totalmins < 10 Then
                $NPEM = "99201"
                $EPEM = "99211"
            ElseIf $totalmins < 15 Then
                $NPEM = "99201"
                $EPEM = "99212"
            ElseIf $totalmins < 20 Then
                $NPEM = "99201"
                $EPEM = "99213"
            ElseIf $totalmins < 25 Then
                $NPEM = "99201"
                $EPEM = "99213"
            ElseIf $totalmins < 30 Then
                $NPEM = "99201"
                $EPEM = "99213"
            ElseIf $totalmins < 40 Then
                $NPEM = "99202"
                $EPEM = "99214"
            ElseIf $totalmins < 45 Then
                $NPEM = "99203"
                $EPEM = "99214"
            ElseIf $totalmins < 60 Then
                $NPEM = "99204"
                $EPEM = "99214"
            ElseIf $totalmins < 70 Then
                $NPEM = "99205"
                $EPEM = "99215"
            ElseIf $totalmins < 90 Then
                $NPEM = "99201"
                $EPEM = "99214"
            ElseIf $totalmins < 115 Then
                $NPEM = "99201"
                $EPEM = "99215"
            EndIf
            GUICtrlSetData($NPCode, $NPEM)
            GUICtrlSetData($EPCode, $EPEM)
            GUICtrlSetData($Edit1, $text, 1)
            AdlibUnRegister()
        Case $cReset
            _GUICtrlEdit_SetText ( $Edit1, "" )
            GUICtrlSetState($cStart, $GUI_ENABLE)
            GUICtrlSetState($cStop, $GUI_DiSABLE)
            ToolTip("HH:MM:SS = " & "00:00:00", 0, 0, "Timer")
    EndSwitch

WEnd

Func show_timer()     ; _TicksToTime to get hours, mins, seconds
   _TicksToTime(Int(TimerDiff($Init0)), $iHours, $iMins, $iSecs)

   ;StringFormat to display the time as HH:MM:SS
   ToolTip("HH:MM:SS = " & StringFormat("%02i:%02i:%02i", $iHours, $iMins, $iSecs), 0, 0, "Timer")
EndFunc   ;==>show_timer

 

Edited by mikell

Share this post


Link to post
Share on other sites

Autobert and mikell thanks for responding.

 

Mikell you are the best, it worked like a champ!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now