NAME

App::BPOMUtils::NutritionLabelRef - Get one or more values from BPOM nutrition label reference (ALG, acuan label gizi)

VERSION

This document describes version 0.004 of App::BPOMUtils::NutritionLabelRef (from Perl distribution App-BPOMUtils-NutritionLabelRef), released on 2024-06-13.

SYNOPSIS

DESCRIPTION

This distribution includes CLI utilities related to BPOM nutrition label reference (ALG, acuan label gizi):

FUNCTIONS

bpom_get_nutrition_label_ref

Usage:

bpom_get_nutrition_label_ref(%args) -> [$status_code, $reason, $payload, \%result_meta]

Get one or more values from BPOM nutrition label reference (ALG, acuan label gizi).

Examples:

  • List all nutrient (symbols):

    bpom_get_nutrition_label_ref(action => "list_nutrients");

    Result:

    [
      200,
      "OK",
      [
        "Alpha_Linoleic_Acid",
        "Biotin",
        "Ca",
    # ...snipped 31 lines for brevity...
        "VD",
        "VE",
        "VK",
        "Zn",
      ],
      {},
    ]
  • List all groups (symbols):

    bpom_get_nutrition_label_ref(action => "list_groups");

    Result:

    [
      200,
      "OK",
      [
        "0to6mo",
        "1to3y",
        "7to11mo",
        "breastfeeding",
        "general",
        "pregnant",
      ],
      {},
    ]
  • List all ALG values:

    bpom_get_nutrition_label_ref();

    Result:

    [
      200,
      "OK",
      [
        { symbol => "Energy", group => "0to6mo", ref => 550, unit => "kkal" },
        { symbol => "Energy", group => "7to11mo", ref => 725, unit => "kkal" },
        { symbol => "Energy", group => "1to3y", ref => 1125, unit => "kkal" },
        { symbol => "Energy", group => "general", ref => 2150, unit => "kkal" },
    # ...snipped 254 lines for brevity...
          symbol => "Myo_Inositol",
          group  => "breastfeeding",
          ref    => undef,
          unit   => "mg",
        },
      ],
      { "table.fields" => ["symbol", "group", "ref", "unit", "%alg"] },
    ]
  • List ALG for vitamin D, for all groups:

    bpom_get_nutrition_label_ref(nutrient => "VD");

    Result:

    [
      200,
      "OK",
      [
        { group => "0to6mo", ref => 5, unit => "mcg" },
        { group => "7to11mo", ref => 5, unit => "mcg" },
        { group => "1to3y", ref => 15, unit => "mcg" },
        { group => "general", ref => 15, unit => "mcg" },
        { group => "pregnant", ref => 15, unit => "mcg" },
        { group => "breastfeeding", ref => 15, unit => "mcg" },
      ],
      { "table.fields" => ["symbol", "group", "ref", "unit", "%alg"] },
    ]
  • List ALG for vitamin D, for 1-3 years olds:

    bpom_get_nutrition_label_ref(nutrient => "VD", group => "1to3y");

    Result:

    [
      200,
      "OK",
      [{ ref => 15, unit => "mcg" }],
      { "table.fields" => ["symbol", "group", "ref", "unit", "%alg"] },
    ]
  • List ALG for vitamin D, for 1-3 years olds, and compare a value to reference:

    bpom_get_nutrition_label_ref(nutrient => "VD", group => "1to3y", value => 10);

    Result:

    [
      200,
      "OK",
      [{ "ref" => 15, "unit" => "mcg", "%alg" => 66.6666666666667 }],
      { "table.fields" => ["symbol", "group", "ref", "unit", "%alg"] },
    ]

This function is not exported by default, but exportable.

Arguments ('*' denotes required arguments):

  • action => str (default: "list_refs")

    (No description)

  • detail => bool

    (No description)

  • group => str

    (No description)

  • nutrient => nutrient::symbol

    (No description)

  • value => float

    (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 https://metacpan.org/release/App-BPOMUtils-NutritionLabelRef.

SOURCE

Source repository is at https://github.com/perlancar/perl-App-BPOMUtils-NutritionLabelRef.

SEE ALSO

TableData::Business::ID::BPOM::NutritionLabelRef

Other App::BPOMUtils::* distributions.

AUTHOR

perlancar <perlancar@cpan.org>

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 <perlancar@cpan.org>.

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 https://rt.cpan.org/Public/Dist/Display.html?Name=App-BPOMUtils-NutritionLabelRef

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.