Specification of the schema usage and changes needed to meet CiviCase requirements/use cases for phase one. |
Case (civicrm_case)
Field |
Type |
CiviCase Usage Notes |
|---|---|---|
id |
int(10) unsigned |
Unique identifier for the case. |
case_type_id |
varchar(128) |
Assign one or more "types" from an admin configurable list of case types. We will cache the latest determination about "what type of case this is" in this field. Refer to Case / Event Attributes and their inheritance in the Requirements document for discussion of case attributes. |
subject |
varchar(128) |
A brief "description" or "title" for the case - shown when cases are listed. |
start_date |
date |
Opening date for the case. Set this value when an Activity with type = "Open Case" is recorded. |
end_date |
date |
Closing date for the case. Set this value when an Activity with type = "Close Case" is recorded. |
details |
text |
Case overview. |
status_id |
int(10) unsigned |
Admin configurable list of status values (foreign key). Current values are "Ongoing", "Resolved". |
Changes to Case
- Implement custom field functionality for Case object.
Relationship (civicrm_relationship)
Relationships will be used to store "Case Roles" by extending the schema to provide linkage between a relationship and a case (in addition to linking the case service provider to the client).
EXAMPLE: In a Physician Health case the roles might be: subject ("client"), primary care physician, workplace monitor, drug screen supervisor, licensing authority representative, medical staff assosciation representative, etc. The "client" is linked directly to the case (civicrm_case.contact_id). The other people are related to the case through a Relationship of a given type. "Drug Screen Supervisor" would be a relationship type.
Note that we would have the flexibility to decide whether the Relationship should be used to link the person in the role to the Case or not. Relationships which persist outside of the case context would NOT have the case linkage. Spouse would definitely link client to their husband / wife without a case linkage. Primary Care physician might be related to the Case or not, based on whether this relationship persists beyond the scope of the Case.
Field |
Type |
CiviCase Usage Notes |
|---|---|---|
id |
int(10) |
Unique identifier for this relationship. |
contact_id_a |
int(10) |
Person A in relationship. This will be the client by convention for CiviCase relationships. |
contact_id_b |
int(10) |
Person B in relationship. |
relationship_type_id |
int(10) |
Admin configurable set of relationship types. |
start_date |
date |
Date relationship began. For CiviCase, this could mark when the person in this role got involved in the case. For person <-> person relationships like Spouse, this would be when that relationship started. |
end_date |
date |
For CiviCase, this could mark when the person in this role stopped working on the case. This allows us to track sequential role assignments - e.g. Pat was Drug Screen Supervisor for this case from June 1, 2007 until Jan 10, 2008. Jerry took over this "role" on Jan 11 (this would be a separate Relationship record). |
is_active |
Yes/No |
Relationships w/ End Date < today are considered "inactive". You can also use this flag to do the same - but an end date is not necessarily stored. |
description |
varchar(255) |
Free-form brief description of THIS relationship. |
is_permission_a_b |
Yes/No |
This is currently used in a very limited way for Employee <-> Employer relationships. For now, we will NOT use this for case permissioning. |
is_permission_b_a |
Yes/No |
(see above) |
Changes to Relationship
- Add an optional foreign key - case_id - to civicrm_relationship table.
NOTE: We will need to create relationships where the case_id and contact_id_a (client) are defined, but the service provider (client_id_b) is not yet assigned (NULL). The schema currently supports this, but there may be business rules in the code which need to be modified to allow it.
Activity (civicrm_activity)
Current schema (as of 2.1)
Field |
Type |
CiviCase Usage Notes |
|---|---|---|
id |
int(10) unsigned |
Unique primary key for each activity |
source_contact_id |
int(10) unsigned |
Person who reported the activity. This may or may NOT be the person entering the activity in the system. |
source_record_id |
int(10) unsigned |
Used to link activity to a transaction such as a contribution or a membership signup or email sent. No special usage for CiviCase activities. |
activity_type_id |
int(10) unsigned |
Admin configurable list of types (foreign key). Pre-configured types might include: Goal, Milestone, Case Opened, Case Closed, Health Status... |
subject |
varchar(255) |
Free form short description of the activity. |
activity_date_time |
datetime |
When the activity occurred or is scheduled to occur. When a non-observed activity is recorded - this would be the date / time it actually occurred. |
due_date_time |
datetime |
Not currently used / exposed (CiviCRM 2.1). We will use this for scheduled activities (including goals) to record when we expect them to happen. Then use activity_date_time to record when they actually happened. |
duration |
int(10) unsigned |
Duration of activity. Useful for service provider to track amount of time spent in client interactions |
location |
varchar(255) |
Free-form text for where the activity will or has occurred. |
phone_id |
int(10) unsigned |
Foreign key to an existing phone number (belonging to the client |
phone_number |
varchar(64) |
|
details |
text |
This is where detailed notes about the activity are stored. For example, counseling session notes... |
status_id |
int(10) unsigned |
Admin configurable list of activity status values (foreign key). Pre-configured statuses might include: Scheduled, Completed, Cancelled... |
priority_id |
int(10) unsigned |
Admin configurable list of priority values (foreign key). Might use this to assign importance rating or ...? |
parent_id |
int(10) unsigned |
Intended to be used for nested activities. No CiviCase usage at this time. |
is_test |
tinyint(4) |
(probably not used for CiviCase) |
Changes to Activity Type
CiviCase will have lots of activity types and users will need to filter activity listings (and input of activity type) using categories. In order to accomplish this, we'll need to move Activity Types out of the current storage in civicrm_option_value (which doesn't support categorization). We'll use single recursive table model to allow storing hierarchical categorisation. In phase 1, we'll limit it programmatically to two levels (top level will be categories, second level will be actual types), but the model will allow more depth if need be, for future versions.
- New table - civicrm_category
- id
- label VARCHAR 255 - the displayed label for this category, can be modified / translated
- name VARCHAR 255 - the internal name for this category, not editable for reserved records so we can use as the key for programmed behaviors
- weight INT
- description VARCHAR 255
- is_active BOOLEAN
- is_reserved BOOLEAN
- parent_id INT FK to civicrm_category.id
- component_id INT FK to civicrm_component.id
Changes to Activity
- Add the following columns:
- medium INT implicit FK to civicrm_option_value (option_group = activity_medium). Used to record the "encounter" medium, e.g. Face-to-face, Inbound phone, Letter, Email, etc.
- is_auto BOOLEAN, Set to true for activities which have been automatically inserted when Case is created. Records with is_auto TRUE will NOT be revisioned when edited by a user - but the flag will be set FALSE in post process. This gives us an easy way to tell which records have been altered by a user.
- relationship_id INT Optional FK to civicrm_relationship table. Used to record the relationship that the source contact has with the "client". This is needed because service providers may fulfill multiple 'roles' in a case.
- Activity Type will be moved back to it's own table. Change activity_type_id to be a "real" foreign key to civicrm_activity_type.id
NOTE: Whenever an activity record is inserted, the date-time and ID of the contact who created each activity will be recorded to the civicrm_log table.
NOTE: Since the "reporter" (source) is always a contact record, the Activity form will need to include an easy way for the user to create a new contact record if that person hasn't been entered in the system yet AND assign them a relationship (case role) if needed. This can work something like the "Current Employer" field in contact editing (but with the additional ability to define a relationship).
Activity Target(s) (civicrm_activity_target)
The target is the contact(s) whom the activity is "about" or "regarding". For CiviCase activities, this will always be the client.
Field |
Type |
CiviCase Usage Notes |
|---|---|---|
activity_id |
int(10) unsigned |
Foreign key to the Activity record. |
target_contact_id |
int(10) unsigned |
Foreign key to the target contact. |
| Activity Usage Example Case Manager meets with Parole Officer about Jane Doe (client): |
Activity Assignment (civicrm_activity_assignment)
One or more contacts assigned to do the activity. Case managers might "assign" other staff to handle activities related to the case.
Field |
Type |
CiviCase Usage Notes |
|---|---|---|
activity_id |
int(10) unsigned |
Foreign key to the Activity record. |
assignee_contact_id |
int(10) unsigned |
Foreign key to the assigned contact. |
