new version
This commit is contained in:
@@ -3,14 +3,16 @@
|
||||
|
||||
<div class="explanation">
|
||||
<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>
|
||||
</div>
|
||||
|
||||
<h3>Conseils</h3>
|
||||
<ng-container *ngIf="hasResults()">
|
||||
<div class="recommendation" *ngFor="let r of recommendations.concat(discouragements)">
|
||||
<div class="treatment" [style.border-color]="computeScoreColor(r.score)"
|
||||
[style.color]="computeScoreColor(r.score)"
|
||||
<div class="recommendation" *ngFor="let r of recommendations.concat(discouragements); let index = index">
|
||||
<div class="treatment" [style.border-color]="computeScoreColor(r.score, index)"
|
||||
[style.color]="computeScoreColor(r.score, index)"
|
||||
(click)="openTreatmentDetails(r.treatment.code)">{{r.treatment.label}} ({{ r.score }})</div>
|
||||
</div>
|
||||
</ng-container>
|
||||
|
||||
@@ -34,7 +34,11 @@ export class ResultsComponent implements OnInit {
|
||||
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){
|
||||
return "#d3274f";
|
||||
}else if (score < 1){
|
||||
@@ -44,5 +48,7 @@ export class ResultsComponent implements OnInit {
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
hasResults = () => this.recommendations.length > 0 || this.discouragements.length > 0;
|
||||
}
|
||||
|
||||
@@ -21,6 +21,8 @@
|
||||
<p>
|
||||
Vous disposez également d'un onglet "CONTRE-INDICATIONS" que vous pouvez consulter pour étayer votre choix.
|
||||
</p>
|
||||
|
||||
<span class="signature">Victoria Allal</span>
|
||||
</div>
|
||||
<div class="buttons">
|
||||
<button class="btn" (click)="goToForm()">Commencer le questionnaire</button>
|
||||
|
||||
@@ -30,3 +30,10 @@ p {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.signature {
|
||||
display: block;
|
||||
text-align: right;
|
||||
width: 100%;
|
||||
font-size: 1.4em;
|
||||
}
|
||||
|
||||
@@ -11,12 +11,10 @@ export class AnswersService {
|
||||
|
||||
addAnswer = (answerIndex: string) => {
|
||||
this.answersIndexes.push(answerIndex);
|
||||
console.log(this.answersIndexes);
|
||||
}
|
||||
|
||||
removeAnswer = (answerIndex: string) => {
|
||||
this.answersIndexes.splice(this.answersIndexes.indexOf(answerIndex), 1);
|
||||
console.log(this.answersIndexes);
|
||||
}
|
||||
|
||||
resetAnswers = () => {
|
||||
|
||||
@@ -42,7 +42,6 @@ export class EngineService {
|
||||
discouraged: row[3].replace('\r', '').replace('_', '').split('')
|
||||
};
|
||||
}
|
||||
console.log('Outcomes loaded', this.OUTCOMES_MAP);
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
@@ -64,7 +64,6 @@ export class TreatmentsService {
|
||||
.subscribe((data) => {
|
||||
let rows = data.split("\n");
|
||||
|
||||
let currentSectionType: SectionType | null = null;
|
||||
let currentSection: Section | null = null;
|
||||
let currentTreatmentDetails: TreatmentDetails | null = null;
|
||||
|
||||
@@ -76,54 +75,49 @@ export class TreatmentsService {
|
||||
}
|
||||
|
||||
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"){
|
||||
// new treatment starts
|
||||
|
||||
// push previous treatment if exists
|
||||
// a new treatment starts, push previous into treatment list
|
||||
if(currentTreatmentDetails){
|
||||
this.TREATMENT_DETAILS.push(currentTreatmentDetails);
|
||||
}
|
||||
|
||||
// init next treatment
|
||||
// init new treatment
|
||||
currentTreatmentDetails = {
|
||||
treatment: parseTreatmentInfo(row),
|
||||
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 = {
|
||||
type: currentSectionType,
|
||||
title: parseSectionTitle(row, currentSectionType),
|
||||
rows: []
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// new line of current section
|
||||
}else{
|
||||
// new row of current section
|
||||
if(currentSection){
|
||||
currentSection.rows.push(row.trim());
|
||||
}else{
|
||||
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);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user