Skip to content

niua-org/Aaina_module_project

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Introduction

This is a backend API application developed using Lumen PHP Framework. This API can be used in frontend and mobile apps. Documentation for the framework can be found on the Lumen website.

Prerequisite

Server requirement

Libraries

  • curl
  • composer

Apache Server(2.4.29)

Enable modules mode_rewrite and headers

  sudo a2enmod rewrite
  sudo a2enmod headers
  sudo service apache2 restart

Add below code in apache virtual host file replace "/var/www/html" with document root path

<Directory /var/www/html>
    Options Indexes FollowSymLinks MultiViews
    AllowOverride All
    Order allow,deny
    allow from all
</Directory>

Install redis server(4.0.9)

PHP

  • PHP >= 7.3
  • BCMath PHP Extension
  • Ctype PHP Extension
  • Fileinfo PHP Extension
  • JSON PHP Extension
  • Mbstring PHP Extension
  • OpenSSL PHP Extension
  • PDO PHP Extension
  • Tokenizer PHP Extension
  • XML PHP Extension
  • php-redis

Install PHP Extensions

  • Install Redis PHP Extension

    sudo apt-get install php-redis
  • Restart Apache Server after PHP Extension installation

    sudo service apache2 restart

MySQL Server(5.7.3)

  • Mysql server must have a character set utf8mb4 installed.

Clone a repository

  • Clone git repository

    git clone https://openforge.gov.in/plugins/git/poshantracker/poshantrackerphpapi.git
  • Make the /public folder as a root document folder.

Install vendor

sudo composer install

Permissions

Give permissions to laravel folders. Go to the application root folder and run below commands.

sudo chown -R www-data:www-data storage
sudo chmod -R ug+rwx storage

Configuration

Configuration options of this application are stored in the .env file.

Copy .env.example to .env if file does not exist.

  • Update the application environment variables like database, application debug, api debug etc. in “.env” file located in the source root folder.
  • Set application environment to production in production environment as APP_ENV=production
  • In production environment, APP_DEBUG and API_DEBUG value should always be false as APP_DEBUG=false and API_DEBUG=false.
  • Set redis cache driver
    • CACHE_DRIVER=redis
  • Redis settings - default redis settings given below, if you have same settings on your redis server then no need to add below variable into .env file otherwise add below variable in .env file and update values as per your redis configuration
    • REDIS_HOST=127.0.0.1
    • REDIS_PASSWORD=null
    • REDIS_PORT=6379
    • REDIS_DB=0
    • REDIS_CLUSTER=false

Application Key

Create APP_KEY by running below php command and set this key in .env file as APP_KEY=<generated key>

php -r "echo strtoupper(bin2hex(random_bytes(16)));"

JWT Secret

Create JWT_SECRET key by running below command. This will update .env file with something like JWT_SECRET=foobar

sudo php artisan jwt:secret

Config

Update the below database variables default values (second param of env function) in /config/database.php under connections->mysql same values used in .evn file

  'host' => env('DB_HOST', '127.0.0.1'),
  'port' => env('DB_PORT', 3306),
  'database' => env('DB_DATABASE', 'poshantracker'),
  'username' => env('DB_USERNAME', 'root'),
  'password' => env('DB_PASSWORD', ''),

Create database and import database dump

  • Create a new database user with full grant permission

  • Create a new database by running the below sql query

    CREATE DATABASE IF NOT EXISTS `poshantracker` DEFAULT CHARACTER SET utf8mb4;
  • Import database dump, if you have a latest dump file or import initial master dump file at /database-dumps/module1-2/poshantracker_master.sql and run the further module queries added in module folders as module3, module4 etc. at path /database-dumps/

      mysql -u<mysql db username> -p poshantracker < <dump sql file path>

