diff --git a/food_data.txt b/food_data.txt new file mode 100644 index 0000000..e9e5d91 --- /dev/null +++ b/food_data.txt @@ -0,0 +1,315 @@ +Banana Bread: Flour, sugar, bananas, baking powder, salt, eggs, vegetable oil, vanilla +Beef Burrito: Tortilla, ground beef, refried beans, cheddar cheese, lettuce, tomato, onion, salsa +Broccoli Cheese Soup: Chicken broth, milk, butter, flour, broccoli, carrots, cheddar cheese, salt, pepper +Caesar Salad: Romaine lettuce, croutons, parmesan cheese, Caesar dressing, garlic, anchovies +Chicken Alfredo: Penne pasta, chicken, butter, heavy cream, garlic, parmesan cheese, salt, pepper +Chocolate Chip Cookies: Flour, sugar, brown sugar, butter, eggs, vanilla, baking soda, salt, chocolate chips +Cornbread: Cornmeal, flour, sugar, baking powder, salt, milk, eggs, butter +Egg Rolls: Egg roll wrappers, cabbage, carrots, green onions, ground pork, garlic, soy sauce, sesame oil +Fajitas: Flour tortillas, sliced chicken, bell peppers, onions, garlic, cumin, chili powder, lime juice +French Fries: Potatoes, vegetable oil, salt, pepper +Garlic Bread: Baguette, garlic, butter, parmesan cheese +Grilled Cheese: Bread, butter, cheddar cheese +Hamburger: Buns, beef, lettuce, tomato, onion, pickles, ketchup, mustard +Hot Dog: Hot dog bun, hot dog, mustard, ketchup, relish +Ice Cream: Cream, milk, sugar, vanilla +Jambalaya: Rice, andouille sausage, chicken, onion, green pepper, celery, garlic, tomato, bay leaves, thyme, paprika, cayenne, salt +Kung Pao Chicken: Chicken, peanuts, bell pepper, zucchini, carrot, green onion, soy sauce, hoisin sauce, rice vinegar, garlic, ginger, chili peppers +Lasagna: Lasagna noodles, ground beef, ricotta cheese, mozzarella cheese, tomato sauce, garlic, onion, basil +Mac and Cheese: Pasta, milk, butter, flour, cheddar cheese, salt, pepper +Meatballs: Ground beef, breadcrumbs, parmesan cheese, garlic, egg, parsley +Meatloaf: Ground beef, breadcrumbs, onion, garlic, egg, milk, ketchup, salt, pepper +Muffins: Flour, sugar, baking powder, salt, milk, eggs, vegetable oil +Nachos: Tortilla chips, beef, beans, cheddar cheese, lettuce, tomato, onion, jalapenos +Omelette: Eggs, milk, salt, pepper, cheese, onion, bell pepper +Pancakes: Flour, sugar, baking powder, salt, milk, eggs, butter +Pasta: Penne, tomato sauce, garlic, onion, basil, olive oil, parmesan cheese +Pizza: Dough, tomato sauce, mozzare,cheese, pepperoni, sausage, mushroom, bell pepper, onion, olives +Pork Chops: Pork chops, salt, pepper, rosemary +Quesadilla: Tortilla, cheese, chicken, beef, beans +Queso: American cheese, Velveeta cheese, milk, Rotel +Rice: White rice, water, butter, salt +Salad: Lettuce, tomato, cucumber, onion +Sandwich: Bread, meat, cheese, lettuce, tomato, onion, mayonnaise, mustard, ketchup +Shrimp: Shrimp, garlic, butter, lemon +Shrimp Scampi: Shrimp, garlic, butter, lemon, white wine, pasta +Sloppy Joes: Ground beef, onion, bell pepper, tomato sauce, ketchup, brown sugar, buns +Spaghetti: Spaghetti, tomato sauce, garlic, onion, beef +Steak: Steak, salt, pepper, garlic +Stew: Beef, potatoes, carrots, onion, garlic, beef, chicken, vegetable +Stir Fry: Rice, vegetables, chicken, beef, shrimp, tofu +Sushi: Rice, seaweed, fish, avocado, cucumber +Tacos: Tortillas, meat, cheese, lettuce, tomato, onion, salsa +Tater Tots: Tater tots, vegetable oil, ketchup +Tuna Salad: Tuna, mayonnaise, onion, celery +Vegetable Stir Fry: Rice, vegetables, soy sauce +Waffles: Flour, sugar, baking powder, salt, milk, eggs, butter +Wings: Chicken wings, sauce +Yogurt Parfait: Yogurt, granola, strawberries, blueberries, peaches +Ziti: Ziti noodles, tomato sauce, meat, cheese +Zucchini Boats: Zucchini, ground beef, tomato sauce, onion, garlic, cheese +Baked Potato: Potato, butter, sour cream, cheese, bacon bits +Baked Ziti: Ziti noodles, tomato sauce, cheese, ground beef ,meatballs +Banana Bread: Flour, sugar, bananas, eggs, butter, baking powder +Beef and Broccoli: Beef, broccoli, soy sauce, garlic, brown sugar +Beef Stroganoff: Beef, mushrooms, onion, beef broth, sour cream, egg noodles +Berry Cobbler: Fruit, sugar, biscuit mix, butter +Breakfast Burrito: Tortilla, eggs, cheese, sausage, potatoes +Bratwurst: Bratwurst, buns, sauerkraut +Bruschetta: Bread, tomatoes, basil, garlic, oil +Buffalo Chicken Dip: Chicken, cream cheese, hot sauce, blue cheese, ranch dressing +Burrito Bowl: Rice, beans, chicken, cheese, sour cream, salsa +Butternut Squash Soup: Butternut squash, chicken broth, onion, garlic +Caesar Salad: Romaine lettuce, croutons, grilled chicken, Caesar dressing +Calzones: Pizza dough, tomato sauce, cheese, meat ,vegetables +Carbonara: Spaghetti, eggs, bacon, parmesan cheese +Chicken and Dumplings: Chicken, dumplings, vegetables, chicken broth +Chicken Fried Rice: Rice, chicken, vegetables, eggs, soy sauce +Chicken Parmesan: Chicken, tomato sauce, cheese, pasta +Chicken Penne: Penne pasta, chicken, tomato sauce, cheese +Chicken Tacos: Tortillas, chicken, cheese, lettuce, tomato, salsa +Chicken Tikka Masala: Chicken, tomato sauce, coconut milk, spices +Chili: Ground beef, beans, tomato sauce, chili powder +Chili Cheese Dog: Hot dog, chili, cheese, bun +Chili Rellenos: Poblano pepper, cheese, tomato sauce, eggs +Chocolate Chip Cookies: Flour, sugar, butter, eggs, vanilla, chocolate chips, baking powder +Chow Mein: Noodles, vegetables, meat +Churros: Flour, sugar, water, cinnamon, oil +Clam Chowder: Clams, potatoes, onion, milk, bacon +Cobb Salad: Romaine lettuce, chicken, bacon, avocado, tomato, blue cheese, dressing +Coleslaw: Cabbage, mayonnaise, sugar +Cornbread: Cornmeal, flour, sugar, baking powder, eggs, milk +Corn on the Cob: Corn, butter, salt +Crab Cakes: Crab, breadcrumbs, mayonnaise, spices +Cream of Mushroom Soup: Mushrooms, chicken broth, cream, flour +Crepes: Flour, eggs, milk, sugar +Croissants: Flour, butter, yeast, sugar +Fried Rice: Rice, eggs, onions, peas, carrots, soy sauce, vegetable oil +Beef and Broccoli: Beef, broccoli, soy sauce, garlic, ginger, sugar, cornstarch +Chicken Fried Steak: Tenderized steak, flour, eggs, milk, breadcrumbs, salt, pepper, vegetable oil +Chicken Curry: Chicken, onions, garlic, ginger, curry powder, coconut milk, chicken broth, tomato paste, salt, pepper, sugar +Chicken Fajitas: Chicken, bell peppers, onions, garlic, cumin, chili powder, salt, pepper, flour tortillas +Chicken Parmesan: Chicken, breadcrumbs, tomato sauce, mozzarella cheese, parmesan cheese, spaghetti +Chicken Shawarma: Chicken, garlic, lemon juice, olive oil, cumin, coriander, paprika, pita bread +Chili Relleno: Poblano peppers, cheese, eggs, flour, tomato sauce, vegetable oil +Clam Chowder: Clams, potatoes, onions, celery, milk, butter, flour, thyme +Cobb Salad: Greens, chicken, bacon, eggs, avocado, tomatoes, blue cheese, vinaigrette +Corned Beef and Cabbage: Corned beef, cabbage, carrots, onions, garlic, beef broth +Creamy Polenta: Polenta, milk, butter, parmesan cheese, salt +Crab Cakes: Crab meat, breadcrumbs, eggs, mayonnaise, mustard, salt, pepper, vegetable oil +Crispy Fish Tacos: White fish, flour tortillas, cabbage, cilantro, avocado, lime, chipotle mayo +Cuban Sandwich: Ham, roasted pork, Swiss cheese, pickles, mustard, Cuban bread +Deviled Eggs: Eggs, mayonnaise, mustard, vinegar, salt, pepper, paprika +Egg Rolls: Cabbage, carrots, onions, garlic, ground pork, soy sauce, egg roll wrappers +Enchiladas: Tortillas, cheese, chicken ,beef, onions, garlic, tomato sauce, chili powder +Fettuccine Alfredo: Fettuccine, butter, heavy cream, parmesan cheese, salt, pepper +Fish and Chips: Cod ,haddock, flour, beer, baking powder, salt, potatoes, vegetable oil +Fried Chicken: Chicken, buttermilk, flour, salt, pepper, vegetable oil +Goulash: Ground beef, onions, garlic, paprika, tomato sauce, beef broth, elbow macaroni, sour cream +Gumbo: Shrimp, chicken, sausage, okra, onions, garlic, bell peppers, celery, tomato sauce, rice +Hamburger Helper: Ground beef, egg noodles, milk, cheese, seasoning packet +Hot and Sour Soup: Chicken, tofu, mushrooms, bamboo shoots, eggs, soy sauce, vinegar, cornstarch +Jambalaya: Rice, chicken, sausage, shrimp, onions, garlic, bell peppers, tomato sauce, spices +Kung Pao Chicken: Chicken, peanuts, bell peppers, dried red chilies, soy sauce, vinegar, sugar, cornstarch +Lobster Bisque: Lobster, butter, onion, garlic, tomato paste, flour, chicken broth, sherry, cream +Macaroni and Cheese: Macaroni, milk, butter, flour, cheddar cheese, salt +Meatballs: Ground beef, breadcrumbs, egg, onion, garlic, parsley +Meatloaf: Ground beef, breadcrumbs, egg, onion, garlic, milk, ketchup +Moussaka: Eggplant, potatoes, ground beef, onion, garlic, tomato sauce, bechamel sauce +Nachos: Tortilla chips, taco seasoning, beef, beans, cheese, salsa +Omelette: Egg, milk, butter, salt, pepper, fillings such as cheese, onions, bell peppers +Onion Soup: Onion, butter, flour, chicken broth, beef bouillon, sherry +Paella: Rice, saffron, chicken, chorizo, onion, garlic, tomato, peas, shrimp +Pancakes: Flour, milk, eggs, sugar, baking powder, salt +Panna Cotta: Heavy cream, sugar, milk, gelatin +Pasta Carbonara: Pasta, bacon, eggs, parmesan cheese, black pepper +Pesto: Basil, garlic, pinenuts, parmesan cheese, olive oil, salt +Pho: Beef, beef broth, rice noodles, onion, ginger, star anise, cinnamon, cloves, fish sauce +Poutine: Fries, cheese curds, gravy +Pumpkin Pie: Pumpkin, evaporated milk, eggs, sugar, cinnamon, nutmeg, pie crust +Quesadilla: Tortilla, cheese, fillings such as chicken, onions, bell peppers +Ratatouille: Eggplant, bell peppers, zucchini, onion, garlic, tomato, herbs +Red Velvet Cake: Flour, sugar, cocoa powder, buttermilk, vegetable oil, baking soda, vinegar, cream cheese frosting +Roasted Chicken: Chicken, oil, salt, pepper +Ropa Vieja: Flank steak, tomato sauce, onion, bell pepper, garlic, olives +Rum Cake: Yellow cake, rum, butter, pecans +Salmon Cakes: Salmon, breadcrumbs, egg, onion, old bay seasoning, oil +Seafood Risotto: Arborio rice, seafood, garlic, white wine, parmesan cheese +Shrimp and Grits: Shrimp, grits, bacon, onion, garlic, hot sauce +Sloppy Joes: Ground beef, onion, bell pepper, garlic, tomato sauce, spices, served on hamburger buns +Spaghetti: Spaghetti, tomato sauce, meatballs ,meat sauce +Spaghetti alla Carbonara: Spaghetti, bacon, eggs, parmesan cheese, black pepper +Spaghetti and Meatballs: Spaghetti, tomato sauce, meatballs +Spinach Artichoke Dip: Spinach, artichoke, cream cheese, parmesan cheese, garlic served with chips ,veggies +Stuffed Bell Peppers: Bell peppers, tomato sauce, ,rice, ground beef, onion, garlic, cheese +Chicken Alfredo: Fettuccine noodles, chicken breast, heavy cream, garlic, butter, parmesan cheese, salt +Beef Tacos: tortillas, ground beef, taco seasoning, lettuce, tomatoes, onions, shredded cheese, sour cream +Shrimp Scampi: Linguine noodles, shrimp, garlic, butter, white wine, lemon juice, red pepper flakes, parsley +Baked Ziti: Ziti noodles, ground beef, marinara sauce, ricotta cheese, mozzarella cheese, parmesan cheese +Grilled Cheese Sandwich: Bread, butter, cheese +Chili: Ground beef, kidney beans, onions, garlic, chili powder, cumin, diced tomatoes, beef broth, salt +Breakfast Burritos: Flour tortillas, scrambled eggs, bacon ,sausage, potatoes, cheese, salsa +Chicken Stir Fry: Chicken breast, broccoli, carrots, onions, garlic, soy sauce, brown sugar +Fajitas: Flour tortillas, chicken ,steak, onions, bell peppers, garlic, lime juice, fajita seasoning +Meatball Sub: Sub rolls, meatballs, marinara sauce, mozzarella cheese, parmesan cheese +Grilled Cheese Sandwich: Bread, cheese, butter Served with tomato soup ,a salad +Chicken Caesar Salad: Romaine lettuce, grilled chicken, croutons, Caesar dressing, Parmesan cheese +Beef Tacos: shell tortillas, ground beef, lettuce, tomatoes, onions, shredded cheese, salsa +Shrimp Scampi: Linguine noodles, shrimp, garlic, butter, white wine, lemon juice, red pepper flakes, parsley +BBQ Ribs: Pork ribs, barbecue sauce, brown sugar, spices Served with coleslaw cornbread +Vegetable Stir Fry: Bell peppers, broccoli, carrots, onions, garlic, soy sauce, sesame oil Served over rice ,noodles +Chicken Fajitas: Flour tortillas, chicken breast, onions, bell peppers, garlic, lime juice, fajita seasoning Served with sour cream, guacamole, salsa +Beef and Broccoli: Flank steak, broccoli florets, soy sauce, brown sugar, garlic, ginger, vegetable oil Served over rice +Baked Ziti: Ziti pasta, ground beef, marinara sauce, mozzarella cheese, Parmesan cheese +Grilled Chicken Breast: Chicken breast, olive oil, lemon juice, garlic, salt, pepper Served with roasted vegetables quinoa +Chicken Tikka Masala: Chicken, tomato sauce, onion, garlic, ginger, cumin, coriander, turmeric, garam masala, yogurt, heavy cream, cilantro +Samosa: Potatoes, peas, onion, garlic, ginger, green chilies, coriander, cumin, garam masala, flour, vegetable oil, salt +Butter Chicken: Chicken, butter, tomato sauce, onion, garlic, ginger, coriander, cumin, garam masala, turmeric, paprika, heavy cream, cilantro +Chana Masala: Chickpeas, onion, tomato sauce, garlic, ginger, cumin, coriander, turmeric, garam masala, amchur powder, cilantro +Biryani: Basmati rice, chicken, onion, garlic, ginger, yogurt, saffron, cardamom, cloves, cinnamon, bay leaves, coriander, mint +Pakora: Chickpea flour, onion, spinach, potatoes, chili powder, coriander, turmeric, salt, water +Tandoori Chicken: Chicken, yogurt, garlic, ginger, cumin, coriander, paprika, turmeric, cayenne, lemon juice, garam masala +Aloo Gobi: Potatoes, cauliflower, onion, garlic, ginger, turmeric, cumin, coriander, garam masala, cilantro +Raita: Yogurt, cucumber, cilantro, mint, cumin, red chili powder +Mango Lassi: Mango, yogurt, milk, sugar, ice +Rogan Josh: Lamb, onion, garlic, ginger, tomato sauce, paprika, cumin, coriander, cinnamon, cardamom, cloves, yogurt +Gulab Jamun: Milk solids, flour, baking soda, ghee, yogurt, cardamom, sugar, rose water +Palak Paneer: Paneer, spinach, onion, garlic, ginger, cumin, coriander, turmeric, garam masala, cream +Naan: flour, yeast, sugar, yogurt, milk, salt, butter +Masala Chai: Black tea, milk, sugar, cinnamon, cardamom, ginger +Tandoori Chicken: Chicken breasts, yogurt, cumin, coriander, cayenne pepper, cinnamon, cardamom, cumin +Bhaji: Onion, gram flour, chili powder, turmeric, coriander +Butter Chicken: Chicken, butter, tomato sauce, onion, garlic, ginger, coriander, cumin, garam masala, turmeric +Baingan Bharta: Eggplant, onion, tomato, garlic, ginger, cumin, coriander, turmeric, garam masala, cilantro +Chole Bhature: Chickpeas, onion, tomato, garlic, ginger, cumin, coriander, turmeric, garam masala, chili, flour, baking powder +Dosa: Lentils, rice, fenugreek seeds, salt, oil +Idli: Lentils, rice, fenugreek seeds, salt, oil +Kadhi: Gram flour, yogurt, onion, garlic, ginger, turmeric, cumin, coriander, mustard seeds, curry leaves, asafetida +Korma: Chicken, cream, almonds, onion, garlic, ginger, coriander, cumin, cardamom, cinnamon, cloves +Malai Kofta: Paneer, potatoes, onion, garlic, ginger, cashews, cream, tomato, coriander, cumin, cardamom, cinnamon +Matar Paneer: Paneer, peas, onion, garlic, ginger, tomato, coriander, cumin, turmeric, garam masala +Pongal: Rice, lentils, ghee, cashews, pepper, cumin, curry leaves +Raita: Yogurt, cucumber, cilantro, mint, cumin, red chili powder +Rasmalai: Milk, sugar, lemon juice, paneer, cardamom, pistachios, saffron +Saag Paneer: Spinach, paneer, onion, garlic, ginger, coriander, cumin, turmeric, garam masala +Samosas: Potatoes, peas, onion, garlic, ginger, green chilies, coriander, cumin, garam masala, flour, vegetable oil +Shrimp Curry: Shrimp, onion, garlic, ginger, tomato, coriander, cumin, turmeric, +Butter Paneer: Paneer, butter, tomato sauce, onion, garlic, ginger, coriander, cumin, turmeric, garam masala, cream +Chicken Tikka: Chicken, yogurt, garlic, ginger, cumin, coriander, paprika, turmeric, cayenne, lemon juice, garam masala +Lamb Biryani: Basmati rice, lamb, onion, garlic, ginger, yogurt, saffron, cardamom, cloves, cinnamon, bay leaves, coriander, mint +Palak Paneer: Paneer, spinach, onion, garlic, ginger, cumin, coriander, turmeric, garam masala, cream +Rogan Josh: Lamb, onion, garlic, ginger, tomato sauce, paprika, cumin, coriander, cinnamon, cardamom, cloves, yogurt +Samosa Chaat: Samosa, chickpeas, yogurt, tamarind chutney, mint chutney, sev , chopped onion, cilantro +Vegetable Biryani: Basmati rice, mixed vegetables, onion, garlic, ginger, yogurt, saffron, cardamom, cloves, cinnamon, coriander, mint +Vindaloo: Chicken, lamb, or pork, vinegar, garlic, ginger, onion, tomato, chili powder, cumin, coriander, turmeric, cinnamon, cloves +Aloo Tikki: Potatoes, onion, ginger, green chili, coriander, cumin, chaat masala, bread crumbs, oil +Bhel Puri: Puffed rice, sev, boiled potatoes, onion, tomato, cilantro, tamarind chutney, mint chutney +Chaat Papdi: Papdi (fried dough wafers), boiled potatoes, chickpeas, yogurt, tamarind chutney, mint chutney +Baingan Bharta: Eggplant, onion, tomato, garlic, ginger, cumin, coriander, turmeric, garam masala, cilantro +Chana Masala: Chickpeas, onion, tomato, garlic, ginger, cumin, coriander, turmeric, garam masala, amchur powder, cilantro +Kadhi: Gram flour, yogurt, onion, garlic, ginger, turmeric, cumin, coriander, mustard seeds, curry leaves, asafetida +Korma: Chicken, cream, almonds, onion, garlic, ginger, coriander, cumin, cardamom, cinnamon, cloves +Malai Kofta: Paneer, potatoes, onion, garlic, ginger, cashews, cream, tomato, coriander, cumin, cardamom, cinnamon +Matar Paneer: Paneer, peas, onion, garlic, ginger, tomato, coriander, cumin, turmeric, garam masala +Pongal: Rice, lentils, ghee, cashews, pepper, cumin, curry leaves +Raita: Yogurt, cucumber, cilantro, mint, cumin, red chili powder +Rasmalai: Milk, sugar, lemon juice, paneer, cardamom, pistachios, saffron +Saag Paneer: Spinach, paneer, onion, garlic, ginger, coriander, cumin, turmeric, garam masala, cream +Samosas: Potatoes, peas, onion, garlic, ginger, green chilies, coriander, cumin, garam masala, flour, vegetable oil +Shrimp Curry: Shrimp, onion, garlic, ginger, tomato, coriander, cumin, turmeric, chili powder, coconut milk +Aloo Gobi: Potatoes, cauliflower, onion, garlic, ginger, turmeric, cumin, coriander, garam masala, cilantro +Chole Bhature: Chickpeas, onion, tomato, garlic, ginger, cumin, coriander, turmeric, garam masala, chili, flour, baking powder +Dosa: Lentils, rice, fenugreek seeds, salt, oil +Gulab Jamun: Milk solids, flour, baking soda, ghee, yogurt, cardamom, sugar, rose water +Idli: Lentils, rice, fenugreek seeds, salt, oil +Jalebi: Gram flour, yogurt, water, sugar, saffron, cardamom, oil +Kebab: chicken, beef, onion, garlic, ginger, coriander, cumin, chili powder, yogurt, oil +Lassi: Yogurt, water, sugar, rose water, cardamom +Masala Chai: Black tea, milk, sugar, cinnamon, cardamom, ginger +Naan: Flour, yeast, sugar, yogurt, milk, salt, butter +Paneer Tikka: Paneer, yogurt, garlic, ginger, cumin, coriander, turmeric, chili powder, oil +Rajma: Kidney beans, onion, tomato, garlic, ginger, cumin, coriander, turmeric, garam masala, chili, oil +Rogan Josh: Lamb, onion, garlic, ginger, tomato sauce, paprika, cumin, coriander, cinnamon, cardamom, cloves, yogurt +Tandoori Chicken: Chicken, yogurt, garlic, ginger, cumin, coriander, paprika, turmeric, cayenne, lemon juice, garam masala +Vada Pav: Spiced potato fritters, buns, green chutney, tamarind +Biryani: rice, meat, yogurt, onion, garlic, ginger, saffron, cardamom, cloves, cinnamon, coriander, mint, fried onions +Chaat: chickpeas, potatoes, yogurt, tamarind chutney, mint chutney, sev , chopped onion, cilantro +Chicken 65: Chicken, yogurt, garlic, ginger, chili powder, coriander, cumin, turmeric, vinegar, oil +Dhokla: Gram flour, semolina, yogurt, lemon juice, turmeric, baking soda, mustard seeds, sesame seeds, green chili, cilantro +Gobi Manchurian: Cauliflower, gram flour, cornstarch, ginger, garlic, green chili, soy sauce, vinegar, ketchup, oil +Hakka Noodles: Noodles, carrots, beans, cabbage, soy sauce, vinegar, chili sauce, garlic, oil +Hyderabadi Biryani: rice, meat, yogurt, onion, garlic, ginger, saffron, cardamom, cloves, cinnamon, coriander, mint, fried onions, rose water, kewra water +Kadai Paneer: Paneer, onion, tomato, garlic, ginger, coriander, cumin, turmeric, garam masala, chili, oil +Kati Roll: Paratha, meat, egg, onion, chili sauce, lime +Luchi: Flour, ghee, oil, salt +Mirchi Bhajji: Green chili, gram flour, chili powder, coriander +Beef Stroganoff: Beef, mushrooms, onion, beef broth, sour cream, egg noodles +Bruschetta: Bread, tomatoes, basil, garlic, oil +Butternut Squash Soup: Butternut squash, chicken broth, onion, garlic +Carbonara: Spaghetti, eggs, bacon, parmesan cheese +Chicken and Dumplings: Chicken, dumplings, vegetables, chicken broth +Chicken Fried Rice: Rice, chicken, vegetables, eggs, soy sauce +Chicken Parmesan: Chicken, tomato sauce, cheese, pasta +Chicken Penne: Penne pasta, chicken, tomato sauce, cheese +Chicken Tacos: Tortillas, chicken, cheese, lettuce, tomato, salsa +Chicken Tikka Masala: Chicken, tomato sauce, coconut milk, spices +Clam Chowder: Clams, potatoes, onion, milk, bacon +Cobb Salad: Romaine lettuce, chicken, bacon, avocado, tomato, blue cheese, dressing +Coleslaw: Cabbage, mayonnaise, sugar +Corn on the Cob: Corn, butter, salt +Crab Cakes: Crab, breadcrumbs, mayonnaise, spices +Cream of Mushroom Soup: Mushrooms, chicken broth, cream, flour +Crepes: Flour, eggs, milk, sugar +Croissants: Flour, butter, yeast, sugar +Cuban Sandwich: Ham, roasted pork, Swiss cheese, pickles, mustard, Cuban bread +Deviled Eggs: Eggs, mayonnaise, mustard, vinegar, salt, pepper, paprika +Egg Rolls: Cabbage, carrots, onions, garlic, ground pork, soy sauce, egg roll wrappers +Enchiladas: Tortillas, cheese, chicken ,beef, onions, garlic, tomato sauce, chili powder +Fried Rice: Rice, eggs, onions, peas, carrots +Beef Bourguignon: Beef, bacon, onion, carrots, mushrooms, red wine, beef broth, tomato paste, garlic, thyme, bay leaves +Beef Wellington: Beef tenderloin, puff pastry, mushroom duxelles, prosciutto, Dijon mustard, egg, salt, pepper +Bouillabaisse: Fish, shellfish, onion, fennel, garlic, tomato, saffron, white wine, Pernod, fish stock, rouille +Carne Asada: Flank steak, lime juice, lemon juice, olive oil, garlic, cumin, chili powder, salt, pepper +Chicken Cordon Bleu: Chicken breast, ham, Swiss cheese, egg, breadcrumbs, flour, butter, oil, mustard, salt, pepper +Chicken Kiev: Chicken breast, butter, garlic, parsley, egg, breadcrumbs, flour, oil, salt, pepper +Cioppino: Fish, shellfish, onion, fennel, garlic, tomato, white wine, fish stock, basil, oregano, thyme, red pepper flakes +Coq au Vin: Chicken, bacon, onion, carrots, mushrooms, red wine, chicken broth, tomato paste, garlic, thyme, bay leaves +Crab Bisque: Crab, onion, celery, carrots, garlic, tomato, brandy, sherry, heavy cream, fish stock, cayenne pepper +Eggplant Parmesan: Eggplant, tomato sauce, mozzarella cheese, Parmesan cheese, breadcrumbs, egg, salt, pepper +Etouffee: Shrimp, onion, bell pepper, celery, garlic, tomato, +Beef Stroganoff: Beef, mushrooms, onion, beef broth, sour cream, egg noodles +Bruschetta: Bread, tomatoes, basil, garlic, oil +Butternut Squash Soup: Butternut squash, chicken broth, onion, garlic +Carbonara: Spaghetti, eggs, bacon, parmesan cheese +Chicken and Dumplings: Chicken, dumplings, vegetables, chicken broth +Chicken Fried Rice: Rice, chicken, vegetables, eggs, soy sauce +Chicken Parmesan: Chicken, tomato sauce, cheese, pasta +Chicken Penne: Penne pasta, chicken, tomato sauce, cheese +Chicken Tacos: Tortillas, chicken, cheese, lettuce, tomato, salsa +Chicken Tikka Masala: Chicken, tomato sauce, coconut milk, spices +Clam Chowder: Clams, potatoes, onion, milk, bacon +Cobb Salad: Romaine lettuce, chicken, bacon, avocado, tomato, blue cheese, dressing +Coleslaw: Cabbage, mayonnaise, sugar +Corn on the Cob: Corn, butter, salt +Crab Cakes: Crab, breadcrumbs, mayonnaise, spices +Cream of Mushroom Soup: Mushrooms, chicken broth, cream, flour +Crepes: Flour, eggs, milk, sugar +Croissants: Flour, butter, yeast, sugar +Cuban Sandwich: Ham, roasted pork, Swiss cheese, pickles, mustard, Cuban bread +Deviled Eggs: Eggs, mayonnaise, mustard, vinegar, salt, pepper, paprika +Egg Rolls: Cabbage, carrots, onions, garlic, ground pork, soy sauce, egg roll wrappers +Enchiladas: Tortillas, cheese, chicken ,beef, onions, garlic, tomato sauce, chili powder +Fried Rice: Rice, eggs, onions, peas, carrots +Bruschetta: Bread, tomatoes, basil, garlic, oil +Carbonara: Spaghetti, eggs, bacon, parmesan cheese +Eggplant Parmesan: Eggplant, tomato sauce, mozzarella cheese, Parmesan cheese, breadcrumbs, egg, salt, pepper +Fettuccine Alfredo: Fettuccine, butter, heavy cream, parmesan cheese, salt, pepper +Lasagna: Lasagna noodles, ground beef, ricotta cheese, mozzarella cheese, tomato sauce, garlic, onion, basil +Manicotti: Manicotti shells, ricotta cheese, mozzarella cheese, tomato sauce, garlic, onion, basil +Minestrone Soup: Vegetables, beans, pasta, tomato, garlic, onion, herbs +Panzanella: Bread, tomatoes, cucumber, onion, basil, vinaigrette +Pasta Carbonara: Pasta, bacon, eggs, parmesan cheese, black pepper +Pizza: Dough, tomato sauce, mozzarella cheese, toppings of your choice +Risotto: Arborio rice, vegetables, broth, butter, parmesan cheese +Tiramisu: Ladyfingers, mascarpone cheese, espresso, cocoa powder +Tortellini: Tortellini, cheese, tomato sauce, garlic, onion, basil \ No newline at end of file diff --git a/formatted_data.xlsx b/formatted_data.xlsx new file mode 100644 index 0000000..313f3a1 Binary files /dev/null and b/formatted_data.xlsx differ diff --git a/module_activity/api/serializers.py b/module_activity/api/serializers.py index 73de20b..b580767 100644 --- a/module_activity/api/serializers.py +++ b/module_activity/api/serializers.py @@ -8,11 +8,34 @@ from rest_framework import serializers from module_iam.models import IAmPrincipal -from ..models import (BeverageRecord, Bowel, ChronicCondition, - FoodIngredientRecord, FoodRecord, Intolerance, - MealRecord, MealSymptomRecord, Medication, Medicine, - PastTreatment, PrincipalHealthData, Symptoms, - SymptomTypeAfterMeal, SymptomTypeBeforeMeal) +from ..models import ( + BeverageRecord, + Bowel, + ChronicCondition, + FoodIngredientRecord, + FoodIngredintDataset, + FoodRecord, + Intolerance, + MealRecord, + MealSymptomRecord, + Medication, + Medicine, + PastTreatment, + PrincipalHealthData, + Symptoms, + SymptomTypeAfterMeal, + SymptomTypeBeforeMeal, +) + +class FoodDatasetSerializer(serializers.ModelSerializer): + class Meta: + model = FoodIngredintDataset + fields = ["id", "food_name"] + +class FoodIngredientDatasetSerializer(serializers.ModelSerializer): + class Meta: + model = FoodIngredintDataset + fields = ['id', 'food_name', 'ingredients'] class IAmPrincipalSerializer(serializers.ModelSerializer): @@ -28,12 +51,17 @@ class IAmPrincipalSerializer(serializers.ModelSerializer): class PrincipalHealthDataSerializer(serializers.ModelSerializer): + weight = serializers.DecimalField(max_digits=5, decimal_places=2, read_only=True) + height = serializers.DecimalField(max_digits=6, decimal_places=2, read_only=True) + class Meta: model = PrincipalHealthData fields = [ "ethenicity", "weight", + "weight_unit", "height", + "height_unit", "gastrointestinal_health", "exercise_frequency", "sleep_duration", @@ -44,7 +72,9 @@ class PrincipalHealthDataSerializer(serializers.ModelSerializer): class PrincipalAndHealthSerializer(serializers.ModelSerializer): ethenicity = serializers.CharField(read_only=True) weight = serializers.DecimalField(max_digits=5, decimal_places=2, read_only=True) + weight_unit = serializers.CharField(max_length=10, read_only=True) height = serializers.DecimalField(max_digits=6, decimal_places=2, read_only=True) + height_unit = serializers.CharField(max_length=10, read_only=True) gastrointestinal_health = serializers.CharField(read_only=True) exercise_frequency = serializers.CharField(read_only=True) sleep_duration = serializers.CharField(read_only=True) @@ -64,19 +94,35 @@ class PrincipalAndHealthSerializer(serializers.ModelSerializer): # "email_verified", "ethenicity", "weight", + "weight_unit", "height", + "height_unit", "gastrointestinal_health", "exercise_frequency", "sleep_duration", "eat_frequency", - "profile_complete" + "profile_complete", ] def calculate_profile_completion(self, user): """ Calculates the profile completion percentage for a user based on the required fields. """ - fields = self.fields + fields = [ + "profile_photo", + "first_name", + "email", + "date_of_birth", + "gender", + "phone_no", + "ethenicity", + "weight", + "height", + "gastrointestinal_health", + "exercise_frequency", + "sleep_duration", + "eat_frequency", + ] try: # Retrieve the user profile from the database profile = IAmPrincipal.objects.get(id=user) @@ -93,10 +139,19 @@ class PrincipalAndHealthSerializer(serializers.ModelSerializer): for field in fields if ( # If the field is in the user profile and the field value is not None, not an empty string, and not an instance of datetime.date - (field in vars(profile) and vars(profile).get(field, '') and vars(profile).get(field) != datetime.date) or - + ( + field in vars(profile) + and vars(profile).get(field, "") + and vars(profile).get(field) != datetime.date + ) + or # If health data exists, the field is in the user's health data, and the field value is not None, not an empty string, and not an instance of datetime.date - (health_data and field in vars(health_data) and vars(health_data).get(field, '') and vars(health_data).get(field) != datetime.date) + ( + health_data + and field in vars(health_data) + and vars(health_data).get(field, "") + and vars(health_data).get(field) != datetime.date + ) ) ) @@ -105,7 +160,7 @@ class PrincipalAndHealthSerializer(serializers.ModelSerializer): return 0 # Calculate the total number of fields - total_fields = len(fields) - 1 # Exclude profile_complete field + total_fields = len(fields) # Calculate the profile completion percentage completion_percentage = math.floor((completed_fields / total_fields) * 100) @@ -136,7 +191,9 @@ class PrincipalAndHealthSerializer(serializers.ModelSerializer): health_data = instance.health_data_principal data["ethenicity"] = health_data.ethenicity data["weight"] = health_data.weight + data["weight_unit"] = health_data.weight_unit data["height"] = health_data.height + data["height_unit"] = health_data.height_unit data["gastrointestinal_health"] = health_data.gastrointestinal_health data["exercise_frequency"] = health_data.exercise_frequency data["sleep_duration"] = health_data.sleep_duration @@ -145,7 +202,9 @@ class PrincipalAndHealthSerializer(serializers.ModelSerializer): # If health_data_principal doesn't exist or is empty, set empty strings for all attributes data["ethenicity"] = "" data["weight"] = 0.00 + data["weight_unit"] = "kg" data["height"] = 0.00 + data["height_unit"] = "cm" data["gastrointestinal_health"] = "" data["exercise_frequency"] = "" data["sleep_duration"] = "" @@ -168,7 +227,7 @@ class SymptomsSerializer(serializers.ModelSerializer): class PastTreatmentSerializer(serializers.ModelSerializer): class Meta: model = PastTreatment - fields = ["id", "name", "duration"] + fields = ["id", "name", "duration", "is_recurring", "treatment_frequency"] class ChronicConditionSerializer(serializers.ModelSerializer): @@ -180,7 +239,7 @@ class ChronicConditionSerializer(serializers.ModelSerializer): class FoodIngredientRecordSerializer(serializers.ModelSerializer): class Meta: model = FoodIngredientRecord - fields = ["name"] + fields = ["name", "from_dataset"] class FoodRecordSerializer(serializers.ModelSerializer): @@ -194,8 +253,6 @@ class BeverageRecordSerializer(serializers.ModelSerializer): model = BeverageRecord fields = [ "beverage_type", - "glass_type", - "glass_count", "quantity", "quantity_measure", ] @@ -334,6 +391,18 @@ class BowelSerializer(serializers.ModelSerializer): ] +class MealRecordSymptomsSerializer(serializers.ModelSerializer): + + class Meta: + model = MealRecord + fields = [ + "id", + "date", + "time", + "meal_type", + ] + + class SymptomTypeBeforeMealSerializer(serializers.ModelSerializer): class Meta: model = SymptomTypeBeforeMeal @@ -349,6 +418,10 @@ class SymptomTypeAfterMealSerializer(serializers.ModelSerializer): class MealSymptomRecordSerializer(serializers.ModelSerializer): symptoms_before_meal = SymptomTypeBeforeMealSerializer(many=True) symptoms_after_meal = SymptomTypeAfterMealSerializer(many=True) + related_meal_id = serializers.PrimaryKeyRelatedField( + queryset=MealRecord.objects.all(), write_only=True + ) # Added field to accept meal ID + related_meal = MealRecordSymptomsSerializer(read_only=True) class Meta: model = MealSymptomRecord @@ -360,13 +433,18 @@ class MealSymptomRecordSerializer(serializers.ModelSerializer): "interval", "symptoms_before_meal", "symptoms_after_meal", + "related_meal_id", + "related_meal" ] def create(self, validated_data): before_meal_data = validated_data.pop("symptoms_before_meal") after_meal_data = validated_data.pop("symptoms_after_meal") + related_meal_id = validated_data.pop("related_meal_id") - meal_symptom_record = MealSymptomRecord.objects.create(**validated_data) + meal_symptom_record = MealSymptomRecord.objects.create( + related_meal=related_meal_id, **validated_data + ) before_meal_list = [] for data in before_meal_data: @@ -391,6 +469,10 @@ class MealSymptomRecordSerializer(serializers.ModelSerializer): ) instance.interval = validated_data.get("interval", instance.interval) + related_meal_id = validated_data.pop("related_meal_id", None) # Extract meal ID + if related_meal_id is not None: + instance.related_meal = related_meal_id + before_meal_data = validated_data.pop("symptoms_before_meal", []) after_meal_data = validated_data.pop("symptoms_after_meal", []) diff --git a/module_activity/api/urls.py b/module_activity/api/urls.py index 4d789ca..5783cf9 100644 --- a/module_activity/api/urls.py +++ b/module_activity/api/urls.py @@ -28,6 +28,9 @@ urlpatterns = [ path("meal/date/", views.MealDateAPIView.as_view()), path("meal//", views.MealAPIView.as_view()), + path("food/data/", views.FoodDataAPIView.as_view()), + path("food/ingredient/data/", views.FoodIngredientSearchAPIView.as_view()), + path("report/", views.ReportAPIView.as_view()), ] diff --git a/module_activity/api/views.py b/module_activity/api/views.py index 16ed30b..42d674b 100644 --- a/module_activity/api/views.py +++ b/module_activity/api/views.py @@ -12,10 +12,10 @@ from module_project import constants, date_utils from module_project.service import OneSignalNotificationService from module_project.utils import ApiResponse -from ..models import (Bowel, ChronicCondition, Intolerance, MealRecord, +from ..models import (FoodIngredintDataset, Bowel, ChronicCondition, Intolerance, MealRecord, MealSymptomRecord, Medication, PastTreatment, PrincipalHealthData, Symptoms) -from .serializers import (BowelSerializer, ChronicConditionSerializer, +from .serializers import (FoodDatasetSerializer, FoodIngredientDatasetSerializer, BowelSerializer, ChronicConditionSerializer, IAmPrincipalSerializer, IntoleranceSerializer, MealRecordSerializer, MealSymptomRecordSerializer, MedicationSerializer, PastTreatmentSerializer, @@ -157,7 +157,7 @@ class DailyRecordAPIView(APIView): ).get(id=request.user.id) serialized_meal_records = [ - {"type": "Meal", **self.serialize_record(record)} + {"type": f"Meal - {record.meal_type}", **self.serialize_record(record)} for record in principal.filtered_meal_record ] @@ -617,6 +617,34 @@ class MealAPIView(APIView): message=constants.RECORD_DELETED, status=status.HTTP_204_NO_CONTENT ) +class FoodDataAPIView(APIView): + authentication_classes = [JWTAuthentication] + permission_classes = [IsAuthenticated] + model = FoodIngredintDataset + serializer_class = FoodDatasetSerializer + + def get(self, request): + obj = self.model.objects.all().order_by("food_name") + serializer = self.serializer_class(obj, many=True) + return ApiResponse.success(message=constants.SUCCESS, data=serializer.data) + +class FoodIngredientSearchAPIView(APIView): + authentication_classes = [JWTAuthentication] + permission_classes = [IsAuthenticated] + model = FoodIngredintDataset + serializer_class = FoodIngredientDatasetSerializer + + def get(self, request): + query = request.query_params.getlist('query') + print(f"Query : {query}") + obj = self.model.objects.filter(food_name__in=query).values_list('ingredients', flat=True) + + unique_ingredients = set() + for ingredients_list in obj: + unique_ingredients.update(ingredients_list) + # serializer = self.serializer_class(obj, many=True) + return ApiResponse.success(message=constants.SUCCESS, data={'ingredients_list': list(unique_ingredients)}) + class MealDateAPIView(APIView): authentication_classes = [JWTAuthentication] permission_classes = [IsAuthenticated] diff --git a/module_activity/forms.py b/module_activity/forms.py index 384b576..6d121db 100644 --- a/module_activity/forms.py +++ b/module_activity/forms.py @@ -3,9 +3,17 @@ from django import forms from module_iam.models import IAmPrincipal from module_project import constants -from .models import ChronicCondition, Intolerance, PastTreatment, Symptoms +from .models import FoodIngredintDataset, ChronicCondition, Intolerance, PastTreatment, Symptoms +class FoodIngredintDatasetForm(forms.ModelForm): + class Meta: + model = FoodIngredintDataset + fields = ['food_name', 'ingredients'] + +class UploadFileForm(forms.Form): + file = forms.FileField() + class IntoleranceForm(forms.ModelForm): class Meta: model = Intolerance diff --git a/module_activity/migrations/0010_principalhealthdata_converted_height_cm_and_more.py b/module_activity/migrations/0010_principalhealthdata_converted_height_cm_and_more.py new file mode 100644 index 0000000..45b5210 --- /dev/null +++ b/module_activity/migrations/0010_principalhealthdata_converted_height_cm_and_more.py @@ -0,0 +1,43 @@ +# Generated by Django 5.0.2 on 2024-03-26 10:55 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('module_activity', '0009_bowel_active_bowel_created_by_bowel_created_on_and_more'), + ] + + operations = [ + migrations.AddField( + model_name='principalhealthdata', + name='converted_height_cm', + field=models.DecimalField(blank=True, decimal_places=2, help_text='The equivalent height converted into centimeters.', max_digits=5, null=True, verbose_name='Converted Height'), + ), + migrations.AddField( + model_name='principalhealthdata', + name='converted_weight_kg', + field=models.DecimalField(blank=True, decimal_places=2, help_text='The equivalent weight converted into kilograms.', max_digits=5, null=True, verbose_name='Converted Weight'), + ), + migrations.AddField( + model_name='principalhealthdata', + name='height_unit', + field=models.CharField(blank=True, choices=[('cm', 'cm'), ('ft+inch', 'ft+inch')], help_text='Select your height unit.', max_length=10, null=True, verbose_name='Height Unit'), + ), + migrations.AddField( + model_name='principalhealthdata', + name='weight_unit', + field=models.CharField(blank=True, choices=[('kg', 'kg'), ('lbs', 'lbs')], help_text='Select your weight unit.', max_length=10, null=True, verbose_name='Weight Unit'), + ), + migrations.AlterField( + model_name='principalhealthdata', + name='height', + field=models.DecimalField(blank=True, decimal_places=2, default=0.0, help_text='Enter your height in centimeters.', max_digits=6, null=True, verbose_name='Height'), + ), + migrations.AlterField( + model_name='principalhealthdata', + name='weight', + field=models.DecimalField(blank=True, decimal_places=2, default=0.0, help_text='Enter your weight in kilograms.', max_digits=5, null=True, verbose_name='Weight'), + ), + ] diff --git a/module_activity/migrations/0011_mealsymptomrecord_related_meal.py b/module_activity/migrations/0011_mealsymptomrecord_related_meal.py new file mode 100644 index 0000000..e529e3d --- /dev/null +++ b/module_activity/migrations/0011_mealsymptomrecord_related_meal.py @@ -0,0 +1,19 @@ +# Generated by Django 5.0.2 on 2024-03-27 07:14 + +import django.db.models.deletion +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('module_activity', '0010_principalhealthdata_converted_height_cm_and_more'), + ] + + operations = [ + migrations.AddField( + model_name='mealsymptomrecord', + name='related_meal', + field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='symptom_related_meal', to='module_activity.mealrecord'), + ), + ] diff --git a/module_activity/migrations/0012_pasttreatment_is_recurring_and_more.py b/module_activity/migrations/0012_pasttreatment_is_recurring_and_more.py new file mode 100644 index 0000000..0380d2d --- /dev/null +++ b/module_activity/migrations/0012_pasttreatment_is_recurring_and_more.py @@ -0,0 +1,23 @@ +# Generated by Django 5.0.2 on 2024-03-27 13:55 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('module_activity', '0011_mealsymptomrecord_related_meal'), + ] + + operations = [ + migrations.AddField( + model_name='pasttreatment', + name='is_recurring', + field=models.BooleanField(default=False), + ), + migrations.AddField( + model_name='pasttreatment', + name='treatment_frequency', + field=models.TextField(blank=True, null=True), + ), + ] diff --git a/module_activity/migrations/0013_foodingredintdataset.py b/module_activity/migrations/0013_foodingredintdataset.py new file mode 100644 index 0000000..f1c9ac6 --- /dev/null +++ b/module_activity/migrations/0013_foodingredintdataset.py @@ -0,0 +1,24 @@ +# Generated by Django 5.0.2 on 2024-03-28 07:47 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('module_activity', '0012_pasttreatment_is_recurring_and_more'), + ] + + operations = [ + migrations.CreateModel( + name='FoodIngredintDataset', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('food_name', models.CharField(max_length=100)), + ('ingredients', models.JSONField(default=list)), + ], + options={ + 'db_table': 'food_ingredient_dataset', + }, + ), + ] diff --git a/module_activity/migrations/0014_foodingredientrecord_from_dataset.py b/module_activity/migrations/0014_foodingredientrecord_from_dataset.py new file mode 100644 index 0000000..ca1027d --- /dev/null +++ b/module_activity/migrations/0014_foodingredientrecord_from_dataset.py @@ -0,0 +1,18 @@ +# Generated by Django 5.0.2 on 2024-03-28 13:49 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('module_activity', '0013_foodingredintdataset'), + ] + + operations = [ + migrations.AddField( + model_name='foodingredientrecord', + name='from_dataset', + field=models.BooleanField(default=False), + ), + ] diff --git a/module_activity/migrations/0015_remove_beveragerecord_glass_count_and_more.py b/module_activity/migrations/0015_remove_beveragerecord_glass_count_and_more.py new file mode 100644 index 0000000..378094b --- /dev/null +++ b/module_activity/migrations/0015_remove_beveragerecord_glass_count_and_more.py @@ -0,0 +1,21 @@ +# Generated by Django 5.0.2 on 2024-03-28 14:12 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('module_activity', '0014_foodingredientrecord_from_dataset'), + ] + + operations = [ + migrations.RemoveField( + model_name='beveragerecord', + name='glass_count', + ), + migrations.RemoveField( + model_name='beveragerecord', + name='glass_type', + ), + ] diff --git a/module_activity/models.py b/module_activity/models.py index 545bee5..9171f62 100644 --- a/module_activity/models.py +++ b/module_activity/models.py @@ -1,9 +1,23 @@ +import json from django.db import models from module_iam.models import BaseModel, IAmPrincipal -# Create your models here. +class FoodIngredintDataset(models.Model): + food_name = models.CharField(max_length=100) + ingredients = models.JSONField(default=list) + + class Meta: + db_table = "food_ingredient_dataset" + + def set_ingredients(self, x): + self.ingredients = json.dumps(x) + + def get_ingredients(self): + return json.loads(self.ingredients) + + class PrincipalHealthData(BaseModel): principal = models.OneToOneField( IAmPrincipal, @@ -53,20 +67,62 @@ class PrincipalHealthData(BaseModel): default=0.0, blank=True, null=True, - verbose_name="Weight (kg)", + verbose_name="Weight", help_text="Enter your weight in kilograms.", ) + weight_unit = models.CharField( + max_length=10, + choices=[ + ('kg', 'kg'), + ('lbs', 'lbs'), + ], + blank=True, + null=True, + verbose_name="Weight Unit", + help_text="Select your weight unit.", + ) + + converted_weight_kg = models.DecimalField( + max_digits=5, + decimal_places=2, + blank=True, + null=True, + verbose_name="Converted Weight", + help_text="The equivalent weight converted into kilograms.", + ) + height = models.DecimalField( max_digits=6, decimal_places=2, default=0.0, blank=True, null=True, - verbose_name="Height (cm)", + verbose_name="Height", help_text="Enter your height in centimeters.", ) + height_unit = models.CharField( + max_length=10, + choices=[ + ('cm', 'cm'), + ('ft+inch', 'ft+inch'), + ], + blank=True, + null=True, + verbose_name="Height Unit", + help_text="Select your height unit.", + ) + + converted_height_cm = models.DecimalField( + max_digits=5, + decimal_places=2, + blank=True, + null=True, + verbose_name="Converted Height", + help_text="The equivalent height converted into centimeters.", + ) + # Eat frequency (choices if applicable) eat_frequency = models.CharField( max_length=255, @@ -81,6 +137,26 @@ class PrincipalHealthData(BaseModel): def __str__(self): return f"Health Data for {self.principal}" + + @property + def converted_height_in_cm(self): + if self.height_unit == 'ft+inch': + feet, inches = divmod(float(self.height) * 10, 12) + return round(feet * 30.48 + inches * 2.54, 2) # Convert feet to cm and inches to cm + return None + + @property + def converted_weight_in_kg(self): + if self.weight_unit == 'lbs': + return round(float(self.weight) * 0.453592, 2) # Convert pounds to kg + return None + + def save(self, *args, **kwargs): + if self.height_unit == 'ft+inch': + self.converted_height_cm = self.converted_height_in_cm # Update converted height + if self.weight_unit == 'lbs': + self.converted_weight_kg = self.converted_weight_in_kg # Update converted weight + super().save(*args, **kwargs) class Intolerance(BaseModel): @@ -126,6 +202,8 @@ class PastTreatment(BaseModel): ) name = models.CharField(max_length=255, blank=True, null=True) duration = models.DateField() + is_recurring = models.BooleanField(default=False) + treatment_frequency = models.TextField(blank=True, null=True) class Meta: db_table = "past_treatment" @@ -153,6 +231,7 @@ class ChronicCondition(BaseModel): class FoodIngredientRecord(models.Model): name = models.CharField(max_length=100) + from_dataset = models.BooleanField(default=False) class Meta: db_table = "food_ingredient_record" @@ -166,8 +245,6 @@ class FoodRecord(models.Model): class BeverageRecord(models.Model): beverage_type = models.CharField(max_length=100) - glass_type = models.CharField(max_length=100) - glass_count = models.IntegerField() quantity = models.IntegerField() quantity_measure = models.CharField(max_length=100) @@ -278,6 +355,7 @@ class SymptomTypeAfterMeal(models.Model): class MealSymptomRecord(BaseModel): principal = models.ForeignKey(IAmPrincipal, related_name="meal_symptom_principal", on_delete=models.CASCADE) + related_meal = models.ForeignKey(MealRecord, related_name="symptom_related_meal", on_delete=models.SET_NULL, null=True) date = models.DateField() time = models.TimeField() symptoms_description = models.TextField(blank=True, null=True) diff --git a/module_activity/urls.py b/module_activity/urls.py index d52d152..d53b18e 100644 --- a/module_activity/urls.py +++ b/module_activity/urls.py @@ -8,6 +8,8 @@ app_name = "module_activity" urlpatterns = [ + path('populate/food/dataset/', views.PopulateFoodIngredientView.as_view(), name='populate_food'), + path('intolerance//', views.IntoleranceView.as_view(), name='intolerance'), path('intolerance//add/', views.CreateOrUpdateIntoleranceView.as_view(), name='intolerance_add'), path('intolerance//edit/', views.CreateOrUpdateIntoleranceView.as_view(), name='intolerance_edit'), @@ -37,6 +39,19 @@ urlpatterns = [ path('chronic_condition/action/', views.ChronicConditionActionView.as_view(), name='chronic_condition_action'), path('chronic_condition/archive/list//', views.ChronicConditionArchiveView.as_view(), name='chronic_condition_archive'), + path('user/meal//', views.MealView.as_view(), name='meal_view'), + path('user/meal/list//', views.MealListJsonView.as_view(), name='meal_list'), + + path('user/medication//', views.MedicationView.as_view(), name='medication_view'), + path('user/medication/list//', views.MedicationListJsonView.as_view(), name='medication_list'), + + path('user/bowel//', views.BowelView.as_view(), name='bowel_view'), + path('user/bowel/list//', views.BowelListJsonView.as_view(), name='bowel_list'), + + path('user/meal-symptoms//', views.MealSymptomsView.as_view(), name='meal_symptoms_view'), + path('user/meal-symptoms/list//', views.MealSymptomsListJsonView.as_view(), name='meal_symptoms_list'), + + path('user_activity//', views.UserActivityRecordView.as_view(), name='activity_list'), path('meal_detail//', views.MealDetialView.as_view(), name='meal_detail'), path('medication_detail//', views.MedicationDetailView.as_view(), name='medication_detail'), diff --git a/module_activity/views.py b/module_activity/views.py index 47a6ee9..0a276da 100644 --- a/module_activity/views.py +++ b/module_activity/views.py @@ -1,7 +1,9 @@ +import csv import logging from collections import defaultdict from datetime import datetime, timedelta +import pandas as pd from django.contrib import messages from django.contrib.auth.mixins import LoginRequiredMixin from django.db.models import Count, Prefetch, Q @@ -17,9 +19,10 @@ from module_project import constants, date_utils from module_project.utils import JsonResponseUtil from .forms import (ChronicConditionForm, IntoleranceForm, PastTreatmentForm, - SymptomsForm) -from .models import (Bowel, ChronicCondition, Intolerance, MealRecord, - MealSymptomRecord, Medication, PastTreatment, Symptoms) + SymptomsForm, UploadFileForm) +from .models import (Bowel, ChronicCondition, FoodIngredintDataset, + Intolerance, MealRecord, MealSymptomRecord, Medication, + PastTreatment, Symptoms) logger = logging.getLogger(__name__) @@ -29,7 +32,7 @@ class BaseView(generic.TemplateView): resource = None action = None template_name = None - model = Intolerance + model = None context_objext_name = "obj" def get_context_data(self, **kwargs): @@ -151,6 +154,62 @@ class BaseArchiveView(generic.TemplateView): data["principal_id"] = kwargs.get("principal_id") data["page_name"] = self.page_name return data + + +class PopulateFoodIngredientView(generic.View): + # Set the page_name and resource + page_name = iam_constant.RESOURCE_MANAGE_DASHBOARD + resource = iam_constant.RESOURCE_MANAGE_DASHBOARD + template_name = "module_activity/food_ingredient_form.html" + model = FoodIngredintDataset + form_class = UploadFileForm + success_url = reverse_lazy("module_iam:dashboard") + error_message = "An error occurred while saving the data." + + # Add page_name and operation to the context + def get_context_data(self, **kwargs): + context = { + "page_name": self.page_name, + "operation": "Add", + } + context.update(kwargs) # Include any additional context data passed to the view + return context + + def get(self, request, *args, **kwargs): + form = self.form_class() + context = self.get_context_data(form=form) + return render(request, self.template_name, context=context) + + def post(self, request, *args, **kwargs): + print("Request data: ", request.POST) + + form = self.form_class(request.POST, request.FILES) + + if not form.is_valid(): + print(form.errors) + context = self.get_context_data(form=form) + return render(request, self.template_name, context=context) + + uploaded_file = request.FILES['file'] + # decoded_file = uploaded_file.read().decode('utf-8', errors='ignore').splitlines() + # csv_reader = csv.reader(decoded_file) + + df = pd.read_excel(uploaded_file) + + for index, row in df.iterrows(): + food_name = row['Food'].strip().capitalize() + ingredients_str = row['Ingredients'].strip() + ingredients = [ingredient.strip().capitalize() for ingredient in ingredients_str.split(',')] + + if self.model.objects.filter(food_name=food_name).exists(): + continue + + print(f"{food_name} : {ingredients}") + food = self.model(food_name=food_name, ingredients=ingredients) + food.save() + + messages.success(self.request, constants.RECORD_CREATED) + return redirect(self.success_url) class IntoleranceView(BaseView): @@ -249,6 +308,119 @@ class ChronicConditionArchiveView(generic.TemplateView): template_name = "module_activity/chronic_condition_archive_list.html" +class MealView(BaseView): + template_name = "module_activity/meal_list.html" + + +class MealListJsonView(BaseDatatableView): + model = MealRecord + columns = ["id", "date", "time", "meal_type"] + order_columns = ["id", "date", "time", "meal_type"] + + def get_initial_queryset(self): + principal_id = self.kwargs.get("principal_id") + deleted_flag = self.request.GET.get("deleted_flag", None) + return self.model.objects.filter(principal=principal_id, deleted=deleted_flag) + + def ordering(self, qs): + qs = super().ordering(qs) + order = self.request.GET.get('order[0][dir]', None) + if order: + column_index = int(self.request.GET.get('order[0][column]', None)) - 1 + order_column = self.order_columns[column_index] + + if order == "asc": + qs = qs.order_by(order_column) + elif order == "desc": + qs = qs.order_by("-" + order_column) + + return qs + + +class MedicationView(BaseView): + template_name = "module_activity/medication_list.html" + + +class MedicationListJsonView(BaseDatatableView): + model = Medication + columns = ["id", "date", "time"] + order_columns = ["id", "date", "time"] + + def get_initial_queryset(self): + principal_id = self.kwargs.get("principal_id") + deleted_flag = self.request.GET.get("deleted_flag", None) + return self.model.objects.filter(principal=principal_id, deleted=deleted_flag) + + def ordering(self, qs): + order = self.request.GET.get('order[0][dir]', None) + if order: + column_index = int(self.request.GET.get('order[0][column]', None)) - 1 + order_column = self.order_columns[column_index] + + if order == "asc": + qs = qs.order_by(order_column) + elif order == "desc": + qs = qs.order_by("-" + order_column) + + return qs + + +class BowelView(BaseView): + template_name = "module_activity/bowel_list.html" + + +class BowelListJsonView(BaseDatatableView): + model = Bowel + columns = ["id", "date", "time", "stool_type"] + order_columns = ["id", "date", "time", "stool_type"] + + def get_initial_queryset(self): + principal_id = self.kwargs.get("principal_id") + deleted_flag = self.request.GET.get("deleted_flag", None) + return self.model.objects.filter(principal=principal_id, deleted=deleted_flag) + + def ordering(self, qs): + order = self.request.GET.get('order[0][dir]', None) + if order: + column_index = int(self.request.GET.get('order[0][column]', None)) - 1 + order_column = self.order_columns[column_index] + + if order == "asc": + qs = qs.order_by(order_column) + elif order == "desc": + qs = qs.order_by("-" + order_column) + + return qs + + +class MealSymptomsView(BaseView): + template_name = "module_activity/meal_symptoms_list.html" + + +class MealSymptomsListJsonView(BaseDatatableView): + model = MealSymptomRecord + columns = ["id", "date", "time"] + order_columns = ["id", "date", "time"] + + def get_initial_queryset(self): + principal_id = self.kwargs.get("principal_id") + deleted_flag = self.request.GET.get("deleted_flag", None) + return self.model.objects.filter(principal=principal_id, deleted=deleted_flag) + + def ordering(self, qs): + order = self.request.GET.get('order[0][dir]', None) + if order: + column_index = int(self.request.GET.get('order[0][column]', None)) - 1 + order_column = self.order_columns[column_index] + + if order == "asc": + qs = qs.order_by(order_column) + elif order == "desc": + qs = qs.order_by("-" + order_column) + + return qs + + class UserActivityRecordView(generic.View): def serialize_record(self, record): time_obj = datetime.strptime(str(record.time), "%H:%M:%S") @@ -356,6 +528,7 @@ class BowelDetailView(generic.TemplateView): def get_record(self): id = self.kwargs.get("pk") obj = get_object_or_404(self.model, id=id) + print(f"obj data of bowel is {obj}") return obj def get_context_data(self, **kwargs): @@ -533,7 +706,7 @@ class ReportDataView(generic.View): if not self.enough_records_exist(start_date, end_date): print("report does not exist") return JsonResponseUtil.success( - message="No report is generated. Minimum Previous 7 days of records required.", status=204 + message="No report is generated. Minimum Previous 7 days of records required.", status=202 ) # Get top food to avoid diff --git a/module_auth/views.py b/module_auth/views.py index c13f07e..cb0d69c 100644 --- a/module_auth/views.py +++ b/module_auth/views.py @@ -16,7 +16,7 @@ from django.urls import reverse_lazy from django.views import generic from django_datatables_view.base_datatable_view import BaseDatatableView -from module_activity.models import (ChronicCondition, Intolerance, +from module_activity.models import (Bowel, ChronicCondition, Intolerance, MealRecord, MealSymptomRecord, Medication, PastTreatment, PrincipalHealthData, Symptoms) from module_iam import iam_constant @@ -58,6 +58,7 @@ class AdminLoginView(generic.View): return render(request, self.template_name, context=context) login(request, user) + messages.success(request, constants.LOGIN_SUCCESS) logging.info(f"User {user.email} logged in.") return redirect(self.success_url) @@ -85,6 +86,7 @@ class UserDashView(LoginRequiredMixin, generic.TemplateView): model = IAmPrincipal context_objext_name = "obj" + def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) context["page_name"] = self.page_name @@ -163,7 +165,7 @@ class UserListJson(BaseDatatableView): qs = super().filter_queryset(qs) # Call the built-in filtering first for column in self.columns: - print(f" columen index pattern {self.request.GET.get(f'columns[{self.columns.index(column)+1}][search][value]', None)}") + print(f" columen index pattern {self.request.GET.get(f'columns[{self.columns.index(column)+2}][search][value]', None)}") search_value = self.request.GET.get(f'columns[{self.columns.index(column)+1}][search][value]', None) if search_value: column_data = self.request.GET.get(f'columns[{self.columns.index(column)+1}][data]') @@ -177,7 +179,7 @@ class UserListJson(BaseDatatableView): def ordering(self, qs): order = self.request.GET.get('order[0][dir]', None) if order: - column_index = int(self.request.GET.get('order[0][column]', None)) - 1 + column_index = int(self.request.GET.get('order[0][column]', None)) - 2 order_column = self.order_columns[column_index] if order == "asc": @@ -220,6 +222,30 @@ class UserRecordView(LoginRequiredMixin, generic.View): model = IAmPrincipal template_name = "module_auth/user_view.html" + def get_recent_meal(self, id): + recent_meal_records = MealRecord.objects.filter( + principal=id + ).order_by('-id')[:5] + return recent_meal_records + + def get_recent_medication(self, id): + recent_medication_records = Medication.objects.filter( + principal=id + ).order_by('-id')[:5] + return recent_medication_records + + def get_recent_bowel(self, id): + recent_bowel_records = Bowel.objects.filter( + principal=id + ).order_by('-id')[:5] + return recent_bowel_records + + def get_recent_meal_symptom(self, id): + recent_meal_symptom_records = MealSymptomRecord.objects.filter( + principal=id + ).order_by('-id')[:5] + + def get(self, request, id): # Retrieve the IAmPrincipal instance principal_instance = get_object_or_404(IAmPrincipal, id=id) @@ -260,8 +286,17 @@ class UserRecordView(LoginRequiredMixin, generic.View): for data in obj.chronic_data: print(f"data is {data.name, data.duration}") + context = { + 'page_name': self.page_name, + 'obj': obj, + "recent_meal": self.get_recent_meal(id), + "recent_medication": self.get_recent_medication(id), + "recent_bowel": self.get_recent_bowel(id), + "recent_meal_symptom": self.get_recent_meal_symptom(id), + } + # Render the template with the principal instance and related data - return render(request, self.template_name, {'obj': obj, 'page_name': self.page_name}) + return render(request, self.template_name, context=context) class UserArchiveList(LoginRequiredMixin, generic.TemplateView): diff --git a/module_cms/migrations/0004_alter_faqs_answer_alter_faqs_question.py b/module_cms/migrations/0004_alter_faqs_answer_alter_faqs_question.py new file mode 100644 index 0000000..1fd9c8e --- /dev/null +++ b/module_cms/migrations/0004_alter_faqs_answer_alter_faqs_question.py @@ -0,0 +1,24 @@ +# Generated by Django 5.0.2 on 2024-03-26 22:11 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('module_cms', '0003_alter_faqs_faq_category'), + ] + + operations = [ + migrations.AlterField( + model_name='faqs', + name='answer', + field=models.TextField(default=1), + preserve_default=False, + ), + migrations.AlterField( + model_name='faqs', + name='question', + field=models.TextField(), + ), + ] diff --git a/module_cms/models.py b/module_cms/models.py index 5a9c936..ab20190 100644 --- a/module_cms/models.py +++ b/module_cms/models.py @@ -43,8 +43,8 @@ class Faqs(BaseModel): faq_category = models.ForeignKey( FaqCategory, related_name="faqs_category", blank=True, null=True, on_delete=models.SET_NULL ) - question = models.TextField(max_length=255) - answer = models.TextField(blank=True, null=True) + question = models.TextField() + answer = models.TextField() class Meta: db_table = "faq" diff --git a/module_iam/models.py b/module_iam/models.py index c442808..6b15257 100644 --- a/module_iam/models.py +++ b/module_iam/models.py @@ -25,8 +25,6 @@ from .iam_constant import (PRINCIPAL_SOURCE_APP, PRINCIPAL_SOURCE_APPLE, # from phonenumber_field.modelfields import PhoneNumberField - - class BaseModel(models.Model): active = models.BooleanField(default=True) deleted = models.BooleanField(default=False) diff --git a/module_notification/forms.py b/module_notification/forms.py index b5c1c76..9c810a1 100644 --- a/module_notification/forms.py +++ b/module_notification/forms.py @@ -6,4 +6,4 @@ from .models import PushNotification class PushNotificationForm(forms.ModelForm): class Meta: model = PushNotification - fields = ('title', 'banner_image', 'message') \ No newline at end of file + fields = ('title', 'message') \ No newline at end of file diff --git a/module_project/settings/base.py b/module_project/settings/base.py index 90d7393..82c437e 100644 --- a/module_project/settings/base.py +++ b/module_project/settings/base.py @@ -195,7 +195,7 @@ REST_FRAMEWORK = { } MESSAGE_TAGS = { - messages.DEBUG: "alert-info", + messages.DEBUG: "alert-primary", messages.INFO: "alert-info", messages.SUCCESS: "alert-success", messages.WARNING: "alert-warning", diff --git a/module_support/views.py b/module_support/views.py index 70a0ac8..b60ee4b 100644 --- a/module_support/views.py +++ b/module_support/views.py @@ -38,6 +38,12 @@ class ContactUsListJson(BaseDatatableView): columns = ["id", "email_address", "subject", "message", "reply", "active"] order_columns = ["id", "email_address", "subject", "message", "reply", "active"] + FILTER_ICONTAINS = "icontains" + + def get_filter_method(self): + """Returns preferred filter method""" + return self.FILTER_ICONTAINS + def get_initial_queryset(self): deleted_flag = self.request.GET.get('deleted_flag', None) diff --git a/process_food_data.py b/process_food_data.py new file mode 100644 index 0000000..5ed2b01 --- /dev/null +++ b/process_food_data.py @@ -0,0 +1,54 @@ +import openpyxl + +# Read existing foods from Excel file +existing_foods = set() +try: + existing_workbook = openpyxl.load_workbook('formatted_data.xlsx') + existing_sheet = existing_workbook.active + for row in existing_sheet.iter_rows(min_row=2, max_col=1, max_row=existing_sheet.max_row): + existing_foods.add(row[0].value) +except FileNotFoundError: + # If the file does not exist, there are no existing foods + pass + +# Read data from text file +with open('food_data.txt', 'r') as file: + data = file.readlines() + +# Process the data +formatted_data = [] +for line in data: + # Split each line by colon ':' + parts = line.strip().split(':') + # Check if there are two parts (food and ingredients) + if len(parts) == 2: + food = parts[0].strip() + ingredients = parts[1].strip() + # Check if the food is already in the existing foods set + if food not in existing_foods: + # If not, add the food to the set and to the formatted data list + existing_foods.add(food) + formatted_data.append((food, ingredients)) + else: + # If only one part is present, add an empty string for ingredients + food = parts[0].strip() + if food not in existing_foods: + existing_foods.add(food) + formatted_data.append((food, '')) + +# Write data to Excel file +workbook = openpyxl.Workbook() +sheet = workbook.active + +# Add headers +sheet.cell(row=1, column=1).value = 'Food' +sheet.cell(row=1, column=2).value = 'Ingredients' + +# Add data +for idx, entry in enumerate(formatted_data, start=2): + # Write food and ingredients to respective columns + sheet.cell(row=idx, column=1).value = entry[0] + sheet.cell(row=idx, column=2).value = entry[1] + +# Save Excel file +workbook.save('formatted_data.xlsx') diff --git a/templates/base_structure/elements/message.html b/templates/base_structure/elements/message.html index c79d952..aee2aec 100644 --- a/templates/base_structure/elements/message.html +++ b/templates/base_structure/elements/message.html @@ -1,5 +1,6 @@ {% for message in messages %} - + {% endfor %} \ No newline at end of file diff --git a/templates/base_structure/includes/dynamic_template_form.html b/templates/base_structure/includes/dynamic_template_form.html index 280bbde..430f3fb 100644 --- a/templates/base_structure/includes/dynamic_template_form.html +++ b/templates/base_structure/includes/dynamic_template_form.html @@ -15,6 +15,7 @@ {% for field in form.visible_fields %} {% comment %}

{{field.errors}}

{% endcomment %} + {% if field.field.choices %}
diff --git a/templates/base_structure/layout/base_authentication_template.html b/templates/base_structure/layout/base_authentication_template.html index 0855b92..9039d91 100644 --- a/templates/base_structure/layout/base_authentication_template.html +++ b/templates/base_structure/layout/base_authentication_template.html @@ -45,6 +45,7 @@ + @@ -52,8 +53,8 @@ {% block javascript %}{% endblock %} diff --git a/templates/base_structure/layout/base_template.html b/templates/base_structure/layout/base_template.html index e571002..083acce 100644 --- a/templates/base_structure/layout/base_template.html +++ b/templates/base_structure/layout/base_template.html @@ -81,8 +81,8 @@ diff --git a/templates/base_structure/layout/dashboard.html b/templates/base_structure/layout/dashboard.html index 2440c76..dea48a4 100644 --- a/templates/base_structure/layout/dashboard.html +++ b/templates/base_structure/layout/dashboard.html @@ -53,7 +53,7 @@
-

Activty Graph

+

Activity Graph

diff --git a/templates/module_activity/bowel_detail.html b/templates/module_activity/bowel_detail.html index b47f46c..89a803f 100644 --- a/templates/module_activity/bowel_detail.html +++ b/templates/module_activity/bowel_detail.html @@ -12,7 +12,7 @@
-

Meal Details

+

Bowel Details

{% comment %}
- {{ bowel.stool_type }} + {{ obj.stool_type }}
@@ -44,7 +44,7 @@

Duration :

- {{ bowel.duration }} + {{ obj.duration }}
@@ -52,7 +52,7 @@

Completeness of Evacuation :

- {{ bowel.completeness_of_evacuation }} + {{ obj.completeness_of_evacuation }}
@@ -60,7 +60,7 @@

Color :

- {{ bowel.color }} + {{ obj.color }}
@@ -69,7 +69,7 @@
- {{bowel.excessive_flatulence}} + {{obj.excessive_flatulence}}
@@ -80,7 +80,7 @@

Urgency :

- {{ bowel.urgency }} + {{ obj.urgency }}
@@ -88,7 +88,7 @@

Smelliness :

- {{ bowel.smellness }} + {{ obj.smellness }}
@@ -96,7 +96,7 @@

Pain level :

- {{ bowel.pain_level }} + {{ obj.pain_level }}
@@ -104,7 +104,7 @@

Volume :

- {{ bowel.volume }} + {{ obj.volume }}
diff --git a/templates/module_activity/bowel_list.html b/templates/module_activity/bowel_list.html new file mode 100644 index 0000000..af243ad --- /dev/null +++ b/templates/module_activity/bowel_list.html @@ -0,0 +1,164 @@ +{% extends 'base_structure/layout/base_template.html' %} +{% load static %} +{% block stylesheet %} + + + {% include "cdn_through_html/datatable_cdn_css.html" %} + {% include "cdn_through_html/animate_cdn_css.html" %} + {% include "cdn_through_html/modal_cdn_css.html" %} + +{% endblock %} + +{% block content %} + +
+
+ + +
+
+
+
+ +
+
+
+
+ + +{% endblock content %} + +{% block javascript %} + + + + {% include "cdn_through_html/datatable_cdn_js.html" %} + + +{% endblock %} \ No newline at end of file diff --git a/templates/module_activity/chronic_conditon_list.html b/templates/module_activity/chronic_conditon_list.html index 157b6af..6d3ac20 100644 --- a/templates/module_activity/chronic_conditon_list.html +++ b/templates/module_activity/chronic_conditon_list.html @@ -21,9 +21,9 @@ User Chronic conditions/diseases - {{principal_id.id}} - {{principal_id.first_name}}
-
+ {% comment %}
Add -
+
{% endcomment %}
@@ -38,19 +38,12 @@ - - # # User Symptoms For how long have you been experiencing this Symptoms - Active - Action @@ -89,8 +82,7 @@ var viewArchiveUrl = "{% url 'module_activity:chronic_condition_archive' princip $(document).ready(function() { dataTableInstance = initializeDataTable(dataTableInstance, mainUrl); - editClickEvent(); - activeSwitchEventListener(); + }); // Function to initialize DataTable @@ -103,38 +95,18 @@ function initializeDataTable(dataTableInstance, mainUrl) { type: "GET", }, columns: [ - { data: null, className: "text-center", render: renderCheckbox }, { data: "id", className: "text-center" }, { data: "name", className: "text-center" }, - { data: "duration", className: "text-center" }, - { data: "active", className: "text-center", render: renderSwitch }, - { data: null, className: "text-center", render: renderActions } + { data: "duration", className: "text-center" } ], debug: true, columnDefs: [ - { targets: [1, 2, 3], searchable: true, orderable: true }, - { targets: [0, -1], searchable: false, orderable: false } + { targets: [1, 2, 0], searchable: true, orderable: true } ], dom: "<'dt--top-section'<'row'<'col-12 col-sm-6 d-flex justify-content-sm-start justify-content-center'l><'col-12 col-sm-6 d-flex justify-content-sm-end justify-content-center mt-sm-0 mt-3'Bf>>>" + "<'table-responsive'tr>" + "<'dt--bottom-section d-sm-flex justify-content-sm-between text-center'<'dt--pages-count mb-sm-0 mb-3'i><'dt--pagination'p>>", buttons: [ - { - text: 'Archive', - className: "btn btn-dark buttons-archive", - action: archiveAction, - init: function(api, node, config){ - $(node).hide(); - } - }, - { - text: 'View Archive List', - className: "btn btn-dark ", - action: function () { - // Add your action here, e.g., redirect to archive page - window.location.href = viewArchiveUrl; - } - } ], oLanguage: { oPaginate: { "sPrevious": '', "sNext": '' }, @@ -145,171 +117,7 @@ function initializeDataTable(dataTableInstance, mainUrl) { }, stripeClasses: [], lengthMenu: [5, 10, 20, 50], - pageLength: 10, - initComplete: initCompleteCallback - }); -} - -// Function to reload the DataTable -function reloadDataTable() { - dataTableInstance.ajax.reload(); -} - -// Render checkbox -function renderCheckbox(data, type, row) { - var checkboxHTML = '
'; - checkboxHTML += ''; - checkboxHTML += '
'; - return checkboxHTML; -} - -// Render switch -function renderSwitch(data, type, row) { - console.log("data is ", data, "type is", typeof(data)) - var checkedAttribute = data.toLowerCase() === 'true' ? 'checked' : ''; - console.log("check attribute", + checkedAttribute) - var switchHTML = '
'; - switchHTML += ''; - switchHTML += '
'; - return switchHTML; -} - -// Render actions -function renderActions(data, type, row) { - return ` - `; -} - -// Callback function for DataTable initialization complete event -function initCompleteCallback() { - var api = this.api(); - - // Add event listener for checkbox change - $('body').on('change', 'input[type="checkbox"]', function () { - var checkedCount = $('#table tbody input.archive-checkbox:checked').length; - var archiveButton = $('.buttons-archive'); - archiveButton.toggle(checkedCount > 0); - }); - -} - -// Function to handle archive action -function archiveAction() { - // Get all the checked checkboxes - var checkedCheckboxes = $('.archive-checkbox:checked'); - // If no checkboxes are checked, show an error message - if (checkedCheckboxes.length === 0) { - Swal.fire({ - title: 'No users selected', - text: 'Please select at least one user to archive.', - icon: 'error', - showConfirmButton: true - }); - return; - } - // Get the IDs of the checked checkboxes - var userIds = checkedCheckboxes.map(function() { - return $(this).val(); - }).get(); - // Perform archive action with the collected user IDs - Swal.fire({ - title: 'Are you sure?', - text: 'Once archived, you will recover it from archive list!', - icon: 'warning', - showCancelButton: true, - confirmButtonColor: '#d33', - cancelButtonColor: '#3085d6', - confirmButtonText: 'Yes, archive it!' - }).then((result) => { - if (result.isConfirmed) { - // Perform archive action - $.ajax({ - url: actionUrl, // Replace with your archive endpoint - type: 'POST', - data: { - action: "archive", - ids: userIds, - csrfmiddlewaretoken: '{{csrf_token}}' - }, - success: function(response) { - // Show success message - Swal.fire({ - title: 'Done!', - text: response.msg, - icon: 'success', - showConfirmButton: true - }); - // Optionally, you can reload the DataTable after successful archive - reloadDataTable(); - }, - error: function(response) { - // Show error message - Swal.fire({ - title: 'Error!', - text: response.message, - icon: 'error', - showConfirmButton: true - }); - } - }); - } - }); -} - -// Function to add event listener for switch -function activeSwitchEventListener() { - // Add event listener for switch change event - $('body').on('change', '.switch-input', function() { - var rowId = $(this).closest('tr').find('.switch-input').data('id'); - var isActive = $(this).prop('checked'); - console.log(rowId, isActive) - // Perform active toggle action for the current user - $.ajax({ - url: actionUrl, // Replace with your active toggle endpoint - type: 'POST', - data: { - action: "active", - ids: [rowId], - active: isActive, - csrfmiddlewaretoken: '{{csrf_token}}' - }, - success: function(response) { - // Show success message - Swal.fire({ - title: 'Done!', - text: response.msg, - icon: 'success', - showConfirmButton: true - }); - // Reload the DataTable after successful toggle - reloadDataTable(); - }, - error: function(response) { - // Show error message - Swal.fire({ - title: 'Error!', - text: response.message, - icon: 'error', - showConfirmButton: true - }); - } - }); - }); -} - - -// Function to handle click event for edit button -function editClickEvent() { - $('body').on('click', '.edit', function(){ - var id =$(this).data('id'); - console.log('Editing user with Id:', id); + pageLength: 10 }); } diff --git a/templates/module_activity/food_ingredient_form.html b/templates/module_activity/food_ingredient_form.html new file mode 100644 index 0000000..c329f8e --- /dev/null +++ b/templates/module_activity/food_ingredient_form.html @@ -0,0 +1,52 @@ +{% extends 'base_structure/layout/base_template.html' %} +{% load static %} +{% block stylesheet %} + + + +{% endblock %} + +{% block content %} + +
+
+ +
+
+
+
+ +
+ {% csrf_token %} + {% include 'base_structure/includes/dynamic_template_form.html' with form=form %} +
+
+
+
+ +
+
+
+
+
+
+ + +{% endblock content %} + +{% block javascript %} + + + + +{% endblock %} \ No newline at end of file diff --git a/templates/module_activity/intolerance_list.html b/templates/module_activity/intolerance_list.html index fcab9f0..828834f 100644 --- a/templates/module_activity/intolerance_list.html +++ b/templates/module_activity/intolerance_list.html @@ -21,9 +21,9 @@ User Intolerances - {{principal_id.id}} - {{principal_id.first_name}}
-
+ {% comment %}
Add -
+
{% endcomment %}
@@ -38,19 +38,13 @@ - - # # User Intolerances For how long have you been experiencing this intolerance - Active - Action + @@ -103,38 +97,18 @@ function initializeDataTable(tableName, mainUrl) { type: "GET", }, columns: [ - { data: null, className: "text-center", render: renderCheckbox }, { data: "id", className: "text-center" }, { data: "name", className: "text-center" }, { data: "duration", className: "text-center" }, - { data: "active", className: "text-center", render: renderSwitch }, - { data: null, className: "text-center", render: renderActions } ], debug: true, columnDefs: [ - { targets: [1, 2, 3], searchable: true, orderable: true }, - { targets: [0, -1], searchable: false, orderable: false } + { targets: [0, 1, 2], searchable: true, orderable: true } ], dom: "<'dt--top-section'<'row'<'col-12 col-sm-6 d-flex justify-content-sm-start justify-content-center'l><'col-12 col-sm-6 d-flex justify-content-sm-end justify-content-center mt-sm-0 mt-3'Bf>>>" + "<'table-responsive'tr>" + "<'dt--bottom-section d-sm-flex justify-content-sm-between text-center'<'dt--pages-count mb-sm-0 mb-3'i><'dt--pagination'p>>", buttons: [ - { - text: 'Archive', - className: "btn btn-dark buttons-archive", - action: archiveAction, - init: function(api, node, config){ - $(node).hide(); - } - }, - { - text: 'View Archive List', - className: "btn btn-dark ", - action: function () { - // Add your action here, e.g., redirect to archive page - window.location.href = viewArchiveUrl; - } - } ], oLanguage: { oPaginate: { "sPrevious": '', "sNext": '' }, @@ -145,160 +119,7 @@ function initializeDataTable(tableName, mainUrl) { }, stripeClasses: [], lengthMenu: [5, 10, 20, 50], - pageLength: 10, - initComplete: initCompleteCallback - }); -} - -// Function to reload the DataTable -function reloadDataTable() { - dataTableInstance.ajax.reload(); -} - -// Render checkbox -function renderCheckbox(data, type, row) { - var checkboxHTML = '
'; - checkboxHTML += ''; - checkboxHTML += '
'; - return checkboxHTML; -} - -// Render switch -function renderSwitch(data, type, row) { - var checkedAttribute = data.toLowerCase() === 'true' ? 'checked' : ''; - var switchHTML = '
'; - switchHTML += ''; - switchHTML += '
'; - return switchHTML; -} - -// Render actions -function renderActions(data, type, row) { - return ` - `; -} - -// Callback function for DataTable initialization complete event -function initCompleteCallback() { - var api = this.api(); - - // Add event listener for checkbox change - $('body').on('change', 'input[type="checkbox"]', function () { - var checkedCount = $('tbody input.archive-checkbox:checked').length; - var archiveButton = $('.buttons-archive'); - archiveButton.toggle(checkedCount > 0); - }); - -} - -// Function to handle archive action -function archiveAction() { - // Get all the checked checkboxes - var checkedCheckboxes = $('.archive-checkbox:checked'); - // If no checkboxes are checked, show an error message - if (checkedCheckboxes.length === 0) { - Swal.fire({ - title: 'No users selected', - text: 'Please select at least one user to archive.', - icon: 'error', - showConfirmButton: true - }); - return; - } - // Get the IDs of the checked checkboxes - var ids = checkedCheckboxes.map(function() { - return $(this).val(); - }).get(); - // Perform archive action with the collected user IDs - Swal.fire({ - title: 'Are you sure?', - text: 'Once archived, you will recover it from archive list!', - icon: 'warning', - showCancelButton: true, - confirmButtonColor: '#d33', - cancelButtonColor: '#3085d6', - confirmButtonText: 'Yes, archive it!' - }).then((result) => { - if (result.isConfirmed) { - // Perform archive action - $.ajax({ - url: actionUrl, // Replace with your archive endpoint - type: 'POST', - data: { - action: "archive", - ids: ids, - csrfmiddlewaretoken: '{{csrf_token}}' - }, - success: function(response) { - // Show success message - Swal.fire({ - title: 'Done!', - text: response.msg, - icon: 'success', - showConfirmButton: true - }); - // Optionally, you can reload the DataTable after successful archive - reloadDataTable(); - }, - error: function(response) { - // Show error message - Swal.fire({ - title: 'Error!', - text: response.message, - icon: 'error', - showConfirmButton: true - }); - } - }); - } - }); -} - -// Function to add event listener for switch -function activeSwitchEventListener() { - // Add event listener for switch change event - $('body').on('change', '.switch-input', function() { - var rowId = $(this).closest('tr').find('.switch-input').data('id'); - var isActive = $(this).prop('checked'); - console.log(rowId, isActive) - // Perform active toggle action for the current user - $.ajax({ - url: actionUrl, // Replace with your active toggle endpoint - type: 'POST', - data: { - action: "active", - ids: [rowId], - active: isActive, - csrfmiddlewaretoken: '{{csrf_token}}' - }, - success: function(response) { - // Show success message - Swal.fire({ - title: 'Done!', - text: response.msg, - icon: 'success', - showConfirmButton: true - }); - // Reload the DataTable after successful toggle - reloadDataTable(); - }, - error: function(response) { - // Show error message - Swal.fire({ - title: 'Error!', - text: response.message, - icon: 'error', - showConfirmButton: true - }); - } - }); + pageLength: 10 }); } diff --git a/templates/module_activity/meal_detail.html b/templates/module_activity/meal_detail.html index 14fc0ed..2ad0cc5 100644 --- a/templates/module_activity/meal_detail.html +++ b/templates/module_activity/meal_detail.html @@ -101,10 +101,6 @@
- - diff --git a/templates/module_activity/meal_list.html b/templates/module_activity/meal_list.html new file mode 100644 index 0000000..328bd73 --- /dev/null +++ b/templates/module_activity/meal_list.html @@ -0,0 +1,212 @@ +{% extends 'base_structure/layout/base_template.html' %} +{% load static %} +{% block stylesheet %} + + + {% include "cdn_through_html/datatable_cdn_css.html" %} + {% include "cdn_through_html/animate_cdn_css.html" %} + {% include "cdn_through_html/modal_cdn_css.html" %} + +{% endblock %} + +{% block content %} + +
+
+ + +
+
+
+
+ +
+
+
+
+ + + + +{% endblock content %} + +{% block javascript %} + + + + {% include "cdn_through_html/datatable_cdn_js.html" %} + + +{% endblock %} \ No newline at end of file diff --git a/templates/module_activity/meal_symptom_details.html b/templates/module_activity/meal_symptom_details.html index dedf74e..cb0daa0 100644 --- a/templates/module_activity/meal_symptom_details.html +++ b/templates/module_activity/meal_symptom_details.html @@ -86,10 +86,6 @@
- - diff --git a/templates/module_activity/meal_symptoms_list.html b/templates/module_activity/meal_symptoms_list.html new file mode 100644 index 0000000..44072bc --- /dev/null +++ b/templates/module_activity/meal_symptoms_list.html @@ -0,0 +1,160 @@ +{% extends 'base_structure/layout/base_template.html' %} +{% load static %} +{% block stylesheet %} + + + {% include "cdn_through_html/datatable_cdn_css.html" %} + {% include "cdn_through_html/animate_cdn_css.html" %} + {% include "cdn_through_html/modal_cdn_css.html" %} + +{% endblock %} + +{% block content %} + +
+
+ + +
+
+
+
+ +
+
+
+
+ + +{% endblock content %} + +{% block javascript %} + + + + {% include "cdn_through_html/datatable_cdn_js.html" %} + + +{% endblock %} \ No newline at end of file diff --git a/templates/module_activity/medication_detail.html b/templates/module_activity/medication_detail.html index 757c57d..5168b57 100644 --- a/templates/module_activity/medication_detail.html +++ b/templates/module_activity/medication_detail.html @@ -62,10 +62,6 @@
- - diff --git a/templates/module_activity/medication_list.html b/templates/module_activity/medication_list.html new file mode 100644 index 0000000..aaf2521 --- /dev/null +++ b/templates/module_activity/medication_list.html @@ -0,0 +1,160 @@ +{% extends 'base_structure/layout/base_template.html' %} +{% load static %} +{% block stylesheet %} + + + {% include "cdn_through_html/datatable_cdn_css.html" %} + {% include "cdn_through_html/animate_cdn_css.html" %} + {% include "cdn_through_html/modal_cdn_css.html" %} + +{% endblock %} + +{% block content %} + +
+
+ + +
+
+
+
+ +
+
+
+
+ + +{% endblock content %} + +{% block javascript %} + + + + {% include "cdn_through_html/datatable_cdn_js.html" %} + + +{% endblock %} \ No newline at end of file diff --git a/templates/module_activity/past_treatment_list.html b/templates/module_activity/past_treatment_list.html index c5671cb..415969d 100644 --- a/templates/module_activity/past_treatment_list.html +++ b/templates/module_activity/past_treatment_list.html @@ -21,9 +21,9 @@ User Past Treatment - {{principal_id.id}} - {{principal_id.first_name}}
-
+ {% comment %}
Add -
+
{% endcomment %}
@@ -38,19 +38,14 @@ - - # + # User Past Treatment Treatment date - Active - Action + @@ -89,8 +84,7 @@ var viewArchiveUrl = "{% url 'module_activity:past_treatment_archive' principal_ $(document).ready(function() { dataTableInstance = initializeDataTable(dataTableInstance, mainUrl); - editClickEvent(); - activeSwitchEventListener(); + }); // Function to initialize DataTable @@ -103,38 +97,18 @@ function initializeDataTable(dataTableInstance, mainUrl) { type: "GET", }, columns: [ - { data: null, className: "text-center", render: renderCheckbox }, { data: "id", className: "text-center" }, { data: "name", className: "text-center" }, { data: "duration", className: "text-center" }, - { data: "active", className: "text-center", render: renderSwitch }, - { data: null, className: "text-center", render: renderActions } ], debug: true, columnDefs: [ - { targets: [1, 2, 3], searchable: true, orderable: true }, - { targets: [0, -1], searchable: false, orderable: false } + { targets: [1, 2, 0], searchable: true, orderable: true } ], dom: "<'dt--top-section'<'row'<'col-12 col-sm-6 d-flex justify-content-sm-start justify-content-center'l><'col-12 col-sm-6 d-flex justify-content-sm-end justify-content-center mt-sm-0 mt-3'Bf>>>" + "<'table-responsive'tr>" + "<'dt--bottom-section d-sm-flex justify-content-sm-between text-center'<'dt--pages-count mb-sm-0 mb-3'i><'dt--pagination'p>>", buttons: [ - { - text: 'Archive', - className: "btn btn-dark buttons-archive", - action: archiveAction, - init: function(api, node, config){ - $(node).hide(); - } - }, - { - text: 'View Archive List', - className: "btn btn-dark ", - action: function () { - // Add your action here, e.g., redirect to archive page - window.location.href = viewArchiveUrl; - } - } ], oLanguage: { oPaginate: { "sPrevious": '', "sNext": '' }, @@ -145,171 +119,7 @@ function initializeDataTable(dataTableInstance, mainUrl) { }, stripeClasses: [], lengthMenu: [5, 10, 20, 50], - pageLength: 10, - initComplete: initCompleteCallback - }); -} - -// Function to reload the DataTable -function reloadDataTable() { - dataTableInstance.ajax.reload(); -} - -// Render checkbox -function renderCheckbox(data, type, row) { - var checkboxHTML = '
'; - checkboxHTML += ''; - checkboxHTML += '
'; - return checkboxHTML; -} - -// Render switch -function renderSwitch(data, type, row) { - console.log("data is ", data, "type is", typeof(data)) - var checkedAttribute = data.toLowerCase() === 'true' ? 'checked' : ''; - console.log("check attribute", + checkedAttribute) - var switchHTML = '
'; - switchHTML += ''; - switchHTML += '
'; - return switchHTML; -} - -// Render actions -function renderActions(data, type, row) { - return ` - `; -} - -// Callback function for DataTable initialization complete event -function initCompleteCallback() { - var api = this.api(); - - // Add event listener for checkbox change - $('body').on('change', 'input[type="checkbox"]', function () { - var checkedCount = $('#table tbody input.archive-checkbox:checked').length; - var archiveButton = $('.buttons-archive'); - archiveButton.toggle(checkedCount > 0); - }); - -} - -// Function to handle archive action -function archiveAction() { - // Get all the checked checkboxes - var checkedCheckboxes = $('.archive-checkbox:checked'); - // If no checkboxes are checked, show an error message - if (checkedCheckboxes.length === 0) { - Swal.fire({ - title: 'No users selected', - text: 'Please select at least one user to archive.', - icon: 'error', - showConfirmButton: true - }); - return; - } - // Get the IDs of the checked checkboxes - var userIds = checkedCheckboxes.map(function() { - return $(this).val(); - }).get(); - // Perform archive action with the collected user IDs - Swal.fire({ - title: 'Are you sure?', - text: 'Once archived, you will recover it from archive list!', - icon: 'warning', - showCancelButton: true, - confirmButtonColor: '#d33', - cancelButtonColor: '#3085d6', - confirmButtonText: 'Yes, archive it!' - }).then((result) => { - if (result.isConfirmed) { - // Perform archive action - $.ajax({ - url: actionUrl, // Replace with your archive endpoint - type: 'POST', - data: { - action: "archive", - ids: userIds, - csrfmiddlewaretoken: '{{csrf_token}}' - }, - success: function(response) { - // Show success message - Swal.fire({ - title: 'Done!', - text: response.msg, - icon: 'success', - showConfirmButton: true - }); - // Optionally, you can reload the DataTable after successful archive - reloadDataTable(); - }, - error: function(response) { - // Show error message - Swal.fire({ - title: 'Error!', - text: response.message, - icon: 'error', - showConfirmButton: true - }); - } - }); - } - }); -} - -// Function to add event listener for switch -function activeSwitchEventListener() { - // Add event listener for switch change event - $('body').on('change', '.switch-input', function() { - var rowId = $(this).closest('tr').find('.switch-input').data('id'); - var isActive = $(this).prop('checked'); - console.log(rowId, isActive) - // Perform active toggle action for the current user - $.ajax({ - url: actionUrl, // Replace with your active toggle endpoint - type: 'POST', - data: { - action: "active", - ids: [rowId], - active: isActive, - csrfmiddlewaretoken: '{{csrf_token}}' - }, - success: function(response) { - // Show success message - Swal.fire({ - title: 'Done!', - text: response.msg, - icon: 'success', - showConfirmButton: true - }); - // Reload the DataTable after successful toggle - reloadDataTable(); - }, - error: function(response) { - // Show error message - Swal.fire({ - title: 'Error!', - text: response.message, - icon: 'error', - showConfirmButton: true - }); - } - }); - }); -} - - -// Function to handle click event for edit button -function editClickEvent() { - $('body').on('click', '.edit', function(){ - var id =$(this).data('id'); - console.log('Editing user with Id:', id); + pageLength: 10 }); } diff --git a/templates/module_activity/symptoms_list.html b/templates/module_activity/symptoms_list.html index 6d558a9..0dec90c 100644 --- a/templates/module_activity/symptoms_list.html +++ b/templates/module_activity/symptoms_list.html @@ -21,9 +21,9 @@ User Symptoms - {{principal_id.id}} - {{principal_id.first_name}}
-
+ {% comment %}
Add -
+
{% endcomment %}
@@ -38,19 +38,13 @@ - - # # User Symptoms For how long have you been experiencing this Symptoms - Active - Action + @@ -90,8 +84,7 @@ var viewArchiveUrl = "{% url 'module_activity:symptoms_archive' principal_id=pri $(document).ready(function() { dataTableInstance = initializeDataTable(dataTableInstance, mainUrl); - editClickEvent(); - activeSwitchEventListener(); + }); // Function to initialize DataTable @@ -104,37 +97,18 @@ function initializeDataTable(dataTableInstance, mainUrl) { type: "GET", }, columns: [ - { data: null, className: "text-center", render: renderCheckbox }, { data: "id", className: "text-center" }, { data: "name", className: "text-center" }, - { data: "duration", className: "text-center" }, - { data: "active", className: "text-center", render: renderSwitch }, - { data: null, className: "text-center", render: renderActions } + { data: "duration", className: "text-center" } ], debug: true, columnDefs: [ - { targets: [1, 2, 3], searchable: true, orderable: true }, - { targets: [0, -1], searchable: false, orderable: false } + { targets: [0, 1, 2], searchable: true, orderable: true } ], dom: "<'dt--top-section'<'row'<'col-12 col-sm-6 d-flex justify-content-sm-start justify-content-center'l><'col-12 col-sm-6 d-flex justify-content-sm-end justify-content-center mt-sm-0 mt-3'Bf>>>" + "<'table-responsive'tr>" + "<'dt--bottom-section d-sm-flex justify-content-sm-between text-center'<'dt--pages-count mb-sm-0 mb-3'i><'dt--pagination'p>>", buttons: [ - { - text: 'Archive', - className: "btn btn-dark buttons-archive", - action: archiveAction, - init: function(api, node, config){ - $(node).hide(); - } - }, - { - text: 'View Archive List', - className: "btn btn-dark ", - action: function () { - window.location.href = viewArchiveUrl; - } - } ], oLanguage: { oPaginate: { "sPrevious": '', "sNext": '' }, @@ -145,174 +119,9 @@ function initializeDataTable(dataTableInstance, mainUrl) { }, stripeClasses: [], lengthMenu: [5, 10, 20, 50], - pageLength: 10, - initComplete: initCompleteCallback + pageLength: 10 }); } -// Function to reload the DataTable -function reloadDataTable() { - dataTableInstance.ajax.reload(); -} - -// Render checkbox -function renderCheckbox(data, type, row) { - var checkboxHTML = '
'; - checkboxHTML += ''; - checkboxHTML += '
'; - return checkboxHTML; -} - -// Render switch -function renderSwitch(data, type, row) { - console.log("data is ", data, "type is", typeof(data)) - var checkedAttribute = data.toLowerCase() === 'true' ? 'checked' : ''; - console.log("check attribute", + checkedAttribute) - var switchHTML = '
'; - switchHTML += ''; - switchHTML += '
'; - return switchHTML; -} - -// Render actions -function renderActions(data, type, row) { - return ` - `; -} - -// Callback function for DataTable initialization complete event -function initCompleteCallback() { - var api = this.api(); - - // Add event listener for checkbox change - $('body').on('change', 'input[type="checkbox"]', function () { - var checkedCount = $('#table tbody input.archive-checkbox:checked').length; - var archiveButton = $('.buttons-archive'); - archiveButton.toggle(checkedCount > 0); - }); - -} - -// Function to handle archive action -function archiveAction() { - // Get all the checked checkboxes - var checkedCheckboxes = $('.archive-checkbox:checked'); - // If no checkboxes are checked, show an error message - if (checkedCheckboxes.length === 0) { - Swal.fire({ - title: 'No users selected', - text: 'Please select at least one user to archive.', - icon: 'error', - showConfirmButton: true - }); - return; - } - // Get the IDs of the checked checkboxes - var userIds = checkedCheckboxes.map(function() { - return $(this).val(); - }).get(); - // Perform archive action with the collected user IDs - Swal.fire({ - title: 'Are you sure?', - text: 'Once archived, you will recover it from archive list!', - icon: 'warning', - showCancelButton: true, - confirmButtonColor: '#d33', - cancelButtonColor: '#3085d6', - confirmButtonText: 'Yes, archive it!' - }).then((result) => { - if (result.isConfirmed) { - // Perform archive action - $.ajax({ - url: actionUrl, // Replace with your archive endpoint - type: 'POST', - data: { - action: "archive", - ids: userIds, - csrfmiddlewaretoken: '{{csrf_token}}' - }, - success: function(response) { - // Show success message - Swal.fire({ - title: 'Done!', - text: response.msg, - icon: 'success', - showConfirmButton: true - }); - // Optionally, you can reload the DataTable after successful archive - reloadDataTable(); - }, - error: function(response) { - // Show error message - Swal.fire({ - title: 'Error!', - text: response.message, - icon: 'error', - showConfirmButton: true - }); - } - }); - } - }); -} - -// Function to add event listener for switch -function activeSwitchEventListener() { - // Add event listener for switch change event - $('body').on('change', '.switch-input', function() { - var rowId = $(this).closest('tr').find('.switch-input').data('id'); - var isActive = $(this).prop('checked'); - console.log(rowId, isActive) - // Perform active toggle action for the current user - $.ajax({ - url: actionUrl, // Replace with your active toggle endpoint - type: 'POST', - data: { - action: "active", - ids: [rowId], - active: isActive, - csrfmiddlewaretoken: '{{csrf_token}}' - }, - success: function(response) { - // Show success message - Swal.fire({ - title: 'Done!', - text: response.msg, - icon: 'success', - showConfirmButton: true - }); - // Reload the DataTable after successful toggle - reloadDataTable(); - }, - error: function(response) { - // Show error message - Swal.fire({ - title: 'Error!', - text: response.message, - icon: 'error', - showConfirmButton: true - }); - } - }); - }); -} - - -// Function to handle click event for edit button -function editClickEvent() { - $('body').on('click', '.edit', function(){ - var id =$(this).data('id'); - console.log('Editing user with Id:', id); - }); -} - - {% endblock %} \ No newline at end of file diff --git a/templates/module_auth/user_view.html b/templates/module_auth/user_view.html index f97783a..99450fe 100644 --- a/templates/module_auth/user_view.html +++ b/templates/module_auth/user_view.html @@ -28,16 +28,9 @@

arrow_back - User Details

+ User Details -- {{obj.id}} -- {{obj.first_name}}
-
- {% comment %} {% endcomment %} - {% comment %} Add Category {% endcomment %} -
@@ -49,9 +42,9 @@ - + {% endcomment %} @@ -100,79 +93,215 @@

How frequently do you eat in a day?

- {{obj.health_data_principal.eat_frequency}} + --> {{obj.health_data_principal.eat_frequency}}

How do you rate your overall gastrointestinal functions?

- {{obj.health_data_principal.gastrointestinal_health}} + --> {{obj.health_data_principal.gastrointestinal_health}}

How much sleep do you take daily?

- {{obj.health_data_principal.sleep_duration}} + --> {{obj.health_data_principal.sleep_duration}}

How frequently do you engage in physical activities?

- {{obj.health_data_principal.exercise_frequency}} + --> {{obj.health_data_principal.exercise_frequency}}

-
-
-
-

User Intolerances?

- {{ obj.intolerance_data.0.name }} +
+ +
+
+
+

User Intolerances?

+ {{ obj.intolerance_data.0.name }} +

For how long have you been experiencing this intolerance?

+ {{ obj.intolerance_data.0.duration }} + View more +
-
-

For how long have you been experiencing this intolerance?

- {{ obj.intolerance_data.0.duration }} -
- View more
-
-
-

User Symptoms?

- {{ obj.symptoms_data.0.name }} +
+
+
+

User Symptoms?

+ {{ obj.symptoms_data.0.name }} +

For how long have you been experiencing these symptoms?

+ {{ obj.symptoms_data.0.duration }} + View more +
-
-

For how long have you been experiencing these symptoms?

- {{ obj.symptoms_data.0.duration }} -
- View more
+
+ +
+
+
+

User Past Treatment Name?

+ {{ obj.pasttreatment_data.0.name }} +

When did you undergo this treatment?

+ {{ obj.pasttreatment_data.0.duration }} + View more +
+
+
+
+
+
+

User Chronic conditions/diseases Name?

+ {{ obj.chronic_data.0 }} +

For how long have you been experiencing this diseases?

+ {{ obj.chronic_data.0 }} + View more +
+
+
+
+
-
-
-
-

User Past Treatment Name?

- {{ obj.pasttreatment_data.0.name }} +
+ +
+
+
+
+
Recent Meal Record
+ View More +
+ + + + + + + + + {% if not recent_meal %} + + + + {% else %} + {% for record in recent_meal %} + + + + + + + {% endfor %} + {% endif %} + +
Sr noDateTimeMeal Type

No meal has been added.

{{ forloop.counter }}{{ record.date }}{{ record.time }}{{ record.meal_type }}
+
-
-

When did you undergo this treatment?

- {{ obj.pasttreatment_data.0.duration }} -
- View more
-
-
-

User Chronic conditions/diseases Name?

- {{ obj.chronic_data.0 }} +
+
+
+
+
Recent Medication Record
+ View More +
+ + + + + + + + {% if not recent_medication %} + + + + {% else %} + {% for record in recent_medication %} + + + + + + {% endfor %} + {% endif %} + +
Sr noDateTime

No medication has been added.

{{ forloop.counter }}{{ record.date }}{{ record.time }}
+
-
-

For how long have you been experiencing this diseases?

- {{ obj.chronic_data.0 }} -
- View more
-
- - Download user profile - - + +
+ +
+
+
+
+
Recent Bowel Record
+ View More +
+ + + + + + + + + {% if not recent_bowel %} + + + + {% else %} + {% for record in recent_bowel %} + + + + + + + {% endfor %} + {% endif %} + +
Sr noDateTimeStool Type

No bowel has been added.

{{ forloop.counter }}{{ record.date }}{{ record.time }}{{ record.stool_type }}
+
+
+
+
+
+
+
+
Recent Symptoms Record
+ View More +
+ + + + + + + + {% if not recent_meal_symptom %} + + + + {% else %} + {% for record in recent_meal_symptom %} + + + + + + {% endfor %} + {% endif %} + +
Sr noDateTime

No symptoms has been added.

{{ forloop.counter }}{{ record.date }}{{ record.time }}
+
+
+
-
+ {% comment %}
@@ -213,7 +342,7 @@
-
+
{% endcomment %}