Mongo Playground

Configuration

db={system:[{"resourceType":"NamingSystem","id":"example-id","name":"Austalian Healthcare Identifier - Individual","status":"active","kind":"identifier","date":"2015-08-31","publisher":"HL7 Australia on behalf of NEHTA","responsible":"HI Service Operator / NEHTA","type":{"coding":[{"system":"http://hl7.org/fhir/v2/0203","code":"JPID","display":"National unique individual identifier"},{"system":"http://hl7.org/fhir/v2/0203","code":"JPID_TEST_THAT_WILL_BE_REMOVED_BY_THE_FILTER","display":"National unique individual identifier"}],"text":"IHI"},"description":"Australian HI Identifier as established by relevant regulations etc","uniqueId":[{"type":"oid","value":"1.2.36.1.2001.1003.0","comment":"This value is used in Australian CDA documents"},{"type":"uri","value":"http://ns.electronichealth.net.au/id/hi/ihi/1.0","preferred":true,"period":{"start":"2015-08-21"}}]}]}

Query

db.system.aggregate([{$match:{"type.coding.code":"JPID"}},{$addFields:{"type.coding":{"$filter":{"input":"$type.coding","as":"tc","cond":{$eq:["$$tc.code","JPID"]}}}}}])

Result