Cache

  • Clear application cache whenever any data updated that are already cached for example always clear cache when settings variable added/updated

  • Remove all application cache data

    sudo php artisan cache:clear
  • Remove specific cache key application data for example "app_settings" is the cache key

    sudo php artisan cache:forget app_settings
  • Disable model caching, update following variable value in .env file

    • MODEL_CACHE_ENABLED=false
  • Model caching TTL can we used to set model caching for defined TTL when model caching enabled, update following variable value in .env file. TTL would be in seconds. Default is 86400 seconds (24 hours). To disable the model caching TTL remove the value as "MODEL_CACHE_TTL=" in .env file.

    • MODEL_CACHE_TTL=86400
  • Command to remove a single model cache

    sudo php artisan modelCache:clear --model=<model path>
    e.g. sudo php artisan modelCache:clear --model="App\\Models\\Beneficiary"

Encryption

  • Request form data should be encrypted with key value pair and send with content type application/x-www-form-urlencoded. Encrypted data key would be "request_data" and value would be whole form json encrypted data using an encryption key.
  • To disable request encryption add the below variable in .env file with value false. When request encryption is disabled then request data need to be send as plain form data(without encryption) with whole form data key value pair.
    • REQUEST_ENCRYPTION_ENABLED=false
  • All APIs response would be send in encrypted json format with key value pair and send with content type application/json. Encrypted data key would be "response_data" and value would be encrypted json data. Response value encrypted using an encryption key.
  • To disable response encryption add the below variable in .env file with value false.
    • RESPONSE_ENCRYPTION_ENABLED=false

State API

  • To enable state api key feature add the below variable in .env file with value true.
    • STATE_API_ENABLED=true

App force update

  • To enable app force update feature add the below variable in .env file with value like 3.0. Users don't have this app version 3.0 will see a force update message in app. To disable this feature empty the variable value.
    • APP_FORCE_UPDATE_VERSION=3.0

Elasticsearch

  • Update following configuration variable values with valid values, ELASTICSEARCH_TIMEZONE value should be in 2 digits hour minute format with + or - sign
    • ELASTICSEARCH_HOST="ec2-65-0-191-169.ap-south-1.compute.amazonaws.com"
    • ELASTICSEARCH_PORT=9200
    • ELASTICSEARCH_SCHEME=http
    • ELASTICSEARCH_TIMEZONE="+05:30"

SMS Gateway

  • To use default sms gateway add sms gateway details for below variables
    • SMS_GATEWAY_BASE_URL=https://******
    • SMS_GATEWAY_URL_PARAMS="username={USER},pin={AUTH_KEY},signature={SENDER},message={MESSAGE},mnumber={MOBILE},dlt_template_id={DLT_TEMPLATE_ID},dlt_entity_id={DLT_ENTITY_ID}"
    • SMS_GATEWAY_USER=******
    • SMS_GATEWAY_AUTH_KEY=******
    • SMS_GATEWAY_SENDER_NAME=******
    • SMS_GATEWAY_PROXY_URL=******
    • SMS_GATEWAY_LOG_FULL_URL=false
    • SMS_GATEWAY_REGISTER_DLT_ENTITY_ID=
    • SMS_GATEWAY_REGISTER_DLT_TEMPLATE_ID=
    • SMS_GATEWAY_FORGOT_MPIN_DLT_ENTITY_ID=
    • SMS_GATEWAY_FORGOT_MPIN_DLT_TEMPLATE_ID=
    • SMS_GATEWAY_BENEFICIARY_MOBILE_VERIFY_DLT_ENTITY_ID=
    • SMS_GATEWAY_BENEFICIARY_MOBILE_VERIFY_DLT_TEMPLATE_ID=
  • To use the Digilocker sms gateway add sms gateway details for below variables
    • DIGILOCKER_SMS_GATEWAY_ENABLED=true
    • DIGILOCKER_SMS_GATEWAY_BASE_URL=http://******
    • DIGILOCKER_SMS_GATEWAY_URL_PARAMS="org_id={SMS_ORG_ID},mobile_no={MOBILE},message={MESSAGE},sms_expire={SMS_EXPIRE},sms_type={SMS_TYPE},template_id={TEMPLATE_ID},hmac={HMAC}"
    • DIGILOCKER_SMS_HMAC_PARAMS="{SECRET_KEY},{SMS_ORG_ID},{MOBILE},{MESSAGE},{SMS_EXPIRE},{SMS_TYPE},{TEMPLATE_ID}"
    • DIGILOCKER_INT_VAL_PARAMS="{SMS_EXPIRE}"
    • DIGILOCKER_SMS_GATEWAY_ORG_ID=******
    • DIGILOCKER_SMS_GATEWAY_SECRET_KEY=******
    • DIGILOCKER_SMS_GATEWAY_SMS_TYPE=******
    • DIGILOCKER_SMS_GATEWAY_SMS_EXPIRE=0
    • DIGILOCKER_SMS_GATEWAY_REGISTER_TEMPLATE_ID=******
    • DIGILOCKER_SMS_GATEWAY_FORGOT_MPIN_TEMPLATE_ID=******
    • DIGILOCKER_SMS_GATEWAY_BENEFICIARY_MOBILE_VERIFY_TEMPLATE_ID=******

Logs

  • Application logs path "storage/logs/" under application root folder
  • Dafault last 7 days application logs retained and days can be changed by adding environment variable as below
    • LOG_DAILY_RETAIN_OLD_LOG_DAYS=7
  • Default log channel stack, this can be changed by updating variable "LOG_CHANNEL" value in .env file. All available log channels are as follows: stack, single, daily, slack, papertrail, stderr, syslog and errorlog. Some channels require additional setting.
    • LOG_CHANNEL=stack
  • Default log level for stack/daily channel is debug, this can be changed by updating variable "LOG_DAILY_LEVEL" value in .env file. All the log levels with severity lower to higher are as follows: debug, info, notice, warning, error, critical, alert and emergency.
    • LOG_DAILY_LEVEL=debug
  • To set log level to log error, critical, alert and emergency messages. Update daily log level variable "LOG_DAILY_LEVEL" value in .env variable e.g. - LOG_DAILY_LEVEL=error

Commands

  • Go to your project root folder and run the below commands

  • Command to remove all beneficiaries of AWC

    php artisan awc:remove-all-beneficiary --awc=<awc id>
    e.g. - php artisan awc:remove-all-beneficiary --awc=1
  • Command to remove all records of a state or awc.

    php artisan awc:remove-all-data --state=<state id> --awc=<awc id>
    e.g. - php artisan awc:remove-all-data --state=1 --awc=1
    • To remove all records of a state use command

      e.g. php artisan awc:remove-all-data --state=1
    • To remove all records of an awc use command

      e.g. php artisan awc:remove-all-data --awc=1
  • Command to update awc data for all existing beneficiaries in the beneficiary table, this command can be used to update the data in chunks as skip some awc records and limit the number of awc records.

    php artisan beneficiary:update-all-beneficiary-awc-data --offset=<skip a given number of results> --limit=<limit the number of results>
    e.g. php artisan beneficiary:update-all-beneficiary-awc-data --offset=10 --limit=20
    • To update awc data for all existing beneficiaries in beneficiary table

      e.g. php artisan beneficiary:update-all-beneficiary-awc-data
    • To update awc data for existing beneficiaries in chunk use offset (skip a given number of results) and limit (limit the number of results), for example update beneficiary awc data and skip 10 awc results and limit to 20 awc results

      e.g. php artisan beneficiary:update-all-beneficiary-awc-data --offset=10 --limit=20
  • Command to update awc data for existing beneficiaries only when beneficiary state is empty in the beneficiary table, this command can be used to update the data in chunks as skip some distinct beneficiary awc_id records and limit the number of distinct awc_id records.

    php artisan beneficiary:update-beneficiary-awc-data-for-empty-state --offset=<skip a given number of results> --limit=<limit the number of results>
    e.g. php artisan beneficiary:update-beneficiary-awc-data-for-empty-state --offset=10 --limit=20
    • To update awc data for existing beneficiaries only when beneficiary state is empty in beneficiary table

      e.g. php artisan beneficiary:update-beneficiary-awc-data-for-empty-state
  • Command to update awc data and status for existing beneficiaries data only when beneficiary data state is empty in the beneficiary data table, this command can be used to update the data in chunks as skip some distinct beneficiary id records and limit the number of distinct beneficiary id records. This can support max-id option to process all the smaller beneficiary data ids when max-id provided.

    php artisan beneficiary:update-beneficiary-data-awc-data-for-empty-state --offset=<skip a given number of results> --limit=<limit the number of results> --max-id=<Maximum id of beneficiary data>
    e.g. php artisan beneficiary:update-beneficiary-awc-data-for-empty-state --offset=10 --limit=20 --max-id=1000
    • To update all awc data and status for existing beneficiaries data only when beneficiary data state is empty in beneficiary data table

      e.g. php artisan beneficiary:update-beneficiary-awc-data-for-empty-state
  • Command to update awc data, beneficiary type and status for existing awc beneficiary tracking records only when awc beneficiary tracking state is empty in the awc beneficiary tracking table, this command can be used to update the data in chunks as skip some distinct beneficiary id records and limit the number of distinct beneficiary id records. This can support max-id option to process all the smaller awc beneficiary tracking ids when max-id provided.

    php artisan beneficiary:update-awc-beneficiary-tracking-awc-data-for-empty-state --offset=<skip a given number of results> --limit=<limit the number of results> --max-id=<Maximum id of awc beneficiary tracking>
    e.g. php artisan beneficiary:update-awc-beneficiary-tracking-awc-data-for-empty-state --offset=10 --limit=20 --max-id=1000
    • To update all awc data, beneficiary type and status for awc beneficiary tracking records only when awc beneficiary tracking state is empty in awc beneficiary tracking table

      e.g. php artisan beneficiary:update-awc-beneficiary-tracking-awc-data-for-empty-state
  • Command to update awc data, beneficiary type and status for existing beneficiary vaccination records only when beneficiary vaccination records state is empty in the beneficiary vaccination records table, this command can be used to update the data in chunks as skip some distinct beneficiary id records and limit the number of distinct beneficiary id records. This can support max-id option to process all the smaller beneficiary vaccination records ids when max-id provided.

    php artisan beneficiary:update-beneficiary-vaccination-record-awc-data-for-empty-state --offset=<skip a given number of results> --limit=<limit the number of results> --max-id=<Maximum id of beneficiary vaccination records>
    e.g. php artisan beneficiary:update-beneficiary-vaccination-record-awc-data-for-empty-state --offset=10 --limit=20 --max-id=1000
    • To update all awc data, beneficiary type and status for beneficiary vaccination records only when beneficiary vaccination records state is empty in beneficiary vaccination records table

      e.g. php artisan beneficiary:update-beneficiary-vaccination-record-awc-data-for-empty-state
  • Command to migrate beneficiaries from one type to another type or inactive. Beneficiary type option is required. State option is optional. Additional flag "--update-stats-count" can we used to udpate beneficiary stats count for national, state and district. Beneficiary types allowed in command are children_0m_6m, children_6m_3y, children_3y_6y, lactating_mother and adolescent.

    php artisan beneficiary:migrate --beneficiary-type=<beneficiary type> --state=<state id> --update-stats-count
    e.g. - php artisan beneficiary:migrate --beneficiary-type=children_0m_6m --state=1 --update-stats-count
    • To migrate beneficiary for specified state without stats count

      e.g. php artisan beneficiary:migrate --beneficiary-type=children_0m_6m --state=1
    • To migrate beneficiary for specified state with stats count

      e.g. php artisan beneficiary:migrate --beneficiary-type=children_0m_6m --state=1 --update-stats-count
    • To migrate all beneficiaries without stats count

      e.g. php artisan beneficiary:migrate --beneficiary-type=children_0m_6m
    • To migrate all beneficiaries with stats count

      e.g. php artisan beneficiary:migrate --beneficiary-type=children_0m_6m --update-stats-count
  • Command to add awc user missing relationship with awc into the mapping table.

    php artisan awc-user:add-missing-relationship-with-awc
  • Command to update beneficiary hcm/thr stats data. Ration type would be either thr or hcm. When date is supplied then script run for that date ration type or if date not supplied then for current date ration type.

    php artisan beneficiary:update-ration-stats --ration-type=<ration type> --date=<date YYYY-MM-DD> --show-query --force
    e.g. - php artisan beneficiary:update-ration-stats --ration-type=hcm --date=2021-05-25 --show-query --force
    • Command options

      --show-query - This flag is used to show all queries run by this command
      --force - This flag is used to disable the confirmation message
      
    • To update thr data for current date

      e.g. php artisan beneficiary:update-ration-stats --ration-type=thr
    • To update thr data for specific date

      e.g. php artisan beneficiary:update-ration-stats --ration-type=thr --date=2021-05-25
  • Command to update beneficiary sam man tracking data. State option is optional.

    php artisan beneficiary:update-beneficiary-data-sam-mam --state=<state id>
    e.g. - php artisan beneficiary:update-beneficiary-data-sam-mam --state=1
    • To update beneficiary sam man tracking data for specific state

      e.g. php artisan beneficiary:update-beneficiary-data-sam-mam --state=1
    • To update all beneficiary sam man tracking data

      e.g. php artisan beneficiary:update-beneficiary-data-sam-mam
  • Command to validate all beneficiary aadhar number

    php artisan beneficiary:aadhar-validator --beneficiary-type
    e.g - php artisan beneficiary:aadhar-validator --beneficiary-type=pregnant_woman
    • Command to remove mobile verify past data
    php artisan beneficiary:remove-mobile-verify
    e.g - php artisan beneficiary:remove-mobile-verify --force --show-query
  • Command to prepare beneficiaries home visit schedule data. Either beneficiary type or awc id option is required. State option is optional. Beneficiary types allowed in command are pregnant_woman, lactating_mother, children_0m_6m, children_6m_3y, children_3y_6y and adolescent_girl.

    php artisan beneficiary:prepare-home-visit-schedule-data --beneficiary-type=<beneficiary type> --awc-id=<awc id> --state=<state id>
    e.g. - php artisan beneficiary:migrate --beneficiary-type=pregnant_woman --state=1
    • To prepare home visit schedule data for a beneficiary for a specific state

      e.g. php artisan beneficiary:prepare-home-visit-schedule-data --beneficiary-type=pregnant_woman --state=1
    • To prepare home visit schedule data for a beneficiary

      e.g. php artisan beneficiary:prepare-home-visit-schedule-data --beneficiary-type=pregnant_woman
    • To prepare home visit schedule data for an awc all beneficiary types

      e.g. php artisan beneficiary:prepare-home-visit-schedule-data --awc-id=1

