The second query is searching for the same HealthcareServiceRequest entity as the first query, but the return items are not the same. Adding the transactId to return statement of the first query doesn’t get you what you want?
Is it the case that there is not always a Attachments275 entity in the first query, so you don’t get results? If so, switch the match on the attachment275 to an optional match.
I am sorry i didnt get it
How should the query will be
I did some research and get that one
match (n:HealthcareServiceRequest) where n.AuthorizationNumber in %s
and n.AuthRequestType = '005010X217' and n.EventName = 'Response278'
Match (m:Attachments275) where n.AttachControlNumber = m.AttachmentControlNumber
return n.AuthorizationNumber as Authorization_ID, n.TransactionID as TransactionID, m.Attachmentpath as Attachmentpath order by n.EventCreationDateTime desc
I was suggesting the following to address the situation where there is not an associated attachment, but you still want a result.
match (n:HealthcareServiceRequest) where n.AuthorizationNumber in %s
and n.AuthRequestType = '005010X217' and n.EventName = 'Response278'
Optional Match (m:Attachments275) where n.AttachControlNumber = m.AttachmentControlNumber
return n.AuthorizationNumber as Authorization_ID, n.TransactionID as TransactionID, m.Attachmentpath as Attachmentpath order by n.EventCreationDateTime desc
match (n:HealthcareServiceRequest) where n.AuthorizationNumber in ['2207090003']
and n.AuthRequestType = '005010X217' and n.EventName = 'Response278'
Match (m:Attachments275) where n.AttachControlNumber = m.AttachmentControlNumber
return id(n), id(m)
Just what I thought. You have multiple Attachment275 nodes that meet the requirement. The results look like duplicates because the fields you are returning for the Attachment275 nodes have the same values. In reality, they are different nodes. id(m) is the internal neo4j id for the Attachment275 nodes returned. The values are all different, thus they are different nodes.
Do you expect this, or have these nodes been unintentionally duplicated? Are all the properties for these nodes identical?
Run this query if you want to compare the Attachment275 nodes:
match (n:HealthcareServiceRequest) where n.AuthorizationNumber in ['2207090003']
and n.AuthRequestType = '005010X217' and n.EventName = 'Response278'
Match (m:Attachments275) where n.AttachControlNumber = m.AttachmentControlNumber
return id(n), id(m), properties(m)