How to get the nested array value in mongodb - laravel

Need to get collection based on component, Subtype, material value which is inside regions array.
"_id":"01"
"pole_num": "1"
"pole_height":"10"
"lat":"39.94142507"
"lon": "-86.07079913"
"image": "_DSC9468.JPG",
"road_accessible": "true",
"regions": {
0: {
"Component": "Pole Test",
"Sub Type": {
},
"Material": "Unknown",
"Condition": {
},
"Misc": {
}
},
1: {
"Component": "TestAnchor",
"Sub Type": {
},
"Material": "Unknown",
"Condition": {
},
"Misc": {
}
}
"_id":"02"
"pole_num": "2"
"pole_height":"10"
"lat":"39.94142507"
"lon": "-86.07079913"
"image": "_DSC9468.JPG",
"road_accessible": "true",
"regions": [
0: {
"Component": "Pole Test",
"Sub Type": {
},
"Material": "Unknown",
"Condition": {
},
"Misc": {
}
},
1: {
"Component": "Test Anchor2",
"Sub Type": {
},
"Material": "Unknown",
"Condition": {
},
"Misc": {
}
}
How to get datas which has "Pole Test" value like given below:
"_id":"01"
"pole_num": "1"
"pole_height":"10"
"lat":"39.94142507"
"lon": "-86.07079913"
"image": "_DSC9468.JPG",
"road_accessible": "true",
"regions": {
0: {
"Component": "Pole Test",
"Sub Type": {
},
"Material": "Unknown",
"Condition": {
},
"Misc": {
}
}
and
"_id":"02"
"pole_num": "2"
"pole_height":"10"
"lat":"39.94142507"
"lon": "-86.07079913"
"image": "_DSC9468.JPG",
"road_accessible": "true",
"regions": [
0: {
"Component": "Pole Test",
"Sub Type": {
},
"Material": "Unknown",
"Condition": {
},
"Misc": {
}
}
is there any possible mongodb query to work with this.

Check the link below. Its a very simple query which can be done using find operator.
Unless there is some sample value provided by you in subtype field.
You can update your question so we can provide better solution
db.collection.find({
"regions.Component": "Pole Test",
"regions.Material": "Unknown"
})
https://mongoplayground.net/p/1K4NXPTllHz

Related

Add extension to R4 Patient

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
}
}
]
}

rethinkdb, How could I pluck the result by a value in particular "array index"?

sample data
[
{
"createdDate": 1508588333821,
"data": {
"image_extension": "png",
"name": "Golden",
"qty": 1,
"remark": "#296-2",
"status": "RETURN",
"owner": [
{
"name": "app1emaker",
"location": 1
},
{
"name": "simss92_lmao",
"location": 31
}
]
},
"deleted": false,
"docId": 307,
"docType": "product",
"id": "db0131f9-9359-4aa3-b6ed-cd9f3ff4aa3e",
"updatedDate": 1553155281691
},
{
"createdDate": 1508588333324,
"data": {
"image_extension": "png",
"name": "Golden",
"qty": 1,
"remark": "#296-2",
"status": "DISCARD",
"owner": [
{
"name": "At533",
"location": 7
},
{
"name": "madsimon",
"location": 64
},
{
"name": "boyboy96",
"location": 1
},
{
"name": "xinfengCN",
"location": 5
}
]
},
"deleted": false,
"docId": 308,
"docType": "product",
"id": "3790bdaa-5347-4ab0-8149-37332c23c6ea",
"updatedDate": 1554555231691
},
...
...
]
And said that, I would like to select the data.owner on array index 0 only (or I should say data.owner[0]), which are
{
"name": "app1emaker",
"location": 1
}
and
{
"name": "At533",
"location": 7
}
in this case. I have a failed code below.
r.db('carbon').table("items").pluck(['id', 'docId', 'createdDate',{data:{name: true, owner:[0]}}])
I saw that for some functions like orderBy, rethinkdb allowed to use orderBy(r.row('data')('owner')(0)('name')) for access nested object, but I have no idea how to do this for pluck? could anyone give me some hints?
Thanks a lot
pluck can not do that, but you can fall back to use the map:
r.db("carbon").table("items").map(function(doc){
return {
"id": doc("id"),
"docId": doc("docId"),
"createdDate": doc("createdDate"),
"data": {
"name": doc("data")("name"),
"owner": doc("data")("owner")(0)
}
}
})

