Skip to content

Commit

Permalink
get a query better, but still a broken one II
Browse files Browse the repository at this point in the history
  • Loading branch information
mafasva committed May 7, 2024
1 parent e9f72d2 commit e53157e
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 18 deletions.
10 changes: 10 additions & 0 deletions src/app/shared/models/aqb/aqb-contains-composition-ui.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,14 @@ export class AqbContainsCompositionUiModel {
}

setContainsItem(archetypeId: string, archetypeReferenceId: number): void {
console.log(
'Lustige Sachen:',
archetypeId,
archetypeReferenceId,
this.compositionId,
this.compositionReferenceId,
this
)
const isExisting = !!this.existingItems.get(archetypeReferenceId)
if (!isExisting && archetypeId !== this.compositionId) {
const containsItem = new AqbContainsItemUiModel(
Expand Down Expand Up @@ -53,6 +61,8 @@ export class AqbContainsCompositionUiModel {
return {
_type: AqbNodeType.Containment,
// identifier: this.compositionReferenceId,
type: 'COMPOSITION',
identifier: 'c',
predicates: `[${this.compositionId}]`,
contains: subContains,
}
Expand Down
3 changes: 2 additions & 1 deletion src/app/shared/models/aqb/aqb-contains-item-ui.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@ export class AqbContainsItemUiModel {
convertToApi(): IAqbContainmentNode {
return {
_type: AqbNodeType.Containment,
type: 'OBSERVATION',
identifier: 'o',
predicates: `[${this.archetypeId}]`,
// identifier: this.archetypeReferenceId,
}
}
}
30 changes: 19 additions & 11 deletions src/app/shared/models/aqb/aqb-contains-ui.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,18 +40,26 @@ export class AqbContainsUiModel {
}

convertToApi(): PossibleContains {
const compositions = Array.from(this.compositions.values())
if (compositions.length > 1) {
const contains: IAqbLogicalOperatorNode<PossibleContains> = {
_type: AqbNodeType.LogicalOperator,
symbol: LogicalOperator.Or,
values: compositions.map((composition) => composition.convertToApi()),
function containsTree(compositions: AqbContainsCompositionUiModel[]) {
if (compositions.length > 1) {
const contains: IAqbLogicalOperatorNode<PossibleContains> = {
_type: AqbNodeType.LogicalOperator,
symbol: LogicalOperator.Or,
values: compositions.map((composition) => composition.convertToApi()),
}
return contains
} else if (compositions.length) {
return compositions[0].convertToApi()
} else {
return null
}
return contains
} else if (compositions.length) {
return compositions[0].convertToApi()
} else {
return null
}

return {
_type: AqbNodeType.Containment,
type: 'EHR',
identifier: 'e',
contains: containsTree(Array.from(this.compositions.values())),
}
}
}
6 changes: 5 additions & 1 deletion src/app/shared/models/aqb/aqb-select-item-ui.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,15 @@ export class AqbSelectItemUiModel {
}

convertToApi(): IAqbSelectExpressionNode {
console.log('RM Type', this.rmType, this)
return {
_type: AqbNodeType.SelectExpression,
columnExpression: {
_type: AqbNodeType.IdentifiedPath,
root: { _type: 'Containment', identifier: this.aqlPath },
root: {
_type: 'Containment',
identifier: `${this.isComposition ? 'c' : 'o'}${this.aqlPath}`,
},
},
alias: this.givenName.length
? this.givenName
Expand Down
1 change: 1 addition & 0 deletions src/app/shared/models/aqb/aqb-ui.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export class AqbUiModel {
constructor() {}

handleElementSelect(clickEvent: IAqbSelectClick): void {
console.log('CLICK', clickEvent)
const archetypeId = clickEvent.item.archetypeId || clickEvent.item.parentArchetypeId
const compositionReferenceKey = clickEvent.templateId + '--' + clickEvent.compositionId
const archetypeReferenceKey = clickEvent.templateId + '--' + archetypeId
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,19 @@ export interface IAqbContainmentNode {
_type: AqbNodeType.Containment

/**
* The id of this containment node.
* **This is the reference id for the select fields**
* RM class name, such as EHR, COMPOSITION, OBSERVATION etc.
*/
identifier?: number
type?: string

/**
* The archetype id from the template containment
* AQL variable name
*/
predicates: string
identifier?: string

/**
* A standard predicate or an archetype predicate.
*/
predicates?: string

/**
* Another nested containment or logical-operator node
Expand Down

0 comments on commit e53157e

Please sign in to comment.