This library provides the ability to show an OPD(Outpatient Department) Register to a client application
Add the module to your project as follows
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'
}
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
Add your implemented OpdRegisterActivity
to the Android.manifest
file
Call OpdRegisterActivity
from your navigation menu
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);
}
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);
startRegistration()
implementationperformPatientAction(@NonNull CommonPersonObjectClient)
implementationYou should add your logic for openning the client profile activity in the implementation of goToClientDetailActivity(@NonNull CommonPersonObjectClient)
This class should extend org.smartregister.opd.presenter.BaseOpdRegisterActivityPresenter
.
This implements the interface method in org.smartregister.opd.contract.OpdRegisterActivityContract.Presenter
not implemented in abstract class org.smartregister.opd.presenter.BaseOpdRegisterActivityPresenter
void saveForm(String jsonString, boolean isEditMode);
You should perform the logic for:
in your implementation of saveForm(String, boolean);
This class should extend org.smartregister.opd.activity.BaseOpdRegisterActivity
.
This implements the abstract method in org.smartregister.opd.activity.BaseOpdRegisterActivity
protected BaseOpdRegisterActivityPresenter createPresenter(@NonNull OpdRegisterActivityContract.View view, @NonNull OpdRegisterActivityContract.Model model);
public void startFormActivity(JSONObject jsonObject);
protected void onActivityResultExtended(int i, int i1, Intent intent);
public void startRegistration();
You should add basically create a new instance of the Presenter implemented above
return new OpdRegisterActivityPresenter(view, model);
in your implementation of BaseOpdRegisterActivityPresenter createPresenter(@NonNull OpdRegisterActivityContract.View, @NonNull OpdRegisterActivityContract.Model)
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"
}
}
]
}