Jolt Spec for Shift Operation

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"
}
}
}
}
}
]

FHIR and DocumentReference

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.

Unable to use ec2 cloudwatch logs on windows 2016

I added a \Program Files\Amazon\SSM\Plugins\awsCloudWatch\AWS.EC2.Windows.Cloudwatch.json file as explained to my user-data startup and restarted the ssm service as explained in the documentation for windows 2016. There are no errors in the ssm agent log. However, I do not see AWS.Cloudwatch.exe running, and no logs make it to cloudwatch.
I am really interested in just the application and system event logs and the \programdata\amazon\ecs\log directory. If I get that working, I will add the launch logs too.
Where can I look for clues? I did try starting the aws.cloudwatch.exe manually but don't know what the configuration argument is supposed to look like.
Here is my configuration
$ssmconfig = #"
{
"IsEnabled": true,
"EngineConfiguration": {
"PollInterval": "00:00:05",
"Components": [
{
"Id": "ApplicationEventLog",
"FullName": "AWS.EC2.Windows.CloudWatch.EventLog.EventLogInputComponent,AWS.EC2.Windows.CloudWatch",
"Parameters": {
"LogName": "Application",
"Levels": "1"
}
},
{
"Id": "SystemEventLog",
"FullName": "AWS.EC2.Windows.CloudWatch.EventLog.EventLogInputComponent,AWS.EC2.Windows.CloudWatch",
"Parameters": {
"LogName": "System",
"Levels": "7"
}
},
{
"Id": "SecurityEventLog",
"FullName": "AWS.EC2.Windows.CloudWatch.EventLog.EventLogInputComponent,AWS.EC2.Windows.CloudWatch",
"Parameters": {
"LogName": "Security",
"Levels": "7"
}
},
{
"Id": "CustomLogs",
"FullName": "AWS.EC2.Windows.CloudWatch.CustomLog.CustomLogInputComponent,AWS.EC2.Windows.CloudWatch",
"Parameters": {
"LogDirectoryPath": "C:\\ProgramData\\Amazon\ECS\Log
",
"TimestampFormat": "MM/dd/yyyy HH:mm:ss",
"Encoding": "UTF-8",
"Filter": "",
"CultureName": "en-US",
"TimeZoneKind": "Local"
}
},
{
"Id": "CloudWatchLogs",
"FullName": "AWS.EC2.Windows.CloudWatch.CloudWatchLogsOutput,AWS.EC2.Windows.CloudWatch",
"Parameters": {
"Region": "MYREGION}",
"LogGroup": "MYLOGGGROUP/win-host-eventlog",
"LogStream": "THISINSTANCEID"
}
},
{
"Id": "CloudWatchEcsLogs",
"FullName": "AWS.EC2.Windows.CloudWatch.CloudWatchLogsOutput,AWS.EC2.Windows.CloudWatch",
"Parameters": {
"Region": "MYREGION",
"LogGroup": "MYLOGGROUP/win-host-ecs-logs",
"LogStream": "THISINSTANCEID"
}
}
],
"Flows": {
"Flows": [
"(ApplicationEventLog,SystemEventLog),CloudWatchLogs"
"CustomLogs,CloudWatchEcsLogs"
]
}
}
}
"#
Add-Content "C:\Program Files\Amazon\SSM\Plugins\awsCloudWatch\AWS.ECS.Windows.CloudWatch.json" $ssmconfig
Restart-Service AmazonSSMAgent
`
According to the documentation:
The EC2Config service is not included in AWS Windows 2016 AMIs and you need to install it manually. Install it, run it, enable log integration, and update the JSON file (normally) located in the following path:
C:\Program Files\Amazon\SSM\Plugins\awsCloudWatch
Here is the configuration I have on my servers. It works fine and I get both logs and performance metrics.
{
"IsEnabled": true,
"EngineConfiguration": {
"Components": [{
"FullName": "AWS.EC2.Windows.CloudWatch.EventLog.EventLogInputComponent,AWS.EC2.Windows.CloudWatch",
"Id": "ApplicationEventLog",
"Parameters": {
"Levels": "1",
"LogName": "Application"
}
}, {
"FullName": "AWS.EC2.Windows.CloudWatch.EventLog.EventLogInputComponent,AWS.EC2.Windows.CloudWatch",
"Id": "SystemEventLog",
"Parameters": {
"Levels": "7",
"LogName": "System"
}
}, {
"FullName": "AWS.EC2.Windows.CloudWatch.EventLog.EventLogInputComponent,AWS.EC2.Windows.CloudWatch",
"Id": "SecurityEventLog",
"Parameters": {
"Levels": "7",
"LogName": "Security"
}
}, {
"FullName": "AWS.EC2.Windows.CloudWatch.EventLog.EventLogInputComponent,AWS.EC2.Windows.CloudWatch",
"Id": "ETW",
"Parameters": {
"Levels": "7",
"LogName": "Microsoft-Windows-WinINet/Analytic"
}
}, {
"FullName": "AWS.EC2.Windows.CloudWatch.IisLog.IisLogInputComponent,AWS.EC2.Windows.CloudWatch",
"Id": "IISLog",
"Parameters": {
"LogDirectoryPath": "C:\\inetpub\\logs\\LogFiles\\W3SVC1"
}
}, {
"FullName": "AWS.EC2.Windows.CloudWatch.CustomLog.CustomLogInputComponent,AWS.EC2.Windows.CloudWatch",
"Id": "CustomLogs",
"Parameters": {
"CultureName": "en-US",
"Encoding": "UTF-8",
"Filter": "",
"LogDirectoryPath": "C:\\Logs\\",
"TimeZoneKind": "Local",
"TimestampFormat": "yyyy-MM-dd HH:mm:ss"
}
}, {
"FullName": "AWS.EC2.Windows.CloudWatch.PerformanceCounterComponent.PerformanceCounterInputComponent,AWS.EC2.Windows.CloudWatch",
"Id": "PerformanceCounterMemory",
"Parameters": {
"CategoryName": "Memory",
"CounterName": "Available MBytes",
"DimensionName": "InstanceId",
"DimensionValue": "{instance_id}",
"InstanceName": "",
"MetricName": "Memory",
"Unit": "Megabytes"
}
}, {
"FullName": "AWS.EC2.Windows.CloudWatch.PerformanceCounterComponent.PerformanceCounterInputComponent,AWS.EC2.Windows.CloudWatch",
"Id": "PerformanceCounterDisk",
"Parameters": {
"CategoryName": "LogicalDisk",
"CounterName": "Free Megabytes",
"DimensionName": "InstanceId",
"DimensionValue": "{instance_id}",
"InstanceName": "D:",
"MetricName": "FreeDisk",
"Unit": "Megabytes"
}
}, {
"FullName": "AWS.EC2.Windows.CloudWatch.CloudWatchLogsOutput,AWS.EC2.Windows.CloudWatch",
"Id": "CloudWatchLogs",
"Parameters": {
"AccessKey": "",
"LogGroup": "ASG",
"LogStream": "{instance_id}",
"Region": "eu-west-1",
"SecretKey": ""
}
}, {
"FullName": "AWS.EC2.Windows.CloudWatch.CloudWatch.CloudWatchOutputComponent,AWS.EC2.Windows.CloudWatch",
"Id": "CloudWatch",
"Parameters": {
"AccessKey": "",
"NameSpace": "PerformanceMonitor",
"Region": "eu-west-1",
"SecretKey": ""
}
}],
"Flows": {
"Flows": [
"(PerformanceCounterMemory,PerformanceCounterDisk),CloudWatch",
"(ApplicationEventLog,SystemEventLog),CloudWatchLogs"
]
},
"PollInterval": "00:00:15"
}
}

Resources