class ProgrammeSurvey{constructor(container,model,resultsModel){this.survey=new Survey.Model(model),this.survey.applyTheme(themeJson),this.$container=jQuery("#"+container),this.container=document.getElementById(container),this.resultsModel=resultsModel,this.init(),this.survey.onComplete.add(sender=>{let resultsData=sender.data;this.sendResults(resultsData).then(results=>{setContentByHandle(ibsResultsModelStack.summaryPageHandle)})})}destroySurvey(){this.container.innerHTML=""}init(){this.destroySurvey(),this.$container.Survey({model:this.survey})}async sendResults(resultsJson){const url=`https://programmes-1dd484baf257.herokuapp.com/results/${programmeCustomerData.id}?hashKey=${programmeCustomerData.secretKey}`;return await(await fetch(url,{method:"POST",body:JSON.stringify({newResult:resultsJson}),headers:{"Content-Type":"application/json"}})).json()}}function severityScore(resultsData){let painSeverity=0,abdominalPain=0,abdominalDistention=0,bowelHabits=0,lifeInterference=0;"painSeverity"in resultsData&&(painSeverity=resultsData.painSeverity),"abdominalPain"in resultsData&&(abdominalPain=resultsData.abdominalPain),"abdominalDistention"in resultsData&&(abdominalDistention=resultsData.abdominalDistention),"bowelHabits"in resultsData&&(bowelHabits=resultsData.bowelHabits),"lifeInterference"in resultsData&&(lifeInterference=resultsData.lifeInterference);let ibsSeverityScore=painSeverity+abdominalPain+abdominalDistention+bowelHabits+lifeInterference;return console.log(ibsSeverityScore,resultsData),ibsSeverityScore}class ProgrammeSurveyResults{constructor(container,resultsStack){this.$container=jQuery("#"+container),this.container=document.getElementById(container),this.resultsModel=resultsStack.resultsModel,this.progressModel=resultsStack.progressModel,this.previousResultsModel=resultsStack.previousResultsModel,this.summaryLine=resultsStack.summaryLine,this.init()}init(){this.getResults().then(results=>{let jsonResults=JSON.parse(results.value),surveyResults=jsonResults.filter(result=>result.painSeverity!=null||result.abdominalPain!=null||result.bristolStoolChart!=null);console.log("Survey Results",surveyResults),this.mountResults(surveyResults);let journalResults=jsonResults.filter(result=>result.mood_scale!=null).reverse();this.mountJournalResults(journalResults),this.createProgressChart(),this.createMoodChart()})}mountResults(resultsJson){if(this.results=resultsJson,this.container.innerHTML+='

IBS-SSS

',this.results.length==0){this.container.innerHTML=`

Previous results

You have no previous results

`;return}this.results.length==1&&(this.container.innerHTML=ibsResultsModel(this.results[0])),this.results.length>=2&&(this.container.innerHTML=` Results Journal `,this.container.innerHTML+=' ',this.container.innerHTML+=this.summaryLine(this.results),this.container.innerHTML+=this.progressModel(this.results),this.container.innerHTML+=this.resultsModel(this.results[this.results.length-1]),this.container.innerHTML+=`

Previous results

${this.previousResultsModel(this.results)}
`)}mountJournalResults(resultsJson){this.journalEntries=resultsJson,this.container.innerHTML+='

Journal

';const addANewEntry=()=>`

Log a new entry

How are you feeling today?

`;if(this.journalEntries.length==0){this.container.innerHTML+=`

Your entries

You have no journal entries

`;return}if(this.journalEntries.length==1){this.container.innerHTML+=`

Your entries

${journalResultsModel(this.journalEntries[0])}
`;return}if(this.journalEntries.length>=2){this.container.innerHTML+=`

Your entries

${this.journalEntries.map(entry=>journalResultsModel(entry)).join("")}
`;return}}async getResults(){const url=`https://programmes-1dd484baf257.herokuapp.com/results/${programmeCustomerData.id}?hashKey=${programmeCustomerData.secretKey}`;let response=await fetch(url);return response.status==404?[]:await response.json()}createProgressChart(){let xValues=[],yValues=[];this.results.reverse().forEach(result=>{xValues.push(new Date(result.date).toLocaleDateString()),yValues.push(severityScore(result))});const chart=new Chart("progressChart",{type:"line",data:{labels:xValues,datasets:[{fill:!1,lineTension:0,backgroundColor:"rgba(0,0,255,1.0)",borderColor:"rgba(0,0,255,0.1)",data:yValues}]},options:{legend:{display:!1},scales:{yAxes:[{ticks:{min:0,max:500},scaleLabel:{display:!0,labelString:"IBS Severity Score"}}]}}})}createMoodChart(){let xValues=[],yValues=[];this.journalEntries.reverse().forEach(result=>{xValues.push(new Date(result.date).toLocaleDateString()),yValues.push(result.mood_scale)});const chart=new Chart("moodChart",{type:"line",data:{labels:xValues,datasets:[{fill:!1,lineTension:0,backgroundColor:"rgba(0,0,255,1.0)",borderColor:"rgba(0,0,255,0.1)",data:yValues}]},options:{legend:{display:!1},scales:{yAxes:[{ticks:{min:0,max:5,stepSize:1},scaleLabel:{display:!0,labelString:"Mood"}}]}}})}}const ibsSymptomCheckerModel={title:"IBS Symptom Severity Score",description:`Please answer all of the following questions based on how you\u2019ve been feeling over the 7 days. `,logoFit:"none",logoPosition:"right",pages:[{name:"page1",description:"Drag the slider anywhere on the line between 0 and 100 to indicate as accurately as possible the severity of your symptoms.",elements:[{name:"painSeverity",title:"How severe is your pain?",rateCount:11,rateMin:0,rateMax:100,step:1,type:"nouislider",defaultValue:0,pipsValues:[0,25,50,75,100],format:wNumb({decimals:0}),pipsText:[{value:0,text:"No pain"},{value:25,text:"Not very severe"},{value:50,text:"Quite severe"},{value:75,text:"Severe"},{value:100,text:"Very severe"}]}],questionTitleLocation:"top"},{name:"page2",elements:[{type:"rating",name:"abdominalPain",title:"If currently in pain, how severe is your abdominal pain?",isRequired:!0,rateCount:11,rateMin:0,rateMax:100,step:1,defaultValue:0,type:"nouislider",pipsValues:[0,25,50,75,100],format:wNumb({decimals:0}),pipsText:[{value:0,text:"No pain"},{value:25,text:"Not very severe"},{value:50,text:"Quite severe"},{value:75,text:"Severe"},{value:100,text:"Very severe"}]}],questionTitleLocation:"top"},{name:"page3",elements:[{type:"rating",name:"abdominalDistention",title:"If you currently have abdominal distention, how severe is it?",isRequired:!0,rateCount:11,rateMin:0,rateMax:100,step:1,defaultValue:0,type:"nouislider",pipsValues:[0,25,50,75,100],format:wNumb({decimals:0}),pipsText:[{value:0,text:"No distention"},{value:25,text:"Not very severe"},{value:50,text:"Quite severe"},{value:75,text:"Severe"},{value:100,text:"Very severe"}]}],questionTitleLocation:"top"},{name:"page4",elements:[{type:"rating",name:"bowelHabits",title:"How satisfied are you with your bowel habits?",isRequired:!0,rateCount:11,rateMin:0,rateMax:100,step:1,type:"nouislider",pipsValues:[0,33,66,100],defaultValue:0,format:wNumb({decimals:0}),pipsText:[{value:0,text:"Very happy"},{value:33,text:"Quite happy"},{value:66,text:"Unhappy"},{value:100,text:"Very unhappy"}]}]},{name:"page5",elements:[{type:"rating",name:"lifeInterference",title:"How much does your IBS interfere or affect your life in general?",rateCount:11,rateMin:0,rateMax:100,step:1,type:"nouislider",pipsValues:[0,33,66,100],defaultValue:0,format:wNumb({decimals:0}),pipsText:[{value:0,text:"Not at all"},{value:33,text:"Not much"},{value:66,text:"Quite a lot"},{value:100,text:"Completely"}]}]},{name:"page6",elements:[{type:"checkbox",name:"bowelOpenings",title:"On average, how often are you opening your bowels? Please tick all that apply",choices:["Once a week","Once every 4-6 days ","Once every 2-3 days","Once a day","2-3 times a day","4-6 times a day","7+ times a day"]}]},{name:"page7",elements:[{type:"checkbox",name:"bristolStoolChart",title:"Which of these best describes your stool (poo)? Please tick all that apply",choices:["Type 1: separate hard lumps, like nuts; hard to pass","Type 2: sausage-shaped but lumpy","Type 3: like a sausage but with cracks on the surface","Type 4: like a sausage or snake, smooth and soft","Type 5: soft blobs with clear-cut edges","Type 6: fluffy pieces with ragged edges, a mushy stool","Type 7: watery, no solid pieces, entirely liquid"]}]}],showProgressBar:"hidden",progressBarType:"questions",goNextPageAutomatic:!0,startSurveyText:"Next",questionsOnPageMode:"questionPerPage",widthMode:"responsive",fitToContainer:!0,showCompletedPage:!1},journalModel={logoFit:"none",logoPosition:"right",pages:[{name:"journal",elements:[{type:"rating",name:"mood_scale",title:"How would you rate your mood today?",rateType:"smileys"},{type:"comment",name:"journal",title:"Journal",description:` This journal is a space for you to record anything that you want to make a note of during your low FODMAP journey. `}]}],showProgressBar:"hidden",progressBarType:"questions",goNextPageAutomatic:!0,startSurveyText:"Next",questionsOnPageMode:"questionPerPage",widthMode:"responsive",fitToContainer:!0,showCompletedPage:!1},themeJson={themeName:"contrast",colorPalette:"light",isPanelless:!1,cssVariables:{"--sjs-general-backcolor":"rgba(255, 255, 255, 1)","--sjs-general-backcolor-dark":"rgba(255, 216, 77, 1)","--sjs-general-backcolor-dim":"#FFFFFF","--sjs-general-backcolor-dim-light":"#ffffff","--sjs-general-backcolor-dim-dark":"rgba(255, 216, 77, 1)","--sjs-general-forecolor":"rgba(0, 0, 0, 1)","--sjs-general-forecolor-light":"rgba(0, 0, 0, 1)","--sjs-general-dim-forecolor":"rgba(0, 0, 0, 1)","--sjs-general-dim-forecolor-light":"rgba(0, 0, 0, 1)","--sjs-primary-backcolor":"rgba(0, 0, 0, 1)","--sjs-primary-backcolor-light":"rgba(255, 216, 77, 1)","--sjs-primary-backcolor-dark":"rgba(83, 83, 83, 1)","--sjs-primary-forecolor":"rgba(255, 255, 255, 1)","--sjs-primary-forecolor-light":"rgba(255, 255, 255, 0.25)","--sjs-base-unit":"8px","--sjs-secondary-backcolor":"rgba(255, 152, 20, 1)","--sjs-secondary-backcolor-light":"rgba(255, 152, 20, 0.1)","--sjs-secondary-backcolor-semi-light":"rgba(255, 152, 20, 0.25)","--sjs-secondary-forecolor":"rgba(255, 255, 255, 1)","--sjs-secondary-forecolor-light":"rgba(255, 255, 255, 0.25)","--sjs-shadow-small":"0px 0px 0px 2px rgba(0, 0, 0, 0)","--sjs-shadow-medium":"0px 0px 0px 2px rgba(0, 0, 0, 0)","--sjs-shadow-large":"0px 6px 0px 0px rgba(0, 0, 0, 0)","--sjs-shadow-inner":"0px 0px 0px 2px rgba(0, 0, 0, 0),0px -2px 0px 2px rgba(0, 0, 0, 0)","--sjs-border-light":"rgba(0, 0, 0, 0.2)","--sjs-border-default":"rgba(0, 0, 0, 0.2)","--sjs-border-inside":"rgba(0, 0, 0, 0.16)","--sjs-special-red":"rgba(229, 10, 62, 1)","--sjs-special-red-light":"rgba(229, 10, 62, 0.1)","--sjs-special-red-forecolor":"rgba(255, 255, 255, 1)","--sjs-special-green":"rgba(25, 179, 148, 1)","--sjs-special-green-light":"rgba(25, 179, 148, 0.1)","--sjs-special-green-forecolor":"rgba(255, 255, 255, 1)","--sjs-special-blue":"rgba(67, 127, 217, 1)","--sjs-special-blue-light":"rgba(67, 127, 217, 0.1)","--sjs-special-blue-forecolor":"rgba(255, 255, 255, 1)","--sjs-special-yellow":"rgba(255, 152, 20, 1)","--sjs-special-yellow-light":"rgba(255, 152, 20, 0.1)","--sjs-special-yellow-forecolor":"rgba(255, 255, 255, 1)","--sd-page-vertical-padding":"4px"}},ibsResultsModel=resultsData=>{let ibsSeverityScore=severityScore(resultsData),category="",explanation="";return ibsSeverityScore<75?(category="In remission",explanation=`Based on your answers, you scored ${ibsSeverityScore}. This suggests your IBS is currently in remission.
Because your symptoms are currently well controlled, it\u2019s unlikely you\u2019ll experience any change in your IBS by following a low FODMAP diet.
IBS symptoms can relapse, so you may want to return to a trial of the low FODMAP diet if your symptoms flare up.`):ibsSeverityScore>=75&&ibsSeverityScore<=174?(category="Mild",explanation=`Based on your answers, you scored ${ibsSeverityScore}, which classes your IBS symptom severity as mild.
We\u2019ll ask you to complete the IBS-SSS questionnaire again after you\u2019ve been following a low FODMAP diet after 2 weeks. This will help us determine if the diet has had a meaningful impact on your symptoms.`):ibsSeverityScore>=175&&ibsSeverityScore<=299?(category="Moderate",explanation=`Based on your answers, you scored ${ibsSeverityScore}, which classes your IBS symptom severity as moderate.
We\u2019ll ask you to complete the IBS-SSS questionnaire again after you\u2019ve been following a low FODMAP diet after 2 weeks. This will help us determine if the diet has had a meaningful impact on your symptoms.`):ibsSeverityScore>=300&&(category="Severe",explanation=`

Based on your answers, you scored ${ibsSeverityScore}, which classes your IBS symptom severity as severe.

We\u2019ll ask you to complete the IBS-SSS questionnaire again after you\u2019ve been following a low FODMAP diet after 2 weeks. This will help us determine if the diet has had a meaningful impact on your symptoms.

`),`

${category} IBS

${explanation}

Mild IBS = 75 to 174 points; moderate IBS = 175 to 299 points; and severe IBS = 300 points to more.

`},ibsResultsModel2=resultsData=>{let ibsSeverityScore=severityScore(resultsData),category="",explanation="";return ibsSeverityScore<75?(category="In remission",explanation=`

Based on your answers, your score is ${ibsSeverityScore}. This suggests your IBS is currently in remission.

Because your symptoms are currently well controlled, it\u2019s unlikely you\u2019ll experience any change in your IBS by following a low FODMAP diet.

IBS symptoms can relapse, so you may want to return to a trial of the low FODMAP diet if your symptoms flare up.

`):ibsSeverityScore>=75&&ibsSeverityScore<=174?(category="Mild",explanation=`Based on your answers, you scored ${ibsSeverityScore}, which classes your IBS symptom severity as mild.`):ibsSeverityScore>=175&&ibsSeverityScore<=299?(category="Moderate",explanation=`Based on your answers, you scored ${ibsSeverityScore}, which classes your IBS symptom severity as moderate.`):ibsSeverityScore>=300&&(category="Severe",explanation=`Based on your answers, you scored ${ibsSeverityScore}, which classes your IBS symptom severity as severe.`),`

Last score: ${category}

${explanation}

`},ibsSummaryLine=resultsDataArray=>{let firstResult=resultsDataArray[0],lastResult=resultsDataArray[resultsDataArray.length-1],firstScore=severityScore(firstResult),scoreDifference=severityScore(lastResult)-firstScore,congratsLine="";return scoreDifference>0?congratsLine=`

\u2757 Your score has increased from baseline by ${scoreDifference} points.

`:scoreDifference<0&&scoreDifference>-50?congratsLine=`

\u{1F44D} Your score has decreased from baseline by ${Math.abs(scoreDifference)} points.

`:scoreDifference<0&&scoreDifference<=-50&&(congratsLine=`

\u{1F389} Your results today suggest that the FODMAP diet has meaningfully improved your symptoms, which is great news!

Your score has decreased from baseline by ${Math.abs(scoreDifference)} points.

`),`${congratsLine}`},ibsPreviousResultsModel=resultsDataArray=>{resultsDataArray.reverse();let tableContents="";return resultsDataArray.forEach(result=>{console.log(result);let currentScore=severityScore(result),category="";currentScore<75?category="In remission":currentScore>=75&¤tScore<=174?category="Mild":currentScore>=175&¤tScore<=299?category="Moderate":currentScore>=300&&(category="Severe");let dateString=new Date(result.date).toLocaleDateString();tableContents+=`${dateString}${currentScore}${category}`}),` ${tableContents}
DateScoreCategory
`},ibsProgressResultsModel=resultsDataArray=>{let firstResult=resultsDataArray[0],lastResult=resultsDataArray[resultsDataArray.length-1],firstScore=severityScore(firstResult),scoreDifference=severityScore(lastResult)-firstScore,daysDifference=Math.round((new Date(lastResult.date)-new Date(firstResult.date))/(1e3*60*60*24)),scoreChange="",scoreChangeText="",whatNext="",congratsLine="",logButton='log a new journal entry';return scoreDifference>0?(scoreChange="Increased",scoreChangeText="Your score has increased from baseline by "+Math.abs(scoreDifference)+" points over "+daysDifference+" days.",whatNext="Abandon diet unless has had ++ stessful event or not following diet closely"):scoreDifference<0&&scoreDifference>-50?(scoreChange="Small decrease",scoreChangeText=`

How are you feeling?

Your score has reduced by XX points from baseline, so there's been some improvement in your symptoms. Now is a good time to make some notes on what changes you've noticed over the last two weeks.

${logButton}

When deciding whether a treatment is effective, health professionals look for a 50-point reduction in symptom severity. Your results today show that the low FODMAP hasn\u2019t had a significant impact on your IBS so far.

It can take up to a month for symptoms to respond to a low FODMAP diet. For this reason, we\u2019d recommend following a low FODMAP diet for a further 2 weeks before deciding on the next steps.

`,whatNext="Continue diet"):scoreDifference<=-51&&(scoreChange="Decreased",scoreChangeText=`

How are you feeling?

Your score has decreased by more than 50 points since baseline. Now is a good time to make some notes on what changes you\u2019ve noticed over the last two weeks.

${logButton}

When deciding whether a treatment is effective, health professionals look for a 50-point reduction in symptom severity.

Your results today suggest that the FODMAP diet has meaningfully improved your symptoms, which is great news!

It can take up to a month for symptoms to respond to a low FODMAP diet. For this reason, we\u2019d recommend following a low FODMAP diet for a further 2 weeks before deciding on the next steps.

`,congratsLine="

Your results today suggest that the FODMAP diet has meaningfully improved your symptoms, which is great news!

",whatNext="Continue diet"),`

Programme results

${scoreChangeText}

`},journalResultsModel=journalData=>`

${new Date(journalData.date).toLocaleDateString()} ${mapMoodScaleNumberToSmiley(journalData.mood_scale)}

${journalData.journal||"No journal data"}

`,ibsResultsModelStack={resultsModel:ibsResultsModel2,progressModel:ibsProgressResultsModel,previousResultsModel:ibsPreviousResultsModel,summaryLine:ibsSummaryLine,summaryPageHandle:"track-symptom-progress"},mapMoodScaleNumberToSmiley=number=>{switch(number){case 1:return"\u{1F62D}";case 2:return"\u{1F61E}";case 3:return"\u{1F610}";case 4:return"\u{1F642}";case 5:return"\u{1F600}"}},mapMoodScaleNumberToColor=number=>{switch(number){case 1:return"red";case 2:return"orange";case 3:return"yellow";case 4:return"lightgreen";case 5:return"green"}}; //# sourceMappingURL=/cdn/shop/t/104/assets/ProgrammeSurvey.js.map

search