Trying to figure out Complementary Correlation

User-to-User discussion about the PhraseExpress macro programming.
Post Reply
AdventurousGoose
Posts: 13
Joined: 24 Feb 21, 06:33

Trying to figure out Complementary Correlation

Post by AdventurousGoose » 24 Feb 21, 06:44

I have been trying to figure out how to do the complementary correlation just as it was done in this post from a few years ago viewtopic.php?f=146&t=15846&p=49439&hilit=batman#p49439:
Peter Stotz wrote:
05 Feb 17, 18:22
@happy5,
here my suggestion - an example with 'a phrase set'
1. Phrase - autotext: (just as you like)
phrase-content:

Code: Select all

{#form -text Cold and flu symptoms}{#formeditbox -text Patient name -single -required} is brought here by the {#formeditbox -text family member -single} because of {#settemp -name ##positive_symptoms -content {#formcheckcombo -text symptoms -hint Make selection… -items sore_throat|abdominal_pain|anorexia|cough|diarrhea|fever|muscle_aches|nausea|vomiting -vals abdominal_pain|anorexia|cough|diarrhea|fever|muscle_aches|nausea|vomiting| -enum ,{#asc 32} -lastenum {#asc 32}and{#asc 32}}}{#check -text {#length {#gettemp ##positive_symptoms}} -case == 0 -output {#settemp -name ##positive_symptoms -content sore_throat} -else }{#replace {#gettemp ##positive_symptoms} -oldtext _ -newtext {#asc 32}} for the past {#formeditbox -text days of sickness -hint days of sickness -single -required} day{#check -text {#formeditbox -text days of sickness -hint days of sickness -single -required} -case != 1 -output s -else }.{#settemp -name ##negative_symptoms -content sore_throat|abdominal_pain|anorexia|cough|diarrhea|fever|muscle_aches|nausea|vomiting|}{#settemp -name ##tmp -content {#replace {#replace {#gettemp ##positive_symptoms} -oldtext {#asc 32}and{#asc 32} -newtext |} -oldtext ,{#asc 32} -newtext |}|}{#insert *negative_symptoms}{#check -text {#length {#gettemp ##negative_symptoms}} -case != 0 -output {#settemp -name ##negative_symptoms -content {#replace {#trimright {#replace {#gettemp ##negative_symptoms} -oldtext {#asc 124} -newtext {#asc 32}}} -oldtext {#asc 32} -newtext ,{#asc 32}}}{#check -text {#gettemp ##negative_symptoms} -case =.= ,{#asc 32} -output {#settemp -name ##negative_symptoms -content {#substr {#gettemp ##negative_symptoms} -from 1 -count {#calc {#lastpos {#gettemp ##negative_symptoms} -substr ,{#asc 32}}-1 -round 0}} or {#substr {#gettemp ##negative_symptoms} -from {#calc {#lastpos {#gettemp ##negative_symptoms} -substr ,{#asc 32}}+2 -round 0} -count }} -else }{#check -text {#gettemp ##negative_symptoms} -case .= {#asc 32}or{#asc 32} -output {#settemp -name ##negative_symptoms -content {#substr {#gettemp ##negative_symptoms} -from 3 -count }} -else } The {#formeditbox -text family member -single} refers {#formeditbox -text Patient name -single -required} does not have {#replace {#gettemp ##negative_symptoms} -oldtext _ -newtext {#asc 32}}. -else }
2. 'Subphrase' (self-referenciell) with autotext: *complementary_correlation
phrase content:

Code: Select all

{#settemp -name ##negative_symptoms -content {#replace {#gettemp ##negative_symptoms} -oldtext {#substr {#gettemp ##tmp} -from 1 -count {#pos {#gettemp ##tmp} -substr |}} -newtext }}{#settemp -name ##tmp -content {#substr {#gettemp ##tmp} -from {#calc {#pos {#gettemp ##tmp} -substr |}+1 -round 0} -count }}{#check -text {#length {#gettemp ##tmp}} -case != 0 -output {#insert *complementary_correlation} -else}
And hey - I wish Batman a speedy recovery! ;-)
Peter
Win 10-1607 64 bit - PhraseExpress 12.0.128i
I am having the same issue as the poster at that time, with it repeating all the symptoms in the second sentence. I have each on in separate phrases, so I don't understand what the issue is exactly or how they fixed the problem.

Peter Stotz
PhraseExpress Expert
Posts: 923
Joined: 27 Feb 08, 15:07

Post by Peter Stotz » 24 Feb 21, 12:27

@AdventurousGoose

An example for a complementary correlation:
superset : ___|Anton|Anna|Ben|Bettina|Emil|Eva|Luca|Lisa|Noah|Nina|
subset : __________|Anna ___|Bettina ____|Eva ___|Lisa_____|Nina|
complement: _|Anton ____|Ben ______|Emil____|Luca __|Noah|

Import file
Complementary Correlation - an example.pxp
Peter Stotz
Windows 10 - PhraseExpress v15.0.84
You do not have the required permissions to view the files attached to this post.

AdventurousGoose
Posts: 13
Joined: 24 Feb 21, 06:33

Post by AdventurousGoose » 24 Feb 21, 22:05

So, the conceptual side of it isn't my main issue, I don't think. In the original post the OP stated the same issue that I am dealing with regarding the second sentence that should show the negatives showing all items, irrespective of if anything was checked. The issue was then resolved when they 'separated' the code into unique phrases, instead of 1 (I assume). I have two phrases created, but I am still having the issue, so I am assuming there is some issue in the way I am setting everything up that is incorrect.
happy5 wrote:
06 Feb 17, 01:02
Ok this works. I know what I did wrong - copied the code into a single phrase file. When I separated them it worked great.

Can you guide me to the part of the online help it explains complementary correlation?

I want to do the same thing with a form checkbox with multiple selections. Once I get the hang of it I can customize it to my needs.

Here is an example of how I would like it to look:

Code: Select all

{#form -text Sore throat}{#formeditbox -text Patient name -single -required } is brought here by the {#formcombobox -text Family member -hint family member -items mother|father|parents|a family member|legal guardian|paternal grandfather|paternal grandmother|maternal grandfather|maternal grandmother|maternal aunt|maternal grandparents|maternal uncle|paternal aunt|paternal grandparents|paternal uncle -def mother -required } because of a sore throat, {#formgroup -text Current symptoms -enum ,  -lastenum  and  -items {#formcheckbox -text abdominal pain -vals abdominal pain}{#FORMCHECKBOX -TEXT anorexia -VALS anorexia}{#FORMCHECKBOX -TEXT cough -VALS cough}{#FORMCHECKBOX -TEXT diarrhea -VALS diarrhea}{#FORMCHECKBOX -TEXT fever -VALS fever}{#FORMCHECKBOX -TEXT muscle aches -VALS muscle aches}{#FORMCHECKBOX -TEXT nausea -VALS nausea}{#FORMCHECKBOX -TEXT vomiting -VALS vomiting}} for the past {#formeditbox -text days of sickness -hint days of sickness -single -required } days.
Peter Stotz wrote:@happy5
here an example of my output:
Tom is brought here by the Mother because of sore throat, cough and fever for the past 2 days. The Mother refers Tom does not have abdominal pain, anorexia, diarrhea, muscle aches, nausea or vomiting.
Maybe a copy problem with the forum software...
Please check the file attachment.

Peter

AdventurousGoose
Posts: 13
Joined: 24 Feb 21, 06:33

Post by AdventurousGoose » 26 Feb 21, 03:28

Here is an example, shown in the images below. I selected sore throat, abdominal pain, and anorexia from the code originally posted.

The output result is:
Will is brought here by the mom because of sore, throat, abdominal pain and anorexia for the past 5 days. The refers does have sore throat, abdominal pain, anorexia, cough, diarrhea, fever, muscle aches, nausea and vomiting.

The mom refers Will does not have sore throat,, abdominal pain,, anorexia,, cough,, diarrhea,, fever,, muscle aches,, nausea,, or vomiting.

What is occurring that is allowing it to repeat the positive symptoms again in the negative symptoms list? And I'm not certain why it is repeating the statement again below the initial statement, again with all the positive symptoms stated a third time.

Image
Image

Peter Stotz
PhraseExpress Expert
Posts: 923
Joined: 27 Feb 08, 15:07

Post by Peter Stotz » 26 Feb 21, 17:18

@AdventurousGoose
Attached is the macro program set c+f Cold and Flu Symptoms.
Recording Cold and Flu Symptoms.pxp
Take a look at the #insert subroutine *complementary_correlation

Output example:
• Peter is brought here by the mother because of a abdominal pain, cough and fever for the past 3 days.
The mother refers Peter does not have anorexia, chills, diarrhea, headache, muscle aches, nausea, rash, sore throat or vomiting.
• No sick contacts/no travel.
• There is no exposure to second-hand smoke.
• concerns...

I think it works properly...

Peter Stotz
Windows 10 - PhraseExpress v15.0.84
You do not have the required permissions to view the files attached to this post.

AdventurousGoose
Posts: 13
Joined: 24 Feb 21, 06:33

Post by AdventurousGoose » 27 Feb 21, 19:13

It worked perfectly! I don't fully understand what the issue was with the copy/paste.

Much appreciated!

Post Reply