Data Sets - openmrs/openmrs-module-reportingrest GitHub Wiki

Table of Contents

dataSetDefinition

Represents saved user-defined dataset definitions.

GET .../dataSetDefinition

Lists all saved dataset definitions

GET .../dataSetDefinition?q=:text

Searches for dataset definitions that contain :text in their name or description

GET .../dataSetDefinition/:uuid

Gets the definition with the given :uuid

POST .../dataSetDefinition/:uuid

Updates the definition with the given :uuid. Only supports modifying name and description. (The actual query instructions can't be modified via REST.)

DELETE .../dataSetDefinition/:uuid

Marks the definition with the given :uuid as deleted.

DELETE .../dataSetDefinition/:uuid?purge=true

Deletes the definition with the given :uuid forever.

Example full representation

{
  "class": "org.openmrs.module.reporting.dataset.definition.SqlDataSetDefinition",
  "uuid": "171fccec-4bd0-41a8-b5f3-a93f54c40040",
  "name": "encounter by type",
  "description": "encounter by type",
  "parameters": [],
  "links": [
	{
	  "rel": "self",
	  "uri": "http://qa-refapp.openmrs.org/openmrs/ws/reporting/v1/reportingrest/dataSetDefinition/171fccec-4bd0-41a8-b5f3-a93f54c40040"
	}
  ],
  "resourceVersion": "1.8"
}

dataSet

Lets you evaluate dataset definitions, either built-in, saved, or specified on the fly.

See Evaluated Resources.

GET .../dataSet/:uuid

GET .../dataSet/:definitionLibraryKey

Evaluates a built-in or saved dataset definition. You may specify it as:

  • the UUID of a saved user-defined definition
  • the key of a definition in a definition library (since 1.8.0)

GET .../dataSet/:uuidOrDefinitionKey?cohort=:cohort

GET .../dataSet/:uuidOrDefinitionKey?cohort=:cohort&cohort.param=val

Evaluates a cohort, then uses it as the base cohort when evaluating the dataset.

Example:

GET .../dataSet/171fccec-4bd0-41a8-b5f3-a93f54c40040?cohort=reporting.library.cohortDefinition.builtIn.males

POST .../dataSet

Evaluates a dataSet definition specified on the fly in the POST body. See Evaluated Resources#post-serialized-xml

Sample evaluated dataSet response:

{
  "uuid": "171fccec-4bd0-41a8-b5f3-a93f54c40040",
  "metadata": {
	"columns": [
	  {
		"datatype": "java.lang.Object",
		"name": "encounter_id",
		"label": "encounter_id"
	  },
	  {
		"datatype": "java.lang.Object",
		"name": "enc_type",
		"label": "enc_type"
	  }
	]
  },
  "rows": [
	{
	  "enc_type": "Admission",
	  "encounter_id": 3945
	},
	{
	  "enc_type": "Vitals",
	  "encounter_id": 2618
	},
	{
	  "enc_type": "Vitals",
	  "encounter_id": 1860
	}
  ],
  "definition": {
	"class": "org.openmrs.module.reporting.dataset.definition.SqlDataSetDefinition",
	"uuid": "171fccec-4bd0-41a8-b5f3-a93f54c40040",
	"name": "encounter by type",
	"description": "encounter by type",
	"parameters": [],
	"links": [
	  {
		"rel": "self",
		"uri": "http://qa-refapp.openmrs.org/openmrs/ws/reporting/v1/reportingrest/dataSetDefinition/171fccec-4bd0-41a8-b5f3-a93f54c40040"
	  },
	  {
		"rel": "full",
		"uri": "http://qa-refapp.openmrs.org/openmrs/ws/reporting/v1/reportingrest/dataSetDefinition/171fccec-4bd0-41a8-b5f3-a93f54c40040?v=full"
	  }
	],
	"resourceVersion": "1.8"
  },
  "links": [
	{
	  "rel": "self",
	  "uri": "http://qa-refapp.openmrs.org/openmrs/ws/rest/v1/reportingrest/dataSet/171fccec-4bd0-41a8-b5f3-a93f54c40040"
	}
  ],
  "resourceVersion": "1.8"
}