Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Exports Overview: 

For endTB we need to regularly export all of the data in the system so that analysis can be performed on it. We can model this export as a set of CSVs that would have all of the data. These CSVs would be linkable through identifier columns in them. The data managers at the local sites would be able to generate these exports and send them to the central location for analysis, as and when needed. 

Note

The patient information would NOT be exported as a part of this. 


Background Job to generate the exports:

 Since the exports would take some time to generate (depending on the amount of data in the system), it makes sense to have a background job to generate these exports so that they are readily available for the end user and can be quickly and easily downloaded. Thus we have provided a background job "bahmni_batch" that would generate the exports. This background job's schedule and frequency can be adjusted as per requirement

Once the frequency is set, the job would run everyday according to that frequency and generate the exports at a prefixed location. These exports would be accessible for the end user through the bahmni application.

Note

The user would be able to see the last 20 instance of the exports on the application. 

Info
titlelocation of exports

The exports would lie in the following directory in the system: 

/home/bahmni/endtb_export
NOTE:


Steps to run the export

The export can be run at any time by following these the steps below.

  1. Login to the server system and open terminal. 
  2. Change the user Switch to 'bahmni' by typing in user using the following command :"sudo su bahmni". This must change your user to bahmni. 

    Code Block
    titleSwitching to bahmni user
    sudo su bahmni
  3. Now execute the command 'below

    Code Block
    /usr/bin/bahmni-batch
    '
    Note

    The system should show "Running bahmni-batch..."

    Info

    When the export is generated the system would give a message "Done".

    Now the export

    Export can now be accessed at

    the file location mentioned above 

    /home/bahmni/endtb_export

Scheduling the background job:

  1. Open the terminal and change the user to "bahmni" by executing the command "sudo su bahmni"

  2. Now type the following command "crontab -l"

  3. You would see a list of List all the cron jobs (background jobs ) in the system for the user "bahmni"

    You would see

    for bahmni user) user following command

    Code Block
    titleCommand to list the cron jobs
    crontab -l
    Info
    titleOutput for above command

    The above command shows the line "30 23 * * * /usr/bin/bahmni-batch >/dev/null 2>&1"

    shown

    as the output

    when you run the above command

    . This is because

    we have provided a schedule to the background job by default

    there is a cron job provided by default to schedule the exports. This schedule would run the job everyday at 11:30PM 

    Note

    One can change the schedule of the job as per requirement.

    Changing/Adding schedule

    Tip
    titleChanging/ Adding a new schedule

    To change this schedule or to add a new schedule

    you would need

    one can take the help of a cron generator

    . This

    which can be accessed at: http://crontab-generator.org/

    Image RemovedAfter selecting the schedule, (for example in the above image the schedule that I would want to generate for my job is every 30 minutes.) you will see a field below labeled "Command to execute". Enter the following in this field and

    Below is the crontab generator page one would see when accessing the above mentioned cron generator url. Choose the schedule that you would wish the job to be scheduled for. 

    Note

    For example in the below image the schedule that is chosen is to generate job every 30 minutes.

    Crontab generatorImage Added

  1. After selecting the schedule from the screenshot shown above, one will see the page below with a field labeled "Command To Execute". Fill the field with /usr/bin/bahmni-batch and then click on "Generate Crontab Line". 
  2. After clicking the button you generating crontab line,  one will see that your crontab expression is generated and shown at the top of the page (as shown below)
  3. Now you should copy this expression

    Copy the expression (generated as mentioned above) and go to the terminal again. Execute the

    command "crontab

    below command 

    Code Block
    crontab -e
    "
  4. You One would be seeing see the file that lists all the schedules for different cron jobs. If you one have not saved any, you one would only see one a line in the file which would represent the schedule that has been set for the jobs by default. (11:30PM every day as mentioned previously
  5. Insert

    Paste the line

    into this file

    copied from the generated expression and save it

    . (insert and save will work as per your editor)

    . This should set the schedule for the background job. 

    Note

    Insert and save will work as per your editor


Accessing the error log:

  1. The error log for the background job can be accessed at

    "

    below mentioned location.

    Code Block
    titleLocation of error log
    /var/log/bahmni-batch
    "
Note

In

this directory there would be a file that would have the log. 

the above mentioned location, file named bahmni-batch.log will hold the errors logged

 






Tip
iconfalse
titleOn this page

Table of Contents