Skip to content

Commit

Permalink
first draft for required value of attribute and value filter #277
Browse files Browse the repository at this point in the history
  • Loading branch information
Shayan1375 committed Nov 10, 2024
1 parent 3ff9d5a commit fcc4be6
Show file tree
Hide file tree
Showing 15 changed files with 178 additions and 30 deletions.
8 changes: 7 additions & 1 deletion src/app/layout/font-awesome-icons.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
import { faAngleDoubleLeft, faExclamation, faFolderOpen } from '@fortawesome/free-solid-svg-icons';
import {
faAngleDoubleLeft,
faExclamation,
faExclamationTriangle,
faFolderOpen,
} from '@fortawesome/free-solid-svg-icons';
import { faAngleDoubleRight } from '@fortawesome/free-solid-svg-icons';
import { faAngleRight } from '@fortawesome/free-solid-svg-icons';
import { faArrowDown } from '@fortawesome/free-solid-svg-icons';
Expand Down Expand Up @@ -117,4 +122,5 @@ export const FONT_AWESOME_ICONS = [
faFileImage,
faFolderOpen,
faExclamation,
faExclamationTriangle,
];
58 changes: 35 additions & 23 deletions src/app/model/FeasibilityQuery/Criterion/AbstractCriterion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export abstract class AbstractCriterion {
private timeRestriction?: AbstractTimeRestriction;
private id: string;
private valueFilters?: Array<ValueFilter> = [];
private isRequiredFilterSet: boolean;

/**
* Constructor for AbstractCriterion.
Expand All @@ -34,6 +35,7 @@ export abstract class AbstractCriterion {
* @param termCodes - Array of TerminologyCode objects.
* @param timeRestriction - AbstractTimeRestriction object.
* @param valueFilters - Array of ValueFilter objects.
* @param isRequiredFilterSet
*/
constructor(
isReference: boolean,
Expand All @@ -42,12 +44,14 @@ export abstract class AbstractCriterion {
criterionHash?: string,
display?: string,
isInvalid?: boolean,
isRequiredFilterSet?: boolean,
position?: CritGroupPosition,
termCodes?: Array<TerminologyCode>,
timeRestriction?: AbstractTimeRestriction,
id?: string,
valueFilters?: Array<ValueFilter>
) {
this.isRequiredFilterSet = isRequiredFilterSet;
this.attributeFilters = attributeFilters;
this.context = context;
this.criterionHash = criterionHash;
Expand All @@ -65,15 +69,15 @@ export abstract class AbstractCriterion {
*
* @param isReference
*/
setisReference(isReference: boolean) {
public setisReference(isReference: boolean) {
this.isReference = isReference;
}

/**
*
* @returns
*/
getisReference(): boolean {
public getisReference(): boolean {
return this.isReference;
}

Expand All @@ -82,14 +86,14 @@ export abstract class AbstractCriterion {
*
* @returns Array of AttributeFilter objects or false if attributeFilters is undefined.
*/
isAttributeFiltersSet(): boolean {
public isAttributeFiltersSet(): boolean {
if (this.attributeFilters === undefined) {
return false;
}
return true;
}

getAttributeFilters(): Array<AttributeFilter> {
public getAttributeFilters(): Array<AttributeFilter> {
if (this.attributeFilters === undefined) {
return [];
}
Expand All @@ -101,7 +105,7 @@ export abstract class AbstractCriterion {
*
* @param attributeFilters - Array of AttributeFilter objects.
*/
setAttributeFilters(attributeFilters: Array<AttributeFilter>): void {
public setAttributeFilters(attributeFilters: Array<AttributeFilter>): void {
this.attributeFilters = attributeFilters;
}

Expand All @@ -110,7 +114,7 @@ export abstract class AbstractCriterion {
*
* @returns TerminologyCode object representing the context.
*/
getContext(): TerminologyCode | undefined {
public getContext(): TerminologyCode | undefined {
return this.context;
}

Expand All @@ -119,7 +123,7 @@ export abstract class AbstractCriterion {
*
* @param context - TerminologyCode object representing the context.
*/
setContext(context: TerminologyCode): void {
public setContext(context: TerminologyCode): void {
this.context = context;
}

Expand All @@ -128,7 +132,7 @@ export abstract class AbstractCriterion {
*
* @returns Hash string for the criterion.
*/
getCriterionHash(): string | undefined {
public getCriterionHash(): string | undefined {
return this.criterionHash;
}

Expand All @@ -137,7 +141,7 @@ export abstract class AbstractCriterion {
*
* @param criterionHash - Hash string for the criterion.
*/
setCriterionHash(criterionHash: string): void {
public setCriterionHash(criterionHash: string): void {
this.criterionHash = criterionHash;
}

Expand All @@ -146,7 +150,7 @@ export abstract class AbstractCriterion {
*
* @returns Display string for the criterion.
*/
getDisplay(): string | undefined {
public getDisplay(): string | undefined {
return this.display;
}

Expand All @@ -155,7 +159,7 @@ export abstract class AbstractCriterion {
*
* @param display - Display string for the criterion.
*/
setDisplay(display: string): void {
public setDisplay(display: string): void {
this.display = display;
}

Expand All @@ -164,7 +168,7 @@ export abstract class AbstractCriterion {
*
* @returns Boolean flag indicating if the criterion is invalid.
*/
getIsInvalid(): boolean | undefined {
public getIsInvalid(): boolean | undefined {
return this.isInvalid;
}

Expand All @@ -173,7 +177,7 @@ export abstract class AbstractCriterion {
*
* @param isInvalid - Boolean flag indicating if the criterion is invalid.
*/
setIsInvalid(isInvalid: boolean): void {
public setIsInvalid(isInvalid: boolean): void {
this.isInvalid = isInvalid;
}

Expand All @@ -182,7 +186,7 @@ export abstract class AbstractCriterion {
*
* @returns CritGroupPosition object representing the position.
*/
getPosition(): CritGroupPosition | undefined {
public getPosition(): CritGroupPosition | undefined {
return this.position;
}

Expand All @@ -191,7 +195,7 @@ export abstract class AbstractCriterion {
*
* @param position - CritGroupPosition object representing the position.
*/
setPosition(position: CritGroupPosition): void {
public setPosition(position: CritGroupPosition): void {
this.position = position;
}

Expand All @@ -200,7 +204,7 @@ export abstract class AbstractCriterion {
*
* @returns Array of TerminologyCode objects.
*/
getTermCodes(): Array<TerminologyCode> | undefined {
public getTermCodes(): Array<TerminologyCode> | undefined {
return this.termCodes;
}

Expand All @@ -209,7 +213,7 @@ export abstract class AbstractCriterion {
*
* @param termCodes - Array of TerminologyCode objects.
*/
setTermCodes(termCodes: Array<TerminologyCode>): void {
public setTermCodes(termCodes: Array<TerminologyCode>): void {
this.termCodes = termCodes;
}

Expand All @@ -218,7 +222,7 @@ export abstract class AbstractCriterion {
*
* @returns AbstractTimeRestriction object.
*/
getTimeRestriction(): AbstractTimeRestriction | undefined {
public getTimeRestriction(): AbstractTimeRestriction | undefined {
return this.timeRestriction;
}

Expand All @@ -227,7 +231,7 @@ export abstract class AbstractCriterion {
*
* @param timeRestriction - AbstractTimeRestriction object.
*/
setTimeRestriction(timeRestriction: AbstractTimeRestriction): void {
public setTimeRestriction(timeRestriction: AbstractTimeRestriction): void {
this.timeRestriction = timeRestriction;
}

Expand All @@ -236,7 +240,7 @@ export abstract class AbstractCriterion {
*
* @returns Unique identifier for the criterion.
*/
getId(): string {
public getId(): string {
return this.id;
}

Expand All @@ -245,7 +249,7 @@ export abstract class AbstractCriterion {
*
* @param id - Unique identifier for the criterion.
*/
setId(id: string): void {
public setId(id: string): void {
this.id = id;
}

Expand All @@ -254,7 +258,7 @@ export abstract class AbstractCriterion {
*
* @returns Array of ValueFilter objects or false if valueFilters is undefined.
*/
getValueFilters(): Array<ValueFilter> {
public getValueFilters(): Array<ValueFilter> {
return this.valueFilters;
}

Expand All @@ -263,7 +267,15 @@ export abstract class AbstractCriterion {
*
* @param valueFilters - Array of ValueFilter objects.
*/
setValueFilters(valueFilters: Array<ValueFilter>): void {
public setValueFilters(valueFilters: Array<ValueFilter>): void {
this.valueFilters = valueFilters;
}

public setIsRequiredFilterSet(isRequiredFilterSet: boolean): void {
this.isRequiredFilterSet = isRequiredFilterSet;
}

public getIsRequiredFilterSet(): boolean {
return this.isRequiredFilterSet;
}
}
5 changes: 5 additions & 0 deletions src/app/model/FeasibilityQuery/Criterion/CriterionBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export class CriterionBuilder {
private criterionHash?: string;
private display?: string;
private isInvalid?: boolean;
private isRequiredFilterSet: boolean;
private parentId: string;
private position?: CritGroupPosition;
private termCodes?: Array<TerminologyCode>;
Expand All @@ -37,6 +38,7 @@ export class CriterionBuilder {
criterionHash: string
display: string
isInvalid: boolean
isRequiredFilterSet: boolean
uniqueID: string
termCodes: Array<TerminologyCode>
}
Expand All @@ -45,6 +47,7 @@ export class CriterionBuilder {
this.criterionHash = mandatoryFields.criterionHash;
this.display = mandatoryFields.display;
this.isInvalid = mandatoryFields.isInvalid;
this.isRequiredFilterSet = mandatoryFields.isRequiredFilterSet;
this.uniqueID = mandatoryFields.uniqueID;
this.termCodes = mandatoryFields.termCodes;
}
Expand Down Expand Up @@ -145,6 +148,7 @@ export class CriterionBuilder {
this.criterionHash,
this.display,
this.isInvalid,
this.isRequiredFilterSet,
this.position,
this.termCodes,
this.timeRestriction,
Expand All @@ -167,6 +171,7 @@ export class CriterionBuilder {
this.criterionHash,
this.display,
this.isInvalid,
this.isRequiredFilterSet,
this.position,
this.termCodes,
this.timeRestriction,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export class ReferenceCriterion extends AbstractCriterion {
criterionHash: string,
display: string,
isInvalid: boolean,
isRequiredFilterSet: boolean,
position: CritGroupPosition,
termCodes: Array<TerminologyCode>,
timeRestriction: AbstractTimeRestriction,
Expand All @@ -29,6 +30,7 @@ export class ReferenceCriterion extends AbstractCriterion {
criterionHash,
display,
isInvalid,
isRequiredFilterSet,
position,
termCodes,
timeRestriction,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export class AttributeDefinitions extends AbstractAttributeDefinition {
constructor(
name: string,
type: FilterTypes,
optional: boolean = false,
optional: boolean,
allowedUnits: Array<QuantityUnit> = [],
attributeCode?: TerminologyCode,
max?: number,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ export class CloneAbstractCriterion {
criterionHash: string
display: string
isInvalid: boolean
isRequiredFilterSet: boolean
uniqueID: string
termCodes: Array<TerminologyCode>
} {
Expand All @@ -59,6 +60,7 @@ export class CloneAbstractCriterion {
criterionHash,
display,
isInvalid: abstractCriterion.getIsInvalid(),
isRequiredFilterSet: abstractCriterion.getIsRequiredFilterSet(),
uniqueID: uuidv4(),
termCodes,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,24 +82,45 @@ export class EditCriterionModalComponent implements OnInit {
criterionHash: string
display: string
isInvalid: boolean
isRequiredFilterSet: boolean
uniqueID: string
termCodes: Array<TerminologyCode>
} {
const context = criterion.getContext();
const termCodes = criterion.getTermCodes();
const display = criterion.getTermCodes()[0].getDisplay();
const criterionHash = this.criterion.getCriterionHash();

const isRequiredFilterSet = this.setIsFilterRequired(criterion);
return {
isReference: false,
context,
criterionHash,
display,
isInvalid: true,
isRequiredFilterSet,
uniqueID: criterion.getId(),
termCodes,
};
}

private setIsFilterRequired(criterion: Criterion): boolean {
return (
criterion
.getValueFilters()
.filter(
(valueFilter) =>
!valueFilter.getOptional() &&
valueFilter.getConcept()?.getSelectedConcepts().length <= 0
).length > 0 ||
this.criterion
.getAttributeFilters()
.filter(
(attributeFilter) =>
!attributeFilter.getOptional() &&
attributeFilter.getConcept()?.getSelectedConcepts().length <= 0
).length > 0
);
}
public updateValueFilter(valueFilter: ValueFilter) {
this.criterionBuilder.withValueFilters([valueFilter]);
}
Expand Down
Loading

0 comments on commit fcc4be6

Please sign in to comment.