Commit 6aabf387 authored by Almouhannad's avatar Almouhannad

(F) Finish history

parent 65713e1b
...@@ -54,6 +54,8 @@ import { CreateVisitComponent } from './components/doctor/create-visit/create-vi ...@@ -54,6 +54,8 @@ import { CreateVisitComponent } from './components/doctor/create-visit/create-vi
import { MedicinesComponent } from './components/doctor/medicines/medicines.component'; import { MedicinesComponent } from './components/doctor/medicines/medicines.component';
import { AccordionDirective } from './directives/accordion.directive'; import { AccordionDirective } from './directives/accordion.directive';
import { PatientIsComingNotificationComponent } from './components/doctor/patient-is-coming-notification/patient-is-coming-notification.component'; import { PatientIsComingNotificationComponent } from './components/doctor/patient-is-coming-notification/patient-is-coming-notification.component';
import { VisitsService } from './services/visits/visits.service';
import { ArabicDatePipe } from './pipes/arabic-date.pipe';
@NgModule({ @NgModule({
...@@ -81,6 +83,7 @@ import { PatientIsComingNotificationComponent } from './components/doctor/patien ...@@ -81,6 +83,7 @@ import { PatientIsComingNotificationComponent } from './components/doctor/patien
WaitingListService, WaitingListService,
EmployeesDataService, EmployeesDataService,
DoctorNotificationsService, DoctorNotificationsService,
VisitsService,
], ],
// components and directives that belong to this module // components and directives that belong to this module
...@@ -126,6 +129,7 @@ import { PatientIsComingNotificationComponent } from './components/doctor/patien ...@@ -126,6 +129,7 @@ import { PatientIsComingNotificationComponent } from './components/doctor/patien
MedicinesComponent, MedicinesComponent,
AccordionDirective, AccordionDirective,
PatientIsComingNotificationComponent, PatientIsComingNotificationComponent,
ArabicDatePipe,
], ],
// identifies the root component that Angular should // identifies the root component that Angular should
......
...@@ -3,9 +3,10 @@ import { MedicineView } from "../medicine/medicine-view"; ...@@ -3,9 +3,10 @@ import { MedicineView } from "../medicine/medicine-view";
export class VisitView { export class VisitView {
doctorName: string; doctorName: string;
diagnosis: string; diagnosis: string;
date: Date;
medicines: MedicineView[]; medicines: MedicineView[];
constructor(doctorName: string = '', diagnosis: string = '', medicines: MedicineView[] = []) { constructor(doctorName: string = '', diagnosis: string = '', date: Date = new Date(Date.now()), medicines: MedicineView[] = []) {
this.doctorName = doctorName; this.doctorName = doctorName;
this.diagnosis = diagnosis; this.diagnosis = diagnosis;
this.medicines = medicines; this.medicines = medicines;
......
<div class="custom-child"> <div class="custom-child">
<section class="section"> <section class="section">
<div class="custom-title"> <div class="custom-title">
<h2 >زيارات المريض محمد رضا وائل تقلا</h2> <h2 >زيارات المريض {{getEmployeeFullName()}}</h2>
</div> </div>
<div *ngFor="let visit of visits; let i = index">
<div> <app-visit [visit]="visit" [index]="i.toString()"></app-visit>
<app-visit [index]="'1'"></app-visit>
<!-- <hr style="border:2px solid var(--heading-color);"> -->
</div> </div>
<div>
<app-visit [index]="'2'"></app-visit>
<!-- <hr style="border:2px solid var(--heading-color);"> -->
</div>
<div>
<app-visit [index]="'3'"></app-visit>
<!-- <hr style="border:2px solid var(--heading-color);"> -->
</div>
<div>
<app-visit [index]="'4'"></app-visit>
<!-- <hr style="border:2px solid var(--heading-color);"> -->
</div>
<div>
<app-visit [index]="'5'"></app-visit>
<!-- <hr style="border:2px solid var(--heading-color);"> -->
</div>
</section> </section>
......
import { Component } from '@angular/core'; import { Component, OnChanges, OnInit, SimpleChanges } from '@angular/core';
import { EmployeesDataService } from '../../../services/employees/employees-data.service';
import { ActivatedRoute, Router } from '@angular/router';
import { ToastrService } from 'ngx-toastr';
import { EmployeeData } from '../../../classes/employeeData/employee-data';
import { VisitView } from '../../../classes/visit/visit-view';
import { VisitsService } from '../../../services/visits/visits.service';
@Component({ @Component({
selector: 'app-history', selector: 'app-history',
templateUrl: './history.component.html', templateUrl: './history.component.html',
styleUrl: './history.component.css' styleUrl: './history.component.css'
}) })
export class HistoryComponent { export class HistoryComponent implements OnInit {
constructor(private employeesDataService: EmployeesDataService,
private route: ActivatedRoute,
private toastrService: ToastrService,
private router: Router,
private visitsService: VisitsService
) {}
ngOnInit(): void {
this.setId();
}
patientId: number;
setId(): void {
this.route.params.subscribe((params: any) => {
this.patientId = Number(params.id);
if (isNaN(this.patientId)) {
this.toastrService.error('حدثت مشكلة، يرجى إعادة المحاولة');
this.router.navigateByUrl('doctor/waitinglist');
}
this.getEmployee();
this.getVisits();
});
}
employee: EmployeeData = new EmployeeData();
getEmployee(): void {
this.employeesDataService.getById(this.patientId)
.subscribe(result => {
if (result.status === false) {
this.toastrService.error('حدثت مشكلة، يرجى إعادة المحاولة');
this.router.navigateByUrl('doctor/waitinglist');
}
else {
this.employee = result.employeeData!;
}
})
}
getEmployeeFullName(): string {
return `${this.employee.firstName} ${this.employee.middleName} ${this.employee.lastName}`;
}
visits: VisitView[];
getVisits(): void {
this.visitsService.getAllByPatientId(this.patientId)
.subscribe(result => {
if (result.status === false) {
this.toastrService.error('حدثت مشكلة، يرجى إعادة المحاولة');
this.router.navigateByUrl('doctor/waitinglist');
}
else {
this.visits = result.visits!;
}
})
}
} }
...@@ -13,22 +13,17 @@ ...@@ -13,22 +13,17 @@
</thead> </thead>
<tbody> <tbody>
<tr>
<th scope="row">1</th> <tr *ngFor="let medicine of medicines; let i = index">
<td>أسبيرين</td> <th scope="row">{{i+1}}</th>
<td>حب</td> <td>{{medicine.name}}</td>
<td>20 حبة</td> <td>{{medicine.form}}</td>
<td>1000</td> <td *ngIf="medicine.form==='حبوب'">{{medicine.amount}} حبة</td>
<td>3</td> <td *ngIf="medicine.form==='شراب'">{{medicine.amount}} مل</td>
</tr> <td>{{medicine.dosage}}</td>
<tr> <td>{{medicine.number}}</td>
<th scope="row">2</th>
<td>باراسيتامول</td>
<td>شراب</td>
<td>500 ملل</td>
<td>500</td>
<td>2</td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
</div> </div>
......
import { Component } from '@angular/core'; import { Component, Input } from '@angular/core';
import { MedicineView } from '../../../classes/medicine/medicine-view';
@Component({ @Component({
selector: 'app-medicines', selector: 'app-medicines',
...@@ -7,4 +8,5 @@ import { Component } from '@angular/core'; ...@@ -7,4 +8,5 @@ import { Component } from '@angular/core';
}) })
export class MedicinesComponent { export class MedicinesComponent {
@Input("medicines") medicines: MedicineView[] = [];
} }
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
appAccordion [index]="index" appAccordion [index]="index"
(click)="isSelected = !isSelected" (click)="isSelected = !isSelected"
> >
زيارة بتاريخ 12/8/2024 زيارة يوم {{visit.date | arabicDate}}
<i *ngIf="!isSelected" class="fas fa-chevron-down"></i> <i *ngIf="!isSelected" class="fas fa-chevron-down"></i>
<i *ngIf="isSelected" class="fas fa-chevron-up"></i> <i *ngIf="isSelected" class="fas fa-chevron-up"></i>
...@@ -23,15 +23,15 @@ ...@@ -23,15 +23,15 @@
<div class="accordion-body custom-child"> <div class="accordion-body custom-child">
<div class="custom-visit-details mb-4"> <div class="custom-visit-details mb-4">
<h2>الطبيب: أحمد محمد فريد حافظ</h2> <h2>الطبيب: د. {{visit.doctorName}}</h2>
</div> </div>
<div class="custom-visit-details mb-4"> <div class="custom-visit-details mb-4">
<h2>التشخيص: التهاب أمعاء</h2> <h2>التشخيص: {{visit.diagnosis}}</h2>
</div> </div>
<div class="custom-visit-details mb-4"> <div class="custom-visit-details mb-4">
<h2>الأدوية:</h2> <h2>الأدوية:</h2>
</div> </div>
<app-medicines></app-medicines> <app-medicines [medicines]="visit.medicines"></app-medicines>
</div> </div>
</div> </div>
......
import { Component, Input } from '@angular/core'; import { Component, Input } from '@angular/core';
import { VisitView } from '../../../classes/visit/visit-view';
@Component({ @Component({
selector: 'app-visit', selector: 'app-visit',
...@@ -8,6 +9,7 @@ import { Component, Input } from '@angular/core'; ...@@ -8,6 +9,7 @@ import { Component, Input } from '@angular/core';
export class VisitComponent { export class VisitComponent {
@Input("index") index: string; @Input("index") index: string;
@Input("visit") visit: VisitView = new VisitView();
isSelected: boolean = false; isSelected: boolean = false;
} }
...@@ -22,7 +22,7 @@ export class DoctorsComponent implements OnInit { ...@@ -22,7 +22,7 @@ export class DoctorsComponent implements OnInit {
this.doctorsService.getAll() this.doctorsService.getAll()
.subscribe(result => { .subscribe(result => {
if (result === null) { if (result === null) {
this.toasreService.error('حدث خطأ، يرجى إعادة المحاولة'); this.toasreService.error('حدثت مشكلة، يرجى إعادة المحاولة');
} }
else this.doctors = result; else this.doctors = result;
}) })
......
...@@ -25,17 +25,17 @@ export class EmployeeComponent implements OnInit { ...@@ -25,17 +25,17 @@ export class EmployeeComponent implements OnInit {
ngOnInit(): void { ngOnInit(): void {
this.getIdFromUrl(); this.getIdFromUrl();
this.updateFormModel();
} }
getIdFromUrl(): void { getIdFromUrl(): void {
this.activeRoute.params.subscribe((params: any) => {
this.id = Number(this.activeRoute.snapshot.paramMap.get('id')); this.id = Number(params.id);
if (isNaN(this.id)) { if (isNaN(this.id)) {
this.toastrService.error('حدثت مشكلة، يرجى إعادة المحاولة'); this.toastrService.error('حدثت مشكلة، يرجى إعادة المحاولة');
this.router.navigateByUrl('receptionist/waitinglist'); this.router.navigateByUrl('receptionist/waitinglist');
} }
this.updateFormModel();
});
} }
updateFormModel(): void { updateFormModel(): void {
......
...@@ -54,7 +54,7 @@ export class WaitingListItemComponent implements OnInit { ...@@ -54,7 +54,7 @@ export class WaitingListItemComponent implements OnInit {
this.deleted.emit(); this.deleted.emit();
} }
else { else {
this.toastrService.error('حدث خطأ، يرجى اعادة المحاولة'); this.toastrService.error('حدثت مشكلة، يرجى إعادة المحاولة');
} }
}) })
} }
...@@ -82,7 +82,7 @@ export class WaitingListItemComponent implements OnInit { ...@@ -82,7 +82,7 @@ export class WaitingListItemComponent implements OnInit {
this.deleted.emit(); this.deleted.emit();
} }
else { else {
this.toastrService.error('حدثت مشكلة، يرجى اعادة المحاولة'); this.toastrService.error('حدثت مشكلة، يرجى إعادة المحاولة');
} }
}) })
} }
......
...@@ -27,7 +27,7 @@ export class WaitingListComponent implements OnInit { ...@@ -27,7 +27,7 @@ export class WaitingListComponent implements OnInit {
this.waitingListService.getAll() this.waitingListService.getAll()
.subscribe(result => { .subscribe(result => {
if (result === null) if (result === null)
this.toastrService.error("حدث خطأ، يرجى إعادة المحاولة"); this.toastrService.error("حدثت مشكلة، يرجى إعادة المحاولة");
else this.records = result; else this.records = result;
}); });
} }
......
import { Pipe, PipeTransform } from '@angular/core';
@Pipe({
name: 'arabicDate'
})
export class ArabicDatePipe implements PipeTransform {
transform(value: any, args?: any): any {
const days = ['الأحد', 'الإثنين', 'الثلاثاء', 'الأربعاء', 'الخميس', 'الجمعة', 'السبت'];
const months = ['كانون الثاني', 'شباط', 'آذار', 'نيسان', 'أيار', 'حزيران', 'تموز', 'آب', 'أيلول', 'تشرين الأول', 'تشرين الثاني', 'كانون الأول'];
const date = new Date(value);
const day = days[date.getDay()];
const year = date.getFullYear();
const month = months[date.getMonth()];
const dayOfMonth = date.getDate();
return `${day} في ${dayOfMonth}/${month}/${year}`;
}
}
import { HttpClient, HttpErrorResponse } from '@angular/common/http';
import { Injectable } from '@angular/core';
import * as config from '../../../../config';
import { catchError, map, Observable, of } from 'rxjs';
import { VisitView } from '../../classes/visit/visit-view';
@Injectable({
providedIn: 'root'
})
export class VisitsService {
constructor(private http: HttpClient) { }
private readonly VISITS_ENDPOINT: string = `${config.apiUrl}/Visits`
getAllByPatientId(patientId: number):
Observable<{status: boolean, errorMessage: string | null, visits: VisitView[] | null}> {
return this.http.get<{visits: VisitView[]}>(`${this.VISITS_ENDPOINT}/${patientId}`)
.pipe(
map((response: {visits: VisitView[]}) => {
return {status: true, errorMessage: null, visits: response.visits};
}),
catchError((error: HttpErrorResponse) => {
console.error(error.error.detail);
return of ({status: false, errorMessage: error.error.detail, visits: null});
})
)
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment