Versions Compared

Key

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

This guide explains how to create an auto-deactivating-user task in OpenMRS. The task involves setting the "number of days to retire users" via the user interface and then running the auto-deactivation task.

...

  1. Log in to OpenMRS.

  2. Set the global property GP_NUMBER_OF_DAYS_FOR_AUTO_RETIRING_USER(users.numberOfDaysToRetire ):

    • Find global property GP_NUMBER_OF_DAYS_FOR_AUTO_RETIRING_USER users.numberOfDaysToRetire.

    • Enter the desired number of days of inactivity after which users should be retired.

    • Save the changes.

...

Steps to Schedule the Task:

  1. Fill in the Set up configuration details for the task:

    • Task config ID: A unique id

    • Name: Name of the task e.g. Auto Retire Users

    • Description: Short description of the task e.g. Retires all active users that are inactive for XX number of days specified by the value of the global property 'users.numberOfDaysToRetire'.

    • Class: Set schedulable_class to be org.openmrs.scheduler.tasks.AutoRetireUsersTask

    • Start Time: Set the desired start time.

    • Start Time Pattern: Determines the pattern of start time.

    • Repeat Interval: Set to 86400 (which represents 24 hours) to run dailydesired repeat interval.

    • Start on Startup: Set to true if you want the schedule to start immediately after the application starts.

    • Started: Set to true to start the task immediately..

    • Other properties: You can set other properties as desired (see example below)

  2. Save the Taskconfiguration:

    1. Save the task configuration.

    2. The task will now be scheduled to run at the specified interval, automatically retiring inactive users based on the global property setting.

...

Code Block
languagexml
<changeSet author="name (generated)" id="202405201900-1">
    <insert tableName="scheduler_task_config">
       <column name="task_config_id" valueNumeric="3"/>
       <column name="name" value="Auto Retire users"/>
       <column name="description" value="Retires all active users that are inactive for XX number of days specified by the value of the global property 'users.numberOfDaysToRetire'"/>
       <column name="schedulable_class" value="org.openmrs.scheduler.tasks.AutoRetireUsersTask"/>
       <column name="start_time" value="2024-05-22T2305/22/2024T23:59:59"/>
       <column name="start_time_pattern" value="MM/dd/yyyy HH:mm:ss"/>
       <column name="repeat_interval" valueNumeric="86400"/>
       <column name="start_on_startup" valueBoolean="true"/>
       <column name="started" valueBoolean="false"/>
       <column name="created_by" valueNumeric="1"/>
       <column name="date_created" value="2024-05-20T10:00:00"/>
       <column name="changed_by"/>
       <column name="date_changed"/>
       <column name="last_execution_time"/>
       <column name="uuid" value="02f598d9-e3bb-4f6f-94b6-182c6856413a"/>
    </insert>
</changeSet>

...