NAME App::BPOMUtils::NutritionFacts - Utilities related to BPOM nutrition facts VERSION This document describes version 0.028 of App::BPOMUtils::NutritionFacts (from Perl distribution App-BPOMUtils-NutritionFacts), released on 2024-11-05. SYNOPSIS DESCRIPTION This distribution includes CLI utilities related to BPOM nutrition facts. * bpom-show-nutrition-facts * bpom-tampilkan-ing FUNCTIONS bpom_show_nutrition_facts Usage: bpom_show_nutrition_facts(%args) -> [$status_code, $reason, $payload, \%result_meta] Render BPOM-compliant nutrition fact table (ING - informasi nilai gizi) in various formats. Examples: * An example, in linear text format (color/emphasis is shown with markup): bpom_show_nutrition_facts( carbohydrate => 13.113, color => "never", fat => 0.223, output_format => "raw_linear", package_size => 20, protein => 0.99, saturated_fat => 0.01, serving_size => 175, sodium => 0.223, sugar => 7.173 ); Result: [ 200, "OK", "*INFORMASI NILAI GIZI* *JUMLAH PER KEMASAN (20 g)* : *Energi total 10 kkal*, Energi dari lemak 0 kkal, Energi dari lemak jenuh 0 kkal, *Lemak total 0 g (0% AKG)*, *Lemak jenuh 0 g (0% AKG)*, *Protein 0 g (0% AKG)*, *Karbohidrat total 3 g (1% AKG)*, *Gula 1 g*, *Garam (Natrium) 0 mg (0% AKG)*. /Persen AKG berdasarkan kebutuhan energi 2150 kkal. Kebutuhan energi Anda mungkin lebih tinggi atau lebih rendah./\n", { "cmdline.skip_format" => 1, "func.raw" => { carbohydrate_per_pkg => 2.6226, carbohydrate_per_pkg_rounded => 3, energy_from_fat_per_pkg => 3.51225, energy_from_fat_per_pkg_rounded => 0, energy_from_saturated_fat_per_pkg => 0.018, energy_from_saturated_fat_per_pkg_rounded => 0, per_package_ing => 1, protein_per_pkg => 0.198, protein_per_pkg_rounded => 0, saturated_fat_per_pkg => 0.002, saturated_fat_per_pkg_rounded => 0, sodium_per_pkg => 0.0446, sodium_per_pkg_rounded => 0, total_energy_pct_dv => 0.543432558139535, total_energy_pct_dv_rounded => 1, total_energy_per_pkg => 11.6838, total_energy_per_pkg_rounded => 10, total_fat_per_pkg => 0.0446, total_fat_per_pkg_rounded => 0, total_sugar_per_pkg => 1.4346, total_sugar_per_pkg_rounded => 1, }, }, ] * An example, in raw_linear format (just like linear_text but with no border): bpom_show_nutrition_facts( carbohydrate => 13.113, color => "never", fat => 0.223, output_format => "linear_text", package_size => 20, protein => 0.99, saturated_fat => 0.01, serving_size => 175, sodium => 0.223, sugar => 7.173 ); Result: [ 200, "OK", ".---------------------------------------------------------------------------------.\n| *INFORMASI NILAI GIZI* *JUMLAH PER KEMASAN (20 g)* : *Energi total 10 kkal*, |\n| Energi dari lemak 0 kkal, Energi dari lemak jenuh 0 kkal, *Lemak total 0 g (0% |\n| AKG)*, *Lemak jenuh 0 g (0% AKG)*, *Protein 0 g (0% AKG)*, *Karbohidrat total 3 |\n| g (1% AKG)*, *Gula 1 g*, *Garam (Natrium) 0 mg (0% AKG)*. /Persen AKG |\n| berdasarkan kebutuhan energi 2150 kkal. Kebutuhan energi Anda mungkin lebih |\n| tinggi atau lebih rendah./ |\n`---------------------------------------------------------------------------------'\n", { "cmdline.skip_format" => 1, "func.raw" => { carbohydrate_per_pkg => 2.6226, carbohydrate_per_pkg_rounded => 3, energy_from_fat_per_pkg => 3.51225, energy_from_fat_per_pkg_rounded => 0, energy_from_saturated_fat_per_pkg => 0.018, energy_from_saturated_fat_per_pkg_rounded => 0, per_package_ing => 1, protein_per_pkg => 0.198, protein_per_pkg_rounded => 0, saturated_fat_per_pkg => 0.002, saturated_fat_per_pkg_rounded => 0, sodium_per_pkg => 0.0446, sodium_per_pkg_rounded => 0, total_energy_pct_dv => 0.543432558139535, total_energy_pct_dv_rounded => 1, total_energy_per_pkg => 11.6838, total_energy_per_pkg_rounded => 10, total_fat_per_pkg => 0.0446, total_fat_per_pkg_rounded => 0, total_sugar_per_pkg => 1.4346, total_sugar_per_pkg_rounded => 1, }, }, ] * The same example in vertical HTML table format: bpom_show_nutrition_facts( carbohydrate => 13.113, fat => 0.223, output_format => "vertical_html_table", package_size => 20, protein => 0.99, saturated_fat => 0.01, serving_size => 175, sodium => 0.223, sugar => 7.173 ); Result: [ 200, "OK", "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
INFORMASI NILAI GIZI
JUMLAH PER KEMASAN (20 g)
Energi total 10 kkal
% AKG*
Lemak total0 g0 %
Lemak jenuh0 g0 %
Protein0 g0 %
Karbohidrat total3 g1 %
Gula1 g
Garam (Natrium)0 mg0 %
*Persen AKG berdasarkan kebutuhan energi 2150 kkal. Kebutuhan energi Anda mungkin lebih tinggi atau lebih rendah.
\n", { "cmdline.skip_format" => 1, "func.raw" => { carbohydrate_per_pkg => 2.6226, carbohydrate_per_pkg_rounded => 3, energy_from_fat_per_pkg => 3.51225, energy_from_fat_per_pkg_rounded => 0, energy_from_saturated_fat_per_pkg => 0.018, energy_from_saturated_fat_per_pkg_rounded => 0, per_package_ing => 1, protein_per_pkg => 0.198, protein_per_pkg_rounded => 0, saturated_fat_per_pkg => 0.002, saturated_fat_per_pkg_rounded => 0, sodium_per_pkg => 0.0446, sodium_per_pkg_rounded => 0, total_energy_pct_dv => 0.543432558139535, total_energy_pct_dv_rounded => 1, total_energy_per_pkg => 11.6838, total_energy_per_pkg_rounded => 10, total_fat_per_pkg => 0.0446, total_fat_per_pkg_rounded => 0, total_sugar_per_pkg => 1.4346, total_sugar_per_pkg_rounded => 1, }, }, ] * The same example, in vertical text format (color/emphasis is shown with markup): bpom_show_nutrition_facts( carbohydrate => 13.113, color => "never", fat => 0.223, output_format => "vertical_text_table", package_size => 20, protein => 0.99, saturated_fat => 0.01, serving_size => 175, sodium => 0.223, sugar => 7.173 ); Result: [ 200, "OK", ".---------------------------------------------------------------------------------------------------------------------.\n| *INFORMASI NILAI GIZI* |\n| |\n| *JUMLAH PER KEMASAN (20 g)* |\n| *Energi total 10 kkal* |\n+-----------------------|----------------------|-----------------------+----------------------|-----------------------+\n| | *% AKG** |\n| *Lemak total* | *0 g* | 0 % | |\n| *Lemak jenuh* | *0 g* | 0 % | |\n| *Protein* | *0 g* | 0 % | |\n| *Karbohidrat total* | *3 g* | 1 % | |\n| *Gula* | *1 g* | | |\n| *Garam (Natrium)* | *0 mg* | 0 % | |\n+-----------------------|----------------------+-----------------------+----------------------+-----------------------+\n| /*Persen AKG berdasarkan kebutuhan energi 2150 kkal. Kebutuhan energi Anda mungkin lebih tinggi atau lebih rendah./ |\n`---------------------------------------------------------------------------------------------------------------------'\n", { "cmdline.skip_format" => 1, "func.raw" => { carbohydrate_per_pkg => 2.6226, carbohydrate_per_pkg_rounded => 3, energy_from_fat_per_pkg => 3.51225, energy_from_fat_per_pkg_rounded => 0, energy_from_saturated_fat_per_pkg => 0.018, energy_from_saturated_fat_per_pkg_rounded => 0, per_package_ing => 1, protein_per_pkg => 0.198, protein_per_pkg_rounded => 0, saturated_fat_per_pkg => 0.002, saturated_fat_per_pkg_rounded => 0, sodium_per_pkg => 0.0446, sodium_per_pkg_rounded => 0, total_energy_pct_dv => 0.543432558139535, total_energy_pct_dv_rounded => 1, total_energy_per_pkg => 11.6838, total_energy_per_pkg_rounded => 10, total_fat_per_pkg => 0.0446, total_fat_per_pkg_rounded => 0, total_sugar_per_pkg => 1.4346, total_sugar_per_pkg_rounded => 1, }, }, ] * The same example, in calculation text format: bpom_show_nutrition_facts( carbohydrate => 13.113, color => "never", fat => 0.223, output_format => "calculation_text", package_size => 20, protein => 0.99, saturated_fat => 0.01, serving_size => 175, sodium => 0.223, sugar => 7.173 ); Result: [ 200, "OK", ".-------------------------------------------------------------------------------------------------------------------------------------------------------------------------.\n| *PERHITUNGAN INFORMASI NILAI GIZI* |\n| *Energi total* |\n| Energi total per 100 g | = lemak \xD7 9 + protein \xD7 4 + karbohidrat \xD7 4 = 0.223 \xD7 9 + 0.99 \xD7 4 + 13.113 \xD7 4 = 58.419 kkal |\n| Energi total per kemasan 20 g | = 58.419 \xD7 20 / 100 = 11.6838 kkal |\n| (dibulatkan: <5 -> 0, <=50 -> 5 kkal terdekat, >50 -> 10 kkal terdekat) | = *10* kkal |\n| | |\n| *%AKG energi total* |\n| %AKG | = 11.6838 / 2150 \xD7 100 = 0.543432558139535 |\n| (dibulatkan ke % terdekat) | = *1* |\n| *Energi dari lemak* |\n| Energi dari lemak per 100 g | = lemak \xD7 9 = 0.223 \xD7 9 = 2.007 kkal |\n| Energi dari lemak per kemasan 20 g | = 2.007 \xD7 20 / 100 = 3.51225 kkal |\n| (dibulatkan: <5 -> 0, <=50 -> 5 kkal terdekat, >50 -> 10 kkal terdekat) | = *0* kkal |\n| *Energi dari lemak jenuh* |\n| Energi dari lemak per 100 g | = lemak jenuh \xD7 9 = 0.01 \xD7 9 = 0.09 kkal |\n| Energi dari lemak jenuh per kemasan 20 g | = 0.09 \xD7 20 / 100 = 0.018 kkal |\n| (dibulatkan: <5 -> 0, <=50 -> 5 kkal terdekat, >50 -> 10 kkal terdekat) | = *0* kkal |\n| *Lemak total* |\n| Lemak total per 100 g | = 0.223 g |\n| Lemak total per kemasan 20 g | = 0.223 \xD7 20 / 100 = 0.0446 g |\n| (dibulatkan: <0.5 -> 0, <=5 -> 0.5 g terdekat, >=5 -> 1 g terdekat) | = *0* g |\n| | |\n| *%AKG lemak total* |\n| %AKG | = 0.0446 / 67 \xD7 100 = 0.0665671641791045 |\n| (dibulatkan ke % terdekat) | = *0* |\n| *Lemak jenuh* |\n| Lemak jenuh per 100 g | = 0.01 g |\n| Lemak jenuh per kemasan 20 g | = 0.01 \xD7 20 / 100 = 0.002 g |\n| (dibulatkan: <0.5 -> 0, <=5 -> 0.5 g terdekat, >=5 -> 1 g terdekat) | = *0* g |\n| | |\n| *%AKG lemak jenuh* |\n| %AKG | = 0.002 / 67 \xD7 100 = 0.01 |\n| (dibulatkan ke % terdekat) | = *0* |\n| *Protein* |\n| Protein per 100 g | = 0.99 g |\n| Protein total per kemasan 20 g | = 0.99 \xD7 20 / 100 = 0.198 g |\n| (dibulatkan: <0.5 -> 0, >=0.5 -> 1 g terdekat) | = *0* g |\n| | |\n| *%AKG protein* |\n| %AKG | = 0.198 / 60 \xD7 100 = 0.33 |\n| (dibulatkan ke % terdekat) | = *0* |\n| *Karbohidrat total* |\n| Karbohidrat total per 100 g | = 13.113 g |\n| Karbohidrat total per kemasan 20 g | = 13.113 \xD7 20 / 100 = 2.6226 g |\n| (dibulatkan: <0.5 -> 0, >=0.5 -> 1 g terdekat) | = *3* g |\n| | |\n| *%AKG karbohidrat total* |\n| %AKG | = 2.6226 / 325 \xD7 100 = 0.0665671641791045 |\n| (dibulatkan ke % terdekat) | = *1* |\n| *Gula* |\n| Gula per 100 g | = 7.173 g |\n| Gula per kemasan 20 g | = 7.173 \xD7 20 / 100 = 1.4346 g |\n| (dibulatkan: <0.5 -> 0, >=0.5 -> 1 g terdekat) | = *1* g |\n| *Natrium* |\n| Natrium per 100 g | = 0.223 mg |\n| Natrium per kemasan 20 g | = 0.223 \xD7 20 / 100 = 0.0446 mg |\n| (dibulatkan: <5 -> 0, <=140 -> 5 mg terdekat, >140 -> 10 mg terdekat) | = *0* mg |\n| | |\n| *%AKG natrium* |\n| %AKG | = 0.0446 / 1500 \xD7 100 = 0.00297333333333333 |\n| (dibulatkan ke % terdekat) | = *0* |\n`-------------------------------------------------------------------------+-----------------------------------------------------------------------------------------------'\n", { "cmdline.skip_format" => 1, "func.raw" => { carbohydrate_per_pkg => 2.6226, carbohydrate_per_pkg_rounded => 3, energy_from_fat_per_pkg => 3.51225, energy_from_fat_per_pkg_rounded => 0, energy_from_saturated_fat_per_pkg => 0.018, energy_from_saturated_fat_per_pkg_rounded => 0, per_package_ing => 1, protein_per_pkg => 0.198, protein_per_pkg_rounded => 0, saturated_fat_per_pkg => 0.002, saturated_fat_per_pkg_rounded => 0, sodium_per_pkg => 0.0446, sodium_per_pkg_rounded => 0, total_energy_pct_dv => 0.543432558139535, total_energy_pct_dv_rounded => 1, total_energy_per_pkg => 11.6838, total_energy_per_pkg_rounded => 10, total_fat_per_pkg => 0.0446, total_fat_per_pkg_rounded => 0, total_sugar_per_pkg => 1.4346, total_sugar_per_pkg_rounded => 1, }, }, ] This function is not exported by default, but exportable. Arguments ('*' denotes required arguments): * biotin => *ufloat* Biotin, in mcg/100g. * biotin_nufact => *ufloat* Biotin, in mcg/100g (value to be used in nutrition facts table instead the lab test result). * biotin_nufact_note => *str* (No description) * browser => *true* View output HTML in browser instead of returning it. * ca => *ufloat* Calcium, in mg/100g. * ca_nufact => *ufloat* Calcium, in mg/100g (value to be used in nutrition facts table instead the lab test result). * ca_nufact_note => *str* (No description) * carbohydrate* => *ufloat* Total carbohydrate, in g/100g. * carbohydrate_nufact => *ufloat* Total carbohydrate, in g/100g (value to be used in nutrition facts table instead the lab test result). * carbohydrate_nufact_note => *str* (No description) * cholesterol => *ufloat* Cholesterol, in mg/100g. * cholesterol_nufact => *ufloat* Cholesterol, in mg/100g (value to be used in nutrition facts table instead the lab test result). * cholesterol_nufact_note => *str* (No description) * choline => *ufloat* Choline, in mg/100g. * choline_nufact => *ufloat* Choline, in mg/100g (value to be used in nutrition facts table instead the lab test result). * choline_nufact_note => *str* (No description) * color => *str* (default: "auto") (No description) * cr => *ufloat* Chromium, in mcg/100g. * cr_nufact => *ufloat* Chromium, in mcg/100g (value to be used in nutrition facts table instead the lab test result). * cr_nufact_note => *str* (No description) * cu => *ufloat* Copper, in mcg/100g. * cu_nufact => *ufloat* Copper, in mcg/100g (value to be used in nutrition facts table instead the lab test result). * cu_nufact_note => *str* (No description) * fat* => *ufloat* Total fat, in g/100g. * fat_nufact => *ufloat* Total fat, in g/100g (value to be used in nutrition facts table instead the lab test result). * fat_nufact_note => *str* (No description) * fe => *ufloat* Iron, in mg/100g. * fe_nufact => *ufloat* Iron, in mg/100g (value to be used in nutrition facts table instead the lab test result). * fe_nufact_note => *str* (No description) * fluorine => *ufloat* Fluorine, in mg/100g. * fluorine_nufact => *ufloat* Fluorine, in mg/100g (value to be used in nutrition facts table instead the lab test result). * fluorine_nufact_note => *str* (No description) * folate => *ufloat* Folate (vitamin B9), in mcg/100g. * folate_nufact => *ufloat* Folate (vitamin B9), in mcg/100g (value to be used in nutrition facts table instead the lab test result). * folate_nufact_note => *str* (No description) * has_claims => *bool* Whether food is registered as having claims. * iodium => *ufloat* Iodium, in mcg/100g. * iodium_nufact => *ufloat* Iodium, in mcg/100g (value to be used in nutrition facts table instead the lab test result). * iodium_nufact_note => *str* (No description) * k => *ufloat* Potassium, in mg/100g. * k_nufact => *ufloat* Potassium, in mg/100g (value to be used in nutrition facts table instead the lab test result). * k_nufact_note => *str* (No description) * mg => *ufloat* Magnesium, in mg/100g. * mg_nufact => *ufloat* Magnesium, in mg/100g (value to be used in nutrition facts table instead the lab test result). * mg_nufact_note => *str* (No description) * mn => *ufloat* Manganese, in mcg/100g. * mn_nufact => *ufloat* Manganese, in mcg/100g (value to be used in nutrition facts table instead the lab test result). * mn_nufact_note => *str* (No description) * name => *str* (No description) * output_format => *str* (default: "vertical_text_table") Pick an output format for the nutrition fact. "vertical_text_table" is the default. The /(vertical)?.*table/ formats presents the information in a table, while the /linear/ formats presents the information in a paragraph. * package_size* => *ufloat* Packaging size, in g. * phosphorus => *ufloat* Phosphorus, in mg/100g. * phosphorus_nufact => *ufloat* Phosphorus, in mg/100g (value to be used in nutrition facts table instead the lab test result). * phosphorus_nufact_note => *str* (No description) * protein* => *ufloat* Protein, in g/100g. * protein_nufact => *ufloat* Protein, in g/100g (value to be used in nutrition facts table instead the lab test result). * protein_nufact_note => *str* (No description) * saturated_fat* => *ufloat* Saturated fat, in g/100g. * saturated_fat_nufact => *ufloat* Saturated fat, in g/100g (value to be used in nutrition facts table instead the lab test result). * saturated_fat_nufact_note => *str* (No description) * se => *ufloat* Selenium, in mcg/100g. * se_nufact => *ufloat* Selenium, in mcg/100g (value to be used in nutrition facts table instead the lab test result). * se_nufact_note => *str* (No description) * serving_size* => *ufloat* Serving size, in g. * sodium* => *ufloat* Sodium, in mg/100g. * sodium_nufact => *ufloat* Sodium, in mg/100g (value to be used in nutrition facts table instead the lab test result). * sodium_nufact_note => *str* (No description) * sugar* => *ufloat* Total sugar, in g/100g. * sugar_nufact => *ufloat* Total sugar, in g/100g (value to be used in nutrition facts table instead the lab test result). * sugar_nufact_note => *str* (No description) * va => *ufloat* Vitamin A, in mcg/100g (all-trans-)retinol. * va_nufact => *ufloat* Vitamin A, in mcg/100g (all-trans-)retinol (value to be used in nutrition facts table instead the lab test result). * va_nufact_note => *str* (No description) * vb1 => *ufloat* Vitamin B1, in mg/100g. * vb12 => *ufloat* Vitamin B12, in mcg/100g. * vb12_nufact => *ufloat* Vitamin B12, in mcg/100g (value to be used in nutrition facts table instead the lab test result). * vb12_nufact_note => *str* (No description) * vb1_nufact => *ufloat* Vitamin B1, in mg/100g (value to be used in nutrition facts table instead the lab test result). * vb1_nufact_note => *str* (No description) * vb2 => *ufloat* Vitamin B2, in mg/100g. * vb2_nufact => *ufloat* Vitamin B2, in mg/100g (value to be used in nutrition facts table instead the lab test result). * vb2_nufact_note => *str* (No description) * vb3 => *ufloat* Vitamin B3, in mg/100g. * vb3_nufact => *ufloat* Vitamin B3, in mg/100g (value to be used in nutrition facts table instead the lab test result). * vb3_nufact_note => *str* (No description) * vb5 => *ufloat* Vitamin B5 (pantothenic acid), in mg/100g. * vb5_nufact => *ufloat* Vitamin B5 (pantothenic acid), in mg/100g (value to be used in nutrition facts table instead the lab test result). * vb5_nufact_note => *str* (No description) * vb6 => *ufloat* Vitamin B6, in mg/100g. * vb6_nufact => *ufloat* Vitamin B6, in mg/100g (value to be used in nutrition facts table instead the lab test result). * vb6_nufact_note => *str* (No description) * vc => *ufloat* Vitamin C, in mg/100g. * vc_nufact => *ufloat* Vitamin C, in mg/100g (value to be used in nutrition facts table instead the lab test result). * vc_nufact_note => *str* (No description) * vd => *ufloat* Vitamin D, in mcg. * vd_nufact => *ufloat* Vitamin D, in mcg (value to be used in nutrition facts table instead the lab test result). * vd_nufact_note => *str* (No description) * ve => *ufloat* Vitamin E, in mg alpha-TE (tocopherol-equivalent). * ve_nufact => *ufloat* Vitamin E, in mg alpha-TE (tocopherol-equivalent) (value to be used in nutrition facts table instead the lab test result). * ve_nufact_note => *str* (No description) * vk => *ufloat* Vitamin K, in mcg. * vk_nufact => *ufloat* Vitamin K, in mcg (value to be used in nutrition facts table instead the lab test result). * vk_nufact_note => *str* (No description) * zn => *ufloat* Zinc, in mg/100g. * zn_nufact => *ufloat* Zinc, in mg/100g (value to be used in nutrition facts table instead the lab test result). * zn_nufact_note => *str* (No description) Returns an enveloped result (an array). First element ($status_code) is an integer containing HTTP-like status code (200 means OK, 4xx caller error, 5xx function error). Second element ($reason) is a string containing error message, or something like "OK" if status is 200. Third element ($payload) is the actual result, but usually not present when enveloped result is an error response ($status_code is not 2xx). Fourth element (%result_meta) is called result metadata and is optional, a hash that contains extra information, much like how HTTP response headers provide additional metadata. Return value: (any) HOMEPAGE Please visit the project's homepage at . SOURCE Source repository is at . SEE ALSO Other "App::BPOMUtils::*" distributions. AUTHOR perlancar CONTRIBUTING To contribute, you can send patches by email/via RT, or send pull requests on GitHub. Most of the time, you don't need to build the distribution yourself. You can simply modify the code, then test via: % prove -l If you want to build the distribution (e.g. to try to install it locally on your system), you can install Dist::Zilla, Dist::Zilla::PluginBundle::Author::PERLANCAR, Pod::Weaver::PluginBundle::Author::PERLANCAR, and sometimes one or two other Dist::Zilla- and/or Pod::Weaver plugins. Any additional steps required beyond that are considered a bug and can be reported to me. COPYRIGHT AND LICENSE This software is copyright (c) 2024 by perlancar . This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. BUGS Please report any bugs or feature requests on the bugtracker website When submitting a bug or request, please include a test-file or a patch to an existing test-file that illustrates the bug or desired feature.