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

@@ -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 = () => {

View File

@@ -42,7 +42,6 @@ export class EngineService {
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) => {
let rows = data.split("\n");
let currentSectionType: SectionType | null = null;
let currentSection: Section | null = null;
let currentTreatmentDetails: TreatmentDetails | null = null;
@@ -75,55 +74,50 @@ export class TreatmentsService {
return;
}
if(isSectionLine(row)){
// new section starts
currentSectionType = getSectionType(row);
if(isSectionLine(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
if(currentSection){
currentSection.rows.push(row.trim());
}else{
throw new Error(`Tried to push row without a section: ${row}`);
// 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);
}
});
}