Skip to content

Commit

Permalink
medical_history
Browse files Browse the repository at this point in the history
  • Loading branch information
kaidux22 committed Jan 12, 2025
1 parent 331e309 commit 6322060
Show file tree
Hide file tree
Showing 7 changed files with 101 additions and 9 deletions.
2 changes: 1 addition & 1 deletion backend/app/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -621,7 +621,7 @@ def predict_disease():
result["percent"] = round(appeal_weight[0][0] / total_weight[0][0] * 100, 2)
predicted_results.append(result)

return jsonify({"ans": predicted_results})
return jsonify({"ans": predicted_results, "symptoms": appeal_symptoms})


@app.route('/api/update_entity', methods=['POST'])
Expand Down
23 changes: 23 additions & 0 deletions frontend/src/app/data.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@ import { BehaviorSubject } from 'rxjs';
export class DataService {
private userDataSubject = new BehaviorSubject<any>(this.getUserDataFromLocalStorage());
private predictDataSubject = new BehaviorSubject<any>(this.getPredictDataFromLocalStorage());
private appealDataSubject = new BehaviorSubject<any>(this.getAppealInformationFromLocalStorage());

userData$ = this.userDataSubject.asObservable();
predictData$ = this.predictDataSubject.asObservable();
appealData$ = this.appealDataSubject.asObservable();

constructor() {
this.userDataSubject.subscribe(data => {
Expand All @@ -22,8 +24,14 @@ export class DataService {
localStorage.setItem('predictData_v2', JSON.stringify(data));
});

this.appealDataSubject.subscribe(data => {
console.log("Appeal Data: ", data)
localStorage.setItem('appealData_v2', JSON.stringify(data));
})

console.log('Initial User Data:', this.getUserData());
console.log('Initial Predict Data:', this.getPredictData());
console.log("Initial Appeal Data: ", this.getAppealData());
}

setUserData(data: any) {
Expand All @@ -34,6 +42,10 @@ export class DataService {
this.predictDataSubject.next(data);
}

setAppealData(data: any){
this.appealDataSubject.next(data);
}

getUserData() {
console.log('Getting User Data:', this.userDataSubject.value);
return this.userDataSubject.value;
Expand All @@ -44,6 +56,11 @@ export class DataService {
return this.predictDataSubject.value;
}

getAppealData(){
console.log("Getting Appeal Data: ", this.appealDataSubject.value);
return this.appealDataSubject.value;
}

private getUserDataFromLocalStorage(): any {
const userData = localStorage.getItem('userData_v2');
console.log('User Data from LocalStorage:', userData);
Expand All @@ -56,6 +73,12 @@ export class DataService {
return predictData ? JSON.parse(predictData) : null;
}

private getAppealInformationFromLocalStorage(): any{
const appealData = localStorage.getItem('appealData_v2');
console.log("Appeal Data From LocalStorage:", appealData);
return appealData ? JSON.parse(appealData) : null;
}

isLoggedIn() {
return this.userData$;
}
Expand Down
7 changes: 7 additions & 0 deletions frontend/src/app/predictor/predictor.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ <h2>Вероятные заболевания</h2>

</div>

<div class="medical_history">
<h3>Анамнез</h3>
<p><b>Дата обращения: </b> {{medical_history['appeal_date']}} </p>
<p><b>Жалобы:</b> {{medical_history['appeal_complaints']}} </p>
<p><b>Симптомы:</b> {{symptoms}}</p>
</div>

<div class="list">
<div class="card" *ngFor="let item of predict" (click)="GoToDisease(item)">
<div class="header">
Expand Down
23 changes: 22 additions & 1 deletion frontend/src/app/predictor/predictor.component.less
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,35 @@
}
}

.medical_history{
width: auto;
margin-left: 100px;
margin-right: 60px;
border-radius: 20px;
margin-top: 0;
background-color: #e8ffff;
padding: 5px;

h3{
font-size: 15px;
color: #159696;
font-family: 'Comfortaa';
}

p{
font-size: 12px;
font-family: 'Comfortaa';
}
}

.list {
margin-left: 100px;
display: grid;
grid-template-columns: repeat(auto-fill, minmax(400px, 1fr));
gap: 20px; /* Adjust the gap as needed */
padding: 16px; /* Add padding if needed */
overflow-y: auto; /* Add vertical scrolling */
max-height: 80vh; /* Set a maximum height for the container */
max-height: 55vh; /* Set a maximum height for the container */
margin-top: 0;

&::-webkit-scrollbar {
Expand Down
12 changes: 11 additions & 1 deletion frontend/src/app/predictor/predictor.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,23 @@ import { config } from 'rxjs';
})
export class PredictorComponent {
predict : any = null;
medical_history: any = null;
symptoms: any = null;
search: string = '';

constructor(private router: Router, private http: HttpClient, private dataService: DataService){}

ngOnInit() {
this.predict = this.dataService.getPredictData();
this.predict = this.dataService.getPredictData()['ans'];
this.symptoms = this.dataService.getPredictData()['symptoms']
this.symptoms = this.symptoms.map((symptom: any) => symptom.symptom_name).join(', ');

console.log("here's :", this.symptoms)

this.sortPredictByPercent();

this.medical_history = this.dataService.getAppealData();
console.log("Take it", this.medical_history)
}

sortPredictByPercent() {
Expand Down
39 changes: 35 additions & 4 deletions frontend/src/app/profile/profile.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,10 +137,41 @@ export class ProfileComponent {
}

GoToPredict(item: any){
this.http.post('http://127.0.0.1:5000/api/predict_disease', {"appeal_date": item.appeal.appeal_date}).subscribe({
next: (response: any) => {
this.dataService.setPredictData(response['ans'])
this.router.navigate(['/predict'])
this.http.post('http://127.0.0.1:5000/api/predict_disease', {"appeal_date": item.appeal.appeal_date}).subscribe({
next: (response: any) => {
this.dataService.setPredictData(response)

this.http.post('http://127.0.0.1:5000/api/appeal_database', {
"filter_params": {
"filter1-field": "appeal_date",
"filter1-action": "<>",
"filter1-value": "",
"filter2-field": "appeal_date",
"filter2-action": ">=",
"filter2-value": "'" + item.appeal.appeal_date.replace(" ", "T") + "'",
"filter3-field": "appeal_date",
"filter3-action": "<=",
"filter3-value": "'" + item.appeal.appeal_date.replace(" ", "T") + "'"
},
"patient_filter_params": {
"filter1-field": "fullname",
"filter1-action": "CONTAINS",
"filter1-value": this.userData['fullname']
}
}).subscribe({
next: (response: any) => {
this.dataService.setAppealData(response['ans'][0]['appeal'])
this.router.navigate(['/predict'])
},
error: error => {
console.error('Error:', error);
},
complete: () => {
console.log('Request complete');
}
});


},
error: error => {
console.error('Error:', error);
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/app/search/search.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,14 +122,14 @@ export class SearchComponent {
}

console.log(data)

this.dataService.setAppealData(data);

this.http.post('http://127.0.0.1:5000/api/create_appeal', data).subscribe({
next: (response: any) => {
console.log(response)
this.http.post('http://127.0.0.1:5000/api/predict_disease', {"appeal_date": data.appeal_date}).subscribe({
next: (response: any) => {
this.dataService.setPredictData(response['ans'])
this.dataService.setPredictData(response)
this.router.navigate(['/predict'])
},
error: error => {
Expand Down

0 comments on commit 6322060

Please sign in to comment.