Commit f6bb20e9 authored by IT20161538's avatar IT20161538

New commit

parent 950ebf2b
import pandas as pd
import pickle
import numpy as np
def sideEffectTreatments(new_person_data):
# Load the trained model
with open('./Models/trained_model.pkl', 'rb') as file:
diseasers_or_side_effects_1_model = pickle.load(file)
diseasers_or_side_effects_2_model = pickle.load(file)
treatments_1_model = pickle.load(file)
treatments_2_model = pickle.load(file)
# Make predictions for the new data
diseasers_or_side_effects_1_prediction = diseasers_or_side_effects_1_model.predict(new_person_data)
diseasers_or_side_effects_2_prediction = diseasers_or_side_effects_2_model.predict(new_person_data)
treatments_1_prediction = treatments_1_model.predict(new_person_data)
treatments_2_prediction = treatments_2_model.predict(new_person_data)
# Round the predictions
diseasers_or_side_effects_1_prediction = np.round(diseasers_or_side_effects_1_prediction)
diseasers_or_side_effects_2_prediction = np.round(diseasers_or_side_effects_2_prediction)
treatments_1_prediction = np.round(treatments_1_prediction)
treatments_2_prediction = np.round(treatments_2_prediction)
if diseasers_or_side_effects_1_prediction == 1:
diseasers_or_side_effects_1 = 'Addiction'
elif diseasers_or_side_effects_1_prediction == 2:
diseasers_or_side_effects_1 = 'Agitation and restlessness'
elif diseasers_or_side_effects_1_prediction == 3:
diseasers_or_side_effects_1 = 'Anxiety and paranoia'
elif diseasers_or_side_effects_1_prediction == 4:
diseasers_or_side_effects_1 = 'Cardiovascular effects'
elif diseasers_or_side_effects_1_prediction == 5:
diseasers_or_side_effects_1 = 'Cognitive impairments'
elif diseasers_or_side_effects_1_prediction == 6:
diseasers_or_side_effects_1 = 'Constipation'
elif diseasers_or_side_effects_1_prediction == 7:
diseasers_or_side_effects_1 = 'Decreased appetite'
elif diseasers_or_side_effects_1_prediction == 8:
diseasers_or_side_effects_1 = 'Dental issues'
elif diseasers_or_side_effects_1_prediction == 9:
diseasers_or_side_effects_1 = 'Dizziness'
elif diseasers_or_side_effects_1_prediction == 10:
diseasers_or_side_effects_1 = 'Drowsiness and sedation'
elif diseasers_or_side_effects_1_prediction == 11:
diseasers_or_side_effects_1 = 'Dry mouth and throat'
elif diseasers_or_side_effects_1_prediction == 12:
diseasers_or_side_effects_1 = 'Elevated body temperature'
elif diseasers_or_side_effects_1_prediction == 13:
diseasers_or_side_effects_1 = 'Gastrointestinal problems'
elif diseasers_or_side_effects_1_prediction == 14:
diseasers_or_side_effects_1 = 'Headaches'
elif diseasers_or_side_effects_1_prediction == 15:
diseasers_or_side_effects_1 = 'Heart attak'
elif diseasers_or_side_effects_1_prediction == 16:
diseasers_or_side_effects_1 = 'Hormonal imbalances'
elif diseasers_or_side_effects_1_prediction == 17:
diseasers_or_side_effects_1 = 'Hypotension'
elif diseasers_or_side_effects_1_prediction == 18:
diseasers_or_side_effects_1 = 'Insomnia'
elif diseasers_or_side_effects_1_prediction == 19:
diseasers_or_side_effects_1 = 'Itching and skin infections'
elif diseasers_or_side_effects_1_prediction == 20:
diseasers_or_side_effects_1 = 'Liver and kidney damage'
elif diseasers_or_side_effects_1_prediction == 21:
diseasers_or_side_effects_1 = 'Mental confusion'
elif diseasers_or_side_effects_1_prediction == 22:
diseasers_or_side_effects_1 = 'Muscle spasms'
elif diseasers_or_side_effects_1_prediction == 23:
diseasers_or_side_effects_1 = 'Nausea and vomiting'
elif diseasers_or_side_effects_1_prediction == 24:
diseasers_or_side_effects_1 = 'Neurological effects'
elif diseasers_or_side_effects_1_prediction == 25:
diseasers_or_side_effects_1 = 'Red eyes'
else:
diseasers_or_side_effects_1 = 'Respiratory problems'
if diseasers_or_side_effects_2_prediction == 1:
diseasers_or_side_effects_2 = 'Addiction'
elif diseasers_or_side_effects_2_prediction == 2:
diseasers_or_side_effects_2 = 'Agitation and restlessness'
elif diseasers_or_side_effects_2_prediction == 3:
diseasers_or_side_effects_2 = 'Anxiety and paranoia'
elif diseasers_or_side_effects_2_prediction == 4:
diseasers_or_side_effects_2 = 'Cardiovascular effects'
elif diseasers_or_side_effects_2_prediction == 5:
diseasers_or_side_effects_2 = 'Cognitive impairments'
elif diseasers_or_side_effects_2_prediction == 6:
diseasers_or_side_effects_2 = 'Constipation'
elif diseasers_or_side_effects_1_prediction == 7:
diseasers_or_side_effects_2 = 'Decreased appetite'
elif diseasers_or_side_effects_2_prediction == 8:
diseasers_or_side_effects_2 = 'Dental issues'
elif diseasers_or_side_effects_2_prediction == 9:
diseasers_or_side_effects_2 = 'Dizziness'
elif diseasers_or_side_effects_2_prediction == 10:
diseasers_or_side_effects_2 = 'Drowsiness and sedation'
elif diseasers_or_side_effects_2_prediction == 11:
diseasers_or_side_effects_2 = 'Dry mouth and throat'
elif diseasers_or_side_effects_2_prediction == 12:
diseasers_or_side_effects_2 = 'Elevated body temperature'
elif diseasers_or_side_effects_2_prediction == 13:
diseasers_or_side_effects_2 = 'Gastrointestinal problems'
elif diseasers_or_side_effects_2_prediction == 14:
diseasers_or_side_effects_2 = 'Headaches'
elif diseasers_or_side_effects_2_prediction == 15:
diseasers_or_side_effects_2 = 'Heart attak'
elif diseasers_or_side_effects_2_prediction == 16:
diseasers_or_side_effects_2 = 'Hormonal imbalances'
elif diseasers_or_side_effects_2_prediction == 17:
diseasers_or_side_effects_2 = 'Hypotension'
elif diseasers_or_side_effects_2_prediction == 18:
diseasers_or_side_effects_2_model = 'Insomnia'
elif diseasers_or_side_effects_2_prediction == 19:
diseasers_or_side_effects_2 = 'Itching and skin infections'
elif diseasers_or_side_effects_2_prediction == 20:
diseasers_or_side_effects_2 = 'Liver and kidney damage'
elif diseasers_or_side_effects_2_prediction == 21:
diseasers_or_side_effects_2 = 'Mental confusion'
elif diseasers_or_side_effects_2_prediction == 22:
diseasers_or_side_effects_2 = 'Muscle spasms'
elif diseasers_or_side_effects_2_prediction == 23:
diseasers_or_side_effects_2 = 'Nausea and vomiting'
elif diseasers_or_side_effects_2_prediction == 24:
diseasers_or_side_effects_2 = 'Neurological effects'
elif diseasers_or_side_effects_2_prediction == 25:
diseasers_or_side_effects_2 = 'Red eyes'
else:
diseasers_or_side_effects_2 = 'Respiratory problems'
if treatments_1_prediction == 1:
treatments_1 = 'Behavioral Therapy, Medications, Support Groups, Inpatient Rehab,Outpatient Rehab'
elif treatments_1_prediction == 2:
treatments_1 = 'Antipsychotics,Talk therapy, If nothing else works, physical restraint may be needed'
elif treatments_1_prediction == 3:
treatments_1 = 'Cognitive behaviour therapy (CBT)'
elif treatments_1_prediction == 4:
treatments_1 = 'Do not smoke, Eat healthy foods, Control blood pressure, Get a cholesterol test, Manage diabetes, Exercise, Maintain a healthy weight, Manage stress'
elif treatments_1_prediction == 5:
treatments_1 = 'Using remediation techniques, compensatory strategies, adaptive approaches'
elif treatments_1_prediction == 6:
treatments_1 = 'Gradually increase your daily fiber intake, make sure you drink plenty of fluids, and try to get more exercise'
elif treatments_1_prediction == 7:
treatments_1 = 'Eating small meals regularly throughout the day, Managing any illnesses, infections or underlying conditions, Receiving IV nutrients which are liquid vitamins and minerals that you receive through a needle into your vein, Talking with a mental health specialist about your eating habits if they are irregular'
elif treatments_1_prediction == 8:
treatments_1 = 'Fluoride treatments, Tooth extractions, Fillings, Crowns, Root canals'
elif treatments_1_prediction == 9:
treatments_1 = 'Focus your attention on a distracting activity such as reading, singing, listening to music, gardening, or exercising'
elif treatments_1_prediction == 10:
treatments_1 = 'Treating underlying sleep disorders, Lifestyle changes, Address the underlying cause'
elif treatments_1_prediction == 11:
treatments_1 = 'Avoid alcohol (including alcohol-based mouthwashes), caffeine and smoking, suck on ice cubes'
elif treatments_1_prediction == 12:
treatments_1 = 'Take paracetamol or ibuprofen in appropriate doses to help bring your temperature down, Drink plenty of fluids, particularly water, Avoid alcohol, tea and coffee, Avoid taking cold baths or showers'
elif treatments_1_prediction == 13:
treatments_1 = 'Taking rest and drinking plenty of healthy liquids, Eating easily digestible foods, Avoiding spices, carbonated drinks, fried foods, alcohol, and other foods that are gastric irritants, Taking prescribed gastrointestinal medications'
elif treatments_1_prediction == 14:
treatments_1 = 'Drink water, Inadequate hydration may lead you to develop a headache,Limit alcohol, Get adequate sleep, Avoid foods high in histamine, Soothe pain with a cold compress'
elif treatments_1_prediction == 15:
treatments_1 = 'Clot-dissolving drugs (thrombolysis), balloon angioplasty (PCI), surgery'
elif treatments_1_prediction == 16:
treatments_1 = 'Hormone replacement therapy, take oral medication (pills) or injection medication'
elif treatments_1_prediction == 17:
treatments_1 = 'Use more salt, Drink more water, Wear compression stockings'
elif treatments_1_prediction == 18:
treatments_1 = 'Stimulus control therapy, Relaxation techniques, Sleep restriction, Remaining passively awake, Light therapy'
elif treatments_1_prediction == 19:
treatments_1 = 'Antibiotics, Antifungal medications, Moisturizers, Cool compresses, Avoiding triggers'
elif treatments_1_prediction == 20:
treatments_1 = 'Liver transplant'
elif treatments_1_prediction == 21:
treatments_1 = 'Find the source, Prioritize sleep, Make time to relax, Meditate, Feed yourself,Move your body'
elif treatments_1_prediction == 22:
treatments_1 = 'Stretch the affected area, Massage the affected area with your hands or a massage roller, Stand up and walk around, Apply heat or ice, Put an ice pack together or apply a heating pad, or take a nice warm bath, Take painkillers such as ibuprofen and acetaminophen'
elif treatments_1_prediction == 23:
treatments_1 = 'Drinking gradually larger amounts of clear liquids, Avoiding solid food until the vomiting episode has passed, Resting'
elif treatments_1_prediction == 24:
treatments_1 = 'Deep brain stimulation, Spinal cord stimulation, Rehabilitation/physical therapy after brain injury or stroke, Spinal surgery'
elif treatments_1_prediction == 25:
treatments_1 = 'Rest, Cool compresses over closed eyes, Lightly massaging your eyelids, Gently washing your eyelids'
else:
treatments_1 = 'Oxygen therapy, fluid therapy, pulmonary rehabilitation, Breathing exercises and surgery'
if treatments_2_prediction == 1:
treatments_2 = 'Behavioral Therapy, Medications, Support Groups, Inpatient Rehab,Outpatient Rehab'
elif treatments_2_prediction == 2:
treatments_2 = 'Antipsychotics,Talk therapy, If nothing else works, physical restraint may be needed'
elif treatments_2_prediction == 3:
treatments_2 = 'Cognitive behaviour therapy (CBT)'
elif treatments_2_prediction == 4:
treatments_2 = 'Do not smoke, Eat healthy foods, Control blood pressure, Get a cholesterol test, Manage diabetes, Exercise, Maintain a healthy weight, Manage stress'
elif treatments_2_prediction == 5:
treatments_2 = 'Using remediation techniques, compensatory strategies, adaptive approaches'
elif treatments_2_prediction == 6:
treatments_2 = 'Gradually increase your daily fiber intake, make sure you drink plenty of fluids, and try to get more exercise'
elif treatments_2_prediction == 7:
treatments_2 = 'Eating small meals regularly throughout the day, Managing any illnesses, infections or underlying conditions, Receiving IV nutrients which are liquid vitamins and minerals that you receive through a needle into your vein, Talking with a mental health specialist about your eating habits if they are irregular'
elif treatments_2_prediction == 8:
treatments_2 = 'Fluoride treatments, Tooth extractions, Fillings, Crowns, Root canals'
elif treatments_2_prediction == 9:
treatments_2 = 'Focus your attention on a distracting activity such as reading, singing, listening to music, gardening, or exercising'
elif treatments_2_prediction == 10:
treatments_2 = 'Treating underlying sleep disorders, Lifestyle changes, Address the underlying cause'
elif treatments_2_prediction == 11:
treatments_2 = 'Avoid alcohol (including alcohol-based mouthwashes), caffeine and smoking, suck on ice cubes'
elif treatments_2_prediction == 12:
treatments_2 = 'Take paracetamol or ibuprofen in appropriate doses to help bring your temperature down, Drink plenty of fluids, particularly water, Avoid alcohol, tea and coffee, Avoid taking cold baths or showers'
elif treatments_2_prediction == 13:
treatments_2 = 'Taking rest and drinking plenty of healthy liquids, Eating easily digestible foods, Avoiding spices, carbonated drinks, fried foods, alcohol, and other foods that are gastric irritants, Taking prescribed gastrointestinal medications'
elif treatments_2_prediction == 14:
treatments_2 = 'Drink water, Inadequate hydration may lead you to develop a headache,Limit alcohol, Get adequate sleep, Avoid foods high in histamine, Soothe pain with a cold compress'
elif treatments_2_prediction == 15:
treatments_2 = 'Clot-dissolving drugs (thrombolysis), balloon angioplasty (PCI), surgery'
elif treatments_2_prediction == 16:
treatments_2 = 'Hormone replacement therapy, take oral medication (pills) or injection medication'
elif treatments_2_prediction == 17:
treatments_2 = 'Use more salt, Drink more water, Wear compression stockings'
elif treatments_2_prediction == 18:
treatments_2 = 'Stimulus control therapy, Relaxation techniques, Sleep restriction, Remaining passively awake, Light therapy'
elif treatments_2_prediction == 19:
treatments_2 = 'Antibiotics, Antifungal medications, Moisturizers, Cool compresses, Avoiding triggers'
elif treatments_2_prediction == 20:
treatments_2 = 'Liver transplant'
elif treatments_2_prediction == 21:
treatments_2 = 'Find the source, Prioritize sleep, Make time to relax, Meditate, Feed yourself,Move your body'
elif treatments_2_prediction == 22:
treatments_2 = 'Stretch the affected area, Massage the affected area with your hands or a massage roller, Stand up and walk around, Apply heat or ice, Put an ice pack together or apply a heating pad, or take a nice warm bath, Take painkillers such as ibuprofen and acetaminophen'
elif treatments_2_prediction == 23:
treatments_2 = 'Drinking gradually larger amounts of clear liquids, Avoiding solid food until the vomiting episode has passed, Resting'
elif treatments_2_prediction == 24:
treatments_2 = 'Deep brain stimulation, Spinal cord stimulation, Rehabilitation/physical therapy after brain injury or stroke, Spinal surgery'
elif treatments_2_prediction == 25:
treatments_2 = 'Rest, Cool compresses over closed eyes, Lightly massaging your eyelids, Gently washing your eyelids'
else:
treatments_2 = 'Oxygen therapy, fluid therapy, pulmonary rehabilitation, Breathing exercises and surgery'
# Print the predicted Diseasers_or_side_effects
print('Predicted Diseasers or Side Effects 1:', diseasers_or_side_effects_1_prediction)
print('Predicted Diseasers or Side Effects 2:', diseasers_or_side_effects_2_prediction)
print('Predicted Treatments 1:', treatments_1_prediction)
print('Predicted Treatments 2:', treatments_2_prediction)
print(diseasers_or_side_effects_1)
print(diseasers_or_side_effects_2)
print(treatments_1)
print(treatments_2)
# Return the predictions if needed
return {
'Predicted Diseasers or Side Effects 1': diseasers_or_side_effects_1_prediction,
'Predicted Diseasers or Side Effects 2': diseasers_or_side_effects_2_prediction,
'Predicted Treatments 1': treatments_1_prediction,
'Predicted Treatments 2': treatments_2_prediction,
'Predicted Diseasers or Side Effects 1': diseasers_or_side_effects_1,
'Predicted Diseasers or Side Effects 2': diseasers_or_side_effects_2,
'Predicted Treatments 1': treatments_1,
'Predicted Treatments 2': treatments_2
}
from flask import Flask, request, jsonify
import pandas as pd
from Decision_Tree.Decision_Tree import sideEffectTreatments
import numpy as np
from flask_cors import CORS
app = Flask(__name__)
CORS(app)
def convert_ndarray_to_list(data_dict):
converted_dict = {}
for key, value in data_dict.items():
if isinstance(value, np.ndarray):
converted_dict[key] = value.tolist()
else:
converted_dict[key] = value
return converted_dict
@app.route('/predict', methods=['OPTIONS', 'GET', 'POST'])
def predict():
if request.method == 'OPTIONS':
# Handle CORS preflight request here
return '', 200
elif request.method == 'POST':
try:
# Extract data from the JSON request
data = request.get_json()
# Convert the JSON data to a pandas DataFrame
new_person_data = pd.DataFrame(data)
print(new_person_data)
# Call the test function to make predictions
predictions = sideEffectTreatments(new_person_data)
# Convert NumPy ndarray predictions to a serializable format
converted_predictions = convert_ndarray_to_list(predictions)
return jsonify(converted_predictions)
except Exception as e:
return jsonify({'error': str(e)})
if __name__ == '__main__':
app.run(host='0.0.0.0', port=5500)
......@@ -11,6 +11,7 @@
"@testing-library/jest-dom": "^5.16.5",
"@testing-library/react": "^13.4.0",
"@testing-library/user-event": "^13.5.0",
"axios": "^1.5.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-router-dom": "^6.10.0",
......@@ -5065,6 +5066,29 @@
"node": ">=4"
}
},
"node_modules/axios": {
"version": "1.5.0",
"resolved": "https://registry.npmjs.org/axios/-/axios-1.5.0.tgz",
"integrity": "sha512-D4DdjDo5CY50Qms0qGQTTw6Q44jl7zRwY7bthds06pUGfChBCTcQs+N743eFWGEd6pRTMd6A+I87aWyFV5wiZQ==",
"dependencies": {
"follow-redirects": "^1.15.0",
"form-data": "^4.0.0",
"proxy-from-env": "^1.1.0"
}
},
"node_modules/axios/node_modules/form-data": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz",
"integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==",
"dependencies": {
"asynckit": "^0.4.0",
"combined-stream": "^1.0.8",
"mime-types": "^2.1.12"
},
"engines": {
"node": ">= 6"
}
},
"node_modules/axobject-query": {
"version": "3.1.1",
"resolved": "https://registry.npmjs.org/axobject-query/-/axobject-query-3.1.1.tgz",
......@@ -14030,6 +14054,11 @@
"node": ">= 0.10"
}
},
"node_modules/proxy-from-env": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz",
"integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg=="
},
"node_modules/psl": {
"version": "1.9.0",
"resolved": "https://registry.npmjs.org/psl/-/psl-1.9.0.tgz",
......
src/assets/6.jpg

73.6 KB | W: | H:

src/assets/6.jpg

6.53 KB | W: | H:

src/assets/6.jpg
src/assets/6.jpg
src/assets/6.jpg
src/assets/6.jpg
  • 2-up
  • Swipe
  • Onion skin
......@@ -16,8 +16,9 @@
border-radius:6px;
box-shadow:0 0 8px #696969;
padding-block: 10px;
width: 45vw;
width: 47vw;
margin-top: 80px;
margin-left: 80px;
}
.title{
......@@ -26,7 +27,7 @@
.form{
width: 35vw;
height: 750px;
height: 950px;
display: flex;
flex-direction: column;
justify-content: start;
......@@ -71,9 +72,7 @@ input{
}
.input-group1{
display: flex;
flex-direction: row;
gap: 10px;
align-items: center;
padding: 5px;
align-items: left;
}
import React, { useState } from 'react'
import './SideEffectsAndTreatments.css';
export default function SideEffectsAndTreatments() {
function SideEffectsAndTreatments() {
// Define state variables for your input fields and predictions
const [age, setAge] = useState('');
const [gender, setGender] = useState('');
const [drugType, setDrugType] = useState('');
const [drugUsageMg, setDrugUsageMg] = useState('');
const [months, setMonths] = useState('');
const [routeOfAdministration, setRouteOfAdministration] = useState('');
const [takingCooccurringSubstances, setTakingCooccurringSubstances] = useState('');
const [preExistingmedicalcondition, setPreExistingmedicalcondition] = useState('');
const [coOccurringSubstances, setCoOccurringSubstances] = useState('');
const [preExistingMedicalCondition, setPreExistingMedicalCondition] = useState('');
const [predictions, setPredictions] = useState(null);
const mapGender = (selectedGender) => {
switch (selectedGender) {
case 'male':
return 1;
case 'female':
return 2;
}
};
const mapDrugTypeToValue = (selectedDrugType) => {
switch (selectedDrugType) {
case 'Heroin':
return 1;
case 'Cannabis':
return 2;
case 'Opium':
return 3;
case 'Hashish':
return 4;
case 'Cocaine':
return 5;
case 'Methamphetamine':
return 6;
}
};
const maprouteOfAdministration = (selectedrouteOfAdministration) => {
switch (selectedrouteOfAdministration) {
case 'Inhalation':
return 1;
case 'Injection':
return 2;
case 'Smoking':
return 3;
}
};
const maptakingCooccurringSubstances = (selectedtakingCooccurringSubstances) => {
switch (selectedtakingCooccurringSubstances) {
case 'yes':
return 1;
case 'no':
return 2;
}
};
const mapcoOccurringSubstances = (selectedcoOccurringSubstances) => {
switch (selectedcoOccurringSubstances) {
case 'Cannabis':
return 1;
case 'Cocaine':
return 2;
case 'Hashish':
return 3;
case 'Heroin':
return 4;
case 'Methamphetamine':
return 5;
case 'Alcohol':
return 6;
case 'No':
return 7;
}
};
const mappreExistingMedicalCondition = (selectedpreExistingMedicalCondition) => {
switch (selectedpreExistingMedicalCondition) {
case 'yes':
return 1;
case 'no':
return 2;
}
};
const handleSubmit = async (event) => {
event.preventDefault();
try {
//console.log('Parsed Data:', requestData);
const genderValue = mapGender(gender);
const drugTypeValue = mapDrugTypeToValue(drugType);
const routeOfAdministrationValue = maprouteOfAdministration(routeOfAdministration);
const takingCooccurringSubstancesValue = maptakingCooccurringSubstances(takingCooccurringSubstances);
const coOccurringSubstancesValue = mapcoOccurringSubstances(coOccurringSubstances);
const preExistingMedicalConditionValue = mappreExistingMedicalCondition(preExistingMedicalCondition);
const response = await fetch('http://localhost:5500/predict', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
age:[age],
gender: [genderValue],
drug_type: [drugTypeValue],
measures_of_drug_used_per_day: [drugUsageMg],
time_used: [months],
taking_co_occurring_substances: [takingCooccurringSubstancesValue],
co_occurring_substances: [coOccurringSubstancesValue],
route_of_administration: [routeOfAdministrationValue],
pre_existing_condision: [preExistingMedicalConditionValue]
}),
});
const data = await response.json();
setPredictions(data);
} catch (error) {
console.error('Error fetching predictions:', error);
}
};
return (
<div className='side-effect-wrapper'><div className='side-effect-form'><br/>
<h1 className='title'>Side Effect & Treatments</h1><br/>
<form className='form'>
<form onSubmit={handleSubmit} className='form'>
<div className='input-group'>
<label>Age: </label>
<input type='number' placeholder='Age' value={age} onChange={(e)=>{setAge(e.target.value)}}/>
</div>
<div className='input-group'>
<label>Gender: </label>
<input type='radio' name='gender' value='male'/>
<input type='radio' name='gender' value='male' onChange={(e) => setGender(e.target.value)}/>
<span>Male</span>
<input type='radio' name='gender' value='female'/>
<input type='radio' name='gender' value='female' onChange={(e) => setGender(e.target.value)}/>
<span>Female</span>
</div>
<div className='input-group'>
<label>Drug Type: </label>
<select name="drugtype">
<select value={drugType} name="drugtype" onChange={(e) => setDrugType(e.target.value)}>
<option>Choose a Drug Type</option>
<option>Heroin</option>
<option>Cannabis</option>
......@@ -45,7 +165,7 @@ export default function SideEffectsAndTreatments() {
</div>
<div className='input-group'>
<label>Route of Administration: </label>
<select name="route_of_administration ">
<select value={routeOfAdministration} name="route_of_administration " onChange={(e) => setRouteOfAdministration(e.target.value)}>
<option>Choose a Route of Administration</option>
<option>Inhalation</option>
<option>Injection</option>
......@@ -61,7 +181,7 @@ export default function SideEffectsAndTreatments() {
</div>
<div className='input-group'>
<label>Co-occurring Substances: </label>
<select name="co-occurringsubstances ">
<select value={coOccurringSubstances} name="co-occurringsubstances " onChange={(e) => setCoOccurringSubstances(e.target.value)}>
<option>Choose a Co-occurring Substances</option>
<option>Cannabis</option>
<option>Cocaine</option>
......@@ -74,20 +194,21 @@ export default function SideEffectsAndTreatments() {
</div>
<div className='input-group'>
<label>Any pre-existing medical conditions?: </label>
<input type='radio' name='preExistingmedicalcondition' value='yes' checked={preExistingmedicalcondition === 'yes'} onChange={() => setPreExistingmedicalcondition('yes')}/>
<input type='radio' name='preExistingmedicalcondition' value='yes' checked={preExistingMedicalCondition === 'yes'} onChange={() => setPreExistingMedicalCondition('yes')}/>
<span>Yes</span>
<input type='radio' name='preExistingmedicalcondition' value='no' checked={preExistingmedicalcondition === 'no'} onChange={() => setPreExistingmedicalcondition('no')}/>
<input type='radio' name='preExistingmedicalcondition' value='no' checked={preExistingMedicalCondition === 'no'} onChange={() => setPreExistingMedicalCondition('no')}/>
<span>No</span>
</div>
<div className='btn-area'>
<div className='btn'>Predict</div>
<button type="submit" className='btn'>Predict</button>
</div>
<div className='input-group1'>
<h2>Predictions:</h2>
{predictions && (<p>Predictions: {JSON.stringify(predictions)}</p>)}
</div>
</form>
</div></div>
</div></div>
)
}
export default SideEffectsAndTreatments;
\ No newline at end of file
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