#Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Icon=Program.ico #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #region Includes ##################################### #include #include #include #include #include #include #include #endregion ########################################### Global $gs_ClinicIni = @ScriptDir & '\Clinic.ini' If FileExists($gs_ClinicIni) = 0 Then Exit MsgBox(16, 'Error', 'File: ' & $gs_ClinicIni & ' does not exist') Global $gs_Workbook = IniRead($gs_ClinicIni, 'Options', 'sWorkbook', @ScriptDir & '\Example Format.xlsx') If FileExists($gs_Workbook) = 0 Then Exit MsgBox(16, 'Error', 'File: ' & $gs_ClinicIni & ' does not exist') Global $go_Excel = _Excel_Open () If @error Then Exit MsgBox(16, "Excel Open Error", "Error creating the Excel application object." & @CRLF & "@error = " & @error & ", @extended = " & @extended) Global $go_Workbook = _Excel_BookOpen($go_Excel, $gs_Workbook) If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel Book Open Error", "Error opening '" & $gs_Workbook & "'." & @CRLF & "@error = " & @error & ", @extended = " & @extended) Global $ga_Workbook = _Excel_RangeRead($go_Workbook) If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel RangeRead Error", "Error reading from workbook." & @CRLF & "@error = " & @error & ", @extended = " & @extended) Global $gi_PatientBlock GUI_Draw() Func GUI_Draw() Local $h_GUI = GUICreate("Appointments", 201, 215, -1, -1, $WS_SYSMENU) GUISetIcon(@ScriptFullPath) GUICtrlCreateLabel("Number Of Patients", 25, 11, 145, 17, $SS_CENTERIMAGE) Local $id_PatientTotal_cbo = GUICtrlCreateCombo("", 25, 29, 145, 25, BitOR($CBS_DROPDOWNLIST, $CBS_AUTOHSCROLL)) Local $s_Clinic = Clinic_GetStrings('Patient Total') ; get a list for selectable patient numbers GUICtrlSetData(-1, $s_Clinic, StringRegExpReplace($s_Clinic, "\|.*$", "")) GUICtrlCreateLabel("Patient Blocks", 25, 53, 145, 17, $SS_CENTERIMAGE) Local $id_PatientBlock_cbo = GUICtrlCreateCombo("", 25, 70, 145, 25, BitOR($CBS_DROPDOWNLIST, $CBS_AUTOHSCROLL)) $s_Clinic = Clinic_GetStrings('Patient Blocks') ; get a list for selectable students GUICtrlSetData(-1, $s_Clinic, StringRegExpReplace($s_Clinic, "\|.*$", "")) GUICtrlCreateLabel("Available Clinics", 25, 95, 145, 17, $SS_CENTERIMAGE) Local $id_PatientClinic_cbo = GUICtrlCreateCombo("", 25, 112, 145, 25, BitOR($CBS_DROPDOWNLIST, $CBS_AUTOHSCROLL)) Local $s_Clinic = Clinic_GetStrings('Clinic Names') ; get a list of clinic names GUICtrlSetData(-1, $s_Clinic, StringRegExpReplace($s_Clinic, "\|.*$", "")) ; fill the combo with the clinic names and set the first one in the list as the default Local $id_Book_btn = GUICtrlCreateButton("Book", 60, 144, 75, 25) ControlFocus($h_GUI, '', $id_Book_btn) ; give the book button focus #Region Constants ################################ ; set the constants that relate to the different property columns in $av_RangeRead/ excel spreadsheet Local Enum _ $e_LastName, _ $e_FirstName, _ $e_DOB, _ $e_Sex, _ $e_Address, _ $e_Zip, _ $e_Phone, _ $e_VisitReason, _ $e_Insurance, _ $e_Clinic, _ $e_Prov, _ $e_ApptTime, _ $e_ApptDate #EndRegion Constants ################################ Local $i_Total = 0 ; number of loops to do (times array is read from = number of patients selected) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $id_Book_btn GUISetState(@SW_HIDE, $h_GUI) ; hide the gui $i_Total = GUICtrlRead($id_PatientTotal_cbo) ; get the patient number $s_Clinic = GUICtrlRead($id_PatientClinic_cbo) ; get the clinic number $i_StartRow = $gi_PatientBlock[_GUICtrlComboBox_GetCurSel($id_PatientBlock_cbo)] ; get the row to start the workbook read from If $i_StartRow = $gi_PatientBlock[_GUICtrlComboBox_GetCount($id_PatientBlock_cbo) - 1] Then $i_EndRow = UBound($ga_Workbook) - 1 Else $i_EndRow = $gi_PatientBlock[_GUICtrlComboBox_GetCurSel($id_PatientBlock_cbo) + 1] EndIf $iCount = 1 For $i = $i_StartRow To $i_EndRow If $ga_Workbook[$i][1] = "" Or $ga_Workbook[$i][2] = "" Or $ga_Workbook[$i][10] <> "" Then ContinueLoop EndIf $ga_Workbook[$i][10] = $s_Clinic _ClinicIni($s_Clinic, $i) If $iCount = $i_Total Then ExitLoop $iCount += 1 Next GUISetState(@SW_SHOW, $h_GUI) Case $GUI_EVENT_CLOSE _Excel_Close($go_Excel) Exit EndSwitch WEnd EndFunc ;==>GUI_Draw ; #FUNCTION# ==================================================================================================================== ; Name ..........: Clinic_GetStrings ; Description ...: Returns Clinic related values based on the passed parameter ; Syntax ........: Clinic_GetStrings($s_Clinic) ; Parameters ....: $s_Clinic - The string of the clinic to process ; Return values .: Success - Clinc Name Passed: Returns an array with the characters for use with ControlSend ; Other string: Returns a list of string for loading combo boxes ; =============================================================================================================================== Func Clinic_GetStrings($s_Clinic = '') Switch $s_Clinic Case 'Patient Total' ; min/max number of patients that are selectable Return '1|2|3|4|5|6' Case 'Patient Blocks' $gi_PatientBlock = _ArrayFindAll($ga_Workbook, '^.+$', 1, 0, 0, 3) Local $a_PatientBlocks[UBound($gi_PatientBlock)] For $i = 0 To UBound($gi_PatientBlock) - 1 $a_PatientBlocks[$i] = $ga_Workbook[$gi_PatientBlock[$i]][0] Next Return _ArrayToString($a_PatientBlocks, '|') Case 'Clinic Names' Local $a_Clinics = IniReadSectionNames($gs_ClinicIni) Return _ArrayToString($a_Clinics, '|', 2) Case Else Local $s_Return = '' Return StringSplit($s_Return, '|') ; split the keystrokes to an array EndSwitch EndFunc ;==>Clinic_GetStrings Func _ClinicIni($s_ClientId, $i_ClientId) Local $a_ClinicId = IniReadSection($gs_ClinicIni, $s_ClientId) For $i = 1 To $a_ClinicId[0][0] Execute($a_ClinicId[$i][1]) Next EndFunc