I have created a workflow that helps me with entering a list of symptoms for a patient. After I enter the list, the output is a list of symptoms separated by a comma. I cannot figure out how to add "and" prior to the last variable. I was thinking of using a simple RegEx Find and Replace on the Variable itself but some of the symptoms variables contain more than one word.
The scoring for the BDI list in my template is 0-3 in case you want to try it.
The challenge with a simple RegEx is that some of my variables contain multiple words in it. For example, a variable can be “pessimism” or “tiredness or fatigue”.
Before:
- Mildly bothered by sadness, pessimism, past failure, loss of pleasure, guilty feelings, self-dislike, suicidal thoughts or wishes, crying, loss of interest, worthlessness, loss of energy, changes in sleeping patterns, changes in appetite, tiredness or fatigue, loss of interest in sex.
After:
- Mildly bothered by sadness, pessimism, past failure, loss of pleasure, guilty feelings, self-dislike, suicidal thoughts or wishes, crying, loss of interest, worthlessness, loss of energy, changes in sleeping patterns, changes in appetite, tiredness or fatigue, and loss of interest in sex.
If you want to summarise when and where and in what form the data is gathered, we may be able to help you. Probably faster for you to do than for others
I attached my KM workflow in my initial post. Once the Prompt For Data Input pops up, I enter the score between 0-3. If the score is 0 then the variable is set to be empty. If the score is between 1-3, the variable is set to its name in either mild, moderate, or sever section. The output is then pasted into something like this:
- Mildly bothered by sadness, pessimism, past failure, loss of pleasure.
I then manually look at the entered data and add a “and” before the last comma. The problem is that the last variable in the sentence can be a single word or a combination of words like in the example above.
To solve this sort of problem I’ll do something like this for simplicity.
Step 1:
Collate answers as paragraphs:
Description, with commas, one
Description, with commas, two
Description, with commas, three
Description, with commas, four
Description, with commas, five
Find and replace to prefix the last line with “and”:
Find:
(?m)^(.+\Z)
Replace
and $1
Then find and replace the linefeeds with comma-space:
Find:
\n
Replace
,<space>
I may also do more passes with regex to remove any possible double-spaces and/or other junk in the finished text.
Well, IMO, it may be more comprehensive, but it is not simpler (your 3+ steps to my 1 step).
I try to provide the simplest solution given the requirement, which in this case was: