You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

health_calc.py 12KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336
  1. #!/usr/bin/env python3
  2. def head_age(gender, age):
  3. if gender == 'boys':
  4. band2 = (2.87342*(10**-7))*(age**5) \
  5. - (0.0000509098*(age**4)) \
  6. + (0.00343161*(age**3)) \
  7. - (0.111613*(age**2)) \
  8. + (1.89389*(age)) \
  9. + 37
  10. band_m2 = (2.67918*(10**-7))*(age**5) \
  11. - (0.0000488281*(age**4)) \
  12. + (0.00339988*(age**3)) \
  13. - (0.113802*(age**2)) \
  14. + (1.92986*(age)) \
  15. + 31.8
  16. # girls
  17. else:
  18. band2 = (2.51173*(10**-7))*(age**5) \
  19. - (0.0000452112*(age**4)) \
  20. + (0.00311294*(age**3)) \
  21. - (0.103906*(age**2)) \
  22. + (1.81319*(age**1)) \
  23. + 36.3
  24. band_m2 = (2.37778*(10**-7))*(age**5) \
  25. - (0.0000430009*(age**4)) \
  26. + (0.00297309*(age**3)) \
  27. - (0.0993634*(age**2)) \
  28. + (1.72528*(age**1)) \
  29. + 31.5
  30. return (band2, band_m2)
  31. def is_head_normal(gender, age, head):
  32. h = head_age(gender, age)
  33. if float(head) < h[0] and float(head) > h[1]:
  34. ans = 'Normal'
  35. elif float(head) >= h[0]:
  36. ans = 'Makrosefali'
  37. else:
  38. ans = 'Mikrosefali'
  39. return ans
  40. def weight_age(band, gender, age):
  41. if gender == 'boys':
  42. if band == -3:
  43. if age <= 24:
  44. w = (6.78168)*(10**-8)*(age**6) \
  45. - (3.25521)*(10**-6)*(age**5) \
  46. - (0.0000217014)*(age**4) \
  47. + (0.00403646)*(age**3) \
  48. - (0.0934201)*(age**2) \
  49. + (1.03625)*(age) \
  50. + 2.
  51. elif age <= 48:
  52. w = (-1.35525)*(10**-20)*(age**5) \
  53. - (0.0000488281)*(age**4) \
  54. + (0.00742187)*(age**3) \
  55. - (0.417969)*(age**2) \
  56. + (10.4312)*(age) \
  57. - 88.1
  58. else:
  59. w = (0.075)*(age) \
  60. + 7.8
  61. elif band == -2:
  62. if age <= 12:
  63. w = (0.000112847)*(age**5) \
  64. - (0.00373264)*(age**4) \
  65. + (0.0480903)*(age**3) \
  66. - (0.326736)*(age**2) \
  67. + (1.5725)*(age) \
  68. + 2.2
  69. else:
  70. w = (1.3262)*(10**-6)*(age**4) \
  71. - (0.000199653)*(age**3) \
  72. + (0.00999421)*(age**2) \
  73. - (0.0616821)*(age) \
  74. + 7.65926
  75. # band == 2
  76. else:
  77. if age <= 12:
  78. w = (0.0000564236)*(age**6) \
  79. - (0.00210937)*(age**5) \
  80. + (0.0296007)*(age**4) \
  81. - (0.186979)*(age**3) \
  82. + (0.430694)*(age**2) \
  83. + (0.931667)*(age) \
  84. + 4.5
  85. else:
  86. w = (-2.00939)*(10**-7)*(age**4) \
  87. + (0.0000434028)*(age**3) \
  88. - (0.00344329)*(age**2) \
  89. + (0.360417)*(age) \
  90. + 8.1
  91. # girls
  92. else:
  93. if band == 2:
  94. if age <= 12:
  95. w = (-8.3348)*(10**-19)*(age**6) \
  96. + (0.000078125)*(age**5) \
  97. - (0.00286458)*(age**4) \
  98. + (0.0411458)*(age**3) \
  99. - (0.313542)*(age**2) \
  100. + (1.78417)*(age) \
  101. + 4.1
  102. else:
  103. w = (-1.00469)*(10**-6)*(age**4) \
  104. + (0.000159144)*(age**3) \
  105. - (0.00853588)*(age**2) \
  106. + (0.45625)*(age) \
  107. + 7.
  108. elif band == -2:
  109. if age <= 12:
  110. w = (-0.0000195313)*(age**6) \
  111. + (0.000716146)*(age**5) \
  112. - (0.0102865)*(age**4) \
  113. + (0.0763021)*(age**3) \
  114. - (0.346042)*(age**2) \
  115. + (1.35833)*(age) \
  116. + 2.2
  117. else:
  118. w = (1.40657)*(10**-6)*(age**4) \
  119. - (0.000207369)*(age**3) \
  120. + (0.0098669)*(age**2) \
  121. - (0.0243056)*(age) \
  122. + 6.3
  123. # band == -3
  124. else:
  125. if age <= 12:
  126. w = (-0.000015191)*(age**6) \
  127. + (0.000455729)*(age**5) \
  128. - (0.00490451)*(age**4) \
  129. + (0.0263021)*(age**3) \
  130. - (0.130139)*(age**2) \
  131. + (0.9375)*(age) \
  132. + 2.
  133. else:
  134. w = (6.02816)*(10**-7)*(age**4) \
  135. - (0.0000916281)*(age**3) \
  136. + (0.00407986)*(age**2) \
  137. + (0.0715278)*(age) \
  138. + 5.
  139. return w
  140. def is_weight_normal(gender, age, weight):
  141. # kelebihan
  142. if weight > weight_age(2, gender, age):
  143. ans = 'Gizi Berlebih'
  144. # buruk
  145. elif weight < weight_age(-3, gender, age):
  146. ans = 'Gizi Buruk'
  147. # kurang
  148. elif weight < weight_age(-2, gender, age):
  149. ans = 'Gizi Kurang'
  150. # normal
  151. else:
  152. ans = 'Gizi Normal'
  153. return ans
  154. def height_age(band, gender, age):
  155. if gender == 'boys':
  156. if band == 2:
  157. if age <= 12:
  158. w = (-0.000141059)*(age**6) \
  159. + (0.00527344)*(age**5) \
  160. - (0.0766059)*(age**4) \
  161. + (0.55599)*(age**3) \
  162. - (2.25382)*(age**2) \
  163. + (7.31667)*(age) \
  164. + 54.
  165. elif age <= 60:
  166. w = (-5.42535)*(10**-6)*(age**4) \
  167. + (0.000921103)*(age**3) \
  168. - (0.0606771)*(age**2) \
  169. + (2.52153)*(age) \
  170. + 57.5
  171. elif age <= 156:
  172. w = (-1.21268*10**-10*age**7) \
  173. + (8.84224*10**-8*age**6) \
  174. - (0.0000272657*age**5) \
  175. + (0.00460575*age**4) \
  176. - (0.459965*age**3) \
  177. + (27.1377*age**2) \
  178. - (874.633*age) \
  179. + (11976.1)
  180. else:
  181. w = (-1.49603*10**-21*age**5) \
  182. + (1.3325*10**-18*age**4) \
  183. + (0.0000578704*age**3) \
  184. - (0.0381944*age**2) \
  185. + (8.46667*age) \
  186. - (442.)
  187. elif band == -2:
  188. if age <= 12:
  189. w = (age**6)/5120 \
  190. - (59)*(age**5)/7680 \
  191. + (29)*(age**4)/256 \
  192. - (289)*(age**3)/384 \
  193. + (307)*(age**2)/160 \
  194. + (143)*(age)/60 \
  195. + 46
  196. elif age <= 60:
  197. w = (-2.00939)*(10**-6)*(age**4) \
  198. + (0.000385802)*(age**3) \
  199. - (0.0292245)*(age**2) \
  200. + (1.54861)*(age) \
  201. + 56.
  202. elif age <= 156:
  203. w = (-2.29799*10**-10*age**7) \
  204. + (1.66984*10**-7*age**6) \
  205. - (0.0000513287*age**5) \
  206. + (0.00864673*age**4) \
  207. - (0.861622*age**3) \
  208. + (50.7566*age**2) \
  209. - (1635.17*age) \
  210. + (22302.5)
  211. else:
  212. w = (1.33959*10**-7*age**5) \
  213. - (0.000122975*age**4) \
  214. + (0.0449653*age**3) \
  215. - (8.19132*age**2) \
  216. + (744.347*age) \
  217. - (26884.)
  218. # band == -3
  219. elif band == 3:
  220. if age <= 12:
  221. elif age <= 60:
  222. elif age <= 156:
  223. w = (-1.32896*10**-10*age**7) \
  224. + (9.32598*10**-8*age**6) \
  225. - (0.0000276375*age**5) \
  226. + (0.00448211*age**4) \
  227. - (0.429503*age**3) \
  228. + (24.3144*age**2) \
  229. - (752.203*age) \
  230. + (9914.)
  231. else:
  232. w = (-2.84663*10**-7*age**5) \
  233. + (0.000264235*age**4) \
  234. - (0.0977165*age**3) \
  235. + (17.9897*age**2) \
  236. - (1647.88*age) \
  237. + (60224.5)
  238. else:
  239. if age <= 12:
  240. w = (0.0000868056)*(age**6) \
  241. - (0.00325521)*(age**5) \
  242. + (0.0451389)*(age**4) \
  243. - (0.268229)*(age**3) \
  244. + (0.380556)*(age**2) \
  245. + (4)*(age) \
  246. + 44.
  247. elif age <= 60:
  248. w = (-3.01408)*(10**-6)*(age**4) \
  249. + (0.000506366)*(age**3) \
  250. - (0.0342882)*(age**2) \
  251. + (1.59375)*(age) \
  252. + 53.5
  253. elif age <= 156:
  254. w = (-7.86301*10**-11*age**7) \
  255. + (5.61884*10**-8*age**6) \
  256. - (0.0000169749*age**5) \
  257. + (0.00280946*age**4) \
  258. - (0.275046*age**3) \
  259. + (15.9234*age**2) \
  260. - (504.133*age) \
  261. + (6821.2)
  262. else:
  263. w = (2.84663*10**-7*age**5) \
  264. - (0.000252178*age**4) \
  265. + (0.0888431*age**3) \
  266. - (15.5626*age**2) \
  267. + (1356.22*age) \
  268. - (46931.5)
  269. # girls
  270. else:
  271. if band == 2:
  272. if age <= 12:
  273. w = (-0.0000108507)*(age**6) \
  274. + (0.000585938)*(age**5) \
  275. - (0.0128038)*(age**4) \
  276. + (0.144531)*(age**3) \
  277. - (0.948611)*(age**2) \
  278. + (5.4125)*(age) \
  279. + 53
  280. else:
  281. w = (2.00939)*(10**-6)*(age**4) \
  282. - (0.000192901)*(age**3) \
  283. - (0.00202546)*(age**2) \
  284. + (1.29861)*(age) \
  285. + 64.
  286. elif band == -2:
  287. if age <= 12:
  288. w = (0.000173611)*(age**6) \
  289. - (0.00638021)*(age**5) \
  290. + (0.0876736)*(age**4) \
  291. - (0.539062)*(age**3) \
  292. + (1.20903)*(age**2) \
  293. + (2.63333)*(age) \
  294. + 46
  295. else:
  296. w = (4.01878)*(10**-6)*(age**4) \
  297. - (0.000530478)*(age**3) \
  298. + (0.0185185)*(age**2) \
  299. + (0.597222)*(age) \
  300. + 60.
  301. # band == -3
  302. else:
  303. if age <= 12:
  304. w = (age**6)/4608 \
  305. - (age**5)/128 \
  306. + (121)*(age**4)/1152 \
  307. - (61)*(age**3)/96 \
  308. + (209)*(age**2)/144 \
  309. + (29)*(age)/12 \
  310. + 44
  311. else:
  312. w = (-4.01878)*(10**-6)*(age**4) \
  313. + (0.000626929)*(age**3) \
  314. - (0.0393519)*(age**2) \
  315. + (1.72222)*(age) \
  316. + 50.
  317. return w
  318. def is_height_normal(gender, age, height):
  319. if height < height_age(-3, gender, age):
  320. ans = 'Sangat pendek'
  321. elif height < height_age(-2, gender, age):
  322. ans = 'Pendek'
  323. elif height > height_age(2, gender, age):
  324. ans = 'Tinggi'
  325. else:
  326. ans = 'Normal'
  327. return ans
  328. # def is_weight_length_normal(gender, length, height):