Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Procedure group sync pr #12

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
import org.sana.android.db.impl.NotificationsHelper;
import org.sana.android.db.impl.ObservationsHelper;
import org.sana.android.db.impl.ObserversHelper;
import org.sana.android.db.impl.ProcedureGroupsHelper;
import org.sana.android.db.impl.ProceduresHelper;
import org.sana.android.db.impl.SubjectsHelper;

Expand Down Expand Up @@ -110,6 +111,8 @@ protected TableHelper<?> getTableHelper(Uri uri) {
return SubjectsHelper.getInstance();
case (Uris.ENCOUNTER_TASK):
return EncounterTasksHelper.getInstance();
case (Uris.PROCEDURE_GROUP):
return ProcedureGroupsHelper.getInstance();
default:
throw new IllegalArgumentException("Invalid uri in "
+ "getTableHelper(): " + uri.toString());
Expand Down
13 changes: 13 additions & 0 deletions api-android/src/main/java/org/sana/android/content/Uris.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
import org.sana.android.provider.ObservationTasks;
import org.sana.android.provider.Observations;
import org.sana.android.provider.Observers;
import org.sana.android.provider.ProcedureGroups;
import org.sana.android.provider.Procedures;
import org.sana.android.provider.Subjects;
import org.sana.util.UUIDUtil;
Expand Down Expand Up @@ -145,6 +146,7 @@ static interface Settings{
public static final int SUBJECT = 512 << CONTENT_SHIFT;
public static final int ENCOUNTER_TASK = 1024 << CONTENT_SHIFT;
public static final int OBSERVATION_TASK = 2048 << CONTENT_SHIFT;
public static final int PROCEDURE_GROUP = 4096 << CONTENT_SHIFT;

// dir match codes OBJECT | ITEMS
public static final int CONCEPT_DIR = CONCEPT | ITEMS;
Expand All @@ -159,6 +161,7 @@ static interface Settings{
public static final int SUBJECT_DIR = SUBJECT | ITEMS;
public static final int ENCOUNTER_TASK_DIR = ENCOUNTER_TASK | ITEMS;
public static final int OBSERVATION_TASK_DIR = OBSERVATION_TASK | ITEMS;
public static final int PROCEDURE_GROUP_DIR = PROCEDURE_GROUP | ITEMS;

// item match codes OBJECT | ITEM_ID
public static final int CONCEPT_ITEM = CONCEPT | ITEM_ID;
Expand All @@ -173,6 +176,7 @@ static interface Settings{
public static final int SUBJECT_ITEM = SUBJECT | ITEM_ID;
public static final int ENCOUNTER_TASK_ITEM = ENCOUNTER_TASK | ITEM_ID;
public static final int OBSERVATION_TASK_ITEM = OBSERVATION_TASK | ITEM_ID;
public static final int PROCEDURE_GROUP_ITEM = PROCEDURE_GROUP | ITEM_ID;

// item match codes OBJECT | ITEM_UUID
public static final int CONCEPT_UUID = CONCEPT | ITEM_UUID;
Expand All @@ -187,6 +191,7 @@ static interface Settings{
public static final int SUBJECT_UUID = SUBJECT | ITEM_UUID;
public static final int ENCOUNTER_TASK_UUID = ENCOUNTER_TASK | ITEM_UUID;
public static final int OBSERVATION_TASK_UUID = OBSERVATION_TASK | ITEM_UUID;
public static final int PROCEDURE_GROUP_UUID = PROCEDURE_GROUP | ITEM_UUID;

// Matcher for mapping the Uri to code mappings
private static final UriMatcher mMatcher = new UriMatcher(UriMatcher.NO_MATCH);
Expand Down Expand Up @@ -233,6 +238,9 @@ static interface Settings{
mMatcher.addURI(Models.AUTHORITY, "core/patient/", SUBJECT_DIR);
mMatcher.addURI(Models.AUTHORITY, "core/patient/#", SUBJECT_ITEM);
mMatcher.addURI(Models.AUTHORITY, "core/patient/*", SUBJECT_UUID);
mMatcher.addURI(Models.AUTHORITY, "core/proceduregroup/", PROCEDURE_GROUP_DIR);
mMatcher.addURI(Models.AUTHORITY, "core/proceduregroup/#", PROCEDURE_GROUP_ITEM);
mMatcher.addURI(Models.AUTHORITY, "core/proceduregroup/*", PROCEDURE_GROUP_UUID);

mMatcher.addURI(Models.AUTHORITY, "tasks/encounter/", ENCOUNTER_TASK_DIR);
mMatcher.addURI(Models.AUTHORITY, "tasks/encounter/#", ENCOUNTER_TASK_ITEM);
Expand Down Expand Up @@ -417,6 +425,11 @@ public static String getType(Uri uri) {
case OBSERVATION_TASK_UUID:
case OBSERVATION_TASK_ITEM:
return ObservationTasks.CONTENT_ITEM_TYPE;
case PROCEDURE_GROUP_DIR:
return ProcedureGroups.CONTENT_TYPE;
case PROCEDURE_GROUP_UUID:
case PROCEDURE_GROUP_ITEM:
return ProcedureGroups.CONTENT_ITEM_TYPE;
case PACKAGE_DIR:
return "application/vnd.android.package-archive";
default:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
/**
* Copyright (c) 2013, Sana
* All rights reserved.
* <p>
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* <p>
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the Sana nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
* <p>
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL Sana BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package org.sana.android.db.impl;

import android.content.ContentValues;
import android.net.Uri;
import android.util.Log;

import org.sana.android.db.TableHelper;
import org.sana.android.provider.ProcedureGroups.Contract;
import org.sana.core.ProcedureGroup;

/**
* A database table helper for a table of procedure groups.
*
* @author Sana Development
*
*/
public class ProcedureGroupsHelper extends TableHelper<ProcedureGroup> {
public static final String TAG = ProcedureGroupsHelper.class.getSimpleName();

private static final ProcedureGroupsHelper HELPER = new ProcedureGroupsHelper();

/**
* Gets the singleton instance of this class.
*
* @return An instance of this class.
*/
public static ProcedureGroupsHelper getInstance() {
return HELPER;
}

protected ProcedureGroupsHelper() {
super(ProcedureGroup.class);
}

/* (non-Javadoc)
* @see org.sana.android.db.InsertHelper#onInsert(android.net.Uri, android.content.ContentValues)
*/
@Override
public ContentValues onInsert(ContentValues values) {
return super.onInsert(values);
}

/* (non-Javadoc)
* @see org.sana.android.db.UpdateHelper#onUpdate(java.lang.String, android.content.ContentValues, java.lang.String, java.lang.String[])
*/
@Override
public ContentValues onUpdate(Uri uri, ContentValues values) {
return super.onUpdate(uri, values);
}

/* (non-Javadoc)
* @see org.sana.android.db.CreateHelper#onCreate(android.database.sqlite.SQLiteDatabase)
*/
@Override
public String onCreate() {
Log.i(TAG, "onCreate()");
return "CREATE TABLE " + getTable() + " ("
+ Contract.UUID + " TEXT PRIMARY KEY, "
+ Contract.CREATED + " DATE, "
+ Contract.MODIFIED + " DATE, "
+ Contract.TITLE + " TEXT NOT NULL, "
+ Contract.AUTHOR + " TEXT NOT NULL, "
+ Contract.DESCRIPTION + " TEXT, "
+ Contract.PROCEDURE_NAMES + " TEXT "
+ ");";
}

/* (non-Javadoc)
* @see org.sana.android.db.UpgradeHelper#onUpgrade(int, int)
*/
@Override
public String onUpgrade(int oldVersion, int newVersion) {
// TODO Auto-generated method stub
return null;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
/**
* Copyright (c) 2013, Sana
* All rights reserved.
* <p>
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* <p>
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the Sana nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
* <p>
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL Sana BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package org.sana.android.provider;

import android.net.Uri;

import org.sana.core.ProcedureGroup;

/**
* Metadata and contract for procedure groups in the database.
*
* @author Sana Development Team
*/
public class ProcedureGroups {

/** The authority for procedure groups. */
public static final String AUTHORITY = "org.sana.provider";

/** The content:// style URI for this content provider. */
public static final Uri CONTENT_URI = Uri.parse("content://"
+ AUTHORITY + "/core/proceduregroup");

/** The MIME type for a directory of procedure groups. */
public static final String CONTENT_TYPE =
"vnd.android.cursor.dir/org.sana.proceduregroup";

/** The MIME type of single procedure group. */
public static final String CONTENT_ITEM_TYPE =
"vnd.android.cursor.item/org.sana.proceduregroup";

/** The default sort order. */
public static final String DEFAULT_SORT_ORDER = "modified DESC";

/**
* Contract for the Procedure Groups table in the database.
*
* @author Sana Development
*
*/
public interface Contract extends BaseContract<ProcedureGroup> {
/** The title of the procedure group. */
String TITLE = "title";

/** The author of the procedure group. */
String AUTHOR = "author";

/** The description of the procedure group. */
String DESCRIPTION = "description";

/** A list of ids of the procedures. */
String PROCEDURE_NAMES = "procedure_names";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public class Subjects {

/** The content:// style URI for this content provider. */
public static final Uri CONTENT_URI = Uri.parse("content://"
+ AUTHORITY + "/core/subject");
+ AUTHORITY + "core/subject");

/** The MIME type of CONTENT_URI providing a directory of subjects. */
public static final String CONTENT_TYPE =
Expand Down
57 changes: 57 additions & 0 deletions api/src/main/java/org/sana/api/IProcedureGroup.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/**
* Copyright (c) 2013, Sana
* All rights reserved.
* <p>
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* <p>
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the Sana nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
* <p>
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL Sana BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package org.sana.api;

import java.util.List;

/**
* @author Sana Development
*
*/
public interface IProcedureGroup extends IModel {

/**
* @return the title
*/
String getTitle();

/**
* @return the author
*/
String getAuthor();

/**
* @return the description
*/
String getDescription();

/**
* @return the list of associated procedure ids
*/
List<String> getProcedureNames();
}
65 changes: 65 additions & 0 deletions api/src/main/java/org/sana/core/ProcedureGroup.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
/**
* Copyright (c) 2013, Sana
* All rights reserved.
* <p>
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* <p>
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the Sana nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
* <p>
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL Sana BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package org.sana.core;

import org.sana.api.IProcedureGroup;

import java.util.List;


/**
* A group of Procedures
*
* @author Sana Development
*/
public class ProcedureGroup extends Model implements IProcedureGroup {
private String title;
private String author;
private String description;
private List<String> procedures;

@Override
public String getTitle() {
return this.title;
}

@Override
public String getAuthor() {
return this.author;
}

@Override
public String getDescription() {
return this.description;
}

@Override
public List<String> getProcedureNames() {
return this.procedures;
}
}
Loading