new version

This commit is contained in:
2023-11-06 22:01:42 +01:00
parent 0ae6ba1325
commit a32a9ceb66
7 changed files with 49 additions and 41 deletions

View File

@@ -3,14 +3,16 @@
<div class="explanation"> <div class="explanation">
<p>Les résultats sont classés du plus conseillé au moins conseillé.</p> <p>Les résultats sont classés du plus conseillé au moins conseillé.</p>
<p>Les résultats moins conseillés apparaissant en rouge ne sont pas forcément contre-indiqués.</p>
<p>Les indices de Pearl (IP) des différentes contraceptions sont notés sous la forme “IP théorique/pratique”, dans l’ordre des différentes contraceptions si plusieurs sont mentionnées dans la phrase.</p>
<p>Cliquez sur un traitement pour plus d'information.</p> <p>Cliquez sur un traitement pour plus d'information.</p>
</div> </div>
<h3>Conseils</h3> <h3>Conseils</h3>
<ng-container *ngIf="hasResults()"> <ng-container *ngIf="hasResults()">
<div class="recommendation" *ngFor="let r of recommendations.concat(discouragements)"> <div class="recommendation" *ngFor="let r of recommendations.concat(discouragements); let index = index">
<div class="treatment" [style.border-color]="computeScoreColor(r.score)" <div class="treatment" [style.border-color]="computeScoreColor(r.score, index)"
[style.color]="computeScoreColor(r.score)" [style.color]="computeScoreColor(r.score, index)"
(click)="openTreatmentDetails(r.treatment.code)">{{r.treatment.label}} ({{ r.score }})</div> (click)="openTreatmentDetails(r.treatment.code)">{{r.treatment.label}} ({{ r.score }})</div>
</div> </div>
</ng-container> </ng-container>

View File

@@ -34,7 +34,11 @@ export class ResultsComponent implements OnInit {
this.currentDetailsCode = null; this.currentDetailsCode = null;
} }
computeScoreColor = (score: number) => { computeScoreColor = (score: number, index: number) => {
if (index < 2){
// first two indexes are always displayed in green
return "#3fa58f";
}else{
if(score < 0){ if(score < 0){
return "#d3274f"; return "#d3274f";
}else if (score < 1){ }else if (score < 1){
@@ -44,5 +48,7 @@ export class ResultsComponent implements OnInit {
} }
} }
}
hasResults = () => this.recommendations.length > 0 || this.discouragements.length > 0; hasResults = () => this.recommendations.length > 0 || this.discouragements.length > 0;
} }

View File

@@ -21,6 +21,8 @@
<p> <p>
Vous disposez également d'un onglet "CONTRE-INDICATIONS" que vous pouvez consulter pour étayer votre choix. Vous disposez également d'un onglet "CONTRE-INDICATIONS" que vous pouvez consulter pour étayer votre choix.
</p> </p>
<span class="signature">Victoria Allal</span>
</div> </div>
<div class="buttons"> <div class="buttons">
<button class="btn" (click)="goToForm()">Commencer le questionnaire</button> <button class="btn" (click)="goToForm()">Commencer le questionnaire</button>

View File

@@ -30,3 +30,10 @@ p {
display: flex; display: flex;
justify-content: center; justify-content: center;
} }
.signature {
display: block;
text-align: right;
width: 100%;
font-size: 1.4em;
}

View File

@@ -11,12 +11,10 @@ export class AnswersService {
addAnswer = (answerIndex: string) => { addAnswer = (answerIndex: string) => {
this.answersIndexes.push(answerIndex); this.answersIndexes.push(answerIndex);
console.log(this.answersIndexes);
} }
removeAnswer = (answerIndex: string) => { removeAnswer = (answerIndex: string) => {
this.answersIndexes.splice(this.answersIndexes.indexOf(answerIndex), 1); this.answersIndexes.splice(this.answersIndexes.indexOf(answerIndex), 1);
console.log(this.answersIndexes);
} }
resetAnswers = () => { resetAnswers = () => {

View File

@@ -42,7 +42,6 @@ export class EngineService {
discouraged: row[3].replace('\r', '').replace('_', '').split('') discouraged: row[3].replace('\r', '').replace('_', '').split('')
}; };
} }
console.log('Outcomes loaded', this.OUTCOMES_MAP);
}); });
}; };

View File

@@ -64,7 +64,6 @@ export class TreatmentsService {
.subscribe((data) => { .subscribe((data) => {
let rows = data.split("\n"); let rows = data.split("\n");
let currentSectionType: SectionType | null = null;
let currentSection: Section | null = null; let currentSection: Section | null = null;
let currentTreatmentDetails: TreatmentDetails | null = null; let currentTreatmentDetails: TreatmentDetails | null = null;
@@ -75,55 +74,50 @@ export class TreatmentsService {
return; return;
} }
if(isSectionLine(row)){ if(isSectionLine(row)) {
// new section starts
currentSectionType = getSectionType(row);
// new section starts: push previous section into its treatment
if(currentTreatmentDetails && currentSection){
currentTreatmentDetails?.sections.push(currentSection);
}
const currentSectionType = getSectionType(row);
if(currentSectionType === "info"){ if(currentSectionType === "info"){
// new treatment starts // a new treatment starts, push previous into treatment list
// push previous treatment if exists
if(currentTreatmentDetails){ if(currentTreatmentDetails){
this.TREATMENT_DETAILS.push(currentTreatmentDetails); this.TREATMENT_DETAILS.push(currentTreatmentDetails);
} }
// init next treatment // init new treatment
currentTreatmentDetails = { currentTreatmentDetails = {
treatment: parseTreatmentInfo(row), treatment: parseTreatmentInfo(row),
sections: [] sections: []
};
}else{
// new free or formatted section starts
// push previous section if exists
if(currentSection){
if(currentTreatmentDetails){
currentTreatmentDetails.sections.push(currentSection)
}else{
throw new Error(`Tried to push section in a non existing treatment: ${currentSection}`);
}
} }
// current section reset
currentSection = null;
}else if (currentSectionType === "formatted" || currentSectionType === "free"){
// formatted section starts, init new section
currentSection = { currentSection = {
type: currentSectionType, type: currentSectionType,
title: parseSectionTitle(row, currentSectionType), title: parseSectionTitle(row, currentSectionType),
rows: [] rows: []
} }
} }
}else{
return; // new row of current section
}
// new line of current section
if(currentSection){ if(currentSection){
currentSection.rows.push(row.trim()); currentSection.rows.push(row.trim());
}else{ }else{
throw new Error(`Tried to push row without a section: ${row}`); throw new Error(`Tried to push row without a section: ${row}`);
} }
}
}); });
console.log(this.TREATMENT_DETAILS); // push previous treatment (the last one)
if(currentTreatmentDetails){
this.TREATMENT_DETAILS.push(currentTreatmentDetails);
}
}); });
} }