Retrieving values of multidimensional array using menu
Posted: 14 Sep 2021, 21:54
Hello, I am trying to retrieve array values using menu. The array has a {{Afluria vaccine code: Afluria admin code}, {Engerix vaccine code: Engerix admin code}...}} type of structure. It's about vaccine administration. The examples I am posting is only some part.
In the menu, you need to make 3 selections:
1. Vaccine types: Afluria or Engerix.
2. Vaccine codes (v): pediatric (P), Adult non Medicare (A), and Medicare (M). Combinations are possible as some have the same codes such as PAM or AM.
3. Comments on the number of vaccination (c): some vaccines are supposed to be given more than one time as a series. c_B (booster), c_1 (1st shot), ...
4. Once the above three are selected, vaccine administration codes (a) will be automatically determined.
Now, you can get 3 values for each vaccine.
1. For Afluria
Vaccines.Afluria.v_PAM (vaccine codes for P, A and M are all the same)
Vaccines.Afluria.a_P
Vaccines.Afluria.n (single shot only needed)
2. For Engerix
Vaccines.Engerix.v_AM (vaccine codes for A and M are all the same)
Vaccines.Engerix.a_M
Vaccines.Engerix.n_B (booster shot)
I have come up with below so far:
So, works. But, why are these two below not working?
How can a variable be used to refer to the array's keys? Please teach me. Thank you.
In the menu, you need to make 3 selections:
1. Vaccine types: Afluria or Engerix.
2. Vaccine codes (v): pediatric (P), Adult non Medicare (A), and Medicare (M). Combinations are possible as some have the same codes such as PAM or AM.
3. Comments on the number of vaccination (c): some vaccines are supposed to be given more than one time as a series. c_B (booster), c_1 (1st shot), ...
4. Once the above three are selected, vaccine administration codes (a) will be automatically determined.
Now, you can get 3 values for each vaccine.
1. For Afluria
Vaccines.Afluria.v_PAM (vaccine codes for P, A and M are all the same)
Vaccines.Afluria.a_P
Vaccines.Afluria.n (single shot only needed)
2. For Engerix
Vaccines.Engerix.v_AM (vaccine codes for A and M are all the same)
Vaccines.Engerix.a_M
Vaccines.Engerix.n_B (booster shot)
I have come up with below so far:
Code: Select all
Afluria := {}, Engerix := {}, Vaccines := {}
Afluria := {v_PAM: "90686: Vaccine, Afluria IIV4, 0.5 mL, IM (≥3 yo)"
, a_P: "90460: Admin, one vaccine, non-MC, (≤18 yo, w/ counseling)"
, a_A: "90471: Admin, one vaccine, non-MC"
, A_M: "G0008: Admin, influenza vaccine, MC"
, n: "Afluria was administered today."}
EngerixB := {v_P: "90744: Vaccine, Engerix-B, 0.5 mL, IM (<20 yo)"
, v_AM: "90746: Vaccine, Engerix-B, 1.0 mL, IM (≥20 yo)"
, a_P: "90460: Admin, one vaccine, non-MC (≤18 yo, w/ counseling)"
, a_A: "90471: Admin, one vaccine, non-MC"
, a_M: "G0010: Admin, hepatitis B vaccine, MC"
, n_B: "One booster vaccination of HBV was administered today."
, n_1: "The first dose of HBV vaccine was administered today. Patient will be scheduled for the second one in a month."
, n_2: "The second dose of HBV vaccine was administered today. Patient will be scheduled for the third one in five months."
, n_3: "The third dose of HBV vaccine was administered today."}
Vaccines := {Afluria: Afluria, Engerix: Engerix}
VaccinationHandler()
{
Global Afluria := {}, Engerix := {}, Vaccines := {}
Global Vaccine_type, Vaccine_code, Admin_code
Menu, SubFlu, Add, Pediatric, FluHandler
Menu, SubFlu, Add, Adult (NonMC), FluHandler
Menu, SubFlu, Add, Medicare, FluHandler
Menu, Vaccination, Add, Influenza, :SubFlu
Menu, SubPed, Add, Booster Vac., HBVHandler
Menu, SubPed, Add, 1st Vac., HBVHandler
Menu, SubPed, Add, 2nd Vac., HBVHandler
Menu, SubPed, Add, 3rd Vac., HBVHandler
Menu, SubHBV, Add, Pediatric, :SubPed
Menu, SubAdu, Add, Booster Vac., HBVHandler
Menu, SubAdu, Add, 1st Vac., HBVHandler
Menu, SubAdu, Add, 2nd Vac., HBVHandler
Menu, SubAdu, Add, 3rd Vac., HBVHandler
Menu, SubHBV, Add, Adult (NonMC), :SubAdu
Menu, SubMC, Add, Booster Vac., HBVHandler
Menu, SubMC, Add, 1st Vac., HBVHandler
Menu, SubMC, Add, 2nd Vac., HBVHandler
Menu, SubMC, Add, 3rd Vac., HBVHandler
Menu, SubHBV, Add, Medicare, :SubMC
Menu, Vaccination, Add, Hepatitis B, :SubHBV
FluHandler:
Vaccine_type := "Afluria"
Vaccine_code := "v_PAM"
NumVac := "n"
If (A_ThisMenuItem = "Pediatric")
Admin_code := "a_P"
Else If (A_ThisMenuItem = "Adult (NonMC)")
Admin_code := "a_A"
Else If (A_ThisMenuItem = "Medicare")
Admin_code := "a_M"
Return
HBVHandler:
Vaccine_type := "Engerix"
If (A_ThisMenu = "SubPedc")
(
Vaccine_code := "v_P"
Admin_code := "a_P"
)
Else If (A_ThisMenu = "Adult (NonMC)")
(
Vaccine_code := "v_AM"
Admin_code := "a_A"
)
Else If (A_ThisMenu = "Medicare")
(
Vaccine_code := "v_AM"
Admin_code := "a_M"
)
If (A_ThisMenuItem = "Booster Vac.")
NumVac := "n_B"
Else If (A_ThisMenuItem = "1st Vac.")
NumVac := "n_1"
Else If (A_ThisMenuItem = "2nd Vac.")
NumVac := "n_2"
Else If (A_ThisMenuItem = "3rd Vac.")
NumVac := "n_3"
Return
F12::
VaccinationHandler()
Sleep, 300
Printing()
Return
Printing()
{
; For Hepatitis B Vaccination
SendInput, % Vaccines.%Vaccine_type%.%Vaccine_code%
SendInput, % Vaccines.%Vaccine_type%.%Admin_code%
SendInput, % Vaccines.%Vaccine_type%.%NumVac%
}
Code: Select all
SendInput, % Vaccines.Engerix.v_AM
Code: Select all
SendInput, % Vaccines.%Vaccine_type%.%Vaccine_code%
Code: Select all
SendInput, % Vaccines.%Vaccine_type%[%Vaccine_code%]
How can a variable be used to refer to the array's keys? Please teach me. Thank you.