Skip to content
Darius Jazayeri edited this page Mar 25, 2017 · 2 revisions

Table of Contents

reportDefinition

Represents saved user-defined report definitions.

GET .../reportDefinition

Lists all saved report definitions

GET .../reportDefinition?q=:text

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

GET .../reportDefinition/:uuid

Gets the definition with the given :uuid

POST .../reportDefinition/:uuid

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

DELETE .../reportDefinition/:uuid

Marks the definition with the given :uuid as deleted.

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

Deletes the definition with the given :uuid forever.

Example full representation

{
  "class": "org.openmrs.module.reporting.report.definition.ReportDefinition",
  "uuid": "0deca109-73ea-4cb1-9bda-7805e516c278",
  "name": "ID Card",
  "description": "A report to print ID Cards.",
  "parameters": [
	{
	  "name": "person",
	  "label": "person",
	  "type": "org.openmrs.Person"
	}
  ],
  "links": [
	{
	  "rel": "self",
	  "uri": "http://qa-refapp.openmrs.org/openmrs/ws/reporting/v1/reportingrest/reportDefinition/0deca109-73ea-4cb1-9bda-7805e516c278"
	}
  ],
  "resourceVersion": "1.8"
}

reportdata

Lets you evaluate report definitions, either saved, or specified on the fly. This will produce report data, but it will not run any ReportRenderer. (To do that, see the reportRequest resource.)

See Evaluated Resources.

This resource has not been tested as well as others, and you may find it buggy. Please report any bugs you find on talk.openmrs.org or issues.openmrs.org.

GET .../reportdata/:uuid

Evaluates a saved dataset definition, given the UUID of a saved user-defined definition.

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

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

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

Example:

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

POST .../reportdata

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

Sample evaluated report response:

{
  "uuid": "71207ad2-ee92-4034-b502-a6f1309107cd",
  "dataSets": [
    {
      "uuid": "5249178e-8f34-42a3-9b74-2bf6c5c36bf9",
      "metadata": {
        "columns": [
          {
            "datatype": "java.lang.String",
            "name": "OpenMRS ID",
            "label": "OpenMRS ID"
          },
          {
            "datatype": "java.lang.String",
            "name": "MA Id",
            "label": "MA Id"
          },
          {
            "datatype": "java.lang.String",
            "name": "givenName",
            "label": "givenName"
          },
          {
            "datatype": "java.lang.String",
            "name": "familyName",
            "label": "familyName"
          },
          {
            "datatype": "java.util.Date",
            "name": "birthdate",
            "label": "birthdate"
          }
        ]
      },
      "rows": [
        {
          "birthdate": 353998800000,
          "givenName": "ahfa",
          "familyName": "haiha",
          "OpenMRS ID": "1000C6",
          "MA Id": null
        },
        {
          "birthdate": 6843600000,
          "givenName": "new",
          "familyName": "patient",
          "OpenMRS ID": "10032N",
          "MA Id": null
        },
        {
          "birthdate": 324190800000,
          "givenName": "Fernando",
          "familyName": "Waters",
          "OpenMRS ID": "10046D",
          "MA Id": null
        },
        {
          "birthdate": 465883200000,
          "givenName": "Darius",
          "familyName": "Manual Test",
          "OpenMRS ID": "100496",
          "MA Id": null
        }
      ],
      "definition": {
        "class": "org.openmrs.module.reporting.dataset.definition.SimplePatientDataSetDefinition",
        "uuid": "5249178e-8f34-42a3-9b74-2bf6c5c36bf9",
        "name": "Simple Dataset",
        "description": "",
        "parameters": [],
        "links": [
          {
            "rel": "self",
            "uri": "http://qa-refapp.openmrs.org/openmrs/ws/reporting/v1/reportingrest/dataSetDefinition/5249178e-8f34-42a3-9b74-2bf6c5c36bf9"
          },
          {
            "rel": "full",
            "uri": "http://qa-refapp.openmrs.org/openmrs/ws/reporting/v1/reportingrest/dataSetDefinition/5249178e-8f34-42a3-9b74-2bf6c5c36bf9?v=full"
          }
        ],
        "resourceVersion": "1.8"
      },
      "links": [
        {
          "rel": "self",
          "uri": "http://qa-refapp.openmrs.org/openmrs/ws/rest/v1/reportingrest/dataSet/5249178e-8f34-42a3-9b74-2bf6c5c36bf9"
        }
      ],
      "resourceVersion": "1.8"
    }
  ],
  "context": {
    "evaluationId": 74,
    "limit": null,
    "baseCohort": null,
    "contextValues": {
      "start_of_today": 1490414400000,
      "end_of_last_month": 1488344399999,
      "now": 1490437004662,
      "start_of_last_month": 1485925200000,
      "generationDate": 1490437004662,
      "end_of_today": 1490500799999,
      "generatedBy": "Super User"
    },
    "parameterValues": {},
    "evaluationDate": 1490437004662,
    "evaluationLevel": 1,
    "allBaseIdSets": {},
    "now": 1490437004662
  },
  "definition": {
    "class": "org.openmrs.module.reporting.report.definition.ReportDefinition",
    "uuid": "71207ad2-ee92-4034-b502-a6f1309107cd",
    "name": "Simple Report",
    "description": "sdcsdcds",
    "parameters": [],
    "links": [
      {
        "rel": "self",
        "uri": "http://qa-refapp.openmrs.org/openmrs/ws/reporting/v1/reportingrest/reportDefinition/71207ad2-ee92-4034-b502-a6f1309107cd"
      },
      {
        "rel": "full",
        "uri": "http://qa-refapp.openmrs.org/openmrs/ws/reporting/v1/reportingrest/reportDefinition/71207ad2-ee92-4034-b502-a6f1309107cd?v=full"
      }
    ],
    "resourceVersion": "1.8"
  },
  "links": [
    {
      "rel": "self",
      "uri": "http://qa-refapp.openmrs.org/openmrs/ws/rest/v1/reportingrest/reportdata/71207ad2-ee92-4034-b502-a6f1309107cd"
    }
  ],
  "resourceVersion": "1.8"
}

reportRequest

Check on the queue and status of asynchronously-run reports. This includes both reports being run now, as well as the past several days of runs that haven't been cleared out yet.

At present this resource's functionality is very limited; you can only track requests and delete them, but not create or update them.

GET .../reportRequest?reportDefinition=:uuid

Lists all requests for the given report definition

GET .../reportRequest/:uuid

Get a single report request

DELETE .../reportRequest/:uuid

Deletes a single report request forever (i.e. does a purge, not a soft-delete). If the request is currently being processed, the system will attempt to cancel it.

Sample full representation:

{
  "uuid": "4e087b92-fcfb-43e7-b53d-3707f6e1cc74",
  "renderingMode": {
    "rendererType": "org.openmrs.module.reporting.web.renderers.DefaultWebRenderer",
    "argument": null,
    "label": "DefaultWebRenderer",
    "sortWeight": null
  },
  "priority": "HIGHEST",
  "requestedBy": {
    "uuid": "70709520-6c84-4518-9f3d-00823a6306ab",
    "display": "admin",
    // and more user fields
  },
  "requestDate": "2017-03-25T18:38:49.000+0530",
  "status": "COMPLETED",
  "evaluateStartDatetime": "2017-03-25T18:38:50.000+0530",
  "evaluateCompleteDatetime": "2017-03-25T18:38:50.000+0530",
  "renderCompleteDatetime": null,
  "description": null,
  "links": [
    {
      "rel": "self",
      "uri": "http://localhost:8080/openmrs/ws/rest/v1/reportingrest/reportRequest/4e087b92-fcfb-43e7-b53d-3707f6e1cc74"
    }
  ],
  "resourceVersion": "1.8"
}