diff --git a/Angular/src/app/app.routes.ts b/Angular/src/app/app.routes.ts index f754216..d32ee30 100644 --- a/Angular/src/app/app.routes.ts +++ b/Angular/src/app/app.routes.ts @@ -58,4 +58,11 @@ export const routes: Routes = [ (c) => c.FeedbackAnalyzerComponent, ), }, + { + path: 'health-report-ai', + loadComponent: () => + import('./pages/heath-report-ai/heath-report-ai.component').then( + (c) => c.HeathReportAiComponent, + ), + }, ]; diff --git a/Angular/src/app/pages/heath-report-ai/heath-report-ai.component.html b/Angular/src/app/pages/heath-report-ai/heath-report-ai.component.html new file mode 100644 index 0000000..617f779 --- /dev/null +++ b/Angular/src/app/pages/heath-report-ai/heath-report-ai.component.html @@ -0,0 +1,23 @@ +
+

Health/Laboratory Report using Vision Api - Google Ai

+
+
+ + + + + + + + + @if (result) { +
+

Ai Reponse on Health Report

+

{{result}}

+
+ } +
+
+
\ No newline at end of file diff --git a/Angular/src/app/pages/heath-report-ai/heath-report-ai.component.scss b/Angular/src/app/pages/heath-report-ai/heath-report-ai.component.scss new file mode 100644 index 0000000..e69de29 diff --git a/Angular/src/app/pages/heath-report-ai/heath-report-ai.component.spec.ts b/Angular/src/app/pages/heath-report-ai/heath-report-ai.component.spec.ts new file mode 100644 index 0000000..67ca53a --- /dev/null +++ b/Angular/src/app/pages/heath-report-ai/heath-report-ai.component.spec.ts @@ -0,0 +1,23 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { HeathReportAiComponent } from './heath-report-ai.component'; + +describe('HeathReportAiComponent', () => { + let component: HeathReportAiComponent; + let fixture: ComponentFixture; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + imports: [HeathReportAiComponent] + }) + .compileComponents(); + + fixture = TestBed.createComponent(HeathReportAiComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/Angular/src/app/pages/heath-report-ai/heath-report-ai.component.ts b/Angular/src/app/pages/heath-report-ai/heath-report-ai.component.ts new file mode 100644 index 0000000..215926d --- /dev/null +++ b/Angular/src/app/pages/heath-report-ai/heath-report-ai.component.ts @@ -0,0 +1,58 @@ +import { Component, inject } from '@angular/core'; +import { FormsModule } from '@angular/forms'; +import { GeminiGoogleAiService } from '../../services/gemini-google-ai/gemini-google-ai.service'; +import { ImageHelperService } from '../../helpers/image-helper.service'; +import { IVisionAi } from '../../interfaces/image-ai'; +import { LoadingService } from '../../services/loading/loading.service'; + +@Component({ + selector: 'app-heath-report-ai', + standalone: true, + imports: [FormsModule], + templateUrl: './heath-report-ai.component.html', + styleUrl: './heath-report-ai.component.scss' +}) +export class HeathReportAiComponent { + image: string = ''; + inlineImageData: IVisionAi = {}; + imageFile: File | null = null; + result: any | null = null; + + private geminiAiService = inject(GeminiGoogleAiService); + private imageHelper = inject(ImageHelperService); + private loadingService = inject(LoadingService); + + onFileChange(e: Event) { + const input = e.target as HTMLInputElement; + + if (input?.files && input.files[0]) { + const file = input.files[0]; + + // Getting base64 from file to render in DOM + this.imageHelper.getBase64(file) + .then((result: any) => { + this.image = result + }) + .catch(e => console.log(e)); + + // Generating content model for Gemini Google AI + this.imageHelper.fileToGenerativePart(file) + .then((image: IVisionAi) => { + this.inlineImageData = image; + }); + } else { + console.log("No file selected."); + } + } + + onHealthReportAnalysis() { + this.loadingService.onLoadingToggle(); + + this.geminiAiService.onImagePrompt('Analysethe provided health report of a patient and give feedback on the disease and some first aid treatment and also provide the best hospital to consult with doctor category to consult.', this.inlineImageData) + .then((response) => { + this.result = response; + this.loadingService.onLoadingToggle(); + }) + .catch(e => console.log(e)); + } +} diff --git a/Angular/src/app/pages/recipes-listing/recipes-listing.component.ts b/Angular/src/app/pages/recipes-listing/recipes-listing.component.ts index 2329da5..b824a10 100644 --- a/Angular/src/app/pages/recipes-listing/recipes-listing.component.ts +++ b/Angular/src/app/pages/recipes-listing/recipes-listing.component.ts @@ -48,7 +48,7 @@ export class RecipesListingComponent { desc: 'AI-Powered Plant Identification Tool for Instant Recognition and Information.', url: '/recognize-plant', github: - 'https://github.com/muhammadawaisshaikh/ai-python-Javascript/tree/main/Angular/src/app/pages/recognize-plant', + 'https://github.com/muhammadawaisshaikh/ai-python-Javascript/tree/main/Angular/src/app/pages/recognise-plant-ai', }, { title: 'Feedback Analyzer', @@ -58,5 +58,13 @@ export class RecipesListingComponent { github: 'https://github.com/muhammadawaisshaikh/ai-python-Javascript/tree/main/Angular/src/app/pages/recognize-plant', }, + { + title: 'Health Report Analysis', + img: 'assets/img/health-report-ai.png', + desc: 'AI-Powered analysis to your health or laboratory reports like CBC, CRP, CP and many more', + url: '/health-report-ai', + github: + 'https://github.com/muhammadawaisshaikh/ai-python-Javascript/tree/main/Angular/src/app/pages/heath-report-ai', + }, ]; } diff --git a/Angular/src/app/pages/recognise-plant-ai/recognise-plant-ai.component.ts b/Angular/src/app/pages/recognise-plant-ai/recognise-plant-ai.component.ts index 3ee3e80..2da78e4 100644 --- a/Angular/src/app/pages/recognise-plant-ai/recognise-plant-ai.component.ts +++ b/Angular/src/app/pages/recognise-plant-ai/recognise-plant-ai.component.ts @@ -32,7 +32,6 @@ export class RecognisePlantAiComponent { this.imageHelper.getBase64(file) .then((result: any) => { this.image = result - console.log(this.image); }) .catch(e => console.log(e)); @@ -40,7 +39,6 @@ export class RecognisePlantAiComponent { this.imageHelper.fileToGenerativePart(file) .then((image: IVisionAi) => { this.inlineImageData = image; - console.log(this.inlineImageData); }); } else { console.log("No file selected."); diff --git a/Angular/src/assets/img/health-report-ai.png b/Angular/src/assets/img/health-report-ai.png new file mode 100644 index 0000000..0d4d0d3 Binary files /dev/null and b/Angular/src/assets/img/health-report-ai.png differ