2 **********************************************************************
4 * Description: Nutritional Assessment App
5 * Author: Agnibho Mondal
6 * Website: http://code.agnibho.com
7 **********************************************************************
8 Copyright (c) 2016 Agnibho Mondal
10 **********************************************************************
11 This file is part of DietSurvey.
13 DietSurvey is free software: you can redistribute it and/or modify
14 it under the terms of the GNU General Public License as published by
15 the Free Software Foundation, either version 3 of the License, or
16 (at your option) any later version.
18 DietSurvey is distributed in the hope that it will be useful,
19 but WITHOUT ANY WARRANTY; without even the implied warranty of
20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 GNU General Public License for more details.
23 You should have received a copy of the GNU General Public License
24 along with DietSurvey. If not, see <http://www.gnu.org/licenses/>.
25 **********************************************************************
28 <div v-if="calcVal" class="panel panel-default">
29 <div class="panel-body">
31 <div class="panel panel-info">
32 <div class="panel-heading">
33 <div class="panel-title"><h3>Nutritional Requirements</h3></div>
35 <div class="panel-body">
36 <div class="table-responsive">
39 <tr><th>Member</th><th>Energy</th><th>Protein</th><th>Iron</th><th>Vitamin A</th><th>Thiamine</th><th>Riboflavin</th><th>Vitamin C</th></tr>
42 <tr v-for="i in calcVal.req.list">
43 <td>{{i.name}}</td><td>{{i.energy|dec2}}</td><td>{{i.protein|dec2}}</td><td>{{i.iron|dec2}}</td><td>{{i.vitA|dec2}}</td><td>{{i.thiamine|dec2}}</td><td>{{i.riboflavin|dec2}}</td><td>{{i.vitC|dec2}}</td>
47 <tr><th>Total</th><th>{{calcVal.req.total.energy|dec2}}</th><th>{{calcVal.req.total.protein|dec2}}</th><th>{{calcVal.req.total.iron|dec2}}</th><th>{{calcVal.req.total.vitA|dec2}}</th><th>{{calcVal.req.total.thiamine|dec2}}</th><th>{{calcVal.req.total.riboflavin|dec2}}</th><th>{{calcVal.req.total.vitC|dec2}}</th></tr>
54 <div class="panel panel-info">
55 <div class="panel-heading">
56 <div class="panel-title"><h3>Nutritional Value of Consumed Foods</h3></div>
58 <div class="panel-body">
59 <div class="table-responsive">
62 <tr><th>Food</th><th>Energy</th><th>Protein</th><th>Iron</th><th>Vitamin A</th><th>Thiamine</th><th>Riboflavin</th><th>Vitamin C</th></tr>
65 <tr v-for="i in calcVal.intk.list">
66 <td>{{i.name}}</td><td>{{i.energy|dec2}}</td><td>{{i.protein|dec2}}</td><td>{{i.iron|dec2}}</td><td>{{i.vitA|dec2}}</td><td>{{i.thiamine|dec2}}</td><td>{{i.riboflavin|dec2}}</td><td>{{i.vitC|dec2}}</td>
70 <tr><th>Total</th><th>{{calcVal.intk.total.energy|dec2}}</th><th>{{calcVal.intk.total.protein|dec2}}</th><th>{{calcVal.intk.total.iron|dec2}}</th><th>{{calcVal.intk.total.vitA|dec2}}</th><th>{{calcVal.intk.total.thiamine|dec2}}</th><th>{{calcVal.intk.total.riboflavin|dec2}}</th><th>{{calcVal.intk.total.vitC|dec2}}</th></tr>
77 <div class="panel panel-info">
78 <div class="panel-heading">
79 <div class="panel-title"><h3>Requirement vs Intake Comparison</h3></div>
81 <div class="panel-body">
82 <div class="table-responsive">
84 <thead><tr><th>Nutrient</th><th>Total Requirement</th><th>Total Intake</th><th>Excess /Deficiency</th></tr></thead>
86 <tr><td>Energy</td><td>{{calcVal.req.total.energy|dec2}}</td><td>{{calcVal.intk.total.energy|dec2}}</td><td>{{calcVal.comp.energy[0]|cmp(2)}}</td></tr>
87 <tr><td>Protein</td><td>{{calcVal.req.total.protein|dec2}}</td><td>{{calcVal.intk.total.protein|dec2}}</td><td>{{calcVal.comp.protein[0]|cmp(2)}}</td></tr>
88 <tr><td>Iron</td><td>{{calcVal.req.total.iron|dec2}}</td><td>{{calcVal.intk.total.iron|dec2}}</td><td>{{calcVal.comp.iron[0]|cmp(2)}}</td></tr>
89 <tr><td>Vitamin A</td><td>{{calcVal.req.total.vitA|dec2}}</td><td>{{calcVal.intk.total.vitA|dec2}}</td><td>{{calcVal.comp.vitA[0]|cmp(2)}}</td></tr>
90 <tr><td>Thiamine</td><td>{{calcVal.req.total.thiamine|dec2}}</td><td>{{calcVal.intk.total.thiamine|dec2}}</td><td>{{calcVal.comp.thiamine[0]|cmp(2)}}</td></tr>
91 <tr><td>Riboflavin</td><td>{{calcVal.req.total.riboflavin|dec2}}</td><td>{{calcVal.intk.total.riboflavin|dec2}}</td><td>{{calcVal.comp.riboflavin[0]|cmp(2)}}</td></tr>
92 <tr><td>Vitamin C</td><td>{{calcVal.req.total.vitC|dec2}}</td><td>{{calcVal.intk.total.vitC|dec2}}</td><td>{{calcVal.comp.vitC[0]|cmp(2)}}</td></tr>
99 <div class="panel panel-info">
100 <div class="panel-heading">
101 <div class="panel-title"><h3>Summary</h3></div>
103 <div class="panel-body">
104 <ul class="list-group col-md-offset-4 col-md-4">
105 <li class="list-group-item" v-bind:class="colorCls(calcVal.comp.energy[0])">Energy {{calcVal.comp.energy[0]|cmp(1)}} is {{calcVal.comp.energy[1]|cmp}}%</li>
106 <li class="list-group-item" v-bind:class="colorCls(calcVal.comp.protein[0])">Protein {{calcVal.comp.protein[0]|cmp(1)}} is {{calcVal.comp.protein[1]|cmp}}%</li>
107 <li class="list-group-item" v-bind:class="colorCls(calcVal.comp.iron[0])">Iron {{calcVal.comp.iron[0]|cmp(1)}} is {{calcVal.comp.iron[1]|cmp}}%</li>
108 <li class="list-group-item" v-bind:class="colorCls(calcVal.comp.vitA[0])">Vitamin A {{calcVal.comp.vitA[0]|cmp(1)}} is {{calcVal.comp.vitA[1]|cmp}}%</li>
109 <li class="list-group-item" v-bind:class="colorCls(calcVal.comp.thiamine[0])">Thiamine {{calcVal.comp.thiamine[0]|cmp(1)}} is {{calcVal.comp.thiamine[1]|cmp}}%</li>
110 <li class="list-group-item" v-bind:class="colorCls(calcVal.comp.riboflavin[0])">Riboflavin {{calcVal.comp.riboflavin[0]|cmp(1)}} is {{calcVal.comp.riboflavin[1]|cmp}}%</li>
111 <li class="list-group-item" v-bind:class="colorCls(calcVal.comp.vitC[0])">Vitamin C {{calcVal.comp.vitC[0]|cmp(1)}} is {{calcVal.comp.vitC[1]|cmp}}%</li>
123 props:["dataObj", "dataRef"],
126 return Math.round(v*100)/100;
130 if(v<0) return "deficit";
131 else return "excess";
133 if(v<0) return "Deficit by "+Math.abs(Math.round(v*100)/100);
134 else return "Excess by "+Math.abs(Math.round(v*100)/100);
137 return Math.abs(Math.round(v*100)/100);
142 colorCls: function(v){
143 if (v<0) return {"list-group-item-danger": true};
144 else return {"list-group-item-success": true};
149 var rda=this.dataRef.rda;
150 var val=this.dataRef.food;
152 // Requirement Calculation
156 for(var i=0; i<this.dataObj.family.length; i++){
157 var mem=this.dataObj.family[i];
159 // Retrieve individual rda
163 if(mem.state=="preg"){
164 buff=rda.filter(function(d){
165 return d.subject=="pregnant";
168 else if(mem.state=="lact-6"){
169 buff=rda.filter(function(d){
170 return d.subject=="lactating_below6";
173 else if(mem.state=="lact+6"){
174 buff=rda.filter(function(d){
175 return d.subject=="lactating_above6";
178 else if(mem.state=="npnl"){
179 if(mem.work=="sedentary"){
180 buff=rda.filter(function(d){
181 return d.subject=="female_sedentary";
184 else if(mem.work=="moderate"){
185 buff=rda.filter(function(d){
186 return d.subject=="female_moderate";
189 else if(mem.work=="heavy"){
190 buff=rda.filter(function(d){
191 return d.subject=="female_heavy";
199 else if(mem.age<18 && mem.age>0){
200 buff=rda.filter(function(d){
201 return d.subject=="female_"+mem.age+"y";
204 else if(mem.month>=9){
205 buff=rda.filter(function(d){
206 return d.subject=="infant_9m-12m";
209 else if(mem.month>=6){
210 buff=rda.filter(function(d){
211 return d.subject=="infant_6m-9m";
214 else if(mem.month>=0){
218 buff=rda.filter(function(d){
219 return d.subject=="infant_0m-6m";
227 else if(mem.sex=="m"){
229 if(mem.work=="sedentary"){
230 buff=rda.filter(function(d){
231 return d.subject=="male_sedentary";
234 else if(mem.work=="moderate"){
235 buff=rda.filter(function(d){
236 return d.subject=="male_moderate";
239 else if(mem.work=="heavy"){
240 buff=rda.filter(function(d){
241 return d.subject=="male_heavy";
248 else if(mem.age<18 && mem.age>0){
249 buff=rda.filter(function(d){
250 return d.subject=="male_"+mem.age+"y";
253 else if(mem.month>=9){
254 buff=rda.filter(function(d){
255 return d.subject=="infant_9m-12m";
258 else if(mem.month>=6){
259 buff=rda.filter(function(d){
260 return d.subject=="infant_6m-9m";
263 else if(mem.month>=0){
267 buff=rda.filter(function(d){
268 return d.subject=="infant_0m-6m";
279 root.req.list.push(buff);
281 root.req.total.energy=0;
282 root.req.total.protein=0;
283 root.req.total.iron=0;
284 root.req.total.vitA=0;
285 root.req.total.thiamine=0;
286 root.req.total.riboflavin=0;
287 root.req.total.vitC=0;
288 for(var i=0; i<root.req.list.length; i++){
289 root.req.total.energy = +root.req.total.energy + +root.req.list[i].energy;
290 root.req.total.protein = +root.req.total.protein + +root.req.list[i].protein;
291 root.req.total.iron = +root.req.total.iron + +root.req.list[i].iron;
292 root.req.total.vitA = +root.req.total.vitA + +root.req.list[i].vitA;
293 root.req.total.thiamine = +root.req.total.thiamine + +root.req.list[i].thiamine;
294 root.req.total.riboflavin = +root.req.total.riboflavin + +root.req.list[i].riboflavin;
295 root.req.total.vitC = +root.req.total.vitC + +root.req.list[i].vitC;
297 // Intake Calculation
301 for(var i=0; i<this.dataObj.food.length; i++){
302 var food=this.dataObj.food[i];
304 if(food.name!=="" && food.amount!=="" && food.amount>=0){
306 buff.energy=val.filter(function(d){
307 return d.name==buff.name;
308 })[0].energy*food.amount/100;
309 buff.protein=val.filter(function(d){
310 return d.name==buff.name;
311 })[0].protein*food.amount/100;
312 buff.iron=val.filter(function(d){
313 return d.name==buff.name;
314 })[0].iron*food.amount/100;
315 buff.vitA=val.filter(function(d){
316 return d.name==buff.name;
317 })[0].vitA*food.amount/100;
318 buff.thiamine=val.filter(function(d){
319 return d.name==buff.name;
320 })[0].thiamine*food.amount/100;
321 buff.riboflavin=val.filter(function(d){
322 return d.name==buff.name;
323 })[0].riboflavin*food.amount/100;
324 buff.vitC=val.filter(function(d){
325 return d.name==buff.name;
326 })[0].vitC*food.amount/100;
327 root.intk.list.push(buff);
334 root.intk.total.energy=0;
335 root.intk.total.protein=0;
336 root.intk.total.iron=0;
337 root.intk.total.vitA=0;
338 root.intk.total.thiamine=0;
339 root.intk.total.riboflavin=0;
340 root.intk.total.vitC=0;
341 for(var i=0; i<root.intk.list.length; i++){
342 root.intk.total.energy = +root.intk.total.energy + +root.intk.list[i].energy;
343 root.intk.total.protein = +root.intk.total.protein + +root.intk.list[i].protein;
344 root.intk.total.iron = +root.intk.total.iron + +root.intk.list[i].iron;
345 root.intk.total.vitA = +root.intk.total.vitA + +root.intk.list[i].vitA;
346 root.intk.total.thiamine = +root.intk.total.thiamine + +root.intk.list[i].thiamine;
347 root.intk.total.riboflavin = +root.intk.total.riboflavin + +root.intk.list[i].riboflavin;
348 root.intk.total.vitC = +root.intk.total.vitC + +root.intk.list[i].vitC;
352 root.comp.energy = [ +root.intk.total.energy - +root.req.total.energy , (+root.intk.total.energy - +root.req.total.energy)*100/(+root.req.total.energy)];
353 root.comp.protein = [ +root.intk.total.protein - +root.req.total.protein , (+root.intk.total.protein - +root.req.total.protein)*100/(+root.req.total.protein)];
354 root.comp.iron = [ +root.intk.total.iron - +root.req.total.iron , (+root.intk.total.iron - +root.req.total.iron)*100/(+root.req.total.iron)];
355 root.comp.vitA = [ +root.intk.total.vitA - +root.req.total.vitA , (+root.intk.total.vitA - +root.req.total.vitA)*100/(+root.req.total.vitA)];
356 root.comp.thiamine = [ +root.intk.total.thiamine - +root.req.total.thiamine , (+root.intk.total.thiamine - +root.req.total.thiamine)*100/(+root.req.total.thiamine)];
357 root.comp.riboflavin = [ +root.intk.total.riboflavin - +root.req.total.riboflavin , (+root.intk.total.riboflavin - +root.req.total.riboflavin)*100/(+root.req.total.riboflavin)];
358 root.comp.vitC = [ +root.intk.total.vitC - +root.req.total.vitC , (+root.intk.total.vitC - +root.req.total.vitC)*100/(+root.req.total.vitC)];