Skip to content

Instantly share code, notes, and snippets.

@djazayeri
Last active April 12, 2017 23:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save djazayeri/6404c739ff16b2a4cd28ec3037e760fd to your computer and use it in GitHub Desktop.
Save djazayeri/6404c739ff16b2a4cd28ec3037e760fd to your computer and use it in GitHub Desktop.
pre-2.1 cohort REST API
--- Create a cohort
POST https://demo.openmrs.org/openmrs/ws/rest/v1/cohort
{"name":"Darius testing", "description": "REST", "memberIds": [515]}
=>
{
"uuid": "ca254345-429b-491c-b833-1933cdd7d828",
"display": "Darius testing",
"name": "Darius testing",
"description": "REST",
"voided": false,
"memberIds": [
515
],
"links": [
{
"rel": "self",
"uri": "http://127.0.0.1:8080/openmrs/ws/rest/v1/cohort/ca254345-429b-491c-b833-1933cdd7d828"
},
{
"rel": "full",
"uri": "http://127.0.0.1:8080/openmrs/ws/rest/v1/cohort/ca254345-429b-491c-b833-1933cdd7d828?v=full"
}
],
"resourceVersion": "1.8"
}
--- List all members in a cohort
GET https://demo.openmrs.org/openmrs/ws/rest/v1/cohort/ca254345-429b-491c-b833-1933cdd7d828/member
=>
{
"results": [
{
"display": "100HWJ - test person",
"patient": {
"uuid": "478acb06-79e6-48ce-931a-fce79a082e1e",
"display": "100HWJ - test person",
"identifiers": [
{
"uuid": "9ecaffe6-c7c4-4c43-9453-d459fbcd2665",
"display": "OpenMRS ID = 100HWJ",
"links": [
{
"rel": "self",
"uri": "http://127.0.0.1:8080/openmrs/ws/rest/v1/patient/478acb06-79e6-48ce-931a-fce79a082e1e/identifier/9ecaffe6-c7c4-4c43-9453-d459fbcd2665"
}
]
}
],
"person": {
"uuid": "478acb06-79e6-48ce-931a-fce79a082e1e",
"display": "test person",
"gender": "M",
"age": 42,
"birthdate": "1974-08-12T00:00:00.000+0000",
"birthdateEstimated": false,
"dead": false,
"deathDate": null,
"causeOfDeath": null,
"preferredName": {
"uuid": "dcd2f97a-9be7-4afb-9fab-2daba263acf4",
"display": "test person",
"links": [
{
"rel": "self",
"uri": "http://127.0.0.1:8080/openmrs/ws/rest/v1/person/478acb06-79e6-48ce-931a-fce79a082e1e/name/dcd2f97a-9be7-4afb-9fab-2daba263acf4"
}
]
},
"preferredAddress": {
"uuid": "f86284b2-2432-4c23-bd10-7261420d9cf3",
"display": "1234 anystreet usa",
"links": [
{
"rel": "self",
"uri": "http://127.0.0.1:8080/openmrs/ws/rest/v1/person/478acb06-79e6-48ce-931a-fce79a082e1e/address/f86284b2-2432-4c23-bd10-7261420d9cf3"
}
]
},
"attributes": [],
"voided": false,
"deathdateEstimated": false,
"birthtime": null,
"links": [
{
"rel": "self",
"uri": "http://127.0.0.1:8080/openmrs/ws/rest/v1/person/478acb06-79e6-48ce-931a-fce79a082e1e"
},
{
"rel": "full",
"uri": "http://127.0.0.1:8080/openmrs/ws/rest/v1/person/478acb06-79e6-48ce-931a-fce79a082e1e?v=full"
}
],
"resourceVersion": "1.11"
},
"voided": false,
"links": [
{
"rel": "self",
"uri": "http://127.0.0.1:8080/openmrs/ws/rest/v1/patient/478acb06-79e6-48ce-931a-fce79a082e1e"
},
{
"rel": "full",
"uri": "http://127.0.0.1:8080/openmrs/ws/rest/v1/patient/478acb06-79e6-48ce-931a-fce79a082e1e?v=full"
}
],
"resourceVersion": "1.8"
},
"links": [
{
"rel": "self",
"uri": "http://127.0.0.1:8080/openmrs/ws/rest/v1/cohort/ca254345-429b-491c-b833-1933cdd7d828/member/478acb06-79e6-48ce-931a-fce79a082e1e"
},
{
"rel": "full",
"uri": "http://127.0.0.1:8080/openmrs/ws/rest/v1/cohort/ca254345-429b-491c-b833-1933cdd7d828/member/478acb06-79e6-48ce-931a-fce79a082e1e?v=full"
}
],
"resourceVersion": "1.8"
}
]
}
--- Add member to a cohort
POST https://demo.openmrs.org/openmrs/ws/rest/v1/cohort/ca254345-429b-491c-b833-1933cdd7d828/member
{"patient":"c3bf8a00-52e7-4998-b18d-b1978adab4fa"}
=>
{
"display": "100HUN - Tiger Lee",
"patient": {
"uuid": "c3bf8a00-52e7-4998-b18d-b1978adab4fa",
"display": "100HUN - Tiger Lee",
"identifiers": [
{
"uuid": "7458dff2-c3b9-44ed-bcfd-ca2263f09bae",
"display": "OpenMRS ID = 100HUN",
"links": [
{
"rel": "self",
"uri": "http://127.0.0.1:8080/openmrs/ws/rest/v1/patient/c3bf8a00-52e7-4998-b18d-b1978adab4fa/identifier/7458dff2-c3b9-44ed-bcfd-ca2263f09bae"
}
]
}
],
"person": {
"uuid": "c3bf8a00-52e7-4998-b18d-b1978adab4fa",
"display": "Tiger Lee",
"gender": "M",
"age": 16,
"birthdate": "2000-04-29T00:00:00.000+0000",
"birthdateEstimated": false,
"dead": false,
"deathDate": null,
"causeOfDeath": null,
"preferredName": {
"uuid": "b4b31386-9706-4a13-b2c3-3c0b3da801da",
"display": "Tiger Lee",
"links": [
{
"rel": "self",
"uri": "http://127.0.0.1:8080/openmrs/ws/rest/v1/person/c3bf8a00-52e7-4998-b18d-b1978adab4fa/name/b4b31386-9706-4a13-b2c3-3c0b3da801da"
}
]
},
"preferredAddress": {
"uuid": "4ad4601f-4c24-48d9-8eb7-d11dbdba6b67",
"display": "Manchester UK",
"links": [
{
"rel": "self",
"uri": "http://127.0.0.1:8080/openmrs/ws/rest/v1/person/c3bf8a00-52e7-4998-b18d-b1978adab4fa/address/4ad4601f-4c24-48d9-8eb7-d11dbdba6b67"
}
]
},
"attributes": [
{
"uuid": "f76b4ed1-6a4f-47ae-b1bb-245b0629e5e9",
"display": "Telephone Number = 444444444",
"links": [
{
"rel": "self",
"uri": "http://127.0.0.1:8080/openmrs/ws/rest/v1/person/c3bf8a00-52e7-4998-b18d-b1978adab4fa/attribute/f76b4ed1-6a4f-47ae-b1bb-245b0629e5e9"
}
]
}
],
"voided": false,
"deathdateEstimated": false,
"birthtime": null,
"links": [
{
"rel": "self",
"uri": "http://127.0.0.1:8080/openmrs/ws/rest/v1/person/c3bf8a00-52e7-4998-b18d-b1978adab4fa"
},
{
"rel": "full",
"uri": "http://127.0.0.1:8080/openmrs/ws/rest/v1/person/c3bf8a00-52e7-4998-b18d-b1978adab4fa?v=full"
}
],
"resourceVersion": "1.11"
},
"voided": false,
"links": [
{
"rel": "self",
"uri": "http://127.0.0.1:8080/openmrs/ws/rest/v1/patient/c3bf8a00-52e7-4998-b18d-b1978adab4fa"
},
{
"rel": "full",
"uri": "http://127.0.0.1:8080/openmrs/ws/rest/v1/patient/c3bf8a00-52e7-4998-b18d-b1978adab4fa?v=full"
}
],
"resourceVersion": "1.8"
},
"links": [
{
"rel": "self",
"uri": "http://127.0.0.1:8080/openmrs/ws/rest/v1/cohort/ca254345-429b-491c-b833-1933cdd7d828/member/c3bf8a00-52e7-4998-b18d-b1978adab4fa"
},
{
"rel": "full",
"uri": "http://127.0.0.1:8080/openmrs/ws/rest/v1/cohort/ca254345-429b-491c-b833-1933cdd7d828/member/c3bf8a00-52e7-4998-b18d-b1978adab4fa?v=full"
}
],
"resourceVersion": "1.8"
}
--- Get one member from a cohort
GET https://demo.openmrs.org/openmrs/ws/rest/v1/cohort/ca254345-429b-491c-b833-1933cdd7d828/member/478acb06-79e6-48ce-931a-fce79a082e1e
=>
{
"display": "100HWJ - test person",
"patient": {
"uuid": "478acb06-79e6-48ce-931a-fce79a082e1e",
"display": "100HWJ - test person",
"identifiers": [
{
"uuid": "9ecaffe6-c7c4-4c43-9453-d459fbcd2665",
"display": "OpenMRS ID = 100HWJ",
"links": [
{
"rel": "self",
"uri": "http://127.0.0.1:8080/openmrs/ws/rest/v1/patient/478acb06-79e6-48ce-931a-fce79a082e1e/identifier/9ecaffe6-c7c4-4c43-9453-d459fbcd2665"
}
]
}
],
"person": {
"uuid": "478acb06-79e6-48ce-931a-fce79a082e1e",
"display": "test person",
"gender": "M",
"age": 42,
"birthdate": "1974-08-12T00:00:00.000+0000",
"birthdateEstimated": false,
"dead": false,
"deathDate": null,
"causeOfDeath": null,
"preferredName": {
"uuid": "dcd2f97a-9be7-4afb-9fab-2daba263acf4",
"display": "test person",
"links": [
{
"rel": "self",
"uri": "http://127.0.0.1:8080/openmrs/ws/rest/v1/person/478acb06-79e6-48ce-931a-fce79a082e1e/name/dcd2f97a-9be7-4afb-9fab-2daba263acf4"
}
]
},
"preferredAddress": {
"uuid": "f86284b2-2432-4c23-bd10-7261420d9cf3",
"display": "1234 anystreet usa",
"links": [
{
"rel": "self",
"uri": "http://127.0.0.1:8080/openmrs/ws/rest/v1/person/478acb06-79e6-48ce-931a-fce79a082e1e/address/f86284b2-2432-4c23-bd10-7261420d9cf3"
}
]
},
"attributes": [],
"voided": false,
"deathdateEstimated": false,
"birthtime": null,
"links": [
{
"rel": "self",
"uri": "http://127.0.0.1:8080/openmrs/ws/rest/v1/person/478acb06-79e6-48ce-931a-fce79a082e1e"
},
{
"rel": "full",
"uri": "http://127.0.0.1:8080/openmrs/ws/rest/v1/person/478acb06-79e6-48ce-931a-fce79a082e1e?v=full"
}
],
"resourceVersion": "1.11"
},
"voided": false,
"links": [
{
"rel": "self",
"uri": "http://127.0.0.1:8080/openmrs/ws/rest/v1/patient/478acb06-79e6-48ce-931a-fce79a082e1e"
},
{
"rel": "full",
"uri": "http://127.0.0.1:8080/openmrs/ws/rest/v1/patient/478acb06-79e6-48ce-931a-fce79a082e1e?v=full"
}
],
"resourceVersion": "1.8"
},
"links": [
{
"rel": "self",
"uri": "http://127.0.0.1:8080/openmrs/ws/rest/v1/cohort/ca254345-429b-491c-b833-1933cdd7d828/member/478acb06-79e6-48ce-931a-fce79a082e1e"
},
{
"rel": "full",
"uri": "http://127.0.0.1:8080/openmrs/ws/rest/v1/cohort/ca254345-429b-491c-b833-1933cdd7d828/member/478acb06-79e6-48ce-931a-fce79a082e1e?v=full"
}
],
"resourceVersion": "1.8"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment