Need help with this code which uses input selection form

Discussion, questions and support.
Post Reply
prasad383
Posts: 19
Joined: Oct 18th, ’19, 14:43

Post by prasad383 » Jul 22nd, ’20, 04:26

I am using this script for a scoring system.

Code: Select all


Right Upper lobe{tab}{100}%SELECT_Right_Upper_lobe%
Right Middle lobe{tab}{100}%SELECT_Right_Middle_lobe%
Right Lower lobe{tab}{100}%SELECT_Right_Lower_lobe%
Left Upper lobe {tab}{100}%SELECT_left_Upper_lobe%
Left Lower lobe  {tab}{100}%SELECT_left_lower_lobe%

Total score = -------

Each of the above %select% codes contains following options in a combobox entry.

Code: Select all

0%{tab}(0 Points)
<5%{tab}(1 Point)
5 to 25%{tab}(2 Points)
25 to 50%{tab}(3 Points)
50 to 75%{tab}(4 Points)
75 to 100%{tab}(5 Points)
These options range from 0 to 5 points. I want to be able to automatically calculate total score at the end (which can be minimum 0 to maxium 25). Please help me if this is possible. I have added 100 ms pause because it was not behaving properly without pause. I have inserted tabs so that it aligns the text.
User avatar
Marko
Posts: 1718
Joined: Mar 2nd, ’13, 21:02

Post by Marko » Jul 22nd, ’20, 19:39

Everything is possible! :D

Substitute (Type: Send). Pauses are not needed, what was your issue?

Code: Select all

Right Upper lobe{tab}%SELECT_Right_Upper_lobe%
Right Middle lobe{tab}%SELECT_Right_Middle_lobe%
Right Lower lobe{tab}%SELECT_Right_Lower_lobe%
Left Upper lobe {tab}%SELECT_left_Upper_lobe%
Left Lower lobe  {tab}%SELECT_left_lower_lobe%

Total score = %CODE_Calc%
I changed the selections slightly - added descriptions and made sure that the number of points is always on the same position to allow a simple sub-string extraction.

Code: Select all

0%::0%{tab}{tab}(0 Points)
<5%::<5%{tab}{tab}(1 Point )
5-25%::5 to 25%{tab}(2 Points)
25-50%::25 to 50%{tab}(3 Points)
50-75%::50 to 75%{tab}(4 Points)
75-100%::75 to 100%{tab}(5 Points)
And finally, use the Insert Command Code macro to perform the calculation:

Code: Select all

v1:=SubStr(SELECT_Right_Upper_lobe,-8,1)
v2:=SubStr(SELECT_Right_Middle_lobe,-8,1)
v3:=SubStr(SELECT_Right_Lower_lobe,-8,1)
v4:=SubStr(SELECT_left_Upper_lobe,-8,1)
v5:=SubStr(SELECT_left_lower_lobe,-8,1)
Send, % v1+v2+v3+v4+v5
prasad383
Posts: 19
Joined: Oct 18th, ’19, 14:43

Post by prasad383 » Jul 23rd, ’20, 02:12

Thank you Marko..! This code works great.. :) I was using pauses because with my code some of the lines were sent in bold font intermittently. I thought adding pauses will slow it down and correct it, but it didn't. But your code works perfectly. This is one of the scoring systems for covid19 patients and is going to help me with the reports. Thanks once again. Great support.
Post Reply