NAME
    App::BPOMUtils - Utilities related to BPOM

VERSION
    This document describes version 0.005 of App::BPOMUtils (from Perl
    distribution App-BPOMUtils), released on 2022-09-07.

SYNOPSIS
     # Use via the included scripts

DESCRIPTION
    This distribution includes CLI utilities related to BPOM (Badan Pengawas
    Obat dan Makanan, Indonesian equivalent of Food & Drug Administration
    authority).

    *   bpom-daftar-jenis-pangan

    *   bpom-daftar-kode-prefiks-reg

    *   bpom-list-food-types

    *   bpom-list-reg-code-prefixes

    *   bpom-show-nutrition-facts

    *   bpom-tampilkan-ing

FUNCTIONS
  bpom_list_food_types
    Usage:

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

    List food types in BPOM processed food division.

    This function is not exported.

    Arguments ('*' denotes required arguments):

    *   code => *str*

        Only return records where the 'code' field equals specified value.

    *   code.contains => *str*

        Only return records where the 'code' field contains specified text.

    *   code.in => *array[str]*

        Only return records where the 'code' field is in the specified
        values.

    *   code.is => *str*

        Only return records where the 'code' field equals specified value.

    *   code.isnt => *str*

        Only return records where the 'code' field does not equal specified
        value.

    *   code.max => *str*

        Only return records where the 'code' field is less than or equal to
        specified value.

    *   code.min => *str*

        Only return records where the 'code' field is greater than or equal
        to specified value.

    *   code.not_contains => *str*

        Only return records where the 'code' field does not contain
        specified text.

    *   code.not_in => *array[str]*

        Only return records where the 'code' field is not in the specified
        values.

    *   code.xmax => *str*

        Only return records where the 'code' field is less than specified
        value.

    *   code.xmin => *str*

        Only return records where the 'code' field is greater than specified
        value.

    *   detail => *bool* (default: 0)

        Return array of full records instead of just ID fields.

        By default, only the key (ID) field is returned per result entry.

    *   exclude_fields => *array[str]*

        Select fields to return.

    *   fields => *array[str]*

        Select fields to return.

    *   query => *str*

        Search.

    *   random => *bool* (default: 0)

        Return records in random order.

    *   result_limit => *int*

        Only return a certain number of records.

    *   result_start => *int* (default: 1)

        Only return starting from the n'th record.

    *   sort => *array[str]*

        Order records according to certain field(s).

        A list of field names separated by comma. Each field can be prefixed
        with '-' to specify descending order instead of the default
        ascending.

    *   summary => *str*

        Only return records where the 'summary' field equals specified
        value.

    *   summary.contains => *str*

        Only return records where the 'summary' field contains specified
        text.

    *   summary.in => *array[str]*

        Only return records where the 'summary' field is in the specified
        values.

    *   summary.is => *str*

        Only return records where the 'summary' field equals specified
        value.

    *   summary.isnt => *str*

        Only return records where the 'summary' field does not equal
        specified value.

    *   summary.max => *str*

        Only return records where the 'summary' field is less than or equal
        to specified value.

    *   summary.min => *str*

        Only return records where the 'summary' field is greater than or
        equal to specified value.

    *   summary.not_contains => *str*

        Only return records where the 'summary' field does not contain
        specified text.

    *   summary.not_in => *array[str]*

        Only return records where the 'summary' field is not in the
        specified values.

    *   summary.xmax => *str*

        Only return records where the 'summary' field is less than specified
        value.

    *   summary.xmin => *str*

        Only return records where the 'summary' field is greater than
        specified value.

    *   with_field_names => *bool*

        Return field names in each record (as hash/associative array).

        When enabled, function will return each record as hash/associative
        array (field name => value pairs). Otherwise, function will return
        each record as list/array (field value, field value, ...).

    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)

  bpom_list_reg_code_prefixes
    Usage:

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

    List known alphabetical prefixes in BPOM registered product codes.

    This function is not exported.

    Arguments ('*' denotes required arguments):

    *   code => *str*

        Only return records where the 'code' field equals specified value.

    *   code.contains => *str*

        Only return records where the 'code' field contains specified text.

    *   code.in => *array[str]*

        Only return records where the 'code' field is in the specified
        values.

    *   code.is => *str*

        Only return records where the 'code' field equals specified value.

    *   code.isnt => *str*

        Only return records where the 'code' field does not equal specified
        value.

    *   code.max => *str*

        Only return records where the 'code' field is less than or equal to
        specified value.

    *   code.min => *str*

        Only return records where the 'code' field is greater than or equal
        to specified value.

    *   code.not_contains => *str*

        Only return records where the 'code' field does not contain
        specified text.

    *   code.not_in => *array[str]*

        Only return records where the 'code' field is not in the specified
        values.

    *   code.xmax => *str*

        Only return records where the 'code' field is less than specified
        value.

    *   code.xmin => *str*

        Only return records where the 'code' field is greater than specified
        value.

    *   detail => *bool* (default: 0)

        Return array of full records instead of just ID fields.

        By default, only the key (ID) field is returned per result entry.

    *   division => *str*

        Only return records where the 'division' field equals specified
        value.

    *   division.contains => *str*

        Only return records where the 'division' field contains specified
        text.

    *   division.in => *array[str]*

        Only return records where the 'division' field is in the specified
        values.

    *   division.is => *str*

        Only return records where the 'division' field equals specified
        value.

    *   division.isnt => *str*

        Only return records where the 'division' field does not equal
        specified value.

    *   division.max => *str*

        Only return records where the 'division' field is less than or equal
        to specified value.

    *   division.min => *str*

        Only return records where the 'division' field is greater than or
        equal to specified value.

    *   division.not_contains => *str*

        Only return records where the 'division' field does not contain
        specified text.

    *   division.not_in => *array[str]*

        Only return records where the 'division' field is not in the
        specified values.

    *   division.xmax => *str*

        Only return records where the 'division' field is less than
        specified value.

    *   division.xmin => *str*

        Only return records where the 'division' field is greater than
        specified value.

    *   exclude_fields => *array[str]*

        Select fields to return.

    *   fields => *array[str]*

        Select fields to return.

    *   query => *str*

        Search.

    *   random => *bool* (default: 0)

        Return records in random order.

    *   result_limit => *int*

        Only return a certain number of records.

    *   result_start => *int* (default: 1)

        Only return starting from the n'th record.

    *   sort => *array[str]*

        Order records according to certain field(s).

        A list of field names separated by comma. Each field can be prefixed
        with '-' to specify descending order instead of the default
        ascending.

    *   summary_eng => *str*

        Only return records where the 'summary_eng' field equals specified
        value.

    *   summary_eng.contains => *str*

        Only return records where the 'summary_eng' field contains specified
        text.

    *   summary_eng.in => *array[str]*

        Only return records where the 'summary_eng' field is in the
        specified values.

    *   summary_eng.is => *str*

        Only return records where the 'summary_eng' field equals specified
        value.

    *   summary_eng.isnt => *str*

        Only return records where the 'summary_eng' field does not equal
        specified value.

    *   summary_eng.max => *str*

        Only return records where the 'summary_eng' field is less than or
        equal to specified value.

    *   summary_eng.min => *str*

        Only return records where the 'summary_eng' field is greater than or
        equal to specified value.

    *   summary_eng.not_contains => *str*

        Only return records where the 'summary_eng' field does not contain
        specified text.

    *   summary_eng.not_in => *array[str]*

        Only return records where the 'summary_eng' field is not in the
        specified values.

    *   summary_eng.xmax => *str*

        Only return records where the 'summary_eng' field is less than
        specified value.

    *   summary_eng.xmin => *str*

        Only return records where the 'summary_eng' field is greater than
        specified value.

    *   summary_ind => *str*

        Only return records where the 'summary_ind' field equals specified
        value.

    *   summary_ind.contains => *str*

        Only return records where the 'summary_ind' field contains specified
        text.

    *   summary_ind.in => *array[str]*

        Only return records where the 'summary_ind' field is in the
        specified values.

    *   summary_ind.is => *str*

        Only return records where the 'summary_ind' field equals specified
        value.

    *   summary_ind.isnt => *str*

        Only return records where the 'summary_ind' field does not equal
        specified value.

    *   summary_ind.max => *str*

        Only return records where the 'summary_ind' field is less than or
        equal to specified value.

    *   summary_ind.min => *str*

        Only return records where the 'summary_ind' field is greater than or
        equal to specified value.

    *   summary_ind.not_contains => *str*

        Only return records where the 'summary_ind' field does not contain
        specified text.

    *   summary_ind.not_in => *array[str]*

        Only return records where the 'summary_ind' field is not in the
        specified values.

    *   summary_ind.xmax => *str*

        Only return records where the 'summary_ind' field is less than
        specified value.

    *   summary_ind.xmin => *str*

        Only return records where the 'summary_ind' field is greater than
        specified value.

    *   with_field_names => *bool*

        Return field names in each record (as hash/associative array).

        When enabled, function will return each record as hash/associative
        array (field name => value pairs). Otherwise, function will return
        each record as list/array (field value, field value, ...).

    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)

  bpom_show_nutrition_facts
    Usage:

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

    Round values and format them as nutrition fact table (ING - informasi
    nilai gizi).

    Examples:

    *   An example:

         bpom_show_nutrition_facts(
           carbohydrate => 13.113,
           fat => 0.223,
           protein => 0.99,
           saturated_fat => 0.01,
           serving_size => 75,
           sodium => 0.223,
           sugar => 7.173
         );

        Result:

         [
           200,
           "OK",
           [
             {
               name_eng      => "Total energy",
               name_ind      => "Energi total",
               val_per_100g  => 58.419,
               val_per_srv   => 43.81425,
               val_per_srv_R => 45,
               pct_dv        => 2.03787209302326,
               pct_dv_R      => 2,
             },
             {
               name_eng      => "Energy from fat",
               name_ind      => "Energi dari lemak",
               val_per_100g  => 2.007,
               val_per_srv   => 1.50525,
               val_per_srv_R => 0,
             },
             {
               name_eng      => "Energy from saturated fat",
               name_ind      => "Energi dari lemak jenuh",
               val_per_100g  => 0.09,
               val_per_srv   => 0.0675,
               val_per_srv_R => 0,
             },
             {
               name_eng      => "Total fat",
               name_ind      => "Lemak total",
               val_per_100g  => 0.223,
               val_per_srv   => 0.16725,
               val_per_srv_R => 0,
               pct_dv        => 0.249626865671642,
               pct_dv_R      => 0,
             },
             {
               name_eng      => "Saturated fat",
               name_ind      => "Lemak jenuh",
               val_per_100g  => 0.01,
               val_per_srv   => 0.0075,
               val_per_srv_R => 0,
               pct_dv        => 0.0375,
               pct_dv_R      => 0,
             },
             {
               name_eng      => "Protein",
               name_ind      => "Protein",
               val_per_100g  => 0.99,
               val_per_srv   => 0.7425,
               val_per_srv_R => 1,
               pct_dv        => 1.2375,
               pct_dv_R      => 1,
             },
             {
               name_eng      => "Total carbohydrate",
               name_ind      => "Karbohidrat total",
               val_per_100g  => 13.113,
               val_per_srv   => 9.83475,
               val_per_srv_R => 10,
               pct_dv        => 3.02607692307692,
               pct_dv_R      => 3,
             },
             {
               name_eng      => "Total sugar",
               name_ind      => "Gula total",
               val_per_100g  => 7.173,
               val_per_srv   => 5.37975,
               val_per_srv_R => 5,
             },
             {
               name_eng      => "Salt (Sodium)",
               name_ind      => "Garam (Natrium)",
               val_per_100g  => 0.223,
               val_per_srv   => 0.16725,
               val_per_srv_R => 0,
               pct_dv        => 0.0514615384615385,
               pct_dv_R      => 0,
             },
           ],
           {
             "table.fields" => [
               "name_eng",
               "name_ind",
               "val_per_100g",
               "val_per_srv",
               "val_per_srv_R",
               "pct_dv",
               "pct_dv_R",
             ],
           },
         ]

    This function is not exported.

    Arguments ('*' denotes required arguments):

    *   carbohydrate* => *ufloat*

        Total carbohydrate, in g/100g.

    *   fat* => *ufloat*

        Total fat, in g/100g.

    *   protein* => *ufloat*

        Protein, in g/100g.

    *   saturated_fat* => *ufloat*

        Saturated fat, in g/100g.

    *   serving_size* => *ufloat*

        Serving size, in g.

    *   sodium* => *ufloat*

        Sodium, in mg/100g.

    *   sugar* => *ufloat*

        Total sugar, in g/100g.

    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>.

SOURCE
    Source repository is at
    <https://github.com/perlancar/perl-App-BPOMUtils>.

SEE ALSO
    <https://pom.go.id>

    Business::ID::BPOM

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) 2022, 2021 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>

    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.

