opensrp / opensrp-client-opd

Other
0 stars 1 forks source link

Build Status Coverage Status Codacy Badge

OpenSRP Client OPD Library

This library provides the ability to show an OPD(Outpatient Department) Register to a client application

Table Of Contents

  1. Getting started
  2. Required Implementations
  3. Enable OPD Registration

1. Getting started

Add the module to your project as follows

  1. Add the repository to your project-root build.gradle

    allprojects {
     repositories {
         ...
    
         maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' }
     }
    }
    
    dependencies {
    
     ...
    
     implementation 'org.smartregister:opensrp-client-opd:0.0.1-SNAPSHOT'
    }
  2. Initialise the library in the onCreate method of your Application class

    
    public class HealthApplication extends DrishtiApplication {
    
     @Override
     public void onCreate() {
         super.onCreate();
         ...
    
         OpdLibrary.init(context, getRepository(), 
             new OpdConfiguration.Builder(OpdRegisterQueryProvider.class)
                 .build()
         );
     }
    }
    

    where you should have implemented your own:

    • OpdRegisterActivity from the abstract Activity org.smartregister.opd.activity.BaseOpdRegisterActivity
    • OpdRegisterActivityPresenter from the abstract Presenter org.smartregister.opd.presenter.BaseOpdRegisterActivityPresenter
    • OpdRegisterFragment from the abstract Fragment org.smartregister.opd.fragment.BaseOpdRegisterFragment
    • OpdRegisterQueryProvider from the interface org.smartregister.opd.configuration.OpdRegisterQueryProviderContract
  3. Add your implemented OpdRegisterActivity to the Android.manifest file

  4. Call OpdRegisterActivity from your navigation menu

  5. Create the OPD repositories inside your application repository class

    This can be done by adding the following lines of code to your ApplicationRepository#onCreate(SQLiteDatabase):

    
    ...
    
    public void onCreate(SQLiteDatabase database) {
    
        ...
    
        VisitRepository.createTable(database);
        CheckInRepository.createTable(database);
        OpdDetailsRepository.createTable(database);
    }
    

2. Required Implementations

OpdRegisterFragment

This class should extend org.smartregister.opd.fragment.BaseOpdRegisterFragment This implements

The following methods are implemented


 protected void startRegistration();

 protected void performPatientAction(@NonNull CommonPersonObjectClient commonPersonObjectClient);

 protected void goToClientDetailActivity(@NonNull CommonPersonObjectClient commonPersonObjectClient);

3. Enable OPD Registration

Add the following bindobject to your ec_client_fields bindobjects array:

{
      "name": "ec_client",
      "columns": [
        {
          "column_name": "base_entity_id",
          "type": "Client",
          "json_mapping": {
            "field": "baseEntityId"
          }
        },
        {
          "column_name": "opensrp_id",
          "type": "Client",
          "json_mapping": {
            "field": "identifiers.OPENSRP_ID"
          }
        },
        {
          "column_name": "first_name",
          "type": "Client",
          "json_mapping": {
            "field": "firstName"
          }
        },
        {
          "column_name": "last_name",
          "type": "Client",
          "json_mapping": {
            "field": "lastName"
          }
        },
        {
          "column_name": "dob",
          "type": "Client",
          "json_mapping": {
            "field": "birthdate"
          }
        },
        {
          "column_name": "national_id",
          "type": "Client",
          "json_mapping": {
            "field": "attributes.national_id"
          }
        },
        {
          "column_name": "opd_reg_number",
          "type": "Client",
          "json_mapping": {
            "field": "attributes.annual_serial_number"
          }
        },
        {
          "column_name": "bht_mid",
          "type": "Client",
          "json_mapping": {
            "field": "identifiers.bht_mid"
          }
        },
        {
          "column_name": "phone_number",
          "type": "Client",
          "json_mapping": {
            "field": "attributes.phone_number"
          }
        },
        {
          "column_name": "reminders",
          "type": "Client",
          "json_mapping": {
            "field": "attributes.reminders"
          }
        },
        {
          "column_name": "gender",
          "type": "Client",
          "json_mapping": {
            "field": "gender"
          }
        },
        {
          "column_name": "date",
          "type": "Event",
          "json_mapping": {
            "field": "eventDate"
          }
        },
        {
          "column_name": "date_removed",
          "type": "Client",
          "json_mapping": {
            "field": "attributes.dateRemoved"
          }
        }
      ]
    }