Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions Angular/src/app/app.routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
),
},
];
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<div class="container">
<h2 class="mb-4 pb-4 border-bottom text-center">Health/Laboratory Report using Vision Api - Google Ai</h2>
<div class="row justify-content-center">
<div class="mb-3 col-md-6 col-12">
<img [src]='image' class="w-100 mb-5 d-block m-auto" />

<!-- Image upload input -->
<input type="file" (change)="onFileChange($event)" accept="image/*" class="form-control" />

<button (click)="onHealthReportAnalysis()" [disabled]="!image" class="btn btn-primary mt-2 w-100 mt-3">
Analyse Laboratory Report
</button>

<!-- Display Analysis Result -->
@if (result) {
<div class="pt-5 text-center">
<h3>Ai Reponse on Health Report</h3>
<p>{{result}}</p>
</div>
}
</div>
</div>
</div>
Empty file.
Original file line number Diff line number Diff line change
@@ -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<HeathReportAiComponent>;

beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [HeathReportAiComponent]
})
.compileComponents();

fixture = TestBed.createComponent(HeathReportAiComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
});
});
58 changes: 58 additions & 0 deletions Angular/src/app/pages/heath-report-ai/heath-report-ai.component.ts
Original file line number Diff line number Diff line change
@@ -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));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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',
},
];
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,13 @@ export class RecognisePlantAiComponent {
this.imageHelper.getBase64(file)
.then((result: any) => {
this.image = result
console.log(this.image);
})
.catch(e => console.log(e));

// Generating content model for Gemini Google AI
this.imageHelper.fileToGenerativePart(file)
.then((image: IVisionAi) => {
this.inlineImageData = image;
console.log(this.inlineImageData);
});
} else {
console.log("No file selected.");
Expand Down
Binary file added Angular/src/assets/img/health-report-ai.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.