Purpose: get all of the data associated with a case, including all case property values, a list of associated forms and a list of associated referrals. The case data may be presented to the end user as a case details screen.

Base URL: https://www.commcarehq.org/a/[domain]/api/[version]/case/[case_id]/

Input parameters:

NameDescriptionValuesExampleStatus
formatReturn data format

xml, json

format=xmlSupported

properties

Whether to include properties

all, none

properties=allProposed
indicesWhether to include indicesall, noneindices=allProposed
xforms_by_name__fullWhether to include all xforms by nametruexforms_by_name__full=trueSupported
xforms_by_xmls__fullWhether to include all xforms by xmlnstruexforms_by_xmlns__full=trueSupported
child_cases__fullWhether to include child casestruechild_cases__full=trueSupported since version 4
parent_cases__fullWhether to include parent casestrueparent_cases__full=trueSupported since version 4

Output values: 

NameDescriptionExample
case_idCase UUID0X9OCW3JMV98EYOVN32SGN4II
user_nameUser name of case owner, including domainjdoe@example.commcarehq.org
user_idUUID of user that owns the case3c5a623af057e23a32ae4000cf291339
date_modifiedDate and time case was last modified2011-12-13T15:09:47Z
closedStatus of the case (open, closed)false
date_closedDate and time case was closed2011-12-20T15:09:47Z
propertiesList of all editable case properties, including both special predefined properties and user-defined dynamic properties
Special Properties
owner_idID of the owner of the case (can be user or group)
case_nameName of caseRose
external_idExternal ID associated with the case123456
case_typeType of casepregnancy
date_openedDate and time case was opened2011-11-16T14:26:15Z
End Special Properties
indicesList of references to other cases with properties <case_type/> and <case_id/>
Start of data from for each form associated with the case
Repeats for each form, as seen in sample output below
form_idUUID of form associated with the case1J9NF7B4FTH73435PYJJSL5SJ
form_nameName of form associated with the casePrenatal visit
started_onDate and time form was started2011-11-16T14:26:15Z
ended_onDate and time form was completed2011-11-16T14:27:35Z

 

Sample usage:

https://www.commcarehq.org/a/demo/api/v0.4/case/0X9OCW3JMV98EYOVN32SGN4II/?format=xml&properties=all&indices=all

Sample output:

<case>
	<domain>example</domain>
	<case_id>0X9OCW3JMV98EYOVN32SGN4II</case_id>
	<username>jdoe@example.commcarehq.org</user_name>
	<user_id>3c5a623af057e23a32ae4000cf291339</user_id>
	<closed>false</closed>
	<date_closed>2011-12-20 15:09:47Z</date_closed>
	<date_modified>2011-12-13 15:09:47Z</date_modified>
	<properties>
		<case_name>Rose</case_name>
		<case_type>pregnancy</case_type>
		<date_opened>2011-11-16T14:26:15Z</date_opened>
		<external_id>123456</external_id>
		<owner_id>3c5a623af057e23a32ae4000cf291339</owner_id>
		<case_property1>Dynamic property value 1</case_property1>
		<case_property2>Dynamic property value 2</case_property2>
		...
	</properties>
	<indices>
		<case_ref1>
			<case_type>other_case_type</case_type>
			<case_id>8GPM05TVPIUH0Q4XLXVIURRTA</case_id>
		</case_ref1>
		...
	</indices>
	<forms>
		<form>
			<form_id>1J9NF7B4FTH73435PYJJSL5SJ</form_id>
			<form_name>Prenatal visit</form_name>
			<started_on>2011-11-16T14:26:15Z</started_on>
			<ended_on>2011-11-16T14:27:35Z</ended_on>
			<properties>
				<form_property1>Dynamic property value 1</form_property1>
				<form_property2>Dynamic property value 2</form_property2>
				...
			</properties>
		</form>
		...
	</forms>
	<referrals>
		<referral>
			<referral_id>D8LZS28LEUWU7W9QNDM89XWPL</referral_id>
			<referral_type>referred_to_health_center</referral_type>
			<opened_on>2011-11-17T14:26:15Z</opened_on>
			<modified_on>2011-11-17T14:27:10Z</modified_on>
			<followup_on>2011-11-19T00:00:00Z</followup_on>
			<referral_status>open</referral_status>
		</referral>
		...
	<referrals>
	...
</case>

 

 

 

  • No labels

2 Comments

  1. After considering some potential uses of this API call, I have one suggestion to consider....

    Including form property values in the return data set.  By including form property values in the returned xml/json document, the application could include form property values (e.g. patient name) in a "case details" screen without separately fetching information about each form.  For example, building a case details web page that includes a table of patient weights from every prenatal visit.  The encoding of the form properties would match how form properties are included in the Form Data API response.

  2. The user_name property does seem to be part of the response. The API request has no options other than the case_id.

     

    D, [2014-11-01T10:27:13.235028 #1943] DEBUG -- : HTTPI GET request to www.commcarehq.org (httpclient)
    {
      "case_id": "238a835a-047a-4f90-9143-970073586a36",
      "closed": false,
      "date_closed": null,
      "date_modified": "2014-09-27 14:53:22",
      "domain": "sara-csps",
      "id": "238a835a-047a-4f90-9143-970073586a36",
      "indices": {
      },
      "properties": {
        "case_name": "yako-bouria-2015-04",
        "case_type": "qi_report",
        "consults_eval_class_ok_D": "78",
        "consults_eval_class_ok_I": "15.384615384615385",
        "consults_eval_class_ok_N": "12",
        "consults_treat_ok_D": "78",
        "consults_treat_ok_I": "57.692307692307686",
        "consults_treat_ok_N": "45",
        "consults_with_rec_D": "45",
        "consults_with_rec_I": "26.666666666666668",
        "consults_with_rec_N": "12",
        "date_opened": "2014-09-27T14:53:22",
        "days_rec_down_I": "42",
        "district": "yako",
        "external_id": null,
        "health_facility": "bouria",
        "medicine_outage_I": "5",
        "month": "04",
        "owner_id": "511956171be6cbf52e6b686ee99ca79e",
        "report_date": "2015-04",
        "year": "2015"
      },
      "resource_uri": "",
      "server_date_modified": "2014-09-27 14:53:29",
      "server_date_opened": "2014-09-27 14:53:27",
      "user_id": "511956171be6cbf52e6b686ee99ca79e",
      "xform_ids": [
        "fa20b61e-c33a-4dfb-8091-348b582a50f3"
      ]
    }