API URLs

New command for stunted underweight

  • Command to prepare beneficiaries stunted underweight data. Either beneficiary type option is required. State option is optional. Beneficiary types allowed in command are children_0m_6m and children_6m_3y. Only 60 month will be tracked.

    php artisan beneficiary:update-beneficiary-data-stunted-underweight --beneficiary-type=<beneficiary type> --state=<state id>
    
    e.g. - php artisan beneficiary:update-beneficiary-data-stunted-underweight --beneficiary-type=children_0m_6m --state=1
    
    • To prepare stunted underweight data for a beneficiary for a specific state

      e.g. php artisan beneficiary:update-beneficiary-data-stunted-underweight --beneficiary-type=children_0m_6m --state=1
    • To prepare stunted underweight schedule data for a beneficiary

      e.g. php artisan beneficiary:update-beneficiary-data-stunted-underweight --beneficiary-type=children_0m_6m

New command for awc correction list

  • Command to prepare AWC list of data which is not correct in AWC table.

    php artisan awc:awc-data-correction-list --show-query
    
    e.g. - php artisan awc:awc-data-correction-list --show-query
    
    

New command for reset all health status after 5 year

  • Command to update health status to beneficiaries who completed 5 years.

    php artisan beneficiary:update-beneficiary-data-status-reset-after-5year --show-query
    
    e.g. - php artisan beneficiary:update-beneficiary-data-status-reset-after-5year --show-query

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages