Related
I'm dumping my direct messages in Slack.
I manage to get all the messages one by one.
However I don't find any property that tells which message is a parent message and which ones are replies.
How can we get this information?
Typical code in C#
ConversationsListResponse conversationListRespons = await slackClient.GetConversationsListAsync("",false,100,types);
foreach (var channel in conversationListRespons.channels)
{
ConversationsMessageHistory messages = await slackClient.GetConversationsHistoryAsync(channel);
Even when I test the api from the slack interface, it's not giving the information.
Are there any other apis than the ones I'm using to get the required information?
Api used: https://api.slack.com/methods/conversations.history
Here is an example: This a main Direct Message with 4 replies.
conversations.history returns them without any relationship between them.
The query in slack test interface:
and the result:
{
"ok": true,
"messages": [
{
"type": "message",
"text": "voici un log",
"files": [
{
"id": "F04M6EAEXGX",
"created": 1675280228,
"timestamp": 1675280228,
"name": "32x32.ico",
"title": "32x32.ico",
"mimetype": "application/octet-stream",
"filetype": "binary",
"pretty_type": "Binary",
"user": "U0XNQGD0R",
"user_team": "T0XN0RW8H",
"editable": false,
"size": 4286,
"mode": "hosted",
"is_external": false,
"external_type": "",
"is_public": false,
"public_url_shared": false,
"display_as_bot": false,
"username": "",
"url_private": "https://files.slack.com/files-pri/T0XN0RW8H-F04M6EAEXGX/32x32.ico",
"url_private_download": "https://files.slack.com/files-pri/T0XN0RW8H-F04M6EAEXGX/download/32x32.ico",
"media_display_type": "unknown",
"permalink": "https://sanitized.slack.com/files/U0XNQGD0R/F04M6EAEXGX/32x32.ico",
"permalink_public": "https://slack-files.com/T0XN0RW8H-F04M6EAEXGX-bb8c68eec7",
"is_starred": false,
"has_rich_preview": false,
"file_access": "visible",
"media_progress": null
}
],
"upload": false,
"user": "U0XNQGD0R",
"display_as_bot": false,
"ts": "1675280236.783609",
"blocks": [
{
"type": "rich_text",
"block_id": "Twy",
"elements": [
{
"type": "rich_text_section",
"elements": [
{
"type": "text",
"text": "voici un log"
}
]
}
]
}
],
"client_msg_id": "5bda3f9c-64a8-4c1b-8b5e-f37c3b2e2c5d"
},
{
"client_msg_id": "850f4ecc-59c0-4af0-b13f-e527ed7a88de",
"type": "message",
"text": "<#U0XNQ04JD> test",
"user": "U0XNQGD0R",
"ts": "1675280205.367429",
"blocks": [
{
"type": "rich_text",
"block_id": "qi/vH",
"elements": [
{
"type": "rich_text_section",
"elements": [
{
"type": "user",
"user_id": "U0XNQ04JD"
},
{
"type": "text",
"text": " test"
}
]
}
]
}
],
"team": "T0XN0RW8H"
},
{
"client_msg_id": "e249a07d-f887-4edb-859a-1cc38559dc7b",
"type": "message",
"text": ":100:",
"user": "U0XNQGD0R",
"ts": "1675280190.138859",
"blocks": [
{
"type": "rich_text",
"block_id": "rGp",
"elements": [
{
"type": "rich_text_section",
"elements": [
{
"type": "emoji",
"name": "100",
"unicode": "1f4af"
}
]
}
]
}
],
"team": "T0XN0RW8H"
},
{
"client_msg_id": "df2a2f63-21b1-42d5-91db-3c66b083ed7c",
"type": "message",
"text": "yes<https://www.google.com|link to google>",
"user": "U0XNQGD0R",
"ts": "1675280183.929889",
"blocks": [
{
"type": "rich_text",
"block_id": "GZV",
"elements": [
{
"type": "rich_text_section",
"elements": [
{
"type": "text",
"text": "yes"
},
{
"type": "link",
"url": "https://www.google.com",
"text": "link to google"
}
]
}
]
}
],
"team": "T0XN0RW8H",
"reactions": [
{
"name": "+1",
"users": [
"U0XNQGD0R"
],
"count": 1
}
]
},
{
"client_msg_id": "116e4fc3-ef4a-4148-84ad-975ff0f227e6",
"type": "message",
"text": "Salut Christophe,\nthis is a test for Slack",
"user": "U0XNQGD0R",
"ts": "1675254487.545169",
"blocks": [
{
"type": "rich_text",
"block_id": "O2s",
"elements": [
{
"type": "rich_text_section",
"elements": [
{
"type": "text",
"text": "Salut ,\nthis is a test for Slack"
}
]
}
]
}
],
"team": "T0XN0RW8H"
}
],
"has_more": false,
"is_limited": false,
"pin_count": 0,
"channel_actions_ts": null,
"channel_actions_count": 0
}
To start, there might be some confusion as to what constitutes a reply or thread on Slack. Your first screenshot seems like several "normal" messages posted by the same user one after the other. In Slack a thread is a message posted by selecting the thread icon that corresponds to a parent message as seen in the screenshot.
With that established, you can retrieve threaded messages by making a call to conversations.replies.
I want to write Elasticsearch query where I am able to look into a nested array, and check a key for all those elements inside the array, if all of them have that value then the root document should be selected.
this is a sample data :
[
{
"_index": "allproperties",
"_type": "_doc",
"_id": "5241050",
"_score": 0.0,
"_source": {
"id": 5241050,
"type": "HOUSE",
"state": "NSW",
"agency": {
"id": 31,
"code": "AU_LNT",
"name": "Luthor Properties",
"config": "{}"
},
"branch": {
"id": 89,
"name": "Luthor Sales Unit Trust",
"tradingName": "Luthor Properties",
"internalCode": "AU_LNT_G"
},
"images": null,
"leases": [
{
"id": 26439,
"bond": 2000,
"leased": true,
"source": "PORTAL",
"status": "SIGNED",
"endDate": "2022-11-06T00:00:00",
"tenants": [
{
"id": 11106,
"role": "TENANT",
"user": {
"id": 38817,
"dob": "1900-01-01",
"name": "Liam",
"email": "tempo#tempo.com",
"phone": "+61400000000",
"surname": "Tempo",
"salutation": "Mr.",
"invitations": null,
"lastInAppActivity": null
},
"address": "45675 Bruce Hwy, Coolbie QLD 4850, Australia",
"extendedData": "{\"rentSplitAmount\":22.62}",
"roleAdjective": "PRIMARY",
"addressComponents": {
"state": "QLD",
"suburb": "Coolbie",
"country": "Australia",
"postcode": "4850",
"streetName": "Bruce Hwy",
"unitNumber": null,
"poboxNumber": null,
"streetNumber": "45675",
"addressComponentsUnavailable": null
}
}
],
"signDate": "2022-10-05T04:58:08.887",
"startDate": "2022-10-06T00:00:00",
"moveInDate": "2022-10-06T00:00:00",
"appointments": [
{
"id": 3506,
"type": "REMOTE",
"date_time": "2022-10-12T04:56:00+00:00",
"createdBy": "Lex Luthor",
"createdDate": "2022-10-05T04:56:52.936",
"lastModifiedBy": "Lex Luthor",
"lastModifiedDate": "2022-10-05T04:56:53.51"
}
],
"createdDate": "2022-10-05T04:55:42.247",
"rentalAmount": 500,
"dateAvailable": null,
"extendedData": {
"last_rent_adjustment_date": 1665014400000
},
"leaseDuration": 32,
"rentalFrequency": "2",
"signedManually": false
}
],
"refId": "b66326eb-a6b2-42b6-b058-b46847e13399",
"source": "PT",
"status": null,
"suburb": "Hurstville",
"address": "456 Forest Road Hurstville NSW AUSTRALIA 2220",
"country": "Australia",
"bedrooms": 3,
"category": null,
"pmsCode": "84c34d15-a0ab-4791-b9e3-1bdac215b99c",
"postcode": "2220",
"agencyId": 31,
"bathrooms": 3,
"branchId": 89,
"carspaces": 3,
"createdBy": "system",
"streetname": "Forest Road",
"unitnumber": null,
"description": null,
"createdDate": "2022-10-05T04:51:12.619",
"entitlements": [
{
"id": 3453799,
"role": "LANDLORD",
"user": {
"id": 22855,
"dob": null,
"name": "please enter ownership name",
"email": "mag.m#rr.com.au",
"phone": "0400000000",
"surname": "",
"salutation": null,
"lastInAppActivity": null
},
"company": {
"id": 137,
"abn": "",
"acn": "",
"phone": "0400000000",
"address": "1234 Park Avenue New York NY USA 10037-1702",
"companyName": "please enter ownership name",
"displayName": "please enter ownership name",
"email": "mag.m#rr.com.au"
},
"roleAdjective": "GROUP"
},
{
"id": 3453800,
"role": "AGENT",
"user": {
"id": 20054,
"dob": null,
"name": "Paul",
"email": "p.b#mr.com",
"phone": "+61403084232",
"surname": "Botti",
"salutation": null,
"lastInAppActivity": null
},
"company": null,
"roleAdjective": "MANAGING"
},
{
"id": 3453801,
"role": "AGENT",
"user": {
"id": 20054,
"dob": null,
"name": "Paul",
"email": "p.b#mr.com",
"phone": "+61403084232",
"surname": "Botti",
"salutation": null,
"lastInAppActivity": null
},
"company": null,
"roleAdjective": "LEASING"
}
],
"streetnumber": "456",
"advertised": false,
"commission_type": null,
"lastModifiedBy": "system",
"lastModifiedDate": "2022-10-05T04:58:09.043",
"_meta": {
"branches": {
"id": [
89
]
},
"agencies": {
"id": [
31
]
},
"user_property_entitlement": {
"id": [
3453799,
3453800,
3453801
]
},
"users": {
"id": [
20054,
22855,
38817
]
},
"companies": {
"id": [
137
]
},
"leases": {
"id": [
26439
]
},
"user_lease_entitlement": {
"id": [
11106
]
},
"appointments": {
"id": [
3506
]
}
}
},
"sort": [
1664945472619,
0.0
]
}
]
In this particular case, leases is a nested document, I want to select the documents where all the leases are in cancelled state or leases is null, i.e; either all of the objects inside leases should have status as CANCELLED or the leases key should be null.
Already went through this question, but did'nt quite get it as its an old answer from 2015 and methods used in this got deprecated.
Try this query:
GET idx_test/_search?filter_path=hits.hits
{
"query": {
"bool": {
"must_not": [
{
"nested": {
"path": "leases",
"query": {
"bool": {
"must_not": [
{
"bool": {
"should": [
{
"term": {
"leases.status.keyword": "CANCELLED"
}
},
{
"bool": {
"must_not": [
{
"exists": {
"field": "leases"
}
}
]
}
}
]
}
}
]
}
}
}
}
]
}
}
}
How do I add the below to an R4 Patient?
"search": {
"extension": [
{
"url": "http://hl7.org/fhir/StructureDefinition/match-grade",
"valueCode": "certain"
}
],
"mode": "match",
"score": 1.0
}
The objects that were under stu2 and stu3 (I think) have been deprecated.
DSTU3 and Later
// Create an example patient
Patient patient = new Patient();
patient.addIdentifier().setUse(Identifier.IdentifierUse.OFFICIAL).setSystem("urn:example").setValue("7000135");
// Create an extension
Extension ext = new Extension();
ext.setUrl("http://example.com/extensions#someext");
ext.setValue(new DateTimeType("2011-01-02T11:13:15"));
// Add the extension to the resource
patient.addExtension(ext);
Full "response" json from patient match below (sample data, not real data !! )
{
"resourceType": "Bundle",
"id": "94897c77-4120-482f-bdb4-4c8b9a71ade1",
"meta": {
"versionId": "1",
"lastUpdated": "2020-11-24T08:45:49.445-05:00"
},
"type": "searchset",
"total": 1,
"link": [
{
"relation": "self",
"url": "http://wildfhir4.aegis.net/fhir4-0-0/Patient/$match?"
}
],
"entry": [
{
"fullUrl": "http://wildfhir4.aegis.net/fhir4-0-0/Patient/9126db824dcf4d5ab3f68e63bd5eaced",
"resource": {
"resourceType": "Patient",
"id": "9126db824dcf4d5ab3f68e63bd5eaced",
"meta": {
"versionId": "1",
"lastUpdated": "2020-09-03T09:03:28.193-04:00",
"tag": [
{
"system": "http://terminology.hl7.org/CodeSystem/v3-ActReason",
"code": "HTEST",
"display": "test health data"
}
]
},
"text": {
"status": "generated",
"div": "<div xmlns=\"http://www.w3.org/1999/xhtml\"><table><tbody><tr><td>Name</td><td>Peter James \n <b>Chalmers</b> ("Jim") \n </td></tr><tr><td>Address</td><td>534 Erewhon, Pleasantville, Vic, 3999</td></tr><tr><td>Contacts</td><td>Home: unknown. Work: (03) 5555 6473</td></tr><tr><td>Id</td><td>MRN: 12345 (Acme Healthcare)</td></tr></tbody></table></div>"
},
"identifier": [
{
"use": "usual",
"type": {
"coding": [
{
"system": "http://terminology.hl7.org/CodeSystem/v2-0203",
"code": "MR"
}
]
},
"system": "urn:oid:1.2.36.146.595.217.0.1",
"value": "12345",
"period": {
"start": "2001-05-06"
},
"assigner": {
"display": "Acme Healthcare"
}
}
],
"active": true,
"name": [
{
"use": "official",
"family": "Chalmers",
"given": [
"Peter",
"James"
]
},
{
"use": "usual",
"given": [
"Jim"
]
},
{
"use": "maiden",
"family": "Windsor",
"given": [
"Peter",
"James"
],
"period": {
"end": "2002"
}
}
],
"telecom": [
{
"use": "home"
},
{
"system": "phone",
"value": "(03) 5555 6473",
"use": "work",
"rank": 1
},
{
"system": "phone",
"value": "(03) 3410 5613",
"use": "mobile",
"rank": 2
},
{
"system": "phone",
"value": "(03) 5555 8834",
"use": "old",
"period": {
"end": "2014"
}
}
],
"gender": "male",
"birthDate": "1974-12-25",
"_birthDate": {
"extension": [
{
"url": "http://hl7.org/fhir/StructureDefinition/patient-birthTime",
"valueDateTime": "1974-12-25T14:35:45-05:00"
}
]
},
"deceasedBoolean": false,
"address": [
{
"use": "home",
"type": "both",
"text": "534 Erewhon St PeasantVille, Rainbow, Vic 3999",
"line": [
"534 Erewhon St"
],
"city": "PleasantVille",
"district": "Rainbow",
"state": "Vic",
"postalCode": "3999",
"period": {
"start": "1974-12-25"
}
}
],
"contact": [
{
"relationship": [
{
"coding": [
{
"system": "http://terminology.hl7.org/CodeSystem/v2-0131",
"code": "N"
}
]
}
],
"name": {
"family": "du Marché",
"_family": {
"extension": [
{
"url": "http://hl7.org/fhir/StructureDefinition/humanname-own-prefix",
"valueString": "VV"
}
]
},
"given": [
"Bénédicte"
]
},
"telecom": [
{
"system": "phone",
"value": "+33 (237) 998327"
}
],
"address": {
"use": "home",
"type": "both",
"line": [
"534 Erewhon St"
],
"city": "PleasantVille",
"district": "Rainbow",
"state": "Vic",
"postalCode": "3999",
"period": {
"start": "1974-12-25"
}
},
"gender": "female",
"period": {
"start": "2012"
}
}
],
"managingOrganization": {
"reference": "Organization/1"
}
},
"search": {
"extension": [
{
"url": "http://hl7.org/fhir/StructureDefinition/match-grade",
"valueCode": "certain"
}
],
"mode": "match",
"score": 1.0
}
}
]
}
APPEND: I found this:
https://hapifhir.io/hapi-fhir/apidocs/hapi-fhir-structures-r4/org/hl7/fhir/r4/model/codesystems/MatchGrade.html
That extension isn't allowed on Patient. It's defined with a context of Bundle.entry.search. It's not a characteristic of the patient themselves, it's a characteristic of a particular entry in a search result based on a specific set of search criteria. The same Patient instance might well be a good result on one search and a poor result on a different search. So to add the extension, you'd have to add it on a 'search' object, not patient.
Ok.
Here it is. The primary objects were inner/nested objects under Bundle....thus why I didn't see them early. (example : Bundle.BundleEntrySearchComponent)
// a java example with the import statements. #shocking!
//import org.hl7.fhir.r4.model.Bundle;
//import org.hl7.fhir.r4.model.CodeType;
//import org.hl7.fhir.r4.model.Extension;
//import org.hl7.fhir.r4.model.Patient;
//import org.hl7.fhir.r4.model.codesystems.MatchGrade;
//import java.util.Collections;
Bundle innerBundle = new Bundle();
innerBundle.setType(Bundle.BundleType.SEARCHSET);
innerBundle.setTotal(1);
Patient pat = new Patient();
HumanName hn = new HumanName();
hn.setFamily("Smith");
p.setName(Collections.singletonList(hn));
Bundle.BundleEntrySearchComponent besc = new Bundle.BundleEntrySearchComponent();
besc.setScore(0.88);
besc.setMode(Bundle.SearchEntryMode.MATCH);
Bundle.BundleEntryComponent bec = new Bundle.BundleEntryComponent();
Extension matchGradeExtension = besc.addExtension();
matchGradeExtension.setUrl("http://hl7.org/fhir/StructureDefinition/match-grade");
matchGradeExtension.setValue(new CodeType(MatchGrade.PROBABLE.toCode()));
bec.setResource(pat);
bec.setSearch(besc);
innerBundle.setEntry(Collections.singletonList(bec));
Json looks like this:
{
"resourceType": "Bundle",
"type": "searchset",
"total": 1,
"entry": [
{
"resource": {
"resourceType": "Patient",
"name": [
{
"family": "Smith"
}
]
},
"search": {
"extension": [
{
"url": "http://hl7.org/fhir/StructureDefinition/match-grade",
"valueCode": "certain"
}
],
"mode": "match",
"score": 0.88
}
}
]
}
I have the following JSON input
{
"Status": "PENDING",
"TaskId": "0000000001",
"EventType": "change",
"Timestamp": "2019-01-09-15.41.57.473940T01",
"Comment": "{\"comment\":[{\"createDate\":\"2019-01-09T15:41:57:473000-05:00\",\"type\":\"system\",\"text\":\"Assigned to: RAJ\",\"userId\":\"RAJ\",\"userName\":\"RAJA MADHIE\"},{\"createDate\":\"2019-01-09T15:45:59:150000-05:00\",\"type\":\"manual\",\"text\":\"Comments entered for 0000000001\",\"userId\":\"RAJ\",\"userName\":\"RAJA MADHIE\"},{\"createDate\":\"2019-01-09T15:49:09:586000-05:00\",\"type\":\"manual\",\"text\":\"Comments entered for 0000000001 - processed.\",\"userId\":\"RAJ\",\"userName\":\"RAJA MADHIE\"}]}"
}
and expecting the output to be something like:
{
"inputs": [
{
"richInput": {
"subjectId": "0000000001",
"body": {
"messageSegments": [
{
"type": "system",
"text": "Assigned to: RAJ"
}
]
},
"feedElementType": "FeedItem"
}
},
{
"richInput": {
"subjectId": "0000000001",
"body": {
"messageSegments": [
{
"type": "manual",
"text": "Comments entered for 0000000001"
}
]
},
"feedElementType": "FeedItem"
}
},
{
"richInput": {
"subjectId": "0000000001",
"body": {
"messageSegments": [
{
"type": "manual",
"text": "Comments entered for 0000000001-processed."
}
]
},
"feedElementType": "FeedItem"
}
}
]
}
I have tried to transform this using couple of JOLT Specs but no luck... Any suggestions or recommendations are much appreciated. Thanks!
You need to make comments a proper JSON structure, it will appear something as below.
{
"Status": "PENDING",
"TaskId": "0000000001",
"EventType": "change",
"Timestamp": "2019-01-09-15.41.57.473940T01",
"Comment": {
"comment": [
{
"createDate": "2019-01-09T15:41:57:473000-05:00",
"type": "system",
"text": "Assigned to: RAJ",
"userId": "RAJ",
"userName": "RAJA MADHIE"
},
{
"createDate": "2019-01-09T15:45:59:150000-05:00",
"type": "manual",
"text": "Comments entered for 0000000001",
"userId": "RAJ",
"userName": "RAJA MADHIE"
},
{
"createDate": "2019-01-09T15:49:09:586000-05:00",
"type": "manual",
"text": "Comments entered for 0000000001 - processed.",
"userId": "RAJ",
"userName": "RAJA MADHIE"
}
]
}
}
Spec file to transform this:
[
{
"operation": "shift",
"spec": {
"Comment": {
"comment": {
"*": {
"#(3,TaskId)": "inputs[&1].richInput.subjectId",
"type": "inputs[&1].richInput.body.messageSegments[0].type",
"text": "inputs[&1].richInput.body.messageSegments[0].text",
"#FeedItem": "inputs[&1].richInput.feedElementType"
}
}
}
}
},
{
"operation": "shift",
"spec": {
"inputs": {
"*": {
"richInput": {
"subjectId": "inputs[&2].richInput.subjectId",
"body": "inputs[&2].richInput.body",
"feedElementType": "inputs[&2].richInput.feedElementType"
}
}
}
}
}
]
How can I get DocumentReference for particular document from DocumentManifest list of documents?
Here is an example of returned DocumentManifest
{
"title": {
},
"id": {
},
"updated": {
},
"content": {
"type": {
"#id": "urn:uuid:xxxxxx-xxxx-xxxx-xxxx-xxxxxxx",
"text": "Patient Document List"
},
"resourceType": "DocumentManifest",
"text": {
"status": "generated",
"div": "<div xmlns=\"http://www.w3.org/1999/xhtml\">Some Test ORG</div>"
},
"contained": {
"resourceType": "Patient",
"identifier": {
"use": "official",
"system": "",
"value": "12345678987654321"
}
},
"subject": {
"reference": "Patient Documents"
},
"recipient": {
"organization": {
"display": "Some Test ORG"
}
},
"created": "2018-02-09T13:26:53-07:00",
"status": "current",
"content": {
"reference": [
"Binary/DOCUMENT-1000123",
"Binary/DOCUMENT-1000124",
"Binary/DOCUMENT-1000125"
]
}
}
}
I have tried to use something like
GET [service-url]/DocumentReference/?_query=generate&uri=[service-url]/BINARY/DOCUMENT-1000125
but I had no luck.
That DocumentManifest is not pointing at a DocumentReference. It is point at a document.
FYI: What you have shown is not compliant with IHE-MHD use of DocumentReference/DocumentManifest/Binary.