diff --git a/encoder-ui/src/app/analysis/analysis.component.html b/encoder-ui/src/app/analysis/analysis.component.html index bacbab4..29ed338 100644 --- a/encoder-ui/src/app/analysis/analysis.component.html +++ b/encoder-ui/src/app/analysis/analysis.component.html @@ -44,7 +44,7 @@
-
+
@if (loading && !error) { @@ -56,7 +56,7 @@
} @if (!loading && !error) { -
+
} @@ -67,7 +67,7 @@ }
-
+
@@ -82,31 +82,24 @@ {{'TEXT' | transloco}} - {{'CODE' | transloco}} - {{'DESCRIPTION' | transloco}} - {{'SIMILARITY' | transloco}} + {{'MATCHES' | transloco}} + {{'ACTION' | transloco}} @for (textAndDiagnostic of textAndDiagnosticList; track $index) { - @for (diagnostic of textAndDiagnostic.diagnostics; track diagnostic; let i = $index) { - - {{textAndDiagnostic.rawText}} - - {{ diagnostic.code }} - - - {{ diagnostic.description }} - - - {{ diagnostic.similarity }} - - - } - } + + {{textAndDiagnostic.rawText}} + {{textAndDiagnostic.diagnostics.length}} + + + + + } } @@ -114,4 +107,15 @@
+ + + + +
\ No newline at end of file diff --git a/encoder-ui/src/app/analysis/analysis.component.ts b/encoder-ui/src/app/analysis/analysis.component.ts index 6001788..fd70aba 100644 --- a/encoder-ui/src/app/analysis/analysis.component.ts +++ b/encoder-ui/src/app/analysis/analysis.component.ts @@ -1,5 +1,6 @@ -import { Component, OnInit } from '@angular/core'; +import { Component, inject, OnInit, TemplateRef } from '@angular/core'; import { IrisService } from '../services/iris.service'; +import { NgbModal } from '@ng-bootstrap/ng-bootstrap'; interface Diagnostic { code: String; @@ -25,6 +26,7 @@ interface AnalysisText { }) export class AnalysisComponent implements OnInit{ + private modalService = inject(NgbModal); textUpdated: String = ""; diagnostics: Array = []; loading = false; @@ -39,6 +41,8 @@ export class AnalysisComponent implements OnInit{ textOriginal: string = ""; screenHeight: number = 0; textToMark: String = ""; + diagnosticsSelected: Array = []; + diagnosticText: String = ""; constructor(private irisService: IrisService) { @@ -155,4 +159,16 @@ export class AnalysisComponent implements OnInit{ textHTML = textHTML.replace("",""); this.textUpdated = textHTML; } + + open(content: TemplateRef, textAndDiagnostic: TextAndDiagnostic) { + this.diagnosticText = textAndDiagnostic.rawText; + this.diagnosticsSelected = textAndDiagnostic.diagnostics; + this.modalService.open(content, { ariaLabelledBy: 'modal-basic-title', size: 'xl' }).result.then( + (result) => { + }, + (reason) => { + + }, + ); + } } diff --git a/encoder-ui/src/app/analyzer/analyzer.component.html b/encoder-ui/src/app/analyzer/analyzer.component.html index fb98199..e774093 100644 --- a/encoder-ui/src/app/analyzer/analyzer.component.html +++ b/encoder-ui/src/app/analyzer/analyzer.component.html @@ -15,7 +15,7 @@
-
+
@if (loading && !error) { @@ -35,7 +35,7 @@ }
-
+
@@ -50,30 +50,23 @@ {{'TEXT' | transloco}} - {{'CODE' | transloco}} - {{'DESCRIPTION' | transloco}} - {{'SIMILARITY' | transloco}} + {{'MATCHES' | transloco}} + {{'ACTION' | transloco}} @for (textAndDiagnostic of textAndDiagnosticList; track $index) { - @for (diagnostic of textAndDiagnostic.diagnostics; track diagnostic; let i = $index) { - - {{textAndDiagnostic.rawText}} - - {{ diagnostic.code }} - - - {{ diagnostic.description }} - - - {{ diagnostic.similarity }} - - - } + + {{textAndDiagnostic.rawText}} + {{textAndDiagnostic.diagnostics.length}} + + + + } @@ -82,4 +75,15 @@
+ + + + +
\ No newline at end of file diff --git a/encoder-ui/src/app/analyzer/analyzer.component.ts b/encoder-ui/src/app/analyzer/analyzer.component.ts index 61b0693..b678e82 100644 --- a/encoder-ui/src/app/analyzer/analyzer.component.ts +++ b/encoder-ui/src/app/analyzer/analyzer.component.ts @@ -1,7 +1,8 @@ -import { Component } from '@angular/core'; +import { Component, inject, TemplateRef } from '@angular/core'; import { UntypedFormControl, UntypedFormGroup, Validators } from '@angular/forms'; import { IrisService } from '../services/iris.service'; import { TranslocoService } from '@ngneat/transloco'; +import { NgbModal } from '@ng-bootstrap/ng-bootstrap'; interface Diagnostic { code: String; @@ -22,12 +23,15 @@ interface TextAndDiagnostic { export class AnalyzerComponent { + private modalService = inject(NgbModal); textUpdated = ""; diagnostics: Array = []; loading = false; error = false; totalReceived = 0; textAndDiagnosticList: Array = []; + diagnosticsSelected: Array = []; + diagnosticText: String = ""; constructor(private irisService: IrisService, private translocoService: TranslocoService @@ -161,4 +165,16 @@ export class AnalyzerComponent { textHTML = textHTML.replace("",""); this.textUpdated = textHTML; } + + open(content: TemplateRef, textAndDiagnostic: TextAndDiagnostic) { + this.diagnosticText = textAndDiagnostic.rawText; + this.diagnosticsSelected = textAndDiagnostic.diagnostics; + this.modalService.open(content, { ariaLabelledBy: 'modal-basic-title', size: 'xl' }).result.then( + (result) => { + }, + (reason) => { + + }, + ); + } } diff --git a/encoder-ui/src/app/app.module.ts b/encoder-ui/src/app/app.module.ts index d7c0e7d..084300f 100644 --- a/encoder-ui/src/app/app.module.ts +++ b/encoder-ui/src/app/app.module.ts @@ -13,6 +13,7 @@ import { AnalysisComponent } from './analysis/analysis.component'; import { FunctionsPipe } from './utils/functions.pipe'; import { LoaderComponent } from './loader/loader.component'; import { TranslocoRootModule } from './transloco-root.module'; +import { MatchesListComponent } from './matches-list/matches-list.component'; @NgModule({ declarations: [ @@ -22,6 +23,7 @@ import { TranslocoRootModule } from './transloco-root.module'; AnalyzerComponent, AnalysisComponent, LoaderComponent, + MatchesListComponent, FunctionsPipe ], imports: [ diff --git a/encoder-ui/src/app/matches-list/matches-list.component.html b/encoder-ui/src/app/matches-list/matches-list.component.html new file mode 100644 index 0000000..c8d626c --- /dev/null +++ b/encoder-ui/src/app/matches-list/matches-list.component.html @@ -0,0 +1,53 @@ +@if (loading) { +
+
+
+
+ } + @if (!loading) { + + + + + + + + + + + @for (diagnostic of diagnosticsPage; track diagnostic; let i = $index) { + + + + + + + } + +
#{{'ICD-CODE' | transloco}}{{'DESCRIPTION' | transloco}}{{'SIMILARITY' | transloco}}
{{ i + 1 }} + {{ diagnostic.code }} + + {{ diagnostic.description }} + + {{ diagnostic.similarity }} +
+ +
+ + + + +
+ } \ No newline at end of file diff --git a/encoder-ui/src/app/matches-list/matches-list.component.scss b/encoder-ui/src/app/matches-list/matches-list.component.scss new file mode 100644 index 0000000..48d4a71 --- /dev/null +++ b/encoder-ui/src/app/matches-list/matches-list.component.scss @@ -0,0 +1,16 @@ +.similarity-veryhigh { + background-color: #27AE60; + color: white; +} +.similarity-high { + background-color: #46C84E; + color: white; +} +.similarity-medium { + background-color: #FFC300; + color: black; +} +.similarity-low { + background-color: #FF5733; + color: black; +} \ No newline at end of file diff --git a/encoder-ui/src/app/matches-list/matches-list.component.spec.ts b/encoder-ui/src/app/matches-list/matches-list.component.spec.ts new file mode 100644 index 0000000..36580cf --- /dev/null +++ b/encoder-ui/src/app/matches-list/matches-list.component.spec.ts @@ -0,0 +1,23 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { MatchesListComponent } from './matches-list.component'; + +describe('MatchesListComponent', () => { + let component: MatchesListComponent; + let fixture: ComponentFixture; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + imports: [MatchesListComponent] + }) + .compileComponents(); + + fixture = TestBed.createComponent(MatchesListComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/encoder-ui/src/app/matches-list/matches-list.component.ts b/encoder-ui/src/app/matches-list/matches-list.component.ts new file mode 100644 index 0000000..9e47582 --- /dev/null +++ b/encoder-ui/src/app/matches-list/matches-list.component.ts @@ -0,0 +1,49 @@ +import { Component, EventEmitter, Input, OnChanges, Output, SimpleChanges } from '@angular/core'; + +interface Diagnostic { + code: String; + description: String; + similarity: number; +} + +@Component({ + selector: 'app-matches-list', + templateUrl: './matches-list.component.html', + styleUrl: './matches-list.component.scss' +}) + +export class MatchesListComponent implements OnChanges{ + + @Input() diagnostics: Array = []; + @Output() newCodeEvent = new EventEmitter(); + + + diagnosticsPage: Array = []; + loading = true; + page = 1; + pageSize = 10; + collectionSize = 0; + + constructor() { + + } + + ngOnChanges(changes: SimpleChanges): void { + this.loadPage(); + } + + loadPage(): void { + this.collectionSize = this.diagnostics.length; + this.refreshOptions(); + this.loading = false; + + } + + refreshOptions() { + this.diagnosticsPage = this.diagnostics.map((option, i) => ({ id: i + 1, ...option })).slice( + (this.page - 1) * this.pageSize, + (this.page - 1) * this.pageSize + this.pageSize, + ); + } + +} \ No newline at end of file diff --git a/encoder-ui/src/assets/i18n/en.json b/encoder-ui/src/assets/i18n/en.json index 5ef437f..199a70b 100644 --- a/encoder-ui/src/assets/i18n/en.json +++ b/encoder-ui/src/assets/i18n/en.json @@ -37,5 +37,6 @@ "DIAG-5": "Typhoid meningitis", "IMPORTED-RECORDS": "Imported records", "VECTORIZED-RECORDS": "Vectorized records", - "SIMILARITIES": "Similarities found for" + "SIMILARITIES": "Similarities found for", + "MATCHES": "Matches" } diff --git a/encoder-ui/src/assets/i18n/es.json b/encoder-ui/src/assets/i18n/es.json index 4e488fc..3740670 100644 --- a/encoder-ui/src/assets/i18n/es.json +++ b/encoder-ui/src/assets/i18n/es.json @@ -37,5 +37,6 @@ "DIAG-5": "Meningitis tifoidea", "IMPORTED-RECORDS": "Registros importados", "VECTORIZED-RECORDS": "Registros vectorizados", - "SIMILARITIES": "Similitudes encontradas para" + "SIMILARITIES": "Similitudes encontradas para", + "MATCHES": "Coincidencias" } diff --git a/src/ENCODER/BP/AnalyzeTextProcess.cls b/src/ENCODER/BP/AnalyzeTextProcess.cls index 9d0987b..739a9a7 100644 --- a/src/ENCODER/BP/AnalyzeTextProcess.cls +++ b/src/ENCODER/BP/AnalyzeTextProcess.cls @@ -51,7 +51,7 @@ Method AnalyzeText(text As %String, analysisId As %String, language As %String) i = 0 for text in texts: iris.cls("Ens.Util.Log").LogInfo("ENCODER.BP.AnalyzeTextProcess", "AnalyzeText", text) - sqlsentence = "INSERT INTO ENCODER_Object.TextMatches (CodeId, Description, Similarity, AnalysisId, RawText) SELECT * FROM (SELECT CodeId, Description, VECTOR_DOT_PRODUCT(VectorDescription, TO_VECTOR('"+str(embeddingList[i])+"', DECIMAL)) AS Similarity, '"+analysisId+"', '"+text+"' FROM ENCODER_Object.Codes) WHERE Similarity > 0.7" + sqlsentence = "INSERT INTO ENCODER_Object.TextMatches (CodeId, Description, Similarity, AnalysisId, RawText) SELECT TOP 50 * FROM (SELECT CodeId, Description, VECTOR_DOT_PRODUCT(VectorDescription, TO_VECTOR('"+str(embeddingList[i])+"', DECIMAL)) AS Similarity, '"+analysisId+"', '"+text+"' FROM ENCODER_Object.Codes) WHERE Similarity > 0.6 ORDER BY Similarity DESC" #iris.cls("Ens.Util.Log").LogInfo("ENCODER.BP.AnalyzeTextProcess", "AnalyzeText", sqlsentence) iris.cls("ENCODER.Utils.Manager").ExecuteInsertQuery(sqlsentence) iris.cls("Ens.Util.Log").LogInfo("ENCODER.BP.AnalyzeTextProcess", "AnalyzeText", "Sentence finished")