Xray
daily rollups 1h 6h 24h 48h 3d 5d 7d 14d 30d ‹
Last 30 days▾
Ends now. Anything up to this cluster's 30-day retention.
Start and end times
Cancel
Interpreted in UTC (change it at the right of this bar). Earliest available: 2026-10-19 12:06:17.
› →|
updated 1d ago
Sample data. This database was generated by scripts/seed_dev_db.py — every service, deploy, person and figure on this page is synthetic. Names are sample.*@seed.invalid and image tags are prefixed SEED-. Nothing here happened.

Query trends 80

stored 25h ago top 80 of 2,313

Neo4j query shapes on test27 over the last 30d, grouped by plan hash. Click a column to sort; p95 drift (late-half ÷ early-half of the window) ranks the queries getting slower.

Columns
Views
Export CSV
Query shape Count Avg p95 ▾ Max p95 drift
WITH ? as total, null as vector MATCH (doc:Document) WHERE doc.tildaid in $lists.mf0 MATCH (org:Organization{tildaid:$policyOrgId0}) CALL { WITH org, doc UNWIND [doc.studyId] AS studyId OPTIONAL MATCH (study:Study) WHERE study.tildaid = st…
WITH ? as total, null as vector MATCH (doc:Document) WHERE doc.tildaid in $lists.mf0 MATCH (org:Organization{tildaid:$policyOrgId0}) CALL { WITH org, doc UNWIND [doc.studyId] AS studyId OPTIONAL MATCH (study:Study) WHERE study.tildaid = studyId // An inactive actor carries no membership, so it is excluded here rather than at each use: // the sites, countries and roles below all hang off it. OPTIONAL MATCH (study)-[:STUDY_TO_ACTOR]-(studyActor:Actor{orgId:$ctxOrgId0})-[:FOR_USER]->(:User{tildaid:$ctxUserId0}) WHERE studyActor.state <> ? // Collect sites where user has membership in this study OPTIONAL MATCH (studyActor)-[:STUDYSITEACTOR_TO_ACTOR]-(:StudySiteActor)-[:STUDYSITEACTOR_TO_PLAN_DEFINITION]-(pd:DslPlanDefinition)-[:PLAN_DEFINITION_TO_SITE]-(site:Site) WITH org, study, studyActor, collect(DISTINCT site.tildaid) as userSiteIds // Collect countries where user has membership in this study OPTIONAL MATCH (studyActor)<-[:STUDYCOUNTRYACTOR_TO_ACTOR]-(sca:StudyCountryActor) WITH org, study, studyActor, userSiteIds, collect(DISTINCT sca.country) as userCountryIds // Pre-collect policies for this user/role in this study OPTIONAL MATCH (org)<-[:DOC_ACCESS_POLICY_TO_ORG]-(policy:DocumentAccessPolicy{status:?})-[:POLICY_TO_STUDY]->(study) WHERE EXISTS { MATCH (policy)-[:POLICY_FOR_USER]->(:User{tildaid:$ctxUserId0}) } OR (studyActor IS NOT NULL AND EXISTS { MATCH (policy)-[:POLICY_FOR_ROLE]->(role:Role)<-[:APPOINTED_AS]-(studyActor) }) WITH study, studyActor, userSiteIds, userCountryIds, collect(policy) as policies WITH {study:study, studyActor:studyActor, userSiteIds:userSiteIds, userCountryIds:userCountryIds, policies:policies} AS st WITH collect(distinct st) as studies // studyById lets each document row look its context up by study id instead of scanning // the whole list. Entries whose study did not resolve share the ? key; they all carry // the same empty context, so which one wins does not matter. The node-bearing maps go no // further than this subquery; studyIdsInScope needs no lookup, since an id with no Study // node can never equal a matched study?tildaScale?ReadWrite?ReadOnly?s folder and ancestors (up to ? levels for TMF hierarchy) OPTIONAL MATCH (doc1)<-[:INCLUDES]-(docFolder:Folder) OPTIONAL MATCH (docFolder)<-[:INCLUDES*?..?]-(ancestorFolder:Folder) WITH doc1, policies, userSiteIds, userCountryIds, defaultAccessLevel, collect(DISTINCT docFolder) + collect(DISTINCT ancestorFolder) AS folderHierarchy // Check document ownership OPTIONAL MATCH (doc1)-[:UPLOADED_BY]->(uploader:User{tildaid:$policyUploaderId0}) WITH doc1, policies, userSiteIds, userCountryIds, defaultAccessLevel, folderHierarchy, uploader IS NOT NULL AS isOwnedByUser // Filter policies by: // ?. Folder: policy applies if folder is in hierarchy OR policy has no folder (study-wide). A folder-less // ownership policy is the role?Owned Documents?Non Owned Documents?Staging?Pre-Staging?Owned Documents?Non Owned Documents?My Sites Documents?Other Sites Documents?My Countries Documents?Other Countries Documents?Study Scope Documents?NoAccess?NoAccess?ReadOnly?ReadOnly?ReadWrite?ReadOnly?NoAccess? ?Received?Quality Control?PHI Issues???/???/???/???/') ELSE ? END as childFolderPath WITH docObj, ct, child, st, head(collect(childFolderPath)) AS childFolderPath WITH child, CASE WHEN ct IS NULL THEN null ELSE { documentId: child.tildaid, studyId: COALESCE(child.studyId, ?), studyName: COALESCE(st.name, ?), folderPath: childFolderPath, kind: ct.kind, stale: ct.sourceVersionId <> docObj.primaryVersionId, version: COALESCE(child.versionName, toString(child.majorVersion)) } END as copiedToEntry RETURN collect(copiedToEntry) as copiedTo, count(DISTINCT child) as copiedToCount } CALL { WITH doc OPTIONAL MATCH (doc)<-[:PROMOTED_FROM]-(tv:DocumentVersion)<-[:DOCUMENT_VERSION]-(tgt:Document) WITH CASE WHEN tgt IS NULL THEN null ELSE { documentId: tgt.tildaid, targetVersionId: tv.tildaid, version: COALESCE(tv.versionName, toString(tv.majorVersion)) } END as promotedTo RETURN promotedTo LIMIT ? } CALL { return null AS docReviewStatus, null AS hasImportantComment, null AS discrepancyCount } CALL { WITH docObj OPTIONAL MATCH (docObj)<-[:INCLUDES]-(currentFolder:Folder{folderType:?}) WHERE currentFolder.scope IN [?, ?] OPTIONAL MATCH (docObj)-[:FILED_UNDER_SUBARTIFACT]->(currentSubArtifact:SubArtifact)<-[:INCLUDES]-(currentFolder) OPTIONAL MATCH (docObj)-[:HAS_STAGING_INFO]->(stagingInfo:DocumentStagingInfo) WITH CASE WHEN stagingInfo IS NOT NULL THEN {artifactId: stagingInfo.folderId, subArtifactId: stagingInfo.subArtifactId, stagingInfoId: stagingInfo.tildaid} WHEN currentFolder.level = ? THEN {artifactId: currentFolder.tildaid, subArtifactId: COALESCE(currentSubArtifact.tildaid, ?), stagingInfoId: ?} ELSE {artifactId: ?, subArtifactId: ?, stagingInfoId: ?} END as tmfInfo WITH tmfInfo.artifactId as artifactId, tmfInfo.subArtifactId as subArtifactId, tmfInfo.stagingInfoId as stagingInfoId OPTIONAL MATCH (artifact:Folder{tildaid:artifactId})<-[:INCLUDES]-(section:Folder)<-[:INCLUDES]-(zone:Folder)<-[:INCLUDES]-(collection:Folder{name:?}) OPTIONAL MATCH (artifact)-[:INCLUDES]->(allSubArtifacts:SubArtifact) OPTIONAL MATCH (artifact)-[:INCLUDES]->(subArtifact:SubArtifact{tildaid:subArtifactId}) OPTIONAL MATCH (subArtifact)-[:HAS]->(subArtifactConstraints:FolderConstraints) OPTIONAL MATCH (artifact)-[:HAS]->(artifactConstraints:FolderConstraints) WITH artifactId as folderId, subArtifactId, stagingInfoId, CASE WHEN zone.number IS NOT NULL THEN COALESCE(apoc.text.lpad(toString(zone.number), ?, ?)+ ? + zone.name, ?) ELSE ? END as zone, CASE WHEN section.number IS NOT NULL THEN COALESCE(apoc.text.lpad(toString(zone.number), ?, ?)+?+apoc.text.lpad(toString(section.number), ?, ?)+ ? + section.name, ?) ELSE ? END as section, CASE WHEN artifact.number IS NOT NULL THEN COALESCE(apoc.text.lpad(toString(zone.number), ?, ?)+?+apoc.text.lpad(toString(section.number), ?, ?)+?+apoc.text.lpad(toString(artifact.number), ?, ?)+ ? + artifact.name, ?) ELSE ? END as artifact, CASE WHEN subArtifact.number IS NOT NULL THEN COALESCE(apoc.text.lpad(toString(zone.number), ?, ?)+?+apoc.text.lpad(toString(section.number), ?, ?)+?+apoc.text.lpad(toString(artifact.number), ?, ?)+?+apoc.text.lpad(toString(subArtifact.number), ?, ?)+ ? + subArtifact.name, ?) ELSE ? END as subArtifact, COALESCE(subArtifact.name, ?) as subArtifactName, COALESCE(subArtifactConstraints, artifactConstraints) as constraints, NOT(COUNT(allSubArtifacts) > ? AND subArtifactId = ?) as subArtifactValid OPTIONAL MATCH (constraints)-[:HAS_ATTRIBUTE_CONSTRAINT]->(dac:DocAttributeConstraint) WITH folderId, subArtifactId, stagingInfoId, zone, section, artifact, subArtifact, subArtifactName, subArtifactValid, constraints, COLLECT(DISTINCT CASE WHEN dac IS NOT NULL THEN {id: dac.tildaid, key: dac.key, order: dac.order, isMandatory: dac.isMandatory, description: dac.description} ELSE NULL END) as attributeConstraintsList WITH folderId, subArtifactId, stagingInfoId, zone, section, artifact, subArtifact, subArtifactName, subArtifactValid, CASE WHEN constraints IS NOT NULL THEN { id: constraints.tildaid, mandatory: constraints.mandatory, tmfLevel: constraints.tmfLevel, attributeConstraints: [attr IN attributeConstraintsList WHERE attr IS NOT NULL | attr] } ELSE null END as constraints WITH {folderId: folderId, subArtifactId: subArtifactId, stagingInfoId: stagingInfoId, zone: zone, section: section, artifact: artifact, subArtifact: subArtifact, subArtifactName: subArtifactName, subArtifactValid: subArtifactValid, path: apoc.text.join([x IN [zone, section, artifact] WHERE x <> ? | x], ?), constraints: constraints} as tmfCategorization RETURN CASE WHEN tmfCategorization.folderId=? THEN null ELSE tmfCategorization END as tmfCategorization } with distinct doc{.*, status: docObj.status, stateTag: docObj.stateTag, orgAlias: org.alias, owned: owned, docTypeName: doc.docTypeName, userId: doc.userId, user: CASE WHEN user IS NOT NULL THEN {id: user.tildaid, name: user.name, profilePicURL: user.profilePicURL} ELSE NULL END, createdDate: doc.createdat, updatedDate: COALESCE(doc.updatedat, doc.createdat), externalUrl: doc.url, study: study.name, studyId: study.tildaid, site: site.name, siteId: doc.siteId, siteNumber: siteNumber, piNames: piNames, patient: patientName, patientId: doc.patientId, subjectId: subjectId, visit: visit.title, visitId: doc.visitId, reviewDate: reviewDate, assignedToUsers: [], uploadedBy: {id: uploadedBy.tildaid, name: uploadedBy.name, profilePicURL: uploadedBy.profilePicURL}, signedByUsers: signedByUsers, tags: tags, listingFolders: listingFolders, primaryFolder: primaryFolder, latestAIRun: latestAIRun, findingCount: findingCount, queriesCount: queriesCount, confirmedCount: confirmedCount, resolvedCount: resolvedCount, notesCount: notesCount, stagingLabels: stagingLabels, workOrders: workOrders, woContact: COALESCE(woContact, false), stateTags1: stateTags1, stateTags2: stateTags2, docAccessLevel: docAccessLevel, isSigner: isSigner, docReviewStatus: docReviewStatus, hasImportantComment: hasImportantComment, discrepancyCount: discrepancyCount , templateDetails: templateDetails, docTypeDetails: docType{.*}, queries: queries, annotationSpec: annotationSpec, annotationVal: annotationVal, completedAt: annotationVal.completedAt, versions: versions, reviews: reviews, sharedWith: sharedWith, currentShare: currentShare, tmfCategorization: tmfCategorization, docAttributes: docAttributes, eventId: eventId, eventName: eventName, deliverable: deliverable, eventScope: eventScope, provenance: CASE WHEN copiedFrom IS NULL AND size(copiedTo) = ? THEN null ELSE {copiedFrom: copiedFrom, copiedTo: [x IN copiedTo WHERE x IS NOT NULL | x], copiedToCount: copiedToCount} END, promotedTo: promotedTo} AS document, total return document, total
docsvc
3 2.00 s 9.25 s 5.97 s flat
MATCH (u:User{tildaid:$userId}), (o:Organization{delpending:false, alias:$orgAlias}) call { with u, o // An Inactive actor holds no roles (ENG-?): its roles would otherwise // still feed hidePhi, the role list and every policy match. OPTIO…
MATCH (u:User{tildaid:$userId}), (o:Organization{delpending:false, alias:$orgAlias}) call { with u, o // An Inactive actor holds no roles (ENG-?): its roles would otherwise // still feed hidePhi, the role list and every policy match. OPTIONAL MATCH (u)<-[:FOR_USER]-(a:Actor{delpending:false})<-[:ORGANIZATION_TO_ACTOR]-(o), (a)-[:APPOINTED_AS]->(r:Role) WHERE not r.name = ? AND coalesce(a.state, ?) <> ? return r{.*} UNION with u, o // Delegated engagements in o. Only the delegated roles cross over — // the TildaScale Actor?s list. MATCH (u)<-[:FOR_USER]-(da:Actor{delpending:false})<-[:STUDY_TO_DELEGATED_ACTOR]-(st:Study{delpending:false})-[:STUDY_TO_ORG]->(o), (da)-[:APPOINTED_AS]->(r:Role)<-[:APPOINTED_AS]-(sa:Actor{delpending:false}), (da)-[:DELEGATED_FROM]->(sa)<-[:ORGANIZATION_TO_ACTOR]-(:Organization{alias:$tildaScaleAlias}) WHERE st.srcorgid = o.tildaid AND da.state <> ? AND sa.state <> ? AND $orgDelegatedTag IN apoc.text.split(coalesce(r.tags, ?), ?) return distinct r{.*} } WITH u, o, collect(distinct r.name) as roles, collect(distinct case when r.listed = true then r.displayName end) as displayRoles, ANY(n IN COLLECT(r.external) WHERE n = true) as external, ANY(n IN COLLECT(r.name) WHERE n = ?) as isPatient, ALL(n IN COLLECT(r.piiAccess) WHERE n = false) as hidePhi WITH u, o, {organization:o{.*}, external: external, isPatient: isPatient, hidePhi: hidePhi, roles: roles, displayRoles: displayRoles } as context CALL {WITH u, o MATCH (u)<-[:FOR_USER]-(a:Actor{delpending:false})<-[:STAFF_TO_ACTOR]-(si:Site{delpending:false})-[:SITE_TO_SMO]->(:Smo)-[:IS_AN_ORG]->(o) WHERE coalesce(a.state, ?) <> ? OPTIONAL MATCH (a)-[:APPOINTED_AS]->(r:Role) WITH u, o, si, a, r order by r.displayName WITH u, o, si, a, collect(distinct r.name) as roles, collect(distinct case when r.listed = true then r.displayName end) as displayRoles WITH CASE when not si is null then {siteId: si.tildaid, roles: roles, displayRoles: displayRoles} end as si return collect(si) as sites, apoc.coll.flatten(collect(si.roles)) as siteRoles } CALL {WITH u, o // WITH DISTINCT is a required pipeline barrier (see the studyMembership note // in scope.go): without it (u)<-[:FOR_USER]-(a) re-expands once per study in // the org — ?.0M -> 32k db hits. Splitting the MATCH without DISTINCT does // nothing; the barrier is what forbids the bad join order. Not applied to the // sites or org-roles subqueries, where it measured neutral or worse. // No longer OPTIONAL: the subquery ends in an ungrouped aggregation, so zero // matches still yield one row with empty collections. CALL {WITH u, o MATCH (u)<-[:FOR_USER]-(a:Actor{delpending:false, orgId:o.tildaid}) WHERE coalesce(a.state, ?) <> ? WITH DISTINCT u, o, a MATCH (a)<-[:STUDY_TO_ACTOR]-(s:Study{delpending:false})-[:STUDY_TO_ORG]->(o) OPTIONAL MATCH (a)-[:APPOINTED_AS]->(r:Role) RETURN s, a, r UNION // Delegated engagement Actors: orgId is TildaScale? roles. WITH s, r order by r.displayName WITH s, collect(distinct r.name) as roles, collect(distinct case when r.listed = true then r.displayName end) as displayRoles // Ordered so the studies array is a stable sequence for clients; the pipeline // that replaced the old (u,o,s,a) grouping otherwise leaves it plan-dependent. WITH s, CASE when not s is null then {studyId: s.tildaid, roles: roles, displayRoles: displayRoles, srcOrgId: s.srcorgid} end as st ORDER BY s.name, s.tildaid return collect(st) as studies, apoc.coll.flatten(collect(st.roles)) as studyRoles } with distinct context, studies, apoc.coll.toSet(apoc.coll.flatten(collect(studyRoles))) as allStudyRoles, apoc.coll.toSet(apoc.coll.flatten(collect(siteRoles))) as siRoles with context, studies, apoc.coll.toSet(apoc.coll.flatten([context.roles, allStudyRoles, siRoles])) as allRoles return context{.*, studies: studies, allRoles: allRoles}
dashql
8 967 ms 8.00 s 5.41 s flat
MATCH (u:User{tildaid:$userId}), (o:Organization{delpending:false, alias:$orgAlias}) call { with u, o // An Inactive actor holds no roles (ENG-?): its roles would otherwise // still feed hidePhi, the role list and every policy match. OPTIO…
MATCH (u:User{tildaid:$userId}), (o:Organization{delpending:false, alias:$orgAlias}) call { with u, o // An Inactive actor holds no roles (ENG-?): its roles would otherwise // still feed hidePhi, the role list and every policy match. OPTIONAL MATCH (u)<-[:FOR_USER]-(a:Actor{delpending:false})<-[:ORGANIZATION_TO_ACTOR]-(o), (a)-[:APPOINTED_AS]->(r:Role) WHERE not r.name = ? AND coalesce(a.state, ?) <> ? return r{.*} UNION with u, o // Delegated engagements in o. Only the delegated roles cross over — // the TildaScale Actor?s list. MATCH (u)<-[:FOR_USER]-(da:Actor{delpending:false})<-[:STUDY_TO_DELEGATED_ACTOR]-(st:Study{delpending:false})-[:STUDY_TO_ORG]->(o), (da)-[:APPOINTED_AS]->(r:Role)<-[:APPOINTED_AS]-(sa:Actor{delpending:false}), (da)-[:DELEGATED_FROM]->(sa)<-[:ORGANIZATION_TO_ACTOR]-(:Organization{alias:$tildaScaleAlias}) WHERE st.srcorgid = o.tildaid AND da.state <> ? AND sa.state <> ? AND $orgDelegatedTag IN apoc.text.split(coalesce(r.tags, ?), ?) return distinct r{.*} } WITH u, o, collect(distinct r.name) as roles, collect(distinct case when r.listed = true then r.displayName end) as displayRoles, ANY(n IN COLLECT(r.external) WHERE n = true) as external, ANY(n IN COLLECT(r.name) WHERE n = ?) as isPatient, ALL(n IN COLLECT(r.piiAccess) WHERE n = false) as hidePhi WITH u, o, {organization:o{.*}, external: external, isPatient: isPatient, hidePhi: hidePhi, roles: roles, displayRoles: displayRoles } as context CALL {WITH u, o MATCH (u)<-[:FOR_USER]-(a:Actor{delpending:false})<-[:STAFF_TO_ACTOR]-(si:Site{delpending:false})-[:SITE_TO_SMO]->(:Smo)-[:IS_AN_ORG]->(o) WHERE coalesce(a.state, ?) <> ? OPTIONAL MATCH (a)-[:APPOINTED_AS]->(r:Role) WITH u, o, si, a, r order by r.displayName WITH u, o, si, a, collect(distinct r.name) as roles, collect(distinct case when r.listed = true then r.displayName end) as displayRoles WITH CASE when not si is null then {siteId: si.tildaid, roles: roles, displayRoles: displayRoles} end as si return collect(si) as sites, apoc.coll.flatten(collect(si.roles)) as siteRoles } CALL {WITH u, o // WITH DISTINCT is a required pipeline barrier (see the studyMembership note // in scope.go): without it (u)<-[:FOR_USER]-(a) re-expands once per study in // the org — ?.0M -> 32k db hits. Splitting the MATCH without DISTINCT does // nothing; the barrier is what forbids the bad join order. Not applied to the // sites or org-roles subqueries, where it measured neutral or worse. // No longer OPTIONAL: the subquery ends in an ungrouped aggregation, so zero // matches still yield one row with empty collections. CALL {WITH u, o MATCH (u)<-[:FOR_USER]-(a:Actor{delpending:false, orgId:o.tildaid}) WHERE coalesce(a.state, ?) <> ? WITH DISTINCT u, o, a MATCH (a)<-[:STUDY_TO_ACTOR]-(s:Study{delpending:false})-[:STUDY_TO_ORG]->(o) OPTIONAL MATCH (a)-[:APPOINTED_AS]->(r:Role) RETURN s, a, r UNION // Delegated engagement Actors: orgId is TildaScale? roles. WITH s, r order by r.displayName WITH s, collect(distinct r.name) as roles, collect(distinct case when r.listed = true then r.displayName end) as displayRoles // Ordered so the studies array is a stable sequence for clients; the pipeline // that replaced the old (u,o,s,a) grouping otherwise leaves it plan-dependent. WITH s, CASE when not s is null then {studyId: s.tildaid, name: s.name, roles: roles, displayRoles: displayRoles, srcOrgId: s.srcorgid} end as st ORDER BY s.name, s.tildaid return collect(st) as studies, apoc.coll.flatten(collect(st.roles)) as studyRoles } with distinct context, studies, apoc.coll.toSet(apoc.coll.flatten(collect(studyRoles))) as allStudyRoles, apoc.coll.toSet(apoc.coll.flatten(collect(siteRoles))) as siRoles with context, studies, apoc.coll.toSet(apoc.coll.flatten([context.roles, allStudyRoles, siRoles])) as allRoles return context{.*, studies: studies, allRoles: allRoles}
authzd
1 2.70 s 4.85 s 2.70 s flat
MATCH (u:User{tildaid:$user}), (o:Organization{delpending:false, alias:$org}) CALL (u, o) { OPTIONAL MATCH (u)<-[:FOR_USER]-(a:Actor{delpending:false})<-[:ORGANIZATION_TO_ACTOR]-(o), (a)-[:APPOINTED_AS]->(r:Role) WHERE not r.name = ? AND c…
MATCH (u:User{tildaid:$user}), (o:Organization{delpending:false, alias:$org}) CALL (u, o) { OPTIONAL MATCH (u)<-[:FOR_USER]-(a:Actor{delpending:false})<-[:ORGANIZATION_TO_ACTOR]-(o), (a)-[:APPOINTED_AS]->(r:Role) WHERE not r.name = ? AND coalesce(a.state, ?) <> ? return r{.*} UNION MATCH (u)<-[:FOR_USER]-(da:Actor{delpending:false})<-[:STUDY_TO_DELEGATED_ACTOR]-(st:Study{delpending:false})-[:STUDY_TO_ORG]->(o), (da)-[:APPOINTED_AS]->(r:Role)<-[:APPOINTED_AS]-(sa:Actor{delpending:false}), (da)-[:DELEGATED_FROM]->(sa)<-[:ORGANIZATION_TO_ACTOR]-(:Organization{alias:?}) WHERE st.srcorgid = o.tildaid AND da.state <> ? AND sa.state <> ? AND ? IN apoc.text.split(coalesce(r.tags, ?), ?) return distinct r{.*} } WITH u, o, collect(distinct r.name) as roles, collect(distinct case when r.listed = true then r.displayName end) as displayRoles, ANY(n IN COLLECT(r.external) WHERE n = true) as external, ANY(n IN COLLECT(r.name) WHERE n = ?) as isPatient, ALL(n IN COLLECT(r.piiAccess) WHERE n = false) as hidePhi WITH u, o, {organization:o{.*}, external: external, isPatient: isPatient, hidePhi: hidePhi, roles: roles, displayRoles: displayRoles } as context CALL (u, o) { MATCH (u)<-[:FOR_USER]-(a:Actor{delpending:false})<-[:STAFF_TO_ACTOR]-(si:Site{delpending:false})-[:SITE_TO_SMO]->(:Smo)-[:IS_AN_ORG]->(o) WHERE coalesce(a.state, ?) <> ? OPTIONAL MATCH (a)-[:APPOINTED_AS]->(r:Role) WITH u, o, si, a, r order by r.displayName WITH u, o, si, a, collect(distinct r.name) as roles, collect(distinct case when r.listed = true then r.displayName end) as displayRoles WITH CASE when not si is null then {siteId: si.tildaid, roles: roles, displayRoles: displayRoles} end as si return collect(si) as sites, apoc.coll.flatten(collect(si.roles)) as siteRoles } CALL (u, o) { CALL (u, o) { MATCH (u)<-[:FOR_USER]-(a:Actor{delpending:false, orgId:o.tildaid}) WHERE coalesce(a.state, ?) <> ? // Required pipeline barrier: without it the actor match re-expands // once per study in the org (?.0M -> 32k db hits, measured in Go). WITH DISTINCT u, o, a MATCH (a)<-[:STUDY_TO_ACTOR]-(s:Study{delpending:false})-[:STUDY_TO_ORG]->(o) OPTIONAL MATCH (a)-[:APPOINTED_AS]->(r:Role) RETURN s, r UNION // Delegated engagement Actors: orgId is TildaScale? roles. WITH s, r order by r.displayName WITH s, collect(distinct r.name) as roles, collect(distinct case when r.listed = true then r.displayName end) as displayRoles // Ordered so the studies array is a stable sequence for clients. WITH s, {studyId: s.tildaid, roles: roles, displayRoles: displayRoles, srcOrgId: s.srcorgid} as st ORDER BY s.name, s.tildaid return collect(st) as studies, apoc.coll.flatten(collect(st.roles)) as studyRoles } with distinct context, studies, apoc.coll.toSet(apoc.coll.flatten(collect(studyRoles))) as allStudyRoles, apoc.coll.toSet(apoc.coll.flatten(collect(siteRoles))) as siRoles with context, studies, apoc.coll.toSet(apoc.coll.flatten([context.roles, allStudyRoles, siRoles])) as allRoles return context{.*, studies: studies, allRoles: allRoles} as rc
virtual-assistant
1 3.48 s 4.85 s 3.48 s flat
MATCH (u:User{tildaid:$userId}), (o:Organization{delpending:false, alias:$orgAlias}) call { with u, o // An Inactive actor holds no roles (ENG-?): its roles would otherwise // still feed hidePhi, the role list and every policy match. OPTIO…
MATCH (u:User{tildaid:$userId}), (o:Organization{delpending:false, alias:$orgAlias}) call { with u, o // An Inactive actor holds no roles (ENG-?): its roles would otherwise // still feed hidePhi, the role list and every policy match. OPTIONAL MATCH (u)<-[:FOR_USER]-(a:Actor{delpending:false})<-[:ORGANIZATION_TO_ACTOR]-(o), (a)-[:APPOINTED_AS]->(r:Role) WHERE not r.name = ? AND coalesce(a.state, ?) <> ? return r{.*} UNION with u, o // Delegated engagements in o. Only the delegated roles cross over — // the TildaScale Actor?s list. MATCH (u)<-[:FOR_USER]-(da:Actor{delpending:false})<-[:STUDY_TO_DELEGATED_ACTOR]-(st:Study{delpending:false})-[:STUDY_TO_ORG]->(o), (da)-[:APPOINTED_AS]->(r:Role)<-[:APPOINTED_AS]-(sa:Actor{delpending:false}), (da)-[:DELEGATED_FROM]->(sa)<-[:ORGANIZATION_TO_ACTOR]-(:Organization{alias:$tildaScaleAlias}) WHERE st.srcorgid = o.tildaid AND da.state <> ? AND sa.state <> ? AND $orgDelegatedTag IN apoc.text.split(coalesce(r.tags, ?), ?) return distinct r{.*} } WITH u, o, collect(distinct r.name) as roles, collect(distinct case when r.listed = true then r.displayName end) as displayRoles, ANY(n IN COLLECT(r.external) WHERE n = true) as external, ANY(n IN COLLECT(r.name) WHERE n = ?) as isPatient, ALL(n IN COLLECT(r.piiAccess) WHERE n = false) as hidePhi WITH u, o, {organization:o{.*}, external: external, isPatient: isPatient, hidePhi: hidePhi, roles: roles, displayRoles: displayRoles } as context CALL {WITH u, o MATCH (u)<-[:FOR_USER]-(a:Actor{delpending:false})<-[:STAFF_TO_ACTOR]-(si:Site{delpending:false})-[:SITE_TO_SMO]->(:Smo)-[:IS_AN_ORG]->(o) WHERE coalesce(a.state, ?) <> ? OPTIONAL MATCH (a)-[:APPOINTED_AS]->(r:Role) WITH u, o, si, a, r order by r.displayName WITH u, o, si, a, collect(distinct r.name) as roles, collect(distinct case when r.listed = true then r.displayName end) as displayRoles WITH CASE when not si is null then {siteId: si.tildaid, roles: roles, displayRoles: displayRoles} end as si return collect(si) as sites, apoc.coll.flatten(collect(si.roles)) as siteRoles } CALL {WITH u, o // WITH DISTINCT is a required pipeline barrier (see the studyMembership note // in scope.go): without it (u)<-[:FOR_USER]-(a) re-expands once per study in // the org — ?.0M -> 32k db hits. Splitting the MATCH without DISTINCT does // nothing; the barrier is what forbids the bad join order. Not applied to the // sites or org-roles subqueries, where it measured neutral or worse. // No longer OPTIONAL: the subquery ends in an ungrouped aggregation, so zero // matches still yield one row with empty collections. CALL {WITH u, o MATCH (u)<-[:FOR_USER]-(a:Actor{delpending:false, orgId:o.tildaid}) WHERE coalesce(a.state, ?) <> ? WITH DISTINCT u, o, a MATCH (a)<-[:STUDY_TO_ACTOR]-(s:Study{delpending:false})-[:STUDY_TO_ORG]->(o) OPTIONAL MATCH (a)-[:APPOINTED_AS]->(r:Role) RETURN s, a, r UNION // Delegated engagement Actors: orgId is TildaScale? roles. WITH s, r order by r.displayName WITH s, collect(distinct r.name) as roles, collect(distinct case when r.listed = true then r.displayName end) as displayRoles // Ordered so the studies array is a stable sequence for clients; the pipeline // that replaced the old (u,o,s,a) grouping otherwise leaves it plan-dependent. WITH s, CASE when not s is null then {studyId: s.tildaid, roles: roles, displayRoles: displayRoles, srcOrgId: s.srcorgid} end as st ORDER BY s.name, s.tildaid return collect(st) as studies, apoc.coll.flatten(collect(st.roles)) as studyRoles } with distinct context, studies, apoc.coll.toSet(apoc.coll.flatten(collect(studyRoles))) as allStudyRoles, apoc.coll.toSet(apoc.coll.flatten(collect(siteRoles))) as siRoles with context, studies, apoc.coll.toSet(apoc.coll.flatten([context.roles, allStudyRoles, siRoles])) as allRoles return context{.*, studies: studies, allRoles: allRoles}
dashql
1 3.82 s 4.85 s 3.82 s flat
MATCH (org:Organization{tildaid:$scopeOrgId0}) CALL { WITH org UNWIND $lists.allowedStudies0 AS studyId OPTIONAL MATCH (study:Study) WHERE study.tildaid = studyId // An inactive actor carries no membership, so it is excluded here rather th…
MATCH (org:Organization{tildaid:$scopeOrgId0}) CALL { WITH org UNWIND $lists.allowedStudies0 AS studyId OPTIONAL MATCH (study:Study) WHERE study.tildaid = studyId // An inactive actor carries no membership, so it is excluded here rather than at each use: // the sites, countries and roles below all hang off it. OPTIONAL MATCH (study)-[:STUDY_TO_ACTOR]-(studyActor:Actor{orgId:$ctxOrgId0})-[:FOR_USER]->(:User{tildaid:$ctxUserId0}) WHERE studyActor.state <> ? // Collect sites where user has membership in this study OPTIONAL MATCH (studyActor)-[:STUDYSITEACTOR_TO_ACTOR]-(:StudySiteActor)-[:STUDYSITEACTOR_TO_PLAN_DEFINITION]-(pd:DslPlanDefinition)-[:PLAN_DEFINITION_TO_SITE]-(site:Site) WITH org, study, studyActor, collect(DISTINCT site.tildaid) as userSiteIds // Collect countries where user has membership in this study OPTIONAL MATCH (studyActor)<-[:STUDYCOUNTRYACTOR_TO_ACTOR]-(sca:StudyCountryActor) WITH org, study, studyActor, userSiteIds, collect(DISTINCT sca.country) as userCountryIds // Pre-collect policies for this user/role in this study OPTIONAL MATCH (org)<-[:DOC_ACCESS_POLICY_TO_ORG]-(policy:DocumentAccessPolicy{status:?})-[:POLICY_TO_STUDY]->(study) WHERE EXISTS { MATCH (policy)-[:POLICY_FOR_USER]->(:User{tildaid:$ctxUserId0}) } OR (studyActor IS NOT NULL AND EXISTS { MATCH (policy)-[:POLICY_FOR_ROLE]->(role:Role)<-[:APPOINTED_AS]-(studyActor) }) WITH study, studyActor, userSiteIds, userCountryIds, collect(policy) as policies WITH {study:study, studyActor:studyActor, userSiteIds:userSiteIds, userCountryIds:userCountryIds, policies:policies} AS st WITH collect(distinct st) as studies // studyById lets each document row look its context up by study id instead of scanning // the whole list. Entries whose study did not resolve share the ? key; they all carry // the same empty context, so which one wins does not matter. The node-bearing maps go no // further than this subquery; studyIdsInScope needs no lookup, since an id with no Study // node can never equal a matched study??ReadWrite?ReadOnly?s folder and ancestors (up to ? levels for TMF hierarchy) OPTIONAL MATCH (doc1)<-[:INCLUDES]-(docFolder:Folder) OPTIONAL MATCH (docFolder)<-[:INCLUDES*?..?]-(ancestorFolder:Folder) WITH doc1, policies, userSiteIds, userCountryIds, defaultAccessLevel, collect(DISTINCT docFolder) + collect(DISTINCT ancestorFolder) AS folderHierarchy // Check document ownership OPTIONAL MATCH (doc1)-[:UPLOADED_BY]->(uploader:User{tildaid:$policyUploaderId0}) WITH doc1, policies, userSiteIds, userCountryIds, defaultAccessLevel, folderHierarchy, uploader IS NOT NULL AS isOwnedByUser // Filter policies by: // ?. Folder: policy applies if folder is in hierarchy OR policy has no folder (study-wide). A folder-less // ownership policy is the role?Owned Documents?Non Owned Documents?Staging?Pre-Staging?Owned Documents?Non Owned Documents?My Sites Documents?Other Sites Documents?My Countries Documents?Other Countries Documents?Study Scope Documents?NoAccess?NoAccess?ReadOnly?ReadOnly?ReadWrite?ReadOnly?NoAccess?? ?Received?Quality Control?PHI Issues???/???/???/') ELSE ? END as childFolderPath WITH docObj, ct, child, st, head(collect(childFolderPath)) AS childFolderPath WITH child, CASE WHEN ct IS NULL THEN null ELSE { documentId: child.tildaid, studyId: COALESCE(child.studyId, ?), studyName: COALESCE(st.name, ?), folderPath: childFolderPath, kind: ct.kind, stale: ct.sourceVersionId <> docObj.primaryVersionId, version: COALESCE(child.versionName, toString(child.majorVersion)) } END as copiedToEntry RETURN collect(copiedToEntry) as copiedTo, count(DISTINCT child) as copiedToCount } CALL { return null as promotedTo } CALL { return null AS docReviewStatus, null AS hasImportantComment, null AS discrepancyCount } CALL { return null as tmfCategorization } with distinct doc{.*, status: docObj.status, stateTag: docObj.stateTag, orgAlias: org.alias, owned: owned, docTypeName: doc.docTypeName, userId: doc.userId, user: CASE WHEN user IS NOT NULL THEN {id: user.tildaid, name: user.name, profilePicURL: user.profilePicURL} ELSE NULL END, createdDate: doc.createdat, updatedDate: COALESCE(doc.updatedat, doc.createdat), externalUrl: doc.url, study: study.name, studyId: study.tildaid, site: site.name, siteId: doc.siteId, siteNumber: siteNumber, piNames: piNames, patient: patientName, patientId: doc.patientId, subjectId: subjectId, visit: visit.title, visitId: doc.visitId, reviewDate: reviewDate, assignedToUsers: [], uploadedBy: {id: uploadedBy.tildaid, name: uploadedBy.name, profilePicURL: uploadedBy.profilePicURL}, signedByUsers: signedByUsers, tags: tags, listingFolders: listingFolders, primaryFolder: primaryFolder, latestAIRun: latestAIRun, findingCount: findingCount, queriesCount: queriesCount, confirmedCount: confirmedCount, resolvedCount: resolvedCount, notesCount: notesCount, stagingLabels: stagingLabels, workOrders: workOrders, woContact: COALESCE(woContact, false), stateTags1: stateTags1, stateTags2: stateTags2, docAccessLevel: docAccessLevel, isSigner: isSigner, docReviewStatus: docReviewStatus, hasImportantComment: hasImportantComment, discrepancyCount: discrepancyCount , templateDetails: templateDetails, docTypeDetails: docType{.*}, queries: queries, annotationSpec: annotationSpec, annotationVal: annotationVal, completedAt: annotationVal.completedAt, versions: versions, reviews: reviews, sharedWith: sharedWith, currentShare: currentShare, tmfCategorization: tmfCategorization, docAttributes: docAttributes, eventId: eventId, eventName: eventName, deliverable: deliverable, eventScope: eventScope, provenance: CASE WHEN copiedFrom IS NULL AND size(copiedTo) = ? THEN null ELSE {copiedFrom: copiedFrom, copiedTo: [x IN copiedTo WHERE x IS NOT NULL | x], copiedToCount: copiedToCount} END, promotedTo: promotedTo} AS document, total return document, total
docsvc
1 2.35 s 4.85 s 2.35 s flat
MATCH (u:User{tildaid:$userId}), (o:Organization{delpending:false, alias:$orgAlias}) call { with u, o // An Inactive actor holds no roles (ENG-?): its roles would otherwise // still feed hidePhi, the role list and every policy match. OPTIO…
MATCH (u:User{tildaid:$userId}), (o:Organization{delpending:false, alias:$orgAlias}) call { with u, o // An Inactive actor holds no roles (ENG-?): its roles would otherwise // still feed hidePhi, the role list and every policy match. OPTIONAL MATCH (u)<-[:FOR_USER]-(a:Actor{delpending:false})<-[:ORGANIZATION_TO_ACTOR]-(o), (a)-[:APPOINTED_AS]->(r:Role) WHERE not r.name = ? AND coalesce(a.state, ?) <> ? return r{.*} UNION with u, o // Delegated engagements in o. Only the delegated roles cross over — // the TildaScale Actor?s list. MATCH (u)<-[:FOR_USER]-(da:Actor{delpending:false})<-[:STUDY_TO_DELEGATED_ACTOR]-(st:Study{delpending:false})-[:STUDY_TO_ORG]->(o), (da)-[:APPOINTED_AS]->(r:Role)<-[:APPOINTED_AS]-(sa:Actor{delpending:false}), (da)-[:DELEGATED_FROM]->(sa)<-[:ORGANIZATION_TO_ACTOR]-(:Organization{alias:$tildaScaleAlias}) WHERE st.srcorgid = o.tildaid AND da.state <> ? AND sa.state <> ? AND $orgDelegatedTag IN apoc.text.split(coalesce(r.tags, ?), ?) return distinct r{.*} } WITH u, o, collect(distinct r.name) as roles, collect(distinct case when r.listed = true then r.displayName end) as displayRoles, ANY(n IN COLLECT(r.external) WHERE n = true) as external, ANY(n IN COLLECT(r.name) WHERE n = ?) as isPatient, ALL(n IN COLLECT(r.piiAccess) WHERE n = false) as hidePhi WITH u, o, {organization:o{.*}, external: external, isPatient: isPatient, hidePhi: hidePhi, roles: roles, displayRoles: displayRoles } as context CALL {WITH u, o MATCH (u)<-[:FOR_USER]-(a:Actor{delpending:false})<-[:STAFF_TO_ACTOR]-(si:Site{delpending:false})-[:SITE_TO_SMO]->(:Smo)-[:IS_AN_ORG]->(o) WHERE coalesce(a.state, ?) <> ? OPTIONAL MATCH (a)-[:APPOINTED_AS]->(r:Role) WITH u, o, si, a, r order by r.displayName WITH u, o, si, a, collect(distinct r.name) as roles, collect(distinct case when r.listed = true then r.displayName end) as displayRoles WITH CASE when not si is null then {siteId: si.tildaid, roles: roles, displayRoles: displayRoles} end as si return collect(si) as sites, apoc.coll.flatten(collect(si.roles)) as siteRoles } CALL {WITH u, o // WITH DISTINCT is a required pipeline barrier (see the studyMembership note // in scope.go): without it (u)<-[:FOR_USER]-(a) re-expands once per study in // the org — ?.0M -> 32k db hits. Splitting the MATCH without DISTINCT does // nothing; the barrier is what forbids the bad join order. Not applied to the // sites or org-roles subqueries, where it measured neutral or worse. // No longer OPTIONAL: the subquery ends in an ungrouped aggregation, so zero // matches still yield one row with empty collections. CALL {WITH u, o MATCH (u)<-[:FOR_USER]-(a:Actor{delpending:false, orgId:o.tildaid}) WHERE coalesce(a.state, ?) <> ? WITH DISTINCT u, o, a MATCH (a)<-[:STUDY_TO_ACTOR]-(s:Study{delpending:false})-[:STUDY_TO_ORG]->(o) OPTIONAL MATCH (a)-[:APPOINTED_AS]->(r:Role) RETURN s, a, r UNION // Delegated engagement Actors: orgId is TildaScale? roles. WITH s, r order by r.displayName WITH s, collect(distinct r.name) as roles, collect(distinct case when r.listed = true then r.displayName end) as displayRoles // Ordered so the studies array is a stable sequence for clients; the pipeline // that replaced the old (u,o,s,a) grouping otherwise leaves it plan-dependent. WITH s, CASE when not s is null then {studyId: s.tildaid, roles: roles, displayRoles: displayRoles, srcOrgId: s.srcorgid} end as st ORDER BY s.name, s.tildaid return collect(st) as studies, apoc.coll.flatten(collect(st.roles)) as studyRoles } with distinct context, studies, apoc.coll.toSet(apoc.coll.flatten(collect(studyRoles))) as allStudyRoles, apoc.coll.toSet(apoc.coll.flatten(collect(siteRoles))) as siRoles with context, studies, apoc.coll.toSet(apoc.coll.flatten([context.roles, allStudyRoles, siRoles])) as allRoles return context{.*, studies: studies, allRoles: allRoles}
schedsvc
1 2.79 s 4.85 s 2.79 s flat
MATCH (u:User {tildaid:$user}) OPTIONAL MATCH (o:Organization {alias:$org}) UNWIND $lists.checks AS c CALL { WITH u, o, c // scope=Study policies=study-config-read MATCH (u)<-[:FOR_USER]-(a:Actor)-[:APPOINTED_AS]->(x:Role) WHERE a.state <>…
MATCH (u:User {tildaid:$user}) OPTIONAL MATCH (o:Organization {alias:$org}) UNWIND $lists.checks AS c CALL { WITH u, o, c // scope=Study policies=study-config-read MATCH (u)<-[:FOR_USER]-(a:Actor)-[:APPOINTED_AS]->(x:Role) WHERE a.state <> ? AND a.delpending = false AND o.tildaid = a.orgId AND x.name IN $lists.roles_0 WITH DISTINCT u, o, a, c MATCH (a)<-[:STUDY_TO_ACTOR]-(st:Study) WHERE EXISTS { (st)-[:STUDY_TO_ORG]->(o) } AND ( size(c.studyIds) = ? OR st.tildaid IN c.studyIds ) RETURN DISTINCT c.idx AS checkIdx, u AS User, o AS Organization, st AS Study, null AS Site, null AS Patient UNION WITH u, o, c // scope=Study policies=study-config-read MATCH (u)<-[:FOR_USER]-(da:Actor)<-[:STUDY_TO_DELEGATED_ACTOR]-(st:Study)-[:STUDY_TO_ORG]->(o), (da)-[:APPOINTED_AS]->(x:Role)<-[:APPOINTED_AS]-(sa:Actor), (da)-[:DELEGATED_FROM]->(sa)<-[:ORGANIZATION_TO_ACTOR]-(:Organization {alias:$tildaScaleAlias}) WHERE st.srcorgid = o.tildaid AND da.state <> ? AND da.delpending = false AND sa.state <> ? AND sa.delpending = false AND x.name IN $lists.roles_1 AND ? IN apoc.text.split(coalesce(x.tags, ?), ?) AND ( size(c.studyIds) = ? OR st.tildaid IN c.studyIds ) RETURN DISTINCT c.idx AS checkIdx, u AS User, o AS Organization, st AS Study, null AS Site, null AS Patient UNION WITH u, o, c // scope=Organization policies=org-study-read MATCH (u)<-[:FOR_USER]-(a:Actor)-[:APPOINTED_AS]->(x:Role), (o)-[:ORGANIZATION_TO_ACTOR]->(a) WHERE a.state <> ? AND a.delpending = false AND x.name IN $lists.roles_2 RETURN DISTINCT c.idx AS checkIdx, u AS User, o AS Organization, null AS Study, null AS Site, null AS Patient UNION WITH u, o, c // scope=Organization policies=org-study-read MATCH (u)<-[:FOR_USER]-(da:Actor)<-[:STUDY_TO_DELEGATED_ACTOR]-(st:Study)-[:STUDY_TO_ORG]->(o), (da)-[:APPOINTED_AS]->(x:Role)<-[:APPOINTED_AS]-(sa:Actor), (da)-[:DELEGATED_FROM]->(sa)<-[:ORGANIZATION_TO_ACTOR]-(:Organization {alias:$tildaScaleAlias}) WHERE st.srcorgid = o.tildaid AND da.state <> ? AND da.delpending = false AND sa.state <> ? AND sa.delpending = false AND x.name IN $lists.roles_3 AND ? IN apoc.text.split(coalesce(x.tags, ?), ?) RETURN DISTINCT c.idx AS checkIdx, u AS User, o AS Organization, null AS Study, null AS Site, null AS Patient } RETURN checkIdx, User, Organization, Study, Site, Patient
enrollsvc
1 2.19 s 4.85 s 2.19 s flat
MATCH (u:User{tildaid:$userId}), (o:Organization{delpending:false, alias:$orgAlias}) call { with u, o // An Inactive actor holds no roles (ENG-?): its roles would otherwise // still feed hidePhi, the role list and every policy match. OPTIO…
MATCH (u:User{tildaid:$userId}), (o:Organization{delpending:false, alias:$orgAlias}) call { with u, o // An Inactive actor holds no roles (ENG-?): its roles would otherwise // still feed hidePhi, the role list and every policy match. OPTIONAL MATCH (u)<-[:FOR_USER]-(a:Actor{delpending:false})<-[:ORGANIZATION_TO_ACTOR]-(o), (a)-[:APPOINTED_AS]->(r:Role) WHERE not r.name = ? AND coalesce(a.state, ?) <> ? return r{.*} UNION with u, o // Delegated engagements in o. Only the delegated roles cross over — // the TildaScale Actor?s list. MATCH (u)<-[:FOR_USER]-(da:Actor{delpending:false})<-[:STUDY_TO_DELEGATED_ACTOR]-(st:Study{delpending:false})-[:STUDY_TO_ORG]->(o), (da)-[:APPOINTED_AS]->(r:Role)<-[:APPOINTED_AS]-(sa:Actor{delpending:false}), (da)-[:DELEGATED_FROM]->(sa)<-[:ORGANIZATION_TO_ACTOR]-(:Organization{alias:$tildaScaleAlias}) WHERE st.srcorgid = o.tildaid AND da.state <> ? AND sa.state <> ? AND $orgDelegatedTag IN apoc.text.split(coalesce(r.tags, ?), ?) return distinct r{.*} } WITH u, o, collect(distinct r.name) as roles, collect(distinct case when r.listed = true then r.displayName end) as displayRoles, ANY(n IN COLLECT(r.external) WHERE n = true) as external, ANY(n IN COLLECT(r.name) WHERE n = ?) as isPatient, ALL(n IN COLLECT(r.piiAccess) WHERE n = false) as hidePhi WITH u, o, {organization:o{.*}, external: external, isPatient: isPatient, hidePhi: hidePhi, roles: roles, displayRoles: displayRoles } as context CALL {WITH u, o MATCH (u)<-[:FOR_USER]-(a:Actor{delpending:false})<-[:STAFF_TO_ACTOR]-(si:Site{delpending:false})-[:SITE_TO_SMO]->(:Smo)-[:IS_AN_ORG]->(o) WHERE coalesce(a.state, ?) <> ? OPTIONAL MATCH (a)-[:APPOINTED_AS]->(r:Role) WITH u, o, si, a, r order by r.displayName WITH u, o, si, a, collect(distinct r.name) as roles, collect(distinct case when r.listed = true then r.displayName end) as displayRoles WITH CASE when not si is null then {siteId: si.tildaid, roles: roles, displayRoles: displayRoles} end as si return collect(si) as sites, apoc.coll.flatten(collect(si.roles)) as siteRoles } CALL {WITH u, o // WITH DISTINCT is a required pipeline barrier (see the studyMembership note // in scope.go): without it (u)<-[:FOR_USER]-(a) re-expands once per study in // the org — ?.0M -> 32k db hits. Splitting the MATCH without DISTINCT does // nothing; the barrier is what forbids the bad join order. Not applied to the // sites or org-roles subqueries, where it measured neutral or worse. // No longer OPTIONAL: the subquery ends in an ungrouped aggregation, so zero // matches still yield one row with empty collections. CALL {WITH u, o MATCH (u)<-[:FOR_USER]-(a:Actor{delpending:false, orgId:o.tildaid}) WHERE coalesce(a.state, ?) <> ? WITH DISTINCT u, o, a MATCH (a)<-[:STUDY_TO_ACTOR]-(s:Study{delpending:false})-[:STUDY_TO_ORG]->(o) OPTIONAL MATCH (a)-[:APPOINTED_AS]->(r:Role) RETURN s, a, r UNION // Delegated engagement Actors: orgId is TildaScale? roles. WITH s, r order by r.displayName WITH s, collect(distinct r.name) as roles, collect(distinct case when r.listed = true then r.displayName end) as displayRoles // Ordered so the studies array is a stable sequence for clients; the pipeline // that replaced the old (u,o,s,a) grouping otherwise leaves it plan-dependent. WITH s, CASE when not s is null then {studyId: s.tildaid, roles: roles, displayRoles: displayRoles, srcOrgId: s.srcorgid} end as st ORDER BY s.name, s.tildaid return collect(st) as studies, apoc.coll.flatten(collect(st.roles)) as studyRoles } with distinct context, studies, apoc.coll.toSet(apoc.coll.flatten(collect(studyRoles))) as allStudyRoles, apoc.coll.toSet(apoc.coll.flatten(collect(siteRoles))) as siRoles with context, studies, apoc.coll.toSet(apoc.coll.flatten([context.roles, allStudyRoles, siRoles])) as allRoles return context{.*, studies: studies, allRoles: allRoles}
dashql
1 3.06 s 4.85 s 3.06 s flat
MATCH (u:User{tildaid:$userId}), (o:Organization{delpending:false, alias:$orgAlias}) call { with u, o // An Inactive actor holds no roles (ENG-?): its roles would otherwise // still feed hidePhi, the role list and every policy match. OPTIO…
MATCH (u:User{tildaid:$userId}), (o:Organization{delpending:false, alias:$orgAlias}) call { with u, o // An Inactive actor holds no roles (ENG-?): its roles would otherwise // still feed hidePhi, the role list and every policy match. OPTIONAL MATCH (u)<-[:FOR_USER]-(a:Actor{delpending:false})<-[:ORGANIZATION_TO_ACTOR]-(o), (a)-[:APPOINTED_AS]->(r:Role) WHERE not r.name = ? AND coalesce(a.state, ?) <> ? return r{.*} UNION with u, o // Delegated engagements in o. Only the delegated roles cross over — // the TildaScale Actor?s list. MATCH (u)<-[:FOR_USER]-(da:Actor{delpending:false})<-[:STUDY_TO_DELEGATED_ACTOR]-(st:Study{delpending:false})-[:STUDY_TO_ORG]->(o), (da)-[:APPOINTED_AS]->(r:Role)<-[:APPOINTED_AS]-(sa:Actor{delpending:false}), (da)-[:DELEGATED_FROM]->(sa)<-[:ORGANIZATION_TO_ACTOR]-(:Organization{alias:$tildaScaleAlias}) WHERE st.srcorgid = o.tildaid AND da.state <> ? AND sa.state <> ? AND $orgDelegatedTag IN apoc.text.split(coalesce(r.tags, ?), ?) return distinct r{.*} } WITH u, o, collect(distinct r.name) as roles, collect(distinct case when r.listed = true then r.displayName end) as displayRoles, ANY(n IN COLLECT(r.external) WHERE n = true) as external, ANY(n IN COLLECT(r.name) WHERE n = ?) as isPatient, ALL(n IN COLLECT(r.piiAccess) WHERE n = false) as hidePhi WITH u, o, {organization:o{.*}, external: external, isPatient: isPatient, hidePhi: hidePhi, roles: roles, displayRoles: displayRoles } as context CALL {WITH u, o MATCH (u)<-[:FOR_USER]-(a:Actor{delpending:false})<-[:STAFF_TO_ACTOR]-(si:Site{delpending:false})-[:SITE_TO_SMO]->(:Smo)-[:IS_AN_ORG]->(o) WHERE coalesce(a.state, ?) <> ? OPTIONAL MATCH (a)-[:APPOINTED_AS]->(r:Role) WITH u, o, si, a, r order by r.displayName WITH u, o, si, a, collect(distinct r.name) as roles, collect(distinct case when r.listed = true then r.displayName end) as displayRoles WITH CASE when not si is null then {siteId: si.tildaid, roles: roles, displayRoles: displayRoles} end as si return collect(si) as sites, apoc.coll.flatten(collect(si.roles)) as siteRoles } CALL {WITH u, o // WITH DISTINCT is a required pipeline barrier (see the studyMembership note // in scope.go): without it (u)<-[:FOR_USER]-(a) re-expands once per study in // the org — ?.0M -> 32k db hits. Splitting the MATCH without DISTINCT does // nothing; the barrier is what forbids the bad join order. Not applied to the // sites or org-roles subqueries, where it measured neutral or worse. // No longer OPTIONAL: the subquery ends in an ungrouped aggregation, so zero // matches still yield one row with empty collections. CALL {WITH u, o MATCH (u)<-[:FOR_USER]-(a:Actor{delpending:false, orgId:o.tildaid}) WHERE coalesce(a.state, ?) <> ? WITH DISTINCT u, o, a MATCH (a)<-[:STUDY_TO_ACTOR]-(s:Study{delpending:false})-[:STUDY_TO_ORG]->(o) OPTIONAL MATCH (a)-[:APPOINTED_AS]->(r:Role) RETURN s, a, r UNION // Delegated engagement Actors: orgId is TildaScale? roles. WITH s, r order by r.displayName WITH s, collect(distinct r.name) as roles, collect(distinct case when r.listed = true then r.displayName end) as displayRoles // Ordered so the studies array is a stable sequence for clients; the pipeline // that replaced the old (u,o,s,a) grouping otherwise leaves it plan-dependent. WITH s, CASE when not s is null then {studyId: s.tildaid, name: s.name, roles: roles, displayRoles: displayRoles, srcOrgId: s.srcorgid} end as st ORDER BY s.name, s.tildaid return collect(st) as studies, apoc.coll.flatten(collect(st.roles)) as studyRoles } with distinct context, studies, apoc.coll.toSet(apoc.coll.flatten(collect(studyRoles))) as allStudyRoles, apoc.coll.toSet(apoc.coll.flatten(collect(siteRoles))) as siRoles with context, studies, apoc.coll.toSet(apoc.coll.flatten([context.roles, allStudyRoles, siRoles])) as allRoles return context{.*, studies: studies, allRoles: allRoles}
regsvc
1 2.27 s 4.85 s 2.27 s flat
MATCH (u:User{tildaid:$userId}), (o:Organization{delpending:false, alias:$orgAlias}) call { with u, o // An Inactive actor holds no roles (ENG-?): its roles would otherwise // still feed hidePhi, the role list and every policy match. OPTIO…
MATCH (u:User{tildaid:$userId}), (o:Organization{delpending:false, alias:$orgAlias}) call { with u, o // An Inactive actor holds no roles (ENG-?): its roles would otherwise // still feed hidePhi, the role list and every policy match. OPTIONAL MATCH (u)<-[:FOR_USER]-(a:Actor{delpending:false})<-[:ORGANIZATION_TO_ACTOR]-(o), (a)-[:APPOINTED_AS]->(r:Role) WHERE not r.name = ? AND coalesce(a.state, ?) <> ? return r{.*} UNION with u, o // Delegated engagements in o. Only the delegated roles cross over — // the TildaScale Actor?s list. MATCH (u)<-[:FOR_USER]-(da:Actor{delpending:false})<-[:STUDY_TO_DELEGATED_ACTOR]-(st:Study{delpending:false})-[:STUDY_TO_ORG]->(o), (da)-[:APPOINTED_AS]->(r:Role)<-[:APPOINTED_AS]-(sa:Actor{delpending:false}), (da)-[:DELEGATED_FROM]->(sa)<-[:ORGANIZATION_TO_ACTOR]-(:Organization{alias:$tildaScaleAlias}) WHERE st.srcorgid = o.tildaid AND da.state <> ? AND sa.state <> ? AND $orgDelegatedTag IN apoc.text.split(coalesce(r.tags, ?), ?) return distinct r{.*} } WITH u, o, collect(distinct r.name) as roles, collect(distinct case when r.listed = true then r.displayName end) as displayRoles, ANY(n IN COLLECT(r.external) WHERE n = true) as external, ANY(n IN COLLECT(r.name) WHERE n = ?) as isPatient, ALL(n IN COLLECT(r.piiAccess) WHERE n = false) as hidePhi WITH u, o, {organization:o{.*}, external: external, isPatient: isPatient, hidePhi: hidePhi, roles: roles, displayRoles: displayRoles } as context CALL {WITH u, o MATCH (u)<-[:FOR_USER]-(a:Actor{delpending:false})<-[:STAFF_TO_ACTOR]-(si:Site{delpending:false})-[:SITE_TO_SMO]->(:Smo)-[:IS_AN_ORG]->(o) WHERE coalesce(a.state, ?) <> ? OPTIONAL MATCH (a)-[:APPOINTED_AS]->(r:Role) WITH u, o, si, a, r order by r.displayName WITH u, o, si, a, collect(distinct r.name) as roles, collect(distinct case when r.listed = true then r.displayName end) as displayRoles WITH CASE when not si is null then {siteId: si.tildaid, roles: roles, displayRoles: displayRoles} end as si return collect(si) as sites, apoc.coll.flatten(collect(si.roles)) as siteRoles } CALL {WITH u, o // WITH DISTINCT is a required pipeline barrier (see the studyMembership note // in scope.go): without it (u)<-[:FOR_USER]-(a) re-expands once per study in // the org — ?.0M -> 32k db hits. Splitting the MATCH without DISTINCT does // nothing; the barrier is what forbids the bad join order. Not applied to the // sites or org-roles subqueries, where it measured neutral or worse. // No longer OPTIONAL: the subquery ends in an ungrouped aggregation, so zero // matches still yield one row with empty collections. CALL {WITH u, o MATCH (u)<-[:FOR_USER]-(a:Actor{delpending:false, orgId:o.tildaid}) WHERE coalesce(a.state, ?) <> ? WITH DISTINCT u, o, a MATCH (a)<-[:STUDY_TO_ACTOR]-(s:Study{delpending:false})-[:STUDY_TO_ORG]->(o) OPTIONAL MATCH (a)-[:APPOINTED_AS]->(r:Role) RETURN s, a, r UNION // Delegated engagement Actors: orgId is TildaScale? roles. WITH s, r order by r.displayName WITH s, collect(distinct r.name) as roles, collect(distinct case when r.listed = true then r.displayName end) as displayRoles // Ordered so the studies array is a stable sequence for clients; the pipeline // that replaced the old (u,o,s,a) grouping otherwise leaves it plan-dependent. WITH s, CASE when not s is null then {studyId: s.tildaid, roles: roles, displayRoles: displayRoles, srcOrgId: s.srcorgid} end as st ORDER BY s.name, s.tildaid return collect(st) as studies, apoc.coll.flatten(collect(st.roles)) as studyRoles } with distinct context, studies, apoc.coll.toSet(apoc.coll.flatten(collect(studyRoles))) as allStudyRoles, apoc.coll.toSet(apoc.coll.flatten(collect(siteRoles))) as siRoles with context, studies, apoc.coll.toSet(apoc.coll.flatten([context.roles, allStudyRoles, siRoles])) as allRoles return context{.*, studies: studies, allRoles: allRoles}
dashql
1 3.48 s 4.85 s 3.48 s flat
MATCH (u:User {tildaid:$user}) OPTIONAL MATCH (o:Organization {alias:$org}) UNWIND $lists.checks AS c CALL (u, o, c) { // scope=Study policies=work-order-edit MATCH (u)<-[:FOR_USER]-(a:Actor)-[:APPOINTED_AS]->(x:Role) WHERE a.state <> ? AN…
MATCH (u:User {tildaid:$user}) OPTIONAL MATCH (o:Organization {alias:$org}) UNWIND $lists.checks AS c CALL (u, o, c) { // scope=Study policies=work-order-edit MATCH (u)<-[:FOR_USER]-(a:Actor)-[:APPOINTED_AS]->(x:Role) WHERE a.state <> ? AND a.delpending = false AND o.tildaid = a.orgId AND x.name IN $lists.roles_0 WITH DISTINCT u, o, a, c MATCH (a)<-[:STUDY_TO_ACTOR]-(st:Study) WHERE EXISTS { (st)-[:STUDY_TO_ORG]->(o) } AND ( size(c.studyIds) = ? OR st.tildaid IN c.studyIds ) MATCH (wo:WorkOrder {tildaid:c.id}) WHERE wo.study_id = st.tildaid RETURN DISTINCT c.idx AS checkIdx, u AS User, o AS Organization, st AS Study, null AS Site, null AS Patient UNION // scope=Study policies=work-order-edit MATCH (u)<-[:FOR_USER]-(da:Actor)<-[:STUDY_TO_DELEGATED_ACTOR]-(st:Study)-[:STUDY_TO_ORG]->(o), (da)-[:APPOINTED_AS]->(x:Role)<-[:APPOINTED_AS]-(sa:Actor), (da)-[:DELEGATED_FROM]->(sa)<-[:ORGANIZATION_TO_ACTOR]-(:Organization {alias:?}) WHERE st.srcorgid = o.tildaid AND da.state <> ? AND da.delpending = false AND sa.state <> ? AND sa.delpending = false AND x.name IN $lists.roles_1 AND ? IN apoc.text.split(coalesce(x.tags, ?), ?) AND ( size(c.studyIds) = ? OR st.tildaid IN c.studyIds ) MATCH (wo:WorkOrder {tildaid:c.id}) WHERE wo.study_id = st.tildaid RETURN DISTINCT c.idx AS checkIdx, u AS User, o AS Organization, st AS Study, null AS Site, null AS Patient } RETURN checkIdx, User, Organization, Study, Site, Patient
virtual-assistant
6 1.70 s 4.70 s 3.40 s flat
MATCH (u:User {tildaid:$user}) OPTIONAL MATCH (o:Organization {alias:$org}) UNWIND $lists.checks AS c CALL (u, o, c) { // scope=Study policies=work-order-edit MATCH (u)<-[:FOR_USER]-(a:Actor)-[:APPOINTED_AS]->(x:Role) WHERE a.state <> ? AN…
MATCH (u:User {tildaid:$user}) OPTIONAL MATCH (o:Organization {alias:$org}) UNWIND $lists.checks AS c CALL (u, o, c) { // scope=Study policies=work-order-edit MATCH (u)<-[:FOR_USER]-(a:Actor)-[:APPOINTED_AS]->(x:Role) WHERE a.state <> ? AND a.delpending = false AND o.tildaid = a.orgId AND x.name IN $lists.roles_0 WITH DISTINCT u, o, a, c MATCH (a)<-[:STUDY_TO_ACTOR]-(st:Study) WHERE EXISTS { (st)-[:STUDY_TO_ORG]->(o) } AND ( size(c.studyIds) = ? OR st.tildaid IN c.studyIds ) MATCH (wo:WorkOrder {tildaid:c.id}) WHERE wo.study_id = st.tildaid RETURN DISTINCT c.idx AS checkIdx, u AS User, o AS Organization, st AS Study, null AS Site, null AS Patient UNION // scope=Study policies=work-order-edit MATCH (u)<-[:FOR_USER]-(da:Actor)<-[:STUDY_TO_DELEGATED_ACTOR]-(st:Study)-[:STUDY_TO_ORG]->(o), (da)-[:APPOINTED_AS]->(x:Role)<-[:APPOINTED_AS]-(sa:Actor), (da)-[:DELEGATED_FROM]->(sa)<-[:ORGANIZATION_TO_ACTOR]-(:Organization {alias:?}) WHERE st.srcorgid = o.tildaid AND da.state <> ? AND da.delpending = false AND sa.state <> ? AND sa.delpending = false AND x.name IN $lists.roles_1 AND ? IN apoc.text.split(coalesce(x.tags, ?), ?) AND ( size(c.studyIds) = ? OR st.tildaid IN c.studyIds ) MATCH (wo:WorkOrder {tildaid:c.id}) WHERE wo.study_id = st.tildaid RETURN DISTINCT c.idx AS checkIdx, u AS User, o AS Organization, st AS Study, null AS Site, null AS Patient } RETURN checkIdx, User, Organization, Study, Site, Patient
virtual-assistant
2 1.66 s 4.70 s 3.32 s flat
MATCH (u:User{tildaid:$userId}), (o:Organization{delpending:false, alias:$orgAlias}) call { with u, o // An Inactive actor holds no roles (ENG-?): its roles would otherwise // still feed hidePhi, the role list and every policy match. OPTIO…
MATCH (u:User{tildaid:$userId}), (o:Organization{delpending:false, alias:$orgAlias}) call { with u, o // An Inactive actor holds no roles (ENG-?): its roles would otherwise // still feed hidePhi, the role list and every policy match. OPTIONAL MATCH (u)<-[:FOR_USER]-(a:Actor{delpending:false})<-[:ORGANIZATION_TO_ACTOR]-(o), (a)-[:APPOINTED_AS]->(r:Role) WHERE not r.name = ? AND coalesce(a.state, ?) <> ? return r{.*} UNION with u, o // Delegated engagements in o. Only the delegated roles cross over — // the TildaScale Actor?s list. MATCH (u)<-[:FOR_USER]-(da:Actor{delpending:false})<-[:STUDY_TO_DELEGATED_ACTOR]-(st:Study{delpending:false})-[:STUDY_TO_ORG]->(o), (da)-[:APPOINTED_AS]->(r:Role)<-[:APPOINTED_AS]-(sa:Actor{delpending:false}), (da)-[:DELEGATED_FROM]->(sa)<-[:ORGANIZATION_TO_ACTOR]-(:Organization{alias:$tildaScaleAlias}) WHERE st.srcorgid = o.tildaid AND da.state <> ? AND sa.state <> ? AND $orgDelegatedTag IN apoc.text.split(coalesce(r.tags, ?), ?) return distinct r{.*} } WITH u, o, collect(distinct r.name) as roles, collect(distinct case when r.listed = true then r.displayName end) as displayRoles, ANY(n IN COLLECT(r.external) WHERE n = true) as external, ANY(n IN COLLECT(r.name) WHERE n = ?) as isPatient, ALL(n IN COLLECT(r.piiAccess) WHERE n = false) as hidePhi WITH u, o, {organization:o{.*}, external: external, isPatient: isPatient, hidePhi: hidePhi, roles: roles, displayRoles: displayRoles } as context CALL {WITH u, o MATCH (u)<-[:FOR_USER]-(a:Actor{delpending:false})<-[:STAFF_TO_ACTOR]-(si:Site{delpending:false})-[:SITE_TO_SMO]->(:Smo)-[:IS_AN_ORG]->(o) WHERE coalesce(a.state, ?) <> ? OPTIONAL MATCH (a)-[:APPOINTED_AS]->(r:Role) WITH u, o, si, a, r order by r.displayName WITH u, o, si, a, collect(distinct r.name) as roles, collect(distinct case when r.listed = true then r.displayName end) as displayRoles WITH CASE when not si is null then {siteId: si.tildaid, roles: roles, displayRoles: displayRoles} end as si return collect(si) as sites, apoc.coll.flatten(collect(si.roles)) as siteRoles } CALL {WITH u, o // WITH DISTINCT is a required pipeline barrier (see the studyMembership note // in scope.go): without it (u)<-[:FOR_USER]-(a) re-expands once per study in // the org — ?.0M -> 32k db hits. Splitting the MATCH without DISTINCT does // nothing; the barrier is what forbids the bad join order. Not applied to the // sites or org-roles subqueries, where it measured neutral or worse. // No longer OPTIONAL: the subquery ends in an ungrouped aggregation, so zero // matches still yield one row with empty collections. CALL {WITH u, o MATCH (u)<-[:FOR_USER]-(a:Actor{delpending:false, orgId:o.tildaid}) WHERE coalesce(a.state, ?) <> ? WITH DISTINCT u, o, a MATCH (a)<-[:STUDY_TO_ACTOR]-(s:Study{delpending:false})-[:STUDY_TO_ORG]->(o) OPTIONAL MATCH (a)-[:APPOINTED_AS]->(r:Role) RETURN s, a, r UNION // Delegated engagement Actors: orgId is TildaScale? roles. WITH s, r order by r.displayName WITH s, collect(distinct r.name) as roles, collect(distinct case when r.listed = true then r.displayName end) as displayRoles // Ordered so the studies array is a stable sequence for clients; the pipeline // that replaced the old (u,o,s,a) grouping otherwise leaves it plan-dependent. WITH s, CASE when not s is null then {studyId: s.tildaid, name: s.name, roles: roles, displayRoles: displayRoles, srcOrgId: s.srcorgid} end as st ORDER BY s.name, s.tildaid return collect(st) as studies, apoc.coll.flatten(collect(st.roles)) as studyRoles } with distinct context, studies, apoc.coll.toSet(apoc.coll.flatten(collect(studyRoles))) as allStudyRoles, apoc.coll.toSet(apoc.coll.flatten(collect(siteRoles))) as siRoles with context, studies, apoc.coll.toSet(apoc.coll.flatten([context.roles, allStudyRoles, siRoles])) as allRoles return context{.*, studies: studies, allRoles: allRoles}
authzd
2 1.16 s 4.70 s 2.25 s flat
MATCH (doc0:Document{tildaid:$f0}) MATCH (org:Organization{tildaid:$scopeOrgId0}) CALL { WITH org, doc0 UNWIND [x IN $lists.allowedStudies0 WHERE x = doc0.studyId] AS studyId OPTIONAL MATCH (study:Study) WHERE study.tildaid = studyId // An…
MATCH (doc0:Document{tildaid:$f0}) MATCH (org:Organization{tildaid:$scopeOrgId0}) CALL { WITH org, doc0 UNWIND [x IN $lists.allowedStudies0 WHERE x = doc0.studyId] AS studyId OPTIONAL MATCH (study:Study) WHERE study.tildaid = studyId // An inactive actor carries no membership, so it is excluded here rather than at each use: // the sites, countries and roles below all hang off it. OPTIONAL MATCH (study)-[:STUDY_TO_ACTOR]-(studyActor:Actor{orgId:$ctxOrgId0})-[:FOR_USER]->(:User{tildaid:$ctxUserId0}) WHERE studyActor.state <> ? // Collect sites where user has membership in this study OPTIONAL MATCH (studyActor)-[:STUDYSITEACTOR_TO_ACTOR]-(:StudySiteActor)-[:STUDYSITEACTOR_TO_PLAN_DEFINITION]-(pd:DslPlanDefinition)-[:PLAN_DEFINITION_TO_SITE]-(site:Site) WITH org, study, studyActor, collect(DISTINCT site.tildaid) as userSiteIds // Collect countries where user has membership in this study OPTIONAL MATCH (studyActor)<-[:STUDYCOUNTRYACTOR_TO_ACTOR]-(sca:StudyCountryActor) WITH org, study, studyActor, userSiteIds, collect(DISTINCT sca.country) as userCountryIds // Pre-collect policies for this user/role in this study OPTIONAL MATCH (org)<-[:DOC_ACCESS_POLICY_TO_ORG]-(policy:DocumentAccessPolicy{status:?})-[:POLICY_TO_STUDY]->(study) WHERE EXISTS { MATCH (policy)-[:POLICY_FOR_USER]->(:User{tildaid:$ctxUserId0}) } OR (studyActor IS NOT NULL AND EXISTS { MATCH (policy)-[:POLICY_FOR_ROLE]->(role:Role)<-[:APPOINTED_AS]-(studyActor) }) WITH study, studyActor, userSiteIds, userCountryIds, collect(policy) as policies WITH {study:study, studyActor:studyActor, userSiteIds:userSiteIds, userCountryIds:userCountryIds, policies:policies} AS st WITH collect(distinct st) as studies // studyById lets each document row look its context up by study id instead of scanning // the whole list. Entries whose study did not resolve share the ? key; they all carry // the same empty context, so which one wins does not matter. The node-bearing maps go no // further than this subquery; studyIdsInScope needs no lookup, since an id with no Study // node can never equal a matched study?tildaScale??ReadWrite?ReadOnly?s folder and ancestors (up to ? levels for TMF hierarchy) OPTIONAL MATCH (doc1)<-[:INCLUDES]-(docFolder:Folder) OPTIONAL MATCH (docFolder)<-[:INCLUDES*?..?]-(ancestorFolder:Folder) WITH doc1, policies, userSiteIds, userCountryIds, defaultAccessLevel, collect(DISTINCT docFolder) + collect(DISTINCT ancestorFolder) AS folderHierarchy // Check document ownership OPTIONAL MATCH (doc1)-[:UPLOADED_BY]->(uploader:User{tildaid:$policyUploaderId0}) WITH doc1, policies, userSiteIds, userCountryIds, defaultAccessLevel, folderHierarchy, uploader IS NOT NULL AS isOwnedByUser // Filter policies by: // ?. Folder: policy applies if folder is in hierarchy OR policy has no folder (study-wide). A folder-less // ownership policy is the role?Owned Documents?Non Owned Documents?Staging?Pre-Staging?Owned Documents?Non Owned Documents?My Sites Documents?Other Sites Documents?My Countries Documents?Other Countries Documents?Study Scope Documents?NoAccess?NoAccess?ReadOnly?ReadOnly?ReadWrite?ReadOnly?NoAccess??Inactive' AND sst.tildaid IN studyIdsInScope AND (doc1.siteId = ? OR (a)-[:STUDYSITEACTOR_TO_ACTOR]-(:StudySiteActor)- [:STUDYSITEACTOR_TO_PLAN_DEFINITION]-(:DslPlanDefinition{delpending:false,type:?})- [:PLAN_DEFINITION_TO_SITE]-(:Site{tildaid:doc1.siteId})) RETURN doc1 as doc UNION WITH doc1, studyIdsInScope, directAdmit WITH doc1, studyIdsInScope WHERE NOT directAdmit AND (NOT $nonSiteOnlyPatients0 OR doc1.patientId = ?) AND doc1.siteId <> ? MATCH (s:Site{tildaid:doc1.siteId, delpending:false})-[:PLAN_DEFINITION_TO_SITE]- (pd:DslPlanDefinition{delpending:false,type:?})-[:PLAN_DEFINITION_TO_STUDY]->(sst:Study) WHERE sst.tildaid IN studyIdsInScope RETURN doc1 as doc UNION WITH doc1, directAdmit WITH doc1 WHERE directAdmit RETURN doc1 as doc} WITH ({doc: doc, location: location, docObj: docObj, owned: owned, study: study, org: org, vector: vector, docAccessLevel: docAccessLevel}) as row WITH collect(DISTINCT row) as rows, count(DISTINCT row) as total unwind rows as row WITH row.doc as doc, row.location as location, row.docObj as docObj, row.owned as owned, row.study as study, row.org as org, row.vector as vector, row.docAccessLevel as docAccessLevel, total order by doc.createdat asc, doc.tildaid asc skip $skip0 WITH *, EXISTS { (doc)-[:HAS]-(:DocumentAnnotation)-[:ANNOTATION_SIGNER]-(:DocumentSigner{userId:$signerUserId3}) } AS isSigner CALL {return null as patientId, null as patientName, null as subjectId}CALL { return null as site, ? as siteNumber, [] as piNames }CALL { return null as visit }CALL { return null as user }CALL { return null as uploadedBy }CALL { return null as docType }CALL { return null as signedByUsers , null as reviewDate } WITH distinct total, doc, docObj, vector, owned, study, org, docAccessLevel, isSigner, patientId, patientName, subjectId, site, siteNumber, piNames, visit, user, uploadedBy, docType, signedByUsers, reviewDate CALL { return null as workOrders, false as woContact, null as latestAIRun, null as findingCount, null as queriesCount, null as confirmedCount, null as resolvedCount }CALL { return null as tags } CALL { return null as path, null as fold, null as collection, null as stateTags1 } CALL { return null as primaryFolder } CALL { return null as listingFolders } CALL { return null as stateTags2, null as stagingLabels } CALL { return [] as reviews} CALL { return null as templateDetails} CALL { with doc, docObj CALL { with doc, docObj with doc, docObj where doc.primaryVersionId = ? or doc.primaryVersionId is null optional match (doc)-[:UPLOADED_BY]->(uploader:User) return {tildaid: doc.tildaid, fileName: doc.fileName, originalFileName: doc.originalFileName, contentType: doc.contentType, date: doc.date, dateType: doc.dateType, versionName: doc.versionName, rejectReason: doc.rejectReason, language: doc.language, languages: doc.languages, needsAttention: doc.needsAttention, needsAttentionReasons: doc.needsAttentionReasons, trackActiveDuplicates: doc.trackActiveDuplicates, versionNumber: doc.versionNumber, majorVersion: doc.majorVersion, minorVersion: doc.minorVersion, generation: toString(doc.generation), cksum: doc.cksum, size: doc.size, status: doc.status, stateTag: doc.stateTag, pages: doc.pages, uploadMethod: doc.uploadMethod, changeLog: [], createdAt: doc.createdat, renderedCompletedAt: doc.renderedCompletedAt, renderedFieldsRevision: doc.renderedFieldsRevision, renderedSignersRevision: doc.renderedSignersRevision, tmfFiledAt: coalesce(doc.tmfFiledAt, ?), uploadedBy: case when uploader is null then null else {id: uploader.tildaid, name: uploader.name, profilePicURL: uploader.profilePicURL} end} as version union with doc optional match (doc)-[:DOCUMENT_VERSION]->(dv:DocumentVersion) where $versionsSeesPreRedaction0 or coalesce(dv.preRedaction, false) = false or dv.tildaid = doc.primaryVersionId optional match (doc)-[:DOCUMENT_TO_SOURCE]->(ds:DocumentSource)-[:DOCUMENT_SOURCE_TO_VERSION]->(dv) optional match (dv)-[:UPLOADED_BY]->(uploader:User) optional match (dv)-[:PROMOTED_FROM]->(psrc:Document) return case when dv is null then null else {tildaid: dv.tildaid, fileName: dv.fileName, originalFileName: dv.originalFileName, contentType: dv.contentType, date: dv.date, dateType: doc.dateType, versionName: dv.versionName, rejectReason: dv.rejectReason, language: dv.language, languages: dv.languages, needsAttention: dv.needsAttention, needsAttentionReasons: dv.needsAttentionReasons, trackActiveDuplicates: dv.trackActiveDuplicates, versionNumber: dv.versionNumber, majorVersion: dv.majorVersion, minorVersion: dv.minorVersion, documentSourceId: ds.tildaid, promotedFromDocumentId: psrc.tildaid, generation: toString(dv.generation), linearizedPdfUrl: dv.linearizedPdfUrl, linearizedPdfStatus: dv.linearizedPdfStatus, needsProcessedPdf: dv.needsProcessedPdf, langDetectionStatus: dv.langDetectionStatus, translatedPdfUrl: dv.translatedPdfUrl, translatedPdfStatus: dv.translatedPdfStatus, cksum: dv.cksum, size: dv.size, status: dv.status, stateTag: dv.stateTag, pages: dv.pages, uploadMethod: dv.uploadMethod, changeLog: [], url: dv.url, createdAt: dv.createdat, renderedCompletedAt: dv.renderedCompletedAt, renderedFieldsRevision: dv.renderedFieldsRevision, renderedSignersRevision: dv.renderedSignersRevision, preRedaction: coalesce(dv.preRedaction, false), tmfFiledAt: coalesce(dv.tmfFiledAt, ?), uploadedBy: case when uploader is null then null else {id: uploader.tildaid, name: uploader.name, profilePicURL: uploader.profilePicURL} end} end as version // TODO: [Major/Minor Versioning] Once client supports minor version UX, update ordering to: // } with doc, version order by version.majorVersion, version.minorVersion // This will display versions as ?.?, ?.?, ?.? instead of flat ?, ?, ? } with doc, version order by version.versionNumber where $versionsVersionId0 IS NULL OR version.tildaid = $versionsVersionId0 return collect(version) as versions } CALL { return null as annotationSpec, null as annotationVal } CALL { return [] as queries } CALL { return null as sharedWith, null as currentShare } CALL { WITH doc MATCH (doc)-[:DOCUMENT_VERSION]->(dv:DocumentVersion{tildaid: coalesce($docAttrVersionId0, doc.primaryVersionId)}) MATCH (doc)-[:DOCUMENT_TO_SOURCE]->(ds:DocumentSource)-[:DOCUMENT_SOURCE_TO_VERSION]->(dv) OPTIONAL MATCH (ds)-[:HAS_ATTRIBUTE]->(da:DocAttribute) OPTIONAL MATCH (da)-[:HAS_ATTRIBUTE_DEFINITION]->(dad:DocAttributeDefinition) RETURN collect(DISTINCT da{.*, name: COALESCE(dad.name, ?), description: COALESCE(dad.description, ?), documentSourceId: ds.tildaid}) as docAttributes } CALL { WITH doc OPTIONAL MATCH (doc)-[:DOCUMENT_VERSION]->(dv:DocumentVersion{tildaid: coalesce($notesVersionId0, doc.primaryVersionId)})-[:HAS_NOTE]->(n:DocumentNote{archived: false}) RETURN count(n) AS notesCount } CALL { return null as eventId, null as eventName, null as deliverable, null as eventScope } CALL { return null as copiedFrom } CALL { return [] as copiedTo, ? as copiedToCount } CALL { return null as promotedTo } CALL { return null AS docReviewStatus, null AS hasImportantComment, null AS discrepancyCount } CALL { return null as tmfCategorization } with distinct doc{.*, status: docObj.status, stateTag: docObj.stateTag, orgAlias: org.alias, owned: owned, docTypeName: doc.docTypeName, userId: doc.userId, user: CASE WHEN user IS NOT NULL THEN {id: user.tildaid, name: user.name, profilePicURL: user.profilePicURL} ELSE NULL END, createdDate: doc.createdat, updatedDate: COALESCE(doc.updatedat, doc.createdat), externalUrl: doc.url, study: study.name, studyId: study.tildaid, site: site.name, siteId: doc.siteId, siteNumber: siteNumber, piNames: piNames, patient: patientName, patientId: doc.patientId, subjectId: subjectId, visit: visit.title, visitId: doc.visitId, reviewDate: reviewDate, assignedToUsers: [], uploadedBy: {id: uploadedBy.tildaid, name: uploadedBy.name, profilePicURL: uploadedBy.profilePicURL}, signedByUsers: signedByUsers, tags: tags, listingFolders: listingFolders, primaryFolder: primaryFolder, latestAIRun: latestAIRun, findingCount: findingCount, queriesCount: queriesCount, confirmedCount: confirmedCount, resolvedCount: resolvedCount, notesCount: notesCount, stagingLabels: stagingLabels, workOrders: workOrders, woContact: COALESCE(woContact, false), stateTags1: stateTags1, stateTags2: stateTags2, docAccessLevel: docAccessLevel, isSigner: isSigner, docReviewStatus: docReviewStatus, hasImportantComment: hasImportantComment, discrepancyCount: discrepancyCount , templateDetails: templateDetails, docTypeDetails: docType{.*}, queries: queries, annotationSpec: annotationSpec, annotationVal: annotationVal, completedAt: annotationVal.completedAt, versions: versions, reviews: reviews, sharedWith: sharedWith, currentShare: currentShare, tmfCategorization: tmfCategorization, docAttributes: docAttributes, eventId: eventId, eventName: eventName, deliverable: deliverable, eventScope: eventScope, provenance: CASE WHEN copiedFrom IS NULL AND size(copiedTo) = ? THEN null ELSE {copiedFrom: copiedFrom, copiedTo: [x IN copiedTo WHERE x IS NOT NULL | x], copiedToCount: copiedToCount} END, promotedTo: promotedTo} AS document, total return document, total
docsvc
3 820 ms 4.55 s 2.45 s flat
MATCH (u:User{tildaid:$userId}), (o:Organization{delpending:false, alias:$orgAlias}) call { with u, o // An Inactive actor holds no roles (ENG-?): its roles would otherwise // still feed hidePhi, the role list and every policy match. OPTIO…
MATCH (u:User{tildaid:$userId}), (o:Organization{delpending:false, alias:$orgAlias}) call { with u, o // An Inactive actor holds no roles (ENG-?): its roles would otherwise // still feed hidePhi, the role list and every policy match. OPTIONAL MATCH (u)<-[:FOR_USER]-(a:Actor{delpending:false})<-[:ORGANIZATION_TO_ACTOR]-(o), (a)-[:APPOINTED_AS]->(r:Role) WHERE not r.name = ? AND coalesce(a.state, ?) <> ? return r{.*} UNION with u, o // Delegated engagements in o. Only the delegated roles cross over — // the TildaScale Actor?s list. MATCH (u)<-[:FOR_USER]-(da:Actor{delpending:false})<-[:STUDY_TO_DELEGATED_ACTOR]-(st:Study{delpending:false})-[:STUDY_TO_ORG]->(o), (da)-[:APPOINTED_AS]->(r:Role)<-[:APPOINTED_AS]-(sa:Actor{delpending:false}), (da)-[:DELEGATED_FROM]->(sa)<-[:ORGANIZATION_TO_ACTOR]-(:Organization{alias:$tildaScaleAlias}) WHERE st.srcorgid = o.tildaid AND da.state <> ? AND sa.state <> ? AND $orgDelegatedTag IN apoc.text.split(coalesce(r.tags, ?), ?) return distinct r{.*} } WITH u, o, collect(distinct r.name) as roles, collect(distinct case when r.listed = true then r.displayName end) as displayRoles, ANY(n IN COLLECT(r.external) WHERE n = true) as external, ANY(n IN COLLECT(r.name) WHERE n = ?) as isPatient, ALL(n IN COLLECT(r.piiAccess) WHERE n = false) as hidePhi WITH u, o, {organization:o{.*}, external: external, isPatient: isPatient, hidePhi: hidePhi, roles: roles, displayRoles: displayRoles } as context CALL {WITH u, o MATCH (u)<-[:FOR_USER]-(a:Actor{delpending:false})<-[:STAFF_TO_ACTOR]-(si:Site{delpending:false})-[:SITE_TO_SMO]->(:Smo)-[:IS_AN_ORG]->(o) WHERE coalesce(a.state, ?) <> ? OPTIONAL MATCH (a)-[:APPOINTED_AS]->(r:Role) WITH u, o, si, a, r order by r.displayName WITH u, o, si, a, collect(distinct r.name) as roles, collect(distinct case when r.listed = true then r.displayName end) as displayRoles WITH CASE when not si is null then {siteId: si.tildaid, roles: roles, displayRoles: displayRoles} end as si return collect(si) as sites, apoc.coll.flatten(collect(si.roles)) as siteRoles } CALL {WITH u, o // WITH DISTINCT is a required pipeline barrier (see the studyMembership note // in scope.go): without it (u)<-[:FOR_USER]-(a) re-expands once per study in // the org — ?.0M -> 32k db hits. Splitting the MATCH without DISTINCT does // nothing; the barrier is what forbids the bad join order. Not applied to the // sites or org-roles subqueries, where it measured neutral or worse. // No longer OPTIONAL: the subquery ends in an ungrouped aggregation, so zero // matches still yield one row with empty collections. CALL {WITH u, o MATCH (u)<-[:FOR_USER]-(a:Actor{delpending:false, orgId:o.tildaid}) WHERE coalesce(a.state, ?) <> ? WITH DISTINCT u, o, a MATCH (a)<-[:STUDY_TO_ACTOR]-(s:Study{delpending:false})-[:STUDY_TO_ORG]->(o) OPTIONAL MATCH (a)-[:APPOINTED_AS]->(r:Role) RETURN s, a, r UNION // Delegated engagement Actors: orgId is TildaScale? roles. WITH s, r order by r.displayName WITH s, collect(distinct r.name) as roles, collect(distinct case when r.listed = true then r.displayName end) as displayRoles // Ordered so the studies array is a stable sequence for clients; the pipeline // that replaced the old (u,o,s,a) grouping otherwise leaves it plan-dependent. WITH s, CASE when not s is null then {studyId: s.tildaid, roles: roles, displayRoles: displayRoles, srcOrgId: s.srcorgid} end as st ORDER BY s.name, s.tildaid return collect(st) as studies, apoc.coll.flatten(collect(st.roles)) as studyRoles } with distinct context, studies, apoc.coll.toSet(apoc.coll.flatten(collect(studyRoles))) as allStudyRoles, apoc.coll.toSet(apoc.coll.flatten(collect(siteRoles))) as siRoles with context, studies, apoc.coll.toSet(apoc.coll.flatten([context.roles, allStudyRoles, siRoles])) as allRoles return context{.*, studies: studies, allRoles: allRoles}
dashql
3 1.03 s 4.55 s 3.02 s flat
MATCH (u:User {tildaid:$user}) OPTIONAL MATCH (o:Organization {alias:$org}) UNWIND $lists.checks AS c CALL (u, o, c) { // scope=Study policies=study-config-edit MATCH (u)<-[:FOR_USER]-(a:Actor)-[:APPOINTED_AS]->(x:Role) WHERE a.state <> ? …
MATCH (u:User {tildaid:$user}) OPTIONAL MATCH (o:Organization {alias:$org}) UNWIND $lists.checks AS c CALL (u, o, c) { // scope=Study policies=study-config-edit MATCH (u)<-[:FOR_USER]-(a:Actor)-[:APPOINTED_AS]->(x:Role) WHERE a.state <> ? AND a.delpending = false AND o.tildaid = a.orgId AND x.name IN $lists.roles_0 WITH DISTINCT u, o, a, c MATCH (a)<-[:STUDY_TO_ACTOR]-(st:Study) WHERE EXISTS { (st)-[:STUDY_TO_ORG]->(o) } AND ( size(c.studyIds) = ? OR st.tildaid IN c.studyIds ) RETURN DISTINCT c.idx AS checkIdx, u AS User, o AS Organization, st AS Study, null AS Site, null AS Patient UNION // scope=Study policies=study-config-edit MATCH (u)<-[:FOR_USER]-(da:Actor)<-[:STUDY_TO_DELEGATED_ACTOR]-(st:Study)-[:STUDY_TO_ORG]->(o), (da)-[:APPOINTED_AS]->(x:Role)<-[:APPOINTED_AS]-(sa:Actor), (da)-[:DELEGATED_FROM]->(sa)<-[:ORGANIZATION_TO_ACTOR]-(:Organization {alias:?}) WHERE st.srcorgid = o.tildaid AND da.state <> ? AND da.delpending = false AND sa.state <> ? AND sa.delpending = false AND x.name IN $lists.roles_1 AND ? IN apoc.text.split(coalesce(x.tags, ?), ?) AND ( size(c.studyIds) = ? OR st.tildaid IN c.studyIds ) RETURN DISTINCT c.idx AS checkIdx, u AS User, o AS Organization, st AS Study, null AS Site, null AS Patient UNION // scope=Organization policies=org-study-read MATCH (u)<-[:FOR_USER]-(a:Actor)-[:APPOINTED_AS]->(x:Role), (o)-[:ORGANIZATION_TO_ACTOR]->(a) WHERE a.state <> ? AND a.delpending = false AND x.name IN $lists.roles_2 RETURN DISTINCT c.idx AS checkIdx, u AS User, o AS Organization, null AS Study, null AS Site, null AS Patient UNION // scope=Organization policies=org-study-read MATCH (u)<-[:FOR_USER]-(da:Actor)<-[:STUDY_TO_DELEGATED_ACTOR]-(st:Study)-[:STUDY_TO_ORG]->(o), (da)-[:APPOINTED_AS]->(x:Role)<-[:APPOINTED_AS]-(sa:Actor), (da)-[:DELEGATED_FROM]->(sa)<-[:ORGANIZATION_TO_ACTOR]-(:Organization {alias:?}) WHERE st.srcorgid = o.tildaid AND da.state <> ? AND da.delpending = false AND sa.state <> ? AND sa.delpending = false AND x.name IN $lists.roles_3 AND ? IN apoc.text.split(coalesce(x.tags, ?), ?) RETURN DISTINCT c.idx AS checkIdx, u AS User, o AS Organization, null AS Study, null AS Site, null AS Patient } RETURN checkIdx, User, Organization, Study, Site, Patient
chat-agent
3 873 ms 4.55 s 2.60 s flat
MATCH (u:User{tildaid:$user}), (o:Organization{delpending:false, alias:$org}) CALL (u, o) { OPTIONAL MATCH (u)<-[:FOR_USER]-(a:Actor{delpending:false})<-[:ORGANIZATION_TO_ACTOR]-(o), (a)-[:APPOINTED_AS]->(r:Role) WHERE not r.name = ? AND c…
MATCH (u:User{tildaid:$user}), (o:Organization{delpending:false, alias:$org}) CALL (u, o) { OPTIONAL MATCH (u)<-[:FOR_USER]-(a:Actor{delpending:false})<-[:ORGANIZATION_TO_ACTOR]-(o), (a)-[:APPOINTED_AS]->(r:Role) WHERE not r.name = ? AND coalesce(a.state, ?) <> ? return r{.*} UNION MATCH (u)<-[:FOR_USER]-(da:Actor{delpending:false})<-[:STUDY_TO_DELEGATED_ACTOR]-(st:Study{delpending:false})-[:STUDY_TO_ORG]->(o), (da)-[:APPOINTED_AS]->(r:Role)<-[:APPOINTED_AS]-(sa:Actor{delpending:false}), (da)-[:DELEGATED_FROM]->(sa)<-[:ORGANIZATION_TO_ACTOR]-(:Organization{alias:?}) WHERE st.srcorgid = o.tildaid AND da.state <> ? AND sa.state <> ? AND ? IN apoc.text.split(coalesce(r.tags, ?), ?) return distinct r{.*} } WITH u, o, collect(distinct r.name) as roles, collect(distinct case when r.listed = true then r.displayName end) as displayRoles, ANY(n IN COLLECT(r.external) WHERE n = true) as external, ANY(n IN COLLECT(r.name) WHERE n = ?) as isPatient, ALL(n IN COLLECT(r.piiAccess) WHERE n = false) as hidePhi WITH u, o, {organization:o{.*}, external: external, isPatient: isPatient, hidePhi: hidePhi, roles: roles, displayRoles: displayRoles } as context CALL (u, o) { MATCH (u)<-[:FOR_USER]-(a:Actor{delpending:false})<-[:STAFF_TO_ACTOR]-(si:Site{delpending:false})-[:SITE_TO_SMO]->(:Smo)-[:IS_AN_ORG]->(o) WHERE coalesce(a.state, ?) <> ? OPTIONAL MATCH (a)-[:APPOINTED_AS]->(r:Role) WITH u, o, si, a, r order by r.displayName WITH u, o, si, a, collect(distinct r.name) as roles, collect(distinct case when r.listed = true then r.displayName end) as displayRoles WITH CASE when not si is null then {siteId: si.tildaid, roles: roles, displayRoles: displayRoles} end as si return collect(si) as sites, apoc.coll.flatten(collect(si.roles)) as siteRoles } CALL (u, o) { CALL (u, o) { MATCH (u)<-[:FOR_USER]-(a:Actor{delpending:false, orgId:o.tildaid}) WHERE coalesce(a.state, ?) <> ? // Required pipeline barrier: without it the actor match re-expands // once per study in the org (?.0M -> 32k db hits, measured in Go). WITH DISTINCT u, o, a MATCH (a)<-[:STUDY_TO_ACTOR]-(s:Study{delpending:false})-[:STUDY_TO_ORG]->(o) OPTIONAL MATCH (a)-[:APPOINTED_AS]->(r:Role) RETURN s, r UNION // Delegated engagement Actors: orgId is TildaScale? roles. WITH s, r order by r.displayName WITH s, collect(distinct r.name) as roles, collect(distinct case when r.listed = true then r.displayName end) as displayRoles // Ordered so the studies array is a stable sequence for clients. WITH s, {studyId: s.tildaid, roles: roles, displayRoles: displayRoles, srcOrgId: s.srcorgid} as st ORDER BY s.name, s.tildaid return collect(st) as studies, apoc.coll.flatten(collect(st.roles)) as studyRoles } with distinct context, studies, apoc.coll.toSet(apoc.coll.flatten(collect(studyRoles))) as allStudyRoles, apoc.coll.toSet(apoc.coll.flatten(collect(siteRoles))) as siRoles with context, studies, apoc.coll.toSet(apoc.coll.flatten([context.roles, allStudyRoles, siRoles])) as allRoles return context{.*, studies: studies, allRoles: allRoles} as rc
chat-agent
3 841 ms 4.55 s 2.51 s flat
MATCH (org:Organization{tildaid:$scopeOrgId0}) CALL { WITH org UNWIND $lists.allowedStudies0 AS studyId OPTIONAL MATCH (study:Study) WHERE study.tildaid = studyId // An inactive actor carries no membership, so it is excluded here rather th…
MATCH (org:Organization{tildaid:$scopeOrgId0}) CALL { WITH org UNWIND $lists.allowedStudies0 AS studyId OPTIONAL MATCH (study:Study) WHERE study.tildaid = studyId // An inactive actor carries no membership, so it is excluded here rather than at each use: // the sites, countries and roles below all hang off it. OPTIONAL MATCH (study)-[:STUDY_TO_ACTOR]-(studyActor:Actor{orgId:$ctxOrgId0})-[:FOR_USER]->(:User{tildaid:$ctxUserId0}) WHERE studyActor.state <> ? // Collect sites where user has membership in this study OPTIONAL MATCH (studyActor)-[:STUDYSITEACTOR_TO_ACTOR]-(:StudySiteActor)-[:STUDYSITEACTOR_TO_PLAN_DEFINITION]-(pd:DslPlanDefinition)-[:PLAN_DEFINITION_TO_SITE]-(site:Site) WITH org, study, studyActor, collect(DISTINCT site.tildaid) as userSiteIds // Collect countries where user has membership in this study OPTIONAL MATCH (studyActor)<-[:STUDYCOUNTRYACTOR_TO_ACTOR]-(sca:StudyCountryActor) WITH org, study, studyActor, userSiteIds, collect(DISTINCT sca.country) as userCountryIds // Pre-collect policies for this user/role in this study OPTIONAL MATCH (org)<-[:DOC_ACCESS_POLICY_TO_ORG]-(policy:DocumentAccessPolicy{status:?})-[:POLICY_TO_STUDY]->(study) WHERE EXISTS { MATCH (policy)-[:POLICY_FOR_USER]->(:User{tildaid:$ctxUserId0}) } OR (studyActor IS NOT NULL AND EXISTS { MATCH (policy)-[:POLICY_FOR_ROLE]->(role:Role)<-[:APPOINTED_AS]-(studyActor) }) WITH study, studyActor, userSiteIds, userCountryIds, collect(policy) as policies WITH {study:study, studyActor:studyActor, userSiteIds:userSiteIds, userCountryIds:userCountryIds, policies:policies} AS st WITH collect(distinct st) as studies // studyById lets each document row look its context up by study id instead of scanning // the whole list. Entries whose study did not resolve share the ? key; they all carry // the same empty context, so which one wins does not matter. The node-bearing maps go no // further than this subquery; studyIdsInScope needs no lookup, since an id with no Study // node can never equal a matched study?Basic??ReadWrite?ReadOnly?s folder and ancestors (up to ? levels for TMF hierarchy) OPTIONAL MATCH (doc1)<-[:INCLUDES]-(docFolder:Folder) OPTIONAL MATCH (docFolder)<-[:INCLUDES*?..?]-(ancestorFolder:Folder) WITH doc1, policies, userSiteIds, userCountryIds, defaultAccessLevel, collect(DISTINCT docFolder) + collect(DISTINCT ancestorFolder) AS folderHierarchy // Check document ownership OPTIONAL MATCH (doc1)-[:UPLOADED_BY]->(uploader:User{tildaid:$policyUploaderId0}) WITH doc1, policies, userSiteIds, userCountryIds, defaultAccessLevel, folderHierarchy, uploader IS NOT NULL AS isOwnedByUser // Filter policies by: // ?. Folder: policy applies if folder is in hierarchy OR policy has no folder (study-wide). A folder-less // ownership policy is the role?Owned Documents?Non Owned Documents?Staging?Pre-Staging?Owned Documents?Non Owned Documents?My Sites Documents?Other Sites Documents?My Countries Documents?Other Countries Documents?Study Scope Documents?NoAccess?NoAccess?ReadOnly?ReadOnly?ReadWrite?ReadOnly?NoAccess??Inactive? ?Received?Quality Control?PHI Issues???/???/???/') ELSE ? END as childFolderPath WITH docObj, ct, child, st, head(collect(childFolderPath)) AS childFolderPath WITH child, CASE WHEN ct IS NULL THEN null ELSE { documentId: child.tildaid, studyId: COALESCE(child.studyId, ?), studyName: COALESCE(st.name, ?), folderPath: childFolderPath, kind: ct.kind, stale: ct.sourceVersionId <> docObj.primaryVersionId, version: COALESCE(child.versionName, toString(child.majorVersion)) } END as copiedToEntry RETURN collect(copiedToEntry) as copiedTo, count(DISTINCT child) as copiedToCount } CALL { return null as promotedTo } CALL { return null AS docReviewStatus, null AS hasImportantComment, null AS discrepancyCount } CALL { return null as tmfCategorization } with distinct doc{.*, status: docObj.status, stateTag: docObj.stateTag, orgAlias: org.alias, owned: owned, docTypeName: doc.docTypeName, userId: doc.userId, user: CASE WHEN user IS NOT NULL THEN {id: user.tildaid, name: user.name, profilePicURL: user.profilePicURL} ELSE NULL END, createdDate: doc.createdat, updatedDate: COALESCE(doc.updatedat, doc.createdat), externalUrl: doc.url, study: study.name, studyId: study.tildaid, site: site.name, siteId: doc.siteId, siteNumber: siteNumber, piNames: piNames, patient: patientName, patientId: doc.patientId, subjectId: subjectId, visit: visit.title, visitId: doc.visitId, reviewDate: reviewDate, assignedToUsers: [], uploadedBy: {id: uploadedBy.tildaid, name: uploadedBy.name, profilePicURL: uploadedBy.profilePicURL}, signedByUsers: signedByUsers, tags: tags, listingFolders: listingFolders, primaryFolder: primaryFolder, latestAIRun: latestAIRun, findingCount: findingCount, queriesCount: queriesCount, confirmedCount: confirmedCount, resolvedCount: resolvedCount, notesCount: notesCount, stagingLabels: stagingLabels, workOrders: workOrders, woContact: COALESCE(woContact, false), stateTags1: stateTags1, stateTags2: stateTags2, docAccessLevel: docAccessLevel, isSigner: isSigner, docReviewStatus: docReviewStatus, hasImportantComment: hasImportantComment, discrepancyCount: discrepancyCount , templateDetails: templateDetails, docTypeDetails: docType{.*}, queries: queries, annotationSpec: annotationSpec, annotationVal: annotationVal, completedAt: annotationVal.completedAt, versions: versions, reviews: reviews, sharedWith: sharedWith, currentShare: currentShare, tmfCategorization: tmfCategorization, docAttributes: docAttributes, eventId: eventId, eventName: eventName, deliverable: deliverable, eventScope: eventScope, provenance: CASE WHEN copiedFrom IS NULL AND size(copiedTo) = ? THEN null ELSE {copiedFrom: copiedFrom, copiedTo: [x IN copiedTo WHERE x IS NOT NULL | x], copiedToCount: copiedToCount} END, promotedTo: promotedTo} AS document, total return document, total
docsvc
4 914 ms 4.40 s 3.44 s flat
MATCH (org:Organization{tildaid:$scopeOrgId0}) CALL { WITH org UNWIND $lists.allowedStudies0 AS studyId OPTIONAL MATCH (study:Study) WHERE study.tildaid = studyId // An inactive actor carries no membership, so it is excluded here rather th…
MATCH (org:Organization{tildaid:$scopeOrgId0}) CALL { WITH org UNWIND $lists.allowedStudies0 AS studyId OPTIONAL MATCH (study:Study) WHERE study.tildaid = studyId // An inactive actor carries no membership, so it is excluded here rather than at each use: // the sites, countries and roles below all hang off it. OPTIONAL MATCH (study)-[:STUDY_TO_ACTOR]-(studyActor:Actor{orgId:$ctxOrgId0})-[:FOR_USER]->(:User{tildaid:$ctxUserId0}) WHERE studyActor.state <> ? // Collect sites where user has membership in this study OPTIONAL MATCH (studyActor)-[:STUDYSITEACTOR_TO_ACTOR]-(:StudySiteActor)-[:STUDYSITEACTOR_TO_PLAN_DEFINITION]-(pd:DslPlanDefinition)-[:PLAN_DEFINITION_TO_SITE]-(site:Site) WITH org, study, studyActor, collect(DISTINCT site.tildaid) as userSiteIds // Collect countries where user has membership in this study OPTIONAL MATCH (studyActor)<-[:STUDYCOUNTRYACTOR_TO_ACTOR]-(sca:StudyCountryActor) WITH org, study, studyActor, userSiteIds, collect(DISTINCT sca.country) as userCountryIds // Pre-collect policies for this user/role in this study OPTIONAL MATCH (org)<-[:DOC_ACCESS_POLICY_TO_ORG]-(policy:DocumentAccessPolicy{status:?})-[:POLICY_TO_STUDY]->(study) WHERE EXISTS { MATCH (policy)-[:POLICY_FOR_USER]->(:User{tildaid:$ctxUserId0}) } OR (studyActor IS NOT NULL AND EXISTS { MATCH (policy)-[:POLICY_FOR_ROLE]->(role:Role)<-[:APPOINTED_AS]-(studyActor) }) WITH study, studyActor, userSiteIds, userCountryIds, collect(policy) as policies WITH {study:study, studyActor:studyActor, userSiteIds:userSiteIds, userCountryIds:userCountryIds, policies:policies} AS st WITH collect(distinct st) as studies // studyById lets each document row look its context up by study id instead of scanning // the whole list. Entries whose study did not resolve share the ? key; they all carry // the same empty context, so which one wins does not matter. The node-bearing maps go no // further than this subquery; studyIdsInScope needs no lookup, since an id with no Study // node can never equal a matched study??ReadWrite?ReadOnly?s folder and ancestors (up to ? levels for TMF hierarchy) OPTIONAL MATCH (doc1)<-[:INCLUDES]-(docFolder:Folder) OPTIONAL MATCH (docFolder)<-[:INCLUDES*?..?]-(ancestorFolder:Folder) WITH doc1, policies, userSiteIds, userCountryIds, defaultAccessLevel, collect(DISTINCT docFolder) + collect(DISTINCT ancestorFolder) AS folderHierarchy // Check document ownership OPTIONAL MATCH (doc1)-[:UPLOADED_BY]->(uploader:User{tildaid:$policyUploaderId0}) WITH doc1, policies, userSiteIds, userCountryIds, defaultAccessLevel, folderHierarchy, uploader IS NOT NULL AS isOwnedByUser // Filter policies by: // ?. Folder: policy applies if folder is in hierarchy OR policy has no folder (study-wide). A folder-less // ownership policy is the role?Owned Documents?Non Owned Documents?Staging?Pre-Staging?Owned Documents?Non Owned Documents?My Sites Documents?Other Sites Documents?My Countries Documents?Other Countries Documents?Study Scope Documents?NoAccess?NoAccess?ReadOnly?ReadOnly?ReadWrite?ReadOnly?NoAccess??Inactive? ?Received?Quality Control?PHI Issues???/???/???/') ELSE ? END as childFolderPath WITH docObj, ct, child, st, head(collect(childFolderPath)) AS childFolderPath WITH child, CASE WHEN ct IS NULL THEN null ELSE { documentId: child.tildaid, studyId: COALESCE(child.studyId, ?), studyName: COALESCE(st.name, ?), folderPath: childFolderPath, kind: ct.kind, stale: ct.sourceVersionId <> docObj.primaryVersionId, version: COALESCE(child.versionName, toString(child.majorVersion)) } END as copiedToEntry RETURN collect(copiedToEntry) as copiedTo, count(DISTINCT child) as copiedToCount } CALL { return null as promotedTo } CALL { return null AS docReviewStatus, null AS hasImportantComment, null AS discrepancyCount } CALL { return null as tmfCategorization } with distinct doc{.*, status: docObj.status, stateTag: docObj.stateTag, orgAlias: org.alias, owned: owned, docTypeName: doc.docTypeName, userId: doc.userId, user: CASE WHEN user IS NOT NULL THEN {id: user.tildaid, name: user.name, profilePicURL: user.profilePicURL} ELSE NULL END, createdDate: doc.createdat, updatedDate: COALESCE(doc.updatedat, doc.createdat), externalUrl: doc.url, study: study.name, studyId: study.tildaid, site: site.name, siteId: doc.siteId, siteNumber: siteNumber, piNames: piNames, patient: patientName, patientId: doc.patientId, subjectId: subjectId, visit: visit.title, visitId: doc.visitId, reviewDate: reviewDate, assignedToUsers: [], uploadedBy: {id: uploadedBy.tildaid, name: uploadedBy.name, profilePicURL: uploadedBy.profilePicURL}, signedByUsers: signedByUsers, tags: tags, listingFolders: listingFolders, primaryFolder: primaryFolder, latestAIRun: latestAIRun, findingCount: findingCount, queriesCount: queriesCount, confirmedCount: confirmedCount, resolvedCount: resolvedCount, notesCount: notesCount, stagingLabels: stagingLabels, workOrders: workOrders, woContact: COALESCE(woContact, false), stateTags1: stateTags1, stateTags2: stateTags2, docAccessLevel: docAccessLevel, isSigner: isSigner, docReviewStatus: docReviewStatus, hasImportantComment: hasImportantComment, discrepancyCount: discrepancyCount , templateDetails: templateDetails, docTypeDetails: docType{.*}, queries: queries, annotationSpec: annotationSpec, annotationVal: annotationVal, completedAt: annotationVal.completedAt, versions: versions, reviews: reviews, sharedWith: sharedWith, currentShare: currentShare, tmfCategorization: tmfCategorization, docAttributes: docAttributes, eventId: eventId, eventName: eventName, deliverable: deliverable, eventScope: eventScope, provenance: CASE WHEN copiedFrom IS NULL AND size(copiedTo) = ? THEN null ELSE {copiedFrom: copiedFrom, copiedTo: [x IN copiedTo WHERE x IS NOT NULL | x], copiedToCount: copiedToCount} END, promotedTo: promotedTo} AS document, total return document, total
docsvc
4 969 ms 4.40 s 2.79 s flat
MATCH (u:User {tildaid:$user}) OPTIONAL MATCH (o:Organization {alias:$org}) UNWIND $lists.checks AS c CALL { WITH u, o, c // scope=Study policies=study-config-edit MATCH (u)<-[:FOR_USER]-(a:Actor)-[:APPOINTED_AS]->(x:Role) WHERE a.state <>…
MATCH (u:User {tildaid:$user}) OPTIONAL MATCH (o:Organization {alias:$org}) UNWIND $lists.checks AS c CALL { WITH u, o, c // scope=Study policies=study-config-edit MATCH (u)<-[:FOR_USER]-(a:Actor)-[:APPOINTED_AS]->(x:Role) WHERE a.state <> ? AND a.delpending = false AND o.tildaid = a.orgId AND x.name IN $lists.roles_0 WITH DISTINCT u, o, a, c MATCH (a)<-[:STUDY_TO_ACTOR]-(st:Study) WHERE EXISTS { (st)-[:STUDY_TO_ORG]->(o) } AND ( size(c.studyIds) = ? OR st.tildaid IN c.studyIds ) WITH * WHERE st.tildaid = c.id RETURN DISTINCT c.idx AS checkIdx, u AS User, o AS Organization, st AS Study, null AS Site, null AS Patient UNION WITH u, o, c // scope=Study policies=study-config-edit MATCH (u)<-[:FOR_USER]-(da:Actor)<-[:STUDY_TO_DELEGATED_ACTOR]-(st:Study)-[:STUDY_TO_ORG]->(o), (da)-[:APPOINTED_AS]->(x:Role)<-[:APPOINTED_AS]-(sa:Actor), (da)-[:DELEGATED_FROM]->(sa)<-[:ORGANIZATION_TO_ACTOR]-(:Organization {alias:$tildaScaleAlias}) WHERE st.srcorgid = o.tildaid AND da.state <> ? AND da.delpending = false AND sa.state <> ? AND sa.delpending = false AND x.name IN $lists.roles_1 AND ? IN apoc.text.split(coalesce(x.tags, ?), ?) AND ( size(c.studyIds) = ? OR st.tildaid IN c.studyIds ) WITH * WHERE st.tildaid = c.id RETURN DISTINCT c.idx AS checkIdx, u AS User, o AS Organization, st AS Study, null AS Site, null AS Patient UNION WITH u, o, c // scope=Organization policies=org-study-read MATCH (u)<-[:FOR_USER]-(a:Actor)-[:APPOINTED_AS]->(x:Role), (o)-[:ORGANIZATION_TO_ACTOR]->(a) WHERE a.state <> ? AND a.delpending = false AND x.name IN $lists.roles_2 MATCH (o)<-[:STUDY_TO_ORG]-(st:Study {tildaid:c.id}) RETURN DISTINCT c.idx AS checkIdx, u AS User, o AS Organization, null AS Study, null AS Site, null AS Patient UNION WITH u, o, c // scope=Organization policies=org-study-read MATCH (u)<-[:FOR_USER]-(da:Actor)<-[:STUDY_TO_DELEGATED_ACTOR]-(st:Study)-[:STUDY_TO_ORG]->(o), (da)-[:APPOINTED_AS]->(x:Role)<-[:APPOINTED_AS]-(sa:Actor), (da)-[:DELEGATED_FROM]->(sa)<-[:ORGANIZATION_TO_ACTOR]-(:Organization {alias:$tildaScaleAlias}) WHERE st.srcorgid = o.tildaid AND da.state <> ? AND da.delpending = false AND sa.state <> ? AND sa.delpending = false AND x.name IN $lists.roles_3 AND ? IN apoc.text.split(coalesce(x.tags, ?), ?) MATCH (o)<-[:STUDY_TO_ORG]-(st:Study {tildaid:c.id}) RETURN DISTINCT c.idx AS checkIdx, u AS User, o AS Organization, null AS Study, null AS Site, null AS Patient } RETURN checkIdx, User, Organization, Study, Site, Patient
enrollsvc
5 424 ms 4.25 s 2.11 s flat
MATCH (u:User{tildaid:$user}), (o:Organization{delpending:false, alias:$org}) CALL (u, o) { OPTIONAL MATCH (u)<-[:FOR_USER]-(a:Actor{delpending:false})<-[:ORGANIZATION_TO_ACTOR]-(o), (a)-[:APPOINTED_AS]->(r:Role) WHERE not r.name = ? AND c…
MATCH (u:User{tildaid:$user}), (o:Organization{delpending:false, alias:$org}) CALL (u, o) { OPTIONAL MATCH (u)<-[:FOR_USER]-(a:Actor{delpending:false})<-[:ORGANIZATION_TO_ACTOR]-(o), (a)-[:APPOINTED_AS]->(r:Role) WHERE not r.name = ? AND coalesce(a.state, ?) <> ? return r{.*} UNION MATCH (u)<-[:FOR_USER]-(da:Actor{delpending:false})<-[:STUDY_TO_DELEGATED_ACTOR]-(st:Study{delpending:false})-[:STUDY_TO_ORG]->(o), (da)-[:APPOINTED_AS]->(r:Role)<-[:APPOINTED_AS]-(sa:Actor{delpending:false}), (da)-[:DELEGATED_FROM]->(sa)<-[:ORGANIZATION_TO_ACTOR]-(:Organization{alias:?}) WHERE st.srcorgid = o.tildaid AND da.state <> ? AND sa.state <> ? AND ? IN apoc.text.split(coalesce(r.tags, ?), ?) return distinct r{.*} } WITH u, o, collect(distinct r.name) as roles, collect(distinct case when r.listed = true then r.displayName end) as displayRoles, ANY(n IN COLLECT(r.external) WHERE n = true) as external, ANY(n IN COLLECT(r.name) WHERE n = ?) as isPatient, ALL(n IN COLLECT(r.piiAccess) WHERE n = false) as hidePhi WITH u, o, {organization:o{.*}, external: external, isPatient: isPatient, hidePhi: hidePhi, roles: roles, displayRoles: displayRoles } as context CALL (u, o) { MATCH (u)<-[:FOR_USER]-(a:Actor{delpending:false})<-[:STAFF_TO_ACTOR]-(si:Site{delpending:false})-[:SITE_TO_SMO]->(:Smo)-[:IS_AN_ORG]->(o) WHERE coalesce(a.state, ?) <> ? OPTIONAL MATCH (a)-[:APPOINTED_AS]->(r:Role) WITH u, o, si, a, r order by r.displayName WITH u, o, si, a, collect(distinct r.name) as roles, collect(distinct case when r.listed = true then r.displayName end) as displayRoles WITH CASE when not si is null then {siteId: si.tildaid, roles: roles, displayRoles: displayRoles} end as si return collect(si) as sites, apoc.coll.flatten(collect(si.roles)) as siteRoles } CALL (u, o) { CALL (u, o) { MATCH (u)<-[:FOR_USER]-(a:Actor{delpending:false, orgId:o.tildaid}) WHERE coalesce(a.state, ?) <> ? // Required pipeline barrier: without it the actor match re-expands // once per study in the org (?.0M -> 32k db hits, measured in Go). WITH DISTINCT u, o, a MATCH (a)<-[:STUDY_TO_ACTOR]-(s:Study{delpending:false})-[:STUDY_TO_ORG]->(o) OPTIONAL MATCH (a)-[:APPOINTED_AS]->(r:Role) RETURN s, r UNION // Delegated engagement Actors: orgId is TildaScale? roles. WITH s, r order by r.displayName WITH s, collect(distinct r.name) as roles, collect(distinct case when r.listed = true then r.displayName end) as displayRoles // Ordered so the studies array is a stable sequence for clients. WITH s, {studyId: s.tildaid, roles: roles, displayRoles: displayRoles, srcOrgId: s.srcorgid} as st ORDER BY s.name, s.tildaid return collect(st) as studies, apoc.coll.flatten(collect(st.roles)) as studyRoles } with distinct context, studies, apoc.coll.toSet(apoc.coll.flatten(collect(studyRoles))) as allStudyRoles, apoc.coll.toSet(apoc.coll.flatten(collect(siteRoles))) as siRoles with context, studies, apoc.coll.toSet(apoc.coll.flatten([context.roles, allStudyRoles, siRoles])) as allRoles return context{.*, studies: studies, allRoles: allRoles} as rc
chat-agent
5 663 ms 4.25 s 3.28 s flat
MATCH (u:User {tildaid:$user}) OPTIONAL MATCH (o:Organization {alias:$org}) UNWIND $lists.checks AS c CALL (u, o, c) { // scope=Study policies=study-config-edit MATCH (u)<-[:FOR_USER]-(a:Actor)-[:APPOINTED_AS]->(x:Role) WHERE a.state <> ? …
MATCH (u:User {tildaid:$user}) OPTIONAL MATCH (o:Organization {alias:$org}) UNWIND $lists.checks AS c CALL (u, o, c) { // scope=Study policies=study-config-edit MATCH (u)<-[:FOR_USER]-(a:Actor)-[:APPOINTED_AS]->(x:Role) WHERE a.state <> ? AND a.delpending = false AND o.tildaid = a.orgId AND x.name IN $lists.roles_0 WITH DISTINCT u, o, a, c MATCH (a)<-[:STUDY_TO_ACTOR]-(st:Study) WHERE EXISTS { (st)-[:STUDY_TO_ORG]->(o) } AND ( size(c.studyIds) = ? OR st.tildaid IN c.studyIds ) RETURN DISTINCT c.idx AS checkIdx, u AS User, o AS Organization, st AS Study, null AS Site, null AS Patient UNION // scope=Study policies=study-config-edit MATCH (u)<-[:FOR_USER]-(da:Actor)<-[:STUDY_TO_DELEGATED_ACTOR]-(st:Study)-[:STUDY_TO_ORG]->(o), (da)-[:APPOINTED_AS]->(x:Role)<-[:APPOINTED_AS]-(sa:Actor), (da)-[:DELEGATED_FROM]->(sa)<-[:ORGANIZATION_TO_ACTOR]-(:Organization {alias:?}) WHERE st.srcorgid = o.tildaid AND da.state <> ? AND da.delpending = false AND sa.state <> ? AND sa.delpending = false AND x.name IN $lists.roles_1 AND ? IN apoc.text.split(coalesce(x.tags, ?), ?) AND ( size(c.studyIds) = ? OR st.tildaid IN c.studyIds ) RETURN DISTINCT c.idx AS checkIdx, u AS User, o AS Organization, st AS Study, null AS Site, null AS Patient UNION // scope=Organization policies=org-study-read MATCH (u)<-[:FOR_USER]-(a:Actor)-[:APPOINTED_AS]->(x:Role), (o)-[:ORGANIZATION_TO_ACTOR]->(a) WHERE a.state <> ? AND a.delpending = false AND x.name IN $lists.roles_2 RETURN DISTINCT c.idx AS checkIdx, u AS User, o AS Organization, null AS Study, null AS Site, null AS Patient UNION // scope=Organization policies=org-study-read MATCH (u)<-[:FOR_USER]-(da:Actor)<-[:STUDY_TO_DELEGATED_ACTOR]-(st:Study)-[:STUDY_TO_ORG]->(o), (da)-[:APPOINTED_AS]->(x:Role)<-[:APPOINTED_AS]-(sa:Actor), (da)-[:DELEGATED_FROM]->(sa)<-[:ORGANIZATION_TO_ACTOR]-(:Organization {alias:?}) WHERE st.srcorgid = o.tildaid AND da.state <> ? AND da.delpending = false AND sa.state <> ? AND sa.delpending = false AND x.name IN $lists.roles_3 AND ? IN apoc.text.split(coalesce(x.tags, ?), ?) RETURN DISTINCT c.idx AS checkIdx, u AS User, o AS Organization, null AS Study, null AS Site, null AS Patient } RETURN checkIdx, User, Organization, Study, Site, Patient
chat-agent
6 481 ms 4.10 s 2.79 s flat
MATCH (r:Recommendation {tildaid: $id}) WHERE NOT r.category IN [?, ?, ?] MATCH (ai:AIRun)-[:AI_RUN_TO_RECOMMENDATION]->(r) MATCH (r)-[:RECOMMENDATION_TO_ORGANIZATION]->(o:Organization) MATCH (d:Document {tildaid: r.doc_id}) OPTIONAL MATCH…
MATCH (r:Recommendation {tildaid: $id}) WHERE NOT r.category IN [?, ?, ?] MATCH (ai:AIRun)-[:AI_RUN_TO_RECOMMENDATION]->(r) MATCH (r)-[:RECOMMENDATION_TO_ORGANIZATION]->(o:Organization) MATCH (d:Document {tildaid: r.doc_id}) OPTIONAL MATCH (d)<-[:INCLUDES]-(currentFolder:Folder{folderType:?, delpending: FALSE}) WHERE currentFolder.scope IN [?, ?] OPTIONAL MATCH (d)-[:FILED_UNDER_SUBARTIFACT]->(currentSubArtifact:SubArtifact)<-[:INCLUDES]-(currentFolder) OPTIONAL MATCH (d)-[:HAS_STAGING_INFO]->(stagingInfo:DocumentStagingInfo) OPTIONAL MATCH (artifact:Folder{tildaid:coalesce(stagingInfo.folderId, currentFolder.tildaid, ?)})<-[:INCLUDES]-(section:Folder)<-[:INCLUDES]-(zone:Folder)<-[:INCLUDES]-(collection:Folder{level:?}) OPTIONAL MATCH (artifact)-[:INCLUDES]->(subArtifact:SubArtifact{tildaid:coalesce(stagingInfo.subArtifactId, currentSubArtifact.tildaid, ?)}) OPTIONAL MATCH (d) - [:UPLOADED_BY] - (u: User) OPTIONAL MATCH (dv:DocumentVersion{tildaid: d.primaryVersionId}) OPTIONAL MATCH (d)<-[:INCLUDES]-(b:Binder)-[:BINDER_FOR]->(study:Study) OPTIONAL MATCH (d)<-[:INCLUDES]-(b2:Binder)-[:BINDER_FOR]->(site:Site) CALL { WITH d, site OPTIONAL MATCH (study:Study{tildaid: d.studyId})<-[:PLAN_DEFINITION_TO_STUDY]- (pd:DslPlanDefinition{delpending:false, type:?})-[:PLAN_DEFINITION_TO_SITE]->(site) RETURN COALESCE(pd.siteNumber, ?) AS siteNumber } CALL { WITH dv OPTIONAL MATCH (dv)<-[:DOCUMENT_SOURCE_TO_VERSION]-(ds:DocumentSource)-[:HAS_ATTRIBUTE]->(docAttr: DocAttribute) WITH collect([coalesce(docAttr.key, ?), coalesce(docAttr.value, ?)]) AS attributePairs WITH apoc.map.fromPairs(attributePairs) AS attributesMap WITH apoc.convert.toJson(attributesMap) AS attributesJson RETURN attributesJson } // Latest state-change ChangeLog on the version — gives us the user // who triggered the doc into its current state. Merge both event // types (Staging + StateTag) since the BE treats them as the same // documentState concept (mirrors the Python migration script). CALL { WITH dv OPTIONAL MATCH (dv)-[:ALL_CHANGELOG]-(dvcl:ChangeLog) WHERE dvcl.type IN [?, ?] WITH dvcl ORDER BY dvcl.createdat DESC LIMIT ? OPTIONAL MATCH (changer:User {tildaid: dvcl.changedBy}) WHERE dvcl IS NOT NULL RETURN coalesce(dvcl.changedBy, ?) as statePromotedBy, coalesce(changer.name, ?) as statePromotedByName } WITH r, ai, o, d, zone, section, artifact, subArtifact, u, dv, study, site, siteNumber, attributesJson, statePromotedBy, statePromotedByName, // Document Scope key stripping: reduce the rec JSON envelope to the keys // valid for its OWN scope so irrelevant keys (e.g. country on a site rec) // don?scope?country?scope?siteName?siteId?siteNumber?scope?scope???{}?{}?????{}?{?{?{????DRecommendation?t emit irrelevant rows (e.g. country on a site-scoped rec). recommendedValue: CASE WHEN r.category = ? AND recAllowed IS NOT NULL THEN apoc.convert.toJson(apoc.map.fromPairs([k IN keys(recMap) WHERE k IN recAllowed | [k, recMap[k]]])) ELSE coalesce(CASE WHEN coalesce(r.data_formatted, ?) <> ? THEN r.data_formatted END, r.data, ?) END, // originalRecommendation = the AI?Document Scope????Document Metadata?{}??Document Scope???Document Naming??TMF Artifact???.???.??? ??Sub Artifact??Document Scope??country???site?????Document Metadata??Document Metadata?????{}??????{}??{}??Document Scope?????country???site??????Document Naming???????TMF Artifact????????.???.??? ??Sub Artifact???????Document Format?Document Summary?Quality Control?PHI Issues?Confirm?Fix It??') END END) WHEN true THEN ? WHEN false THEN ? ELSE null END END, comment: r.comment, statePromotedBy: statePromotedBy, statePromotedByName: statePromotedByName } ) YIELD node RETURN node
write dashrsvc
8 273 ms 3.80 s 2.17 s flat
MATCH (e:Event {tildaid: $eventId, orgId: $orgId})- [:REQUIRES_RESOLUTION_OF]->(d:Deliverable)-[tracksRel:TRACKS_PLACEHOLDER]->(ph:Document) WHERE COALESCE(tracksRel.state, ?) in $userDecisions OPTIONAL MATCH (ph)-[:SCOPED_TO]->(es:EventSc…
MATCH (e:Event {tildaid: $eventId, orgId: $orgId})- [:REQUIRES_RESOLUTION_OF]->(d:Deliverable)-[tracksRel:TRACKS_PLACEHOLDER]->(ph:Document) WHERE COALESCE(tracksRel.state, ?) in $userDecisions OPTIONAL MATCH (ph)-[:SCOPED_TO]->(es:EventScope)-[:PART_OF_EVENT]->(e) OPTIONAL MATCH (wo:WorkOrder)-[woClaim:WO_CLAIMS_PLACEHOLDER]->(ph) WHERE woClaim.is_current = true WITH e, ph, d, es, tracksRel, head(collect(wo)) AS wo OPTIONAL MATCH (ph)-[acceptedRel:ACCEPTED_DOCUMENT]->(acceptedDoc:Document) OPTIONAL MATCH (ph)-[matchRel:MATCHING_DOCUMENT]->(matchDoc:Document) WHERE acceptedDoc IS NULL OR matchDoc.tildaid <> acceptedDoc.tildaid WITH e, ph, d, es, tracksRel, acceptedDoc, acceptedRel, wo, collect(DISTINCT CASE WHEN matchDoc IS NOT NULL AND matchDoc.collection = ? THEN { documentId: matchDoc.tildaid, displayId: matchDoc.displayId, contentType: matchDoc.contentType, documentName: matchDoc.fileName, documentDate: CASE WHEN matchDoc.createdat IS NOT NULL THEN datetime({epochMillis: matchDoc.createdat}) ELSE null END, isAccepted: false, matchedBy: matchRel.matchedBy, matchedAt: CASE WHEN matchRel.createdat IS NOT NULL THEN datetime({epochMillis: matchRel.createdat}) ELSE null END, docAttributes: [ (matchDoc)-[:DOCUMENT_TO_SOURCE]->(daSrc:DocumentSource)-[:HAS_ATTRIBUTE]->(da:DocAttribute) WHERE (daSrc)-[:DOCUMENT_SOURCE_TO_VERSION]->(:DocumentVersion {tildaid: matchDoc.primaryVersionId}) | {key: da.key, value: da.value, type: da.type, name: COALESCE(head([ (da)-[:HAS_ATTRIBUTE_DEFINITION]->(dad:DocAttributeDefinition) | dad.name ]), ?), description: COALESCE(head([ (da)-[:HAS_ATTRIBUTE_DEFINITION]->(dad:DocAttributeDefinition) | dad.description ]), ?)} ] } END) as matchesExpectedCollected, collect(DISTINCT CASE WHEN matchDoc IS NOT NULL AND (matchDoc.collection IS NULL OR matchDoc.collection <> ?) THEN { documentId: matchDoc.tildaid, displayId: matchDoc.displayId, contentType: matchDoc.contentType, documentName: matchDoc.fileName, documentDate: CASE WHEN matchDoc.createdat IS NOT NULL THEN datetime({epochMillis: matchDoc.createdat}) ELSE null END, isAccepted: false, matchedBy: matchRel.matchedBy, matchedAt: CASE WHEN matchRel.createdat IS NOT NULL THEN datetime({epochMillis: matchRel.createdat}) ELSE null END, docAttributes: [ (matchDoc)-[:DOCUMENT_TO_SOURCE]->(daSrc:DocumentSource)-[:HAS_ATTRIBUTE]->(da:DocAttribute) WHERE (daSrc)-[:DOCUMENT_SOURCE_TO_VERSION]->(:DocumentVersion {tildaid: matchDoc.primaryVersionId}) | {key: da.key, value: da.value, type: da.type, name: COALESCE(head([ (da)-[:HAS_ATTRIBUTE_DEFINITION]->(dad:DocAttributeDefinition) | dad.name ]), ?), description: COALESCE(head([ (da)-[:HAS_ATTRIBUTE_DEFINITION]->(dad:DocAttributeDefinition) | dad.description ]), ?)} ] } END) as pendingMatchesCollected WITH e, ph, d, es, tracksRel, acceptedDoc, acceptedRel, wo, [m IN matchesExpectedCollected WHERE m IS NOT NULL] as matchesExpected, [m IN pendingMatchesCollected WHERE m IS NOT NULL] as pendingMatches WITH e, ph, d, es, tracksRel, acceptedDoc, acceptedRel, wo, matchesExpected, pendingMatches, CASE WHEN ph.status <> ? THEN ? WHEN acceptedDoc IS NOT NULL THEN ? WHEN SIZE(matchesExpected) > ? AND SIZE(pendingMatches) = ? THEN ? WHEN SIZE(matchesExpected) > ? OR SIZE(pendingMatches) > ? THEN ? ELSE ? END as matchStatus OPTIONAL MATCH (ph)-[renewalRel:RENEWAL_OF]->(renewalSrcCandidate:Document) WHERE coalesce(renewalRel.primary, false) = true AND coalesce(renewalSrcCandidate.archived, false) = false WITH e, ph, d, es, tracksRel, acceptedDoc, acceptedRel, wo, matchesExpected, pendingMatches, matchStatus, head(collect(renewalSrcCandidate)) AS renewalSrc OPTIONAL MATCH (e)<-[:EVENTS]-(:EventPlan)-[:PLAN_CONTEXT]->(study) OPTIONAL MATCH (site:Site {tildaid: es.scopeId}) OPTIONAL MATCH (site)-[:PLAN_DEFINITION_TO_SITE]-(pd:DslPlanDefinition {type: ?})-[:PLAN_DEFINITION_TO_STUDY]->(study) WITH e, ph, d, es, tracksRel, acceptedDoc, acceptedRel, wo, matchesExpected, pendingMatches, matchStatus, renewalSrc, COALESCE(head(collect(site.name)), ?) AS siteName, COALESCE(head(collect(pd.siteNumber)), ?) AS siteNumber ORDER BY d.name ASC, ph.fileName ASC WITH collect({ placeholderId: ph.tildaid, placeholderName: ph.fileName, deliverableId: d.tildaid, deliverableName: d.name, eventScopeId: es.tildaid, scopeType: es.scopeType, country: CASE WHEN es.scopeType = ? THEN COALESCE(es.scopeId, ?) ELSE ? END, siteNumber: siteNumber, siteName: siteName, dueDate: es.dueDate, matchStatus: matchStatus, userDecision: COALESCE(tracksRel.state, ?), archived: coalesce(ph.archived, false) OR es.status = ?, origin: COALESCE(tracksRel.origin, ?), feedback: COALESCE(tracksRel.feedback, ?), reason: COALESCE(tracksRel.reason, ?), removalHasAcceptedDocument: COALESCE(tracksRel.removalHasAcceptedDocument, false), workOrder: CASE WHEN wo IS NOT NULL THEN {tildaid: wo.tildaid, work_order_id: wo.work_order_id, status: wo.status} ELSE null END, renewalSource: CASE WHEN renewalSrc IS NOT NULL THEN {documentId: renewalSrc.tildaid, documentName: renewalSrc.fileName} ELSE null END, acceptedMatch: CASE WHEN acceptedDoc IS NOT NULL THEN { documentId: acceptedDoc.tildaid, displayId: acceptedDoc.displayId, contentType: acceptedDoc.contentType, documentName: acceptedDoc.fileName, documentDate: CASE WHEN acceptedDoc.createdat IS NOT NULL THEN datetime({epochMillis: acceptedDoc.createdat}) ELSE null END, isAccepted: true, matchedBy: COALESCE(head([ (ph)-[amr:MATCHING_DOCUMENT]->(acceptedDoc) | amr.matchedBy ]), ?), matchedAt: head([ (ph)-[amr:MATCHING_DOCUMENT]->(acceptedDoc) | CASE WHEN amr.createdat IS NOT NULL THEN datetime({epochMillis: amr.createdat}) ELSE null END ]), acceptedBy: acceptedRel.acceptedBy, acceptedAt: CASE WHEN acceptedRel.createdat IS NOT NULL THEN datetime({epochMillis: acceptedRel.createdat}) ELSE null END, docAttributes: [ (acceptedDoc)-[:DOCUMENT_TO_SOURCE]->(daSrc:DocumentSource)-[:HAS_ATTRIBUTE]->(da:DocAttribute) WHERE (daSrc)-[:DOCUMENT_SOURCE_TO_VERSION]->(:DocumentVersion {tildaid: acceptedDoc.primaryVersionId}) | {key: da.key, value: da.value, type: da.type, name: COALESCE(head([ (da)-[:HAS_ATTRIBUTE_DEFINITION]->(dad:DocAttributeDefinition) | dad.name ]), ?), description: COALESCE(head([ (da)-[:HAS_ATTRIBUTE_DEFINITION]->(dad:DocAttributeDefinition) | dad.description ]), ?)} ] } ELSE null END, matchesExpected: matchesExpected, pendingMatches: pendingMatches }) as allRows WITH allRows, allRows as filteredRows WITH allRows, filteredRows, { total: size(allRows), pending: size([pp IN allRows WHERE pp.userDecision IN [?, ?]]), pendingForDelete: size([pp IN allRows WHERE pp.userDecision = ?]), accepted: size([pp IN allRows WHERE pp.userDecision = ?]), rejected: size([pp IN allRows WHERE pp.userDecision = ?]), incomplete: size([pp IN allRows WHERE pp.matchStatus = ?]), potentialMatchFound: size([pp IN allRows WHERE pp.matchStatus = ?]), matchExpected: size([pp IN allRows WHERE pp.matchStatus = ?]), matched: size([pp IN allRows WHERE pp.matchStatus = ?]), finalized: size([pp IN allRows WHERE pp.matchStatus = ?]), completion: {required: size([pp IN allRows WHERE NOT (pp.userDecision = ? OR coalesce(pp.archived, false)) AND (pp.userDecision IN [?, ?] OR pp.matchStatus = ?)]), completed: size([pp IN allRows WHERE NOT (pp.userDecision = ? OR coalesce(pp.archived, false)) AND (pp.userDecision IN [?, ?] OR pp.matchStatus = ?) AND pp.matchStatus IN [?, ?]]), aiSuggested: size([pp IN allRows WHERE NOT (pp.userDecision = ? OR coalesce(pp.archived, false)) AND (pp.userDecision IN [?, ?] OR pp.matchStatus = ?) AND pp.matchStatus = ?]), inStaging: size([pp IN allRows WHERE NOT (pp.userDecision = ? OR coalesce(pp.archived, false)) AND (pp.userDecision IN [?, ?] OR pp.matchStatus = ?) AND pp.matchStatus = ?]), noMatchFound: size([pp IN allRows WHERE NOT (pp.userDecision = ? OR coalesce(pp.archived, false)) AND (pp.userDecision IN [?, ?] OR pp.matchStatus = ?) AND pp.matchStatus = ?]), notConfirmed: size([pp IN allRows WHERE NOT (pp.userDecision = ? OR coalesce(pp.archived, false)) AND pp.userDecision = ? AND NOT pp.matchStatus = ?]), removed: size([pp IN allRows WHERE (pp.userDecision = ? OR coalesce(pp.archived, false))]), percentComplete: CASE WHEN size([pp IN allRows WHERE NOT (pp.userDecision = ? OR coalesce(pp.archived, false)) AND (pp.userDecision IN [?, ?] OR pp.matchStatus = ?)]) = ? THEN null ELSE toInteger(floor(?.? * size([pp IN allRows WHERE NOT (pp.userDecision = ? OR coalesce(pp.archived, false)) AND (pp.userDecision IN [?, ?] OR pp.matchStatus = ?) AND pp.matchStatus IN [?, ?]]) / size([pp IN allRows WHERE NOT (pp.userDecision = ? OR coalesce(pp.archived, false)) AND (pp.userDecision IN [?, ?] OR pp.matchStatus = ?)]))) END, isComplete: size([pp IN allRows WHERE NOT (pp.userDecision = ? OR coalesce(pp.archived, false)) AND (pp.userDecision IN [?, ?] OR pp.matchStatus = ?)]) > ? AND size([pp IN allRows WHERE NOT (pp.userDecision = ? OR coalesce(pp.archived, false)) AND (pp.userDecision IN [?, ?] OR pp.matchStatus = ?) AND pp.matchStatus IN [?, ?]]) = size([pp IN allRows WHERE NOT (pp.userDecision = ? OR coalesce(pp.archived, false)) AND (pp.userDecision IN [?, ?] OR pp.matchStatus = ?)])}, matchedWithNew: size([pp IN allRows WHERE pp.matchStatus = ? AND (size(pp.pendingMatches) > ? OR size(pp.matchesExpected) > ?)]) } as progress RETURN filteredRows[$pageSkip..$pageEnd] as placeholders, size(filteredRows) as total, progress
docsvc
1 1.06 s 1.95 s 1.06 s flat
MATCH (o:Organization {tildaid: $org_id})<-[:WORK_ORDER_CONFIG_TO_ORGANIZATION]-(b:WorkOrderConfig) WHERE b.delpending = false AND (b.study_id IN $lists.accessible_study_ids OR coalesce(b.study_id, ?) = ?) AND b.event_id = $event_id OPTION…
MATCH (o:Organization {tildaid: $org_id})<-[:WORK_ORDER_CONFIG_TO_ORGANIZATION]-(b:WorkOrderConfig) WHERE b.delpending = false AND (b.study_id IN $lists.accessible_study_ids OR coalesce(b.study_id, ?) = ?) AND b.event_id = $event_id OPTIONAL MATCH (b)-[:WORK_ORDER_CONFIG_TO_CHILD_WORK_ORDER]->(wc:WorkOrder) WHERE wc.delpending = false AND wc.status <> ? WITH b, count(wc) AS _nonarchived_count WHERE b.status <> ? OR _nonarchived_count > ? OPTIONAL MATCH (b)-[:WORK_ORDER_CONFIG_TO_STUDY]->(study:Study) OPTIONAL MATCH (b)-[:WORK_ORDER_CONFIG_TO_CREATOR]->(creator:User) OPTIONAL MATCH (b)-[:WORK_ORDER_CONFIG_TO_TEMPLATE]->(tmpl:WorkOrderTemplate) WITH b, study, creator, tmpl, b.createdat AS _sort_key ORDER BY (CASE WHEN _sort_key IS NULL THEN ? ELSE ? END) ASC, _sort_key DESC, b.tildaid DESC LIMIT $fetch_limit WITH b, study, creator, tmpl, _sort_key // Resolve WorkPlanInstance id/name for workplan-created configs (wp_object_id set). // Mirrors get_workplan_info_for_work_order_config: cfg.wp_object_id -> milestone item // (by tildaid or cfgMilestoneItemId) -> WorkPlanInstance. Non-workplan configs yield null. OPTIONAL MATCH (wpInstance:WorkPlanInstance)-[:WORKPLAN_INSTANCE_TO_MILESTONE]->(:WorkPlanMilestone) -[:REL_WORKPLAN_INSTANCE_MILESTONE_TO_ITEM]->(wpItem:WorkplanInstanceMilestoneItem) WHERE coalesce(b.wp_object_id, ?) <> ? AND (wpItem.tildaid = b.wp_object_id OR wpItem.cfgMilestoneItemId = b.wp_object_id) WITH b, study, creator, tmpl, _sort_key, head(collect(wpInstance.tildaid)) AS workplan_id, head(collect(wpInstance.name)) AS workplan_name OPTIONAL MATCH (b)-[:WORK_ORDER_CONFIG_TO_CHILD_WORK_ORDER]->(w:WorkOrder) WHERE w.delpending = false AND w.status <> ? OPTIONAL MATCH (w)-[:WORK_ORDER_TO_STUDY]->(wStudy:Study) OPTIONAL MATCH (w)-[:WORK_ORDER_TO_SITE]->(wSite:Site) OPTIONAL MATCH (w)-[:WORK_ORDER_TO_CREATOR]->(wCreator:User) OPTIONAL MATCH (w)-[:WORK_ORDER_TO_ASSIGNEE]->(wAssignee:User) // Resolve EventScope for Event-type child WOs (null for Standard-type) OPTIONAL MATCH (w)-[:WORK_ORDER_TO_EVENT_SCOPE]->(wES:EventScope) // Look up the Site node only for Site-scoped events; guards against null wES and non-Site scopes. // wES.scopeId is a site tildaid (UUID) for Site scopes, country name for Country, ? for Trial. OPTIONAL MATCH (wES_Site:Site {tildaid: wES.scopeId}) WHERE wES.scopeType = ? OPTIONAL MATCH (wPartner:Partner {tildaid: w.recipient_key}) OPTIONAL MATCH (:Actor {tildaid: w.recipient_key})-[:FOR_USER]->(wMember:User) OPTIONAL MATCH (w)-[:WORK_ORDER_TO_TASK]->(wTask:WorkOrderTask) WITH b, study, creator, tmpl, workplan_id, workplan_name, _sort_key, w, wStudy, wSite, wCreator, wAssignee, wES, wES_Site, wPartner, wMember, sum(CASE WHEN wTask.status = ? THEN ? ELSE ? END) AS w_pending_count, sum(CASE WHEN wTask.status = ? THEN ? ELSE ? END) AS w_resolved_count // ENG-?: order children in the DB so children_limit keeps the first N in // DISPLAY order. collect() below preserves incoming row order. // The PARENT keyset terms MUST lead. This ORDER BY runs in a WITH stage AFTER // the parent ORDER BY/LIMIT, and a later ORDER BY re-sorts the whole row stream // — ordering on the child value alone silently re-ranked the CONFIGS by their // child?s QUERY order, not display order: the backward // reversal happens later in Python. ORDER BY (CASE WHEN _sort_key IS NULL THEN ? ELSE ? END) ASC, _sort_key DESC, b.tildaid DESC, (w.createdat IS NULL), w.createdat DESC, w.tildaid WITH b, study, creator, tmpl, workplan_id, workplan_name, _sort_key, collect(DISTINCT CASE WHEN w IS NOT NULL THEN { tildaid: w.tildaid, work_order_id: w.work_order_id, title: w.title, work_order_type: w.work_order_type, status: w.status, priority: w.priority, creator_id: w.creator_id, assigned_to_id: w.assigned_to_id, site_id: w.site_id, study_id: w.study_id, document_ids: w.document_ids, contact_list: w.contact_list, cc_list: w.cc_list, goal: w.goal, due_date: w.due_date, last_reachout: w.last_reachout, last_response: w.last_response, resolved_at: w.resolved_at, need_attention_reason: w.need_attention_reason, accepted_count: w.accepted_count, pending_count: w_pending_count, resolved_count: w_resolved_count, // Mandatory documents this child WO still expects to accept. Pattern // comprehension (like site_number below) keeps the task→subtask // traversal out of the children collect()/count aggregation. Predicate // MUST stay in sync with WorkOrderRepository._count_expected_documents. expected_documents_count: size([(w)-[:WORK_ORDER_TO_TASK]->(t2:WorkOrderTask)-[:TASK_HAS_SUBTASK]->(s:WorkOrderSubtask) WHERE coalesce(t2.status, ?) <> ? AND coalesce(s.is_optional, false) = false AND coalesce(s.status, ?) <> ? AND (coalesce(s.expects_document, false) = true OR s.expects_document IS NULL OR s.placeholder_id IS NOT NULL OR s.sent_doc_id IS NOT NULL OR s.received_doc_id IS NOT NULL) | s]), createdat: w.createdat, updatedat: w.updatedat, thread_id: w.thread_id, rfc_msgid: w.rfc_msgid, parent_id: w.parent_id, // The child? ?Unknown User? ?Unknown User?site?Site?country?Country?trial?Trial?study?Trial???Organization??partner?Partner??studyteam?Study Team?Site?Site?Country?partner??Partner?studyTeam?? ???? ????Study Team?Non-site?s // `late_reply`: that field is projected only when include_late_reply AND a // child_status filter are both supplied, so reading it here reported False // for every unfiltered list (Codex review, ENG-?). collect(DISTINCT CASE WHEN w IS NOT NULL AND (w.status = ? AND w.last_response IS NOT NULL AND coalesce(w.resolved_at, w.status_updated_at) IS NOT NULL AND w.last_response > coalesce(w.resolved_at, w.status_updated_at) AND w.last_response > coalesce(w.late_reply_ack_at, ?)) THEN true ELSE null END) AS _late_flags // Aggregates are computed over the FULL matching child set, BEFORE the // children_limit slice, so a truncated page still renders a correct parent row // (ENG-?). Without these the client can only derive them from `children`, // which is exactly what stops it asking for fewer. WITH b, study, creator, tmpl, workplan_id, workplan_name, _sort_key, _late_flags, [child IN _children_raw WHERE child IS NOT NULL] AS _children WITH b, study, creator, tmpl, workplan_id, workplan_name, _sort_key, _children, size(_children) AS _child_total, reduce(acc = ?, c IN _children | acc + coalesce(c.pending_count, ?)) AS _agg_pending, reduce(acc = ?, c IN _children | acc + coalesce(c.resolved_count, ?)) AS _agg_resolved, size([f IN _late_flags WHERE f = true]) > ? AS _has_late_reply, (size(_children) > ? AND all(c IN _children WHERE c.status = ?)) AS _all_draft RETURN { tildaid: b.tildaid, work_order_config_id: COALESCE(b.work_order_config_id, substring(b.tildaid, ?, ?)), study_id: b.study_id, title: b.title, email_subject: b.email_subject, instructions: b.instructions, email: b.email, recipients: b.recipients, nonsite_recipients: b.nonsite_recipients, site_recipients: b.site_recipients, event_scope_recipients: b.event_scope_recipients, scope_recipients: b.scope_recipients, tasks: b.tasks, // ENG-?: without this, GET /work-order-configs returns plan_steps: [] // for every config and _raw_plan_steps() is dead code. plan_steps: b.plan_steps, plan_instructions: b.plan_instructions, status: b.status, work_order_config_type: b.work_order_config_type, entity_type: b.entity_type, event_id: b.event_id, progress: b.progress, child_count: b.child_count, sent_count: b.sent_count, pending_count: b.pending_count, child_creation_pending: coalesce(b.child_creation_pending, false), // ENG-?: the client recomputes child_creation_pending from these two // (isChildCreationPending), so an unprojected pair reads as ? // and kills the row spinner and the spawn poll. Both, or neither. activated_at: b.activated_at, children_created_at: b.children_created_at, creator_id: b.creator_id, org_id: b.org_id, document_ids: b.document_ids, context_document_ids: COALESCE(b.context_document_ids, []), reasoning: b.reasoning, reasoning_summary: b.reasoning_summary, warning: b.warning, error: b.error, createdat: b.createdat, updatedat: b.updatedat, studyName: CASE WHEN coalesce(b.study_id, ?) = ? THEN ? ELSE COALESCE(study.name, ?) END, creatorName: COALESCE(creator.firstName + ? + creator.lastName, creator.email, ?), // $children_limit < ? is the ? sentinel: a null upper bound makes // the whole slice null in Cypher, so the unlimited case takes the CASE branch. children: CASE WHEN $children_limit < ? THEN _children ELSE _children[?..$children_limit] END, // ENG-? additive aggregates. Always over the full matching child set. child_total: _child_total, children_pending_count: _agg_pending, children_resolved_count: _agg_resolved, has_late_reply: _has_late_reply, all_children_draft: _all_draft, template_id: tmpl.tildaid, template_title: tmpl.title, workplan_id: workplan_id, workplan_name: workplan_name } as work_order_config_with_children, _sort_key // Re-assert the parent order AFTER the child aggregation. The child ORDER BY // above leads with these same terms, but group emission order out of an // aggregation is not guaranteed by Cypher — and the Python loop trims the // lookahead by position, so a re-ordered stream drops the WRONG config and // builds cursors from the wrong boundary. Query order, not display order: // the backward reversal happens later in Python. ORDER BY (CASE WHEN _sort_key IS NULL THEN ? ELSE ? END) ASC, _sort_key DESC, b.tildaid DESC
write virtual-assistant
1 1.07 s 1.95 s 1.07 s flat
MATCH (u:User {tildaid:$user}) OPTIONAL MATCH (o:Organization {alias:$org}) UNWIND $lists.checks AS c CALL { WITH u, o, c // scope=OrganizationSMO policies=lead-edit MATCH (u)<-[:FOR_USER]-(a:Actor)-[:APPOINTED_AS]->(x:Role), (o)-[:ORGANIZ…
MATCH (u:User {tildaid:$user}) OPTIONAL MATCH (o:Organization {alias:$org}) UNWIND $lists.checks AS c CALL { WITH u, o, c // scope=OrganizationSMO policies=lead-edit MATCH (u)<-[:FOR_USER]-(a:Actor)-[:APPOINTED_AS]->(x:Role), (o)-[:ORGANIZATION_TO_ACTOR]->(a) WHERE a.state <> ? AND a.delpending = false AND x.name IN $lists.roles_0 WITH * WHERE o.orgType = ? RETURN DISTINCT c.idx AS checkIdx, u AS User, o AS Organization, null AS Study, null AS Site, null AS Patient UNION WITH u, o, c // scope=Study policies=study-patient-document-read MATCH (u)<-[:FOR_USER]-(a:Actor)-[:APPOINTED_AS]->(x:Role) WHERE a.state <> ? AND a.delpending = false AND o.tildaid = a.orgId AND x.name IN $lists.roles_1 WITH DISTINCT u, o, a, c MATCH (a)<-[:STUDY_TO_ACTOR]-(st:Study) WHERE EXISTS { (st)-[:STUDY_TO_ORG]->(o) } AND ( size(c.studyIds) = ? OR st.tildaid IN c.studyIds ) RETURN DISTINCT c.idx AS checkIdx, u AS User, o AS Organization, st AS Study, null AS Site, null AS Patient UNION WITH u, o, c // scope=Study policies=study-patient-document-read MATCH (u)<-[:FOR_USER]-(da:Actor)<-[:STUDY_TO_DELEGATED_ACTOR]-(st:Study)-[:STUDY_TO_ORG]->(o), (da)-[:APPOINTED_AS]->(x:Role)<-[:APPOINTED_AS]-(sa:Actor), (da)-[:DELEGATED_FROM]->(sa)<-[:ORGANIZATION_TO_ACTOR]-(:Organization {alias:$tildaScaleAlias}) WHERE st.srcorgid = o.tildaid AND da.state <> ? AND da.delpending = false AND sa.state <> ? AND sa.delpending = false AND x.name IN $lists.roles_2 AND ? IN apoc.text.split(coalesce(x.tags, ?), ?) AND ( size(c.studyIds) = ? OR st.tildaid IN c.studyIds ) RETURN DISTINCT c.idx AS checkIdx, u AS User, o AS Organization, st AS Study, null AS Site, null AS Patient } RETURN checkIdx, User, Organization, Study, Site, Patient
docsvc
1 1.66 s 1.95 s 1.66 s flat
MATCH (u:User {tildaid:$user}) OPTIONAL MATCH (o:Organization {alias:$org}) UNWIND $lists.checks AS c CALL (u, o, c) { // scope=Organization policies=org-work-order-edit,org-work-order-read MATCH (u)<-[:FOR_USER]-(a:Actor)-[:APPOINTED_AS]-…
MATCH (u:User {tildaid:$user}) OPTIONAL MATCH (o:Organization {alias:$org}) UNWIND $lists.checks AS c CALL (u, o, c) { // scope=Organization policies=org-work-order-edit,org-work-order-read MATCH (u)<-[:FOR_USER]-(a:Actor)-[:APPOINTED_AS]->(x:Role), (o)-[:ORGANIZATION_TO_ACTOR]->(a) WHERE a.state <> ? AND a.delpending = false AND x.name IN $lists.roles_0 RETURN DISTINCT c.idx AS checkIdx, u AS User, o AS Organization, null AS Study, null AS Site, null AS Patient UNION // scope=Organization policies=org-work-order-edit,org-work-order-read MATCH (u)<-[:FOR_USER]-(da:Actor)<-[:STUDY_TO_DELEGATED_ACTOR]-(st:Study)-[:STUDY_TO_ORG]->(o), (da)-[:APPOINTED_AS]->(x:Role)<-[:APPOINTED_AS]-(sa:Actor), (da)-[:DELEGATED_FROM]->(sa)<-[:ORGANIZATION_TO_ACTOR]-(:Organization {alias:?}) WHERE st.srcorgid = o.tildaid AND da.state <> ? AND da.delpending = false AND sa.state <> ? AND sa.delpending = false AND x.name IN $lists.roles_1 AND ? IN apoc.text.split(coalesce(x.tags, ?), ?) RETURN DISTINCT c.idx AS checkIdx, u AS User, o AS Organization, null AS Study, null AS Site, null AS Patient } RETURN checkIdx, User, Organization, Study, Site, Patient
virtual-assistant
1 1.21 s 1.95 s 1.21 s flat
MATCH (currentUser:User {deltimestamp:?}) WHERE (currentUser.isDummy IS NULL OR currentUser.isDummy <> true) AND currentUser.email = $ident OPTIONAL MATCH (supportUser:User {email:$supportEmail}) OPTIONAL MATCH (targetOrg:Organization {del…
MATCH (currentUser:User {deltimestamp:?}) WHERE (currentUser.isDummy IS NULL OR currentUser.isDummy <> true) AND currentUser.email = $ident OPTIONAL MATCH (supportUser:User {email:$supportEmail}) OPTIONAL MATCH (targetOrg:Organization {delpending:false, alias:$org}) OPTIONAL MATCH (currentUser)-[:FOR_USER]-(orgActor:Actor{delpending:false})-[:ORGANIZATION_TO_ACTOR]-(targetOrg) WHERE coalesce(orgActor.state, ?) <> ? OPTIONAL MATCH (currentUser)-[supports:SUPPORTS_ORG]-(targetOrg) WHERE EXISTS { MATCH (currentUser)<-[:FOR_USER]-(scaleActor:Actor{delpending:false})<-[:ORGANIZATION_TO_ACTOR]-(:Organization{alias:$tildaScaleAlias}), (scaleActor)-[:APPOINTED_AS]->(scaleRole:Role) WHERE coalesce(scaleActor.state, ?) <> ? AND scaleRole.name <> ? } WITH *, false AS repOf WITH *, CASE WHEN orgActor IS NULL THEN EXISTS { MATCH (currentUser)<-[:FOR_USER]-(da:Actor{delpending:false})<-[:STUDY_TO_DELEGATED_ACTOR]-(st:Study{delpending:false})-[:STUDY_TO_ORG]->(targetOrg), (da)-[:APPOINTED_AS]->(dr:Role)<-[:APPOINTED_AS]-(sa:Actor{delpending:false}), (da)-[:DELEGATED_FROM]->(sa)<-[:ORGANIZATION_TO_ACTOR]-(:Organization{alias:$tildaScaleAlias}) WHERE st.srcorgid = targetOrg.tildaid AND da.state <> ? AND sa.state <> ? AND $delegatedTag IN apoc.text.split(coalesce(dr.tags, ?), ?) } ELSE false END as delegated RETURN CASE WHEN orgActor is not null THEN currentUser WHEN delegated THEN currentUser WHEN repOf THEN currentUser WHEN supports is not null THEN coalesce(supportUser, currentUser) ELSE currentUser END as user, CASE WHEN orgActor is not null OR delegated OR repOf OR supports is not null THEN targetOrg ELSE null END as org, currentUser as tokenUser
ontologysvc
1 1.35 s 1.95 s 1.35 s flat
MATCH (o:Organization {tildaid: $org_id})<-[:WORK_ORDER_CONFIG_TO_ORGANIZATION]-(b:WorkOrderConfig) WHERE b.delpending = false AND b.study_id = $study_id AND b.study_id IN $lists.accessible_study_ids AND b.status <> ? OPTIONAL MATCH (b)-[:…
MATCH (o:Organization {tildaid: $org_id})<-[:WORK_ORDER_CONFIG_TO_ORGANIZATION]-(b:WorkOrderConfig) WHERE b.delpending = false AND b.study_id = $study_id AND b.study_id IN $lists.accessible_study_ids AND b.status <> ? OPTIONAL MATCH (b)-[:WORK_ORDER_CONFIG_TO_CHILD_WORK_ORDER]->(wc:WorkOrder) WHERE wc.delpending = false AND wc.status <> ? AND (wc.status IN $lists.child_statuses OR (wc.status = ? AND wc.last_response IS NOT NULL AND coalesce(wc.resolved_at, wc.status_updated_at) IS NOT NULL AND wc.last_response > coalesce(wc.resolved_at, wc.status_updated_at) AND wc.last_response > coalesce(wc.late_reply_ack_at, ?))) WITH b, count(wc) AS _match_count WHERE _match_count > ? OPTIONAL MATCH (b)-[:WORK_ORDER_CONFIG_TO_STUDY]->(study:Study) OPTIONAL MATCH (b)-[:WORK_ORDER_CONFIG_TO_CREATOR]->(creator:User) OPTIONAL MATCH (b)-[:WORK_ORDER_CONFIG_TO_TEMPLATE]->(tmpl:WorkOrderTemplate) WITH b, study, creator, tmpl, b.createdat AS _sort_key ORDER BY (CASE WHEN _sort_key IS NULL THEN ? ELSE ? END) ASC, _sort_key DESC, b.tildaid DESC LIMIT $fetch_limit WITH b, study, creator, tmpl, _sort_key // Resolve WorkPlanInstance id/name for workplan-created configs (wp_object_id set). // Mirrors get_workplan_info_for_work_order_config: cfg.wp_object_id -> milestone item // (by tildaid or cfgMilestoneItemId) -> WorkPlanInstance. Non-workplan configs yield null. OPTIONAL MATCH (wpInstance:WorkPlanInstance)-[:WORKPLAN_INSTANCE_TO_MILESTONE]->(:WorkPlanMilestone) -[:REL_WORKPLAN_INSTANCE_MILESTONE_TO_ITEM]->(wpItem:WorkplanInstanceMilestoneItem) WHERE coalesce(b.wp_object_id, ?) <> ? AND (wpItem.tildaid = b.wp_object_id OR wpItem.cfgMilestoneItemId = b.wp_object_id) WITH b, study, creator, tmpl, _sort_key, head(collect(wpInstance.tildaid)) AS workplan_id, head(collect(wpInstance.name)) AS workplan_name OPTIONAL MATCH (b)-[:WORK_ORDER_CONFIG_TO_CHILD_WORK_ORDER]->(w:WorkOrder) WHERE w.delpending = false AND w.status <> ? AND (w.status IN $lists.child_statuses OR (w.status = ? AND w.last_response IS NOT NULL AND coalesce(w.resolved_at, w.status_updated_at) IS NOT NULL AND w.last_response > coalesce(w.resolved_at, w.status_updated_at) AND w.last_response > coalesce(w.late_reply_ack_at, ?))) OPTIONAL MATCH (w)-[:WORK_ORDER_TO_STUDY]->(wStudy:Study) OPTIONAL MATCH (w)-[:WORK_ORDER_TO_SITE]->(wSite:Site) OPTIONAL MATCH (w)-[:WORK_ORDER_TO_CREATOR]->(wCreator:User) OPTIONAL MATCH (w)-[:WORK_ORDER_TO_ASSIGNEE]->(wAssignee:User) // Resolve EventScope for Event-type child WOs (null for Standard-type) OPTIONAL MATCH (w)-[:WORK_ORDER_TO_EVENT_SCOPE]->(wES:EventScope) // Look up the Site node only for Site-scoped events; guards against null wES and non-Site scopes. // wES.scopeId is a site tildaid (UUID) for Site scopes, country name for Country, ? for Trial. OPTIONAL MATCH (wES_Site:Site {tildaid: wES.scopeId}) WHERE wES.scopeType = ? OPTIONAL MATCH (wPartner:Partner {tildaid: w.recipient_key}) OPTIONAL MATCH (:Actor {tildaid: w.recipient_key})-[:FOR_USER]->(wMember:User) OPTIONAL MATCH (w)-[:WORK_ORDER_TO_TASK]->(wTask:WorkOrderTask) WITH b, study, creator, tmpl, workplan_id, workplan_name, _sort_key, w, wStudy, wSite, wCreator, wAssignee, wES, wES_Site, wPartner, wMember, sum(CASE WHEN wTask.status = ? THEN ? ELSE ? END) AS w_pending_count, sum(CASE WHEN wTask.status = ? THEN ? ELSE ? END) AS w_resolved_count // ENG-?: order children in the DB so children_limit keeps the first N in // DISPLAY order. collect() below preserves incoming row order. // The PARENT keyset terms MUST lead. This ORDER BY runs in a WITH stage AFTER // the parent ORDER BY/LIMIT, and a later ORDER BY re-sorts the whole row stream // — ordering on the child value alone silently re-ranked the CONFIGS by their // child?s QUERY order, not display order: the backward // reversal happens later in Python. ORDER BY (CASE WHEN _sort_key IS NULL THEN ? ELSE ? END) ASC, _sort_key DESC, b.tildaid DESC, (w.createdat IS NULL), w.createdat DESC, w.tildaid WITH b, study, creator, tmpl, workplan_id, workplan_name, _sort_key, collect(DISTINCT CASE WHEN w IS NOT NULL THEN { tildaid: w.tildaid, work_order_id: w.work_order_id, title: w.title, work_order_type: w.work_order_type, status: w.status, priority: w.priority, creator_id: w.creator_id, assigned_to_id: w.assigned_to_id, site_id: w.site_id, study_id: w.study_id, document_ids: w.document_ids, contact_list: w.contact_list, cc_list: w.cc_list, goal: w.goal, due_date: w.due_date, last_reachout: w.last_reachout, last_response: w.last_response, resolved_at: w.resolved_at, need_attention_reason: w.need_attention_reason, late_reply: (w.status = ? AND w.last_response IS NOT NULL AND coalesce(w.resolved_at, w.status_updated_at) IS NOT NULL AND w.last_response > coalesce(w.resolved_at, w.status_updated_at) AND w.last_response > coalesce(w.late_reply_ack_at, ?)), accepted_count: w.accepted_count, pending_count: w_pending_count, resolved_count: w_resolved_count, // Mandatory documents this child WO still expects to accept. Pattern // comprehension (like site_number below) keeps the task→subtask // traversal out of the children collect()/count aggregation. Predicate // MUST stay in sync with WorkOrderRepository._count_expected_documents. expected_documents_count: size([(w)-[:WORK_ORDER_TO_TASK]->(t2:WorkOrderTask)-[:TASK_HAS_SUBTASK]->(s:WorkOrderSubtask) WHERE coalesce(t2.status, ?) <> ? AND coalesce(s.is_optional, false) = false AND coalesce(s.status, ?) <> ? AND (coalesce(s.expects_document, false) = true OR s.expects_document IS NULL OR s.placeholder_id IS NOT NULL OR s.sent_doc_id IS NOT NULL OR s.received_doc_id IS NOT NULL) | s]), createdat: w.createdat, updatedat: w.updatedat, thread_id: w.thread_id, rfc_msgid: w.rfc_msgid, parent_id: w.parent_id, // The child? ?Unknown User? ?Unknown User?site?Site?country?Country?trial?Trial?study?Trial???Organization??partner?Partner??studyteam?Study Team?Site?Site?Country?partner??Partner?studyTeam?? ???? ????Study Team?Non-site?s // `late_reply`: that field is projected only when include_late_reply AND a // child_status filter are both supplied, so reading it here reported False // for every unfiltered list (Codex review, ENG-?). collect(DISTINCT CASE WHEN w IS NOT NULL AND (w.status = ? AND w.last_response IS NOT NULL AND coalesce(w.resolved_at, w.status_updated_at) IS NOT NULL AND w.last_response > coalesce(w.resolved_at, w.status_updated_at) AND w.last_response > coalesce(w.late_reply_ack_at, ?)) THEN true ELSE null END) AS _late_flags // Aggregates are computed over the FULL matching child set, BEFORE the // children_limit slice, so a truncated page still renders a correct parent row // (ENG-?). Without these the client can only derive them from `children`, // which is exactly what stops it asking for fewer. WITH b, study, creator, tmpl, workplan_id, workplan_name, _sort_key, _late_flags, [child IN _children_raw WHERE child IS NOT NULL] AS _children WITH b, study, creator, tmpl, workplan_id, workplan_name, _sort_key, _children, size(_children) AS _child_total, reduce(acc = ?, c IN _children | acc + coalesce(c.pending_count, ?)) AS _agg_pending, reduce(acc = ?, c IN _children | acc + coalesce(c.resolved_count, ?)) AS _agg_resolved, size([f IN _late_flags WHERE f = true]) > ? AS _has_late_reply, (size(_children) > ? AND all(c IN _children WHERE c.status = ?)) AS _all_draft RETURN { tildaid: b.tildaid, work_order_config_id: COALESCE(b.work_order_config_id, substring(b.tildaid, ?, ?)), study_id: b.study_id, title: b.title, email_subject: b.email_subject, instructions: b.instructions, email: b.email, recipients: b.recipients, nonsite_recipients: b.nonsite_recipients, site_recipients: b.site_recipients, event_scope_recipients: b.event_scope_recipients, scope_recipients: b.scope_recipients, tasks: b.tasks, // ENG-?: without this, GET /work-order-configs returns plan_steps: [] // for every config and _raw_plan_steps() is dead code. plan_steps: b.plan_steps, plan_instructions: b.plan_instructions, status: b.status, work_order_config_type: b.work_order_config_type, entity_type: b.entity_type, event_id: b.event_id, progress: b.progress, child_count: b.child_count, sent_count: b.sent_count, pending_count: b.pending_count, child_creation_pending: coalesce(b.child_creation_pending, false), // ENG-?: the client recomputes child_creation_pending from these two // (isChildCreationPending), so an unprojected pair reads as ? // and kills the row spinner and the spawn poll. Both, or neither. activated_at: b.activated_at, children_created_at: b.children_created_at, creator_id: b.creator_id, org_id: b.org_id, document_ids: b.document_ids, context_document_ids: COALESCE(b.context_document_ids, []), reasoning: b.reasoning, reasoning_summary: b.reasoning_summary, warning: b.warning, error: b.error, createdat: b.createdat, updatedat: b.updatedat, studyName: CASE WHEN coalesce(b.study_id, ?) = ? THEN ? ELSE COALESCE(study.name, ?) END, creatorName: COALESCE(creator.firstName + ? + creator.lastName, creator.email, ?), // $children_limit < ? is the ? sentinel: a null upper bound makes // the whole slice null in Cypher, so the unlimited case takes the CASE branch. children: CASE WHEN $children_limit < ? THEN _children ELSE _children[?..$children_limit] END, // ENG-? additive aggregates. Always over the full matching child set. child_total: _child_total, children_pending_count: _agg_pending, children_resolved_count: _agg_resolved, has_late_reply: _has_late_reply, all_children_draft: _all_draft, template_id: tmpl.tildaid, template_title: tmpl.title, workplan_id: workplan_id, workplan_name: workplan_name } as work_order_config_with_children, _sort_key // Re-assert the parent order AFTER the child aggregation. The child ORDER BY // above leads with these same terms, but group emission order out of an // aggregation is not guaranteed by Cypher — and the Python loop trims the // lookahead by position, so a re-ordered stream drops the WRONG config and // builds cursors from the wrong boundary. Query order, not display order: // the backward reversal happens later in Python. ORDER BY (CASE WHEN _sort_key IS NULL THEN ? ELSE ? END) ASC, _sort_key DESC, b.tildaid DESC
write virtual-assistant
1 1.19 s 1.95 s 1.19 s flat
MATCH (o:Organization {tildaid: $org_id})<-[:WORK_ORDER_CONFIG_TO_ORGANIZATION]-(b:WorkOrderConfig) WHERE b.delpending = false AND (b.study_id IN $lists.accessible_study_ids OR coalesce(b.study_id, ?) = ?) AND b.status <> ? OPTIONAL MATCH …
MATCH (o:Organization {tildaid: $org_id})<-[:WORK_ORDER_CONFIG_TO_ORGANIZATION]-(b:WorkOrderConfig) WHERE b.delpending = false AND (b.study_id IN $lists.accessible_study_ids OR coalesce(b.study_id, ?) = ?) AND b.status <> ? OPTIONAL MATCH (b)-[:WORK_ORDER_CONFIG_TO_CHILD_WORK_ORDER]->(wc:WorkOrder) WHERE wc.delpending = false AND wc.status <> ? AND wc.status IN $lists.child_statuses WITH b, count(wc) AS _match_count WHERE _match_count > ? OPTIONAL MATCH (b)-[:WORK_ORDER_CONFIG_TO_STUDY]->(study:Study) OPTIONAL MATCH (b)-[:WORK_ORDER_CONFIG_TO_CREATOR]->(creator:User) OPTIONAL MATCH (b)-[:WORK_ORDER_CONFIG_TO_TEMPLATE]->(tmpl:WorkOrderTemplate) WITH b, study, creator, tmpl, b.createdat AS _sort_key ORDER BY (CASE WHEN _sort_key IS NULL THEN ? ELSE ? END) ASC, _sort_key DESC, b.tildaid DESC LIMIT $fetch_limit WITH b, study, creator, tmpl, _sort_key // Resolve WorkPlanInstance id/name for workplan-created configs (wp_object_id set). // Mirrors get_workplan_info_for_work_order_config: cfg.wp_object_id -> milestone item // (by tildaid or cfgMilestoneItemId) -> WorkPlanInstance. Non-workplan configs yield null. OPTIONAL MATCH (wpInstance:WorkPlanInstance)-[:WORKPLAN_INSTANCE_TO_MILESTONE]->(:WorkPlanMilestone) -[:REL_WORKPLAN_INSTANCE_MILESTONE_TO_ITEM]->(wpItem:WorkplanInstanceMilestoneItem) WHERE coalesce(b.wp_object_id, ?) <> ? AND (wpItem.tildaid = b.wp_object_id OR wpItem.cfgMilestoneItemId = b.wp_object_id) WITH b, study, creator, tmpl, _sort_key, head(collect(wpInstance.tildaid)) AS workplan_id, head(collect(wpInstance.name)) AS workplan_name OPTIONAL MATCH (b)-[:WORK_ORDER_CONFIG_TO_CHILD_WORK_ORDER]->(w:WorkOrder) WHERE w.delpending = false AND w.status <> ? AND w.status IN $lists.child_statuses OPTIONAL MATCH (w)-[:WORK_ORDER_TO_STUDY]->(wStudy:Study) OPTIONAL MATCH (w)-[:WORK_ORDER_TO_SITE]->(wSite:Site) OPTIONAL MATCH (w)-[:WORK_ORDER_TO_CREATOR]->(wCreator:User) OPTIONAL MATCH (w)-[:WORK_ORDER_TO_ASSIGNEE]->(wAssignee:User) // Resolve EventScope for Event-type child WOs (null for Standard-type) OPTIONAL MATCH (w)-[:WORK_ORDER_TO_EVENT_SCOPE]->(wES:EventScope) // Look up the Site node only for Site-scoped events; guards against null wES and non-Site scopes. // wES.scopeId is a site tildaid (UUID) for Site scopes, country name for Country, ? for Trial. OPTIONAL MATCH (wES_Site:Site {tildaid: wES.scopeId}) WHERE wES.scopeType = ? OPTIONAL MATCH (wPartner:Partner {tildaid: w.recipient_key}) OPTIONAL MATCH (:Actor {tildaid: w.recipient_key})-[:FOR_USER]->(wMember:User) OPTIONAL MATCH (w)-[:WORK_ORDER_TO_TASK]->(wTask:WorkOrderTask) WITH b, study, creator, tmpl, workplan_id, workplan_name, _sort_key, w, wStudy, wSite, wCreator, wAssignee, wES, wES_Site, wPartner, wMember, sum(CASE WHEN wTask.status = ? THEN ? ELSE ? END) AS w_pending_count, sum(CASE WHEN wTask.status = ? THEN ? ELSE ? END) AS w_resolved_count // ENG-?: order children in the DB so children_limit keeps the first N in // DISPLAY order. collect() below preserves incoming row order. // The PARENT keyset terms MUST lead. This ORDER BY runs in a WITH stage AFTER // the parent ORDER BY/LIMIT, and a later ORDER BY re-sorts the whole row stream // — ordering on the child value alone silently re-ranked the CONFIGS by their // child?s QUERY order, not display order: the backward // reversal happens later in Python. ORDER BY (CASE WHEN _sort_key IS NULL THEN ? ELSE ? END) ASC, _sort_key DESC, b.tildaid DESC, (w.createdat IS NULL), w.createdat DESC, w.tildaid WITH b, study, creator, tmpl, workplan_id, workplan_name, _sort_key, collect(DISTINCT CASE WHEN w IS NOT NULL THEN { tildaid: w.tildaid, work_order_id: w.work_order_id, title: w.title, work_order_type: w.work_order_type, status: w.status, priority: w.priority, creator_id: w.creator_id, assigned_to_id: w.assigned_to_id, site_id: w.site_id, study_id: w.study_id, document_ids: w.document_ids, contact_list: w.contact_list, cc_list: w.cc_list, goal: w.goal, due_date: w.due_date, last_reachout: w.last_reachout, last_response: w.last_response, resolved_at: w.resolved_at, need_attention_reason: w.need_attention_reason, accepted_count: w.accepted_count, pending_count: w_pending_count, resolved_count: w_resolved_count, // Mandatory documents this child WO still expects to accept. Pattern // comprehension (like site_number below) keeps the task→subtask // traversal out of the children collect()/count aggregation. Predicate // MUST stay in sync with WorkOrderRepository._count_expected_documents. expected_documents_count: size([(w)-[:WORK_ORDER_TO_TASK]->(t2:WorkOrderTask)-[:TASK_HAS_SUBTASK]->(s:WorkOrderSubtask) WHERE coalesce(t2.status, ?) <> ? AND coalesce(s.is_optional, false) = false AND coalesce(s.status, ?) <> ? AND (coalesce(s.expects_document, false) = true OR s.expects_document IS NULL OR s.placeholder_id IS NOT NULL OR s.sent_doc_id IS NOT NULL OR s.received_doc_id IS NOT NULL) | s]), createdat: w.createdat, updatedat: w.updatedat, thread_id: w.thread_id, rfc_msgid: w.rfc_msgid, parent_id: w.parent_id, // The child? ?Unknown User? ?Unknown User?site?Site?country?Country?trial?Trial?study?Trial???Organization??partner?Partner??studyteam?Study Team?Site?Site?Country?partner??Partner?studyTeam?? ???? ????Study Team?Non-site?s // `late_reply`: that field is projected only when include_late_reply AND a // child_status filter are both supplied, so reading it here reported False // for every unfiltered list (Codex review, ENG-?). collect(DISTINCT CASE WHEN w IS NOT NULL AND (w.status = ? AND w.last_response IS NOT NULL AND coalesce(w.resolved_at, w.status_updated_at) IS NOT NULL AND w.last_response > coalesce(w.resolved_at, w.status_updated_at) AND w.last_response > coalesce(w.late_reply_ack_at, ?)) THEN true ELSE null END) AS _late_flags // Aggregates are computed over the FULL matching child set, BEFORE the // children_limit slice, so a truncated page still renders a correct parent row // (ENG-?). Without these the client can only derive them from `children`, // which is exactly what stops it asking for fewer. WITH b, study, creator, tmpl, workplan_id, workplan_name, _sort_key, _late_flags, [child IN _children_raw WHERE child IS NOT NULL] AS _children WITH b, study, creator, tmpl, workplan_id, workplan_name, _sort_key, _children, size(_children) AS _child_total, reduce(acc = ?, c IN _children | acc + coalesce(c.pending_count, ?)) AS _agg_pending, reduce(acc = ?, c IN _children | acc + coalesce(c.resolved_count, ?)) AS _agg_resolved, size([f IN _late_flags WHERE f = true]) > ? AS _has_late_reply, (size(_children) > ? AND all(c IN _children WHERE c.status = ?)) AS _all_draft RETURN { tildaid: b.tildaid, work_order_config_id: COALESCE(b.work_order_config_id, substring(b.tildaid, ?, ?)), study_id: b.study_id, title: b.title, email_subject: b.email_subject, instructions: b.instructions, email: b.email, recipients: b.recipients, nonsite_recipients: b.nonsite_recipients, site_recipients: b.site_recipients, event_scope_recipients: b.event_scope_recipients, scope_recipients: b.scope_recipients, tasks: b.tasks, // ENG-?: without this, GET /work-order-configs returns plan_steps: [] // for every config and _raw_plan_steps() is dead code. plan_steps: b.plan_steps, plan_instructions: b.plan_instructions, status: b.status, work_order_config_type: b.work_order_config_type, entity_type: b.entity_type, event_id: b.event_id, progress: b.progress, child_count: b.child_count, sent_count: b.sent_count, pending_count: b.pending_count, child_creation_pending: coalesce(b.child_creation_pending, false), // ENG-?: the client recomputes child_creation_pending from these two // (isChildCreationPending), so an unprojected pair reads as ? // and kills the row spinner and the spawn poll. Both, or neither. activated_at: b.activated_at, children_created_at: b.children_created_at, creator_id: b.creator_id, org_id: b.org_id, document_ids: b.document_ids, context_document_ids: COALESCE(b.context_document_ids, []), reasoning: b.reasoning, reasoning_summary: b.reasoning_summary, warning: b.warning, error: b.error, createdat: b.createdat, updatedat: b.updatedat, studyName: CASE WHEN coalesce(b.study_id, ?) = ? THEN ? ELSE COALESCE(study.name, ?) END, creatorName: COALESCE(creator.firstName + ? + creator.lastName, creator.email, ?), // $children_limit < ? is the ? sentinel: a null upper bound makes // the whole slice null in Cypher, so the unlimited case takes the CASE branch. children: CASE WHEN $children_limit < ? THEN _children ELSE _children[?..$children_limit] END, // ENG-? additive aggregates. Always over the full matching child set. child_total: _child_total, children_pending_count: _agg_pending, children_resolved_count: _agg_resolved, has_late_reply: _has_late_reply, all_children_draft: _all_draft, template_id: tmpl.tildaid, template_title: tmpl.title, workplan_id: workplan_id, workplan_name: workplan_name } as work_order_config_with_children, _sort_key // Re-assert the parent order AFTER the child aggregation. The child ORDER BY // above leads with these same terms, but group emission order out of an // aggregation is not guaranteed by Cypher — and the Python loop trims the // lookahead by position, so a re-ordered stream drops the WRONG config and // builds cursors from the wrong boundary. Query order, not display order: // the backward reversal happens later in Python. ORDER BY (CASE WHEN _sort_key IS NULL THEN ? ELSE ? END) ASC, _sort_key DESC, b.tildaid DESC
write virtual-assistant
1 1.02 s 1.95 s 1.02 s flat
MATCH (u:User {tildaid:$user}) OPTIONAL MATCH (o:Organization {alias:$org}) UNWIND $lists.checks AS c CALL { WITH u, o, c // scope=Organization policies=org-edit,org-read MATCH (u)<-[:FOR_USER]-(a:Actor)-[:APPOINTED_AS]->(x:Role), (o)-[:OR…
MATCH (u:User {tildaid:$user}) OPTIONAL MATCH (o:Organization {alias:$org}) UNWIND $lists.checks AS c CALL { WITH u, o, c // scope=Organization policies=org-edit,org-read MATCH (u)<-[:FOR_USER]-(a:Actor)-[:APPOINTED_AS]->(x:Role), (o)-[:ORGANIZATION_TO_ACTOR]->(a) WHERE a.state <> ? AND a.delpending = false AND x.name IN $lists.roles_0 WITH * WHERE o.tildaid = c.id RETURN DISTINCT c.idx AS checkIdx, u AS User, o AS Organization, null AS Study, null AS Site, null AS Patient UNION WITH u, o, c // scope=Organization policies=org-edit,org-read MATCH (u)<-[:FOR_USER]-(da:Actor)<-[:STUDY_TO_DELEGATED_ACTOR]-(st:Study)-[:STUDY_TO_ORG]->(o), (da)-[:APPOINTED_AS]->(x:Role)<-[:APPOINTED_AS]-(sa:Actor), (da)-[:DELEGATED_FROM]->(sa)<-[:ORGANIZATION_TO_ACTOR]-(:Organization {alias:$tildaScaleAlias}) WHERE st.srcorgid = o.tildaid AND da.state <> ? AND da.delpending = false AND sa.state <> ? AND sa.delpending = false AND x.name IN $lists.roles_1 AND ? IN apoc.text.split(coalesce(x.tags, ?), ?) WITH * WHERE o.tildaid = c.id RETURN DISTINCT c.idx AS checkIdx, u AS User, o AS Organization, null AS Study, null AS Site, null AS Patient } RETURN checkIdx, User, Organization, Study, Site, Patient
execsvc
1 1.06 s 1.95 s 1.06 s flat
MATCH (pv:ParticipantVisit) WHERE (pv.edcStatus IS NULL OR pv.edcStatus = ? OR pv.edcStatus = ? OR pv.edcStatus = ?) AND (pv.status = ? OR pv.status = ?) AND pv.deltimestamp = ? MATCH (cp:CarePlan {tildaid: pv.carePlanId})-[:EXECUTE_SOA]- …
MATCH (pv:ParticipantVisit) WHERE (pv.edcStatus IS NULL OR pv.edcStatus = ? OR pv.edcStatus = ? OR pv.edcStatus = ?) AND (pv.status = ? OR pv.status = ?) AND pv.deltimestamp = ? MATCH (cp:CarePlan {tildaid: pv.carePlanId})-[:EXECUTE_SOA]- (soa:ScheduleOfActivities)-[:SOA_TO_PLAN_DEFINITION]- (pd:DslPlanDefinition) MATCH (pd)-[:PLAN_DEFINITION_TO_STUDY]-(st:Study) MATCH (pd)-[:PLAN_DEFINITION_TO_SITE]-(site:Site)-[:SITE_TO_SMO]- (smo)-[:IS_AN_ORG]-(org:Organization) OPTIONAL MATCH (visit:VisitV2)-[:BELONGS_TO_VISIT]-(pv) WITH pv, cp, st, site, org, visit OPTIONAL MATCH (pv)-[:PARTICIPANT_ACTIVITY]->(emptyPa:ParticipantActivity) WHERE (emptyPa.edcStatus IS NULL OR emptyPa.edcStatus = ?) AND emptyPa.deltimestamp = ? WITH pv, cp, st, site, org, visit, collect(emptyPa) AS emptyPas OPTIONAL MATCH (pv)-[:PARTICIPANT_ACTIVITY]->(pa:ParticipantActivity)-[:BELONGS_TO_ACTIVITY]->(act:ActivityV2) WHERE pa.deltimestamp = ? RETURN pv, cp, st, site, org, visit, emptyPas, collect({pa: pa, activity: act}) AS paActPairs LIMIT ?
execsvc
1 1.24 s 1.95 s 1.24 s flat
MATCH (u:User{tildaid:$userId}), (o:Organization{delpending:false, alias:$orgAlias}) call { with u, o // An Inactive actor holds no roles (ENG-?): its roles would otherwise // still feed hidePhi, the role list and every policy match. OPTIO…
MATCH (u:User{tildaid:$userId}), (o:Organization{delpending:false, alias:$orgAlias}) call { with u, o // An Inactive actor holds no roles (ENG-?): its roles would otherwise // still feed hidePhi, the role list and every policy match. OPTIONAL MATCH (u)<-[:FOR_USER]-(a:Actor{delpending:false})<-[:ORGANIZATION_TO_ACTOR]-(o), (a)-[:APPOINTED_AS]->(r:Role) WHERE not r.name = ? AND coalesce(a.state, ?) <> ? return r{.*} UNION with u, o // Delegated engagements in o. Only the delegated roles cross over — // the TildaScale Actor?s list. MATCH (u)<-[:FOR_USER]-(da:Actor{delpending:false})<-[:STUDY_TO_DELEGATED_ACTOR]-(st:Study{delpending:false})-[:STUDY_TO_ORG]->(o), (da)-[:APPOINTED_AS]->(r:Role)<-[:APPOINTED_AS]-(sa:Actor{delpending:false}), (da)-[:DELEGATED_FROM]->(sa)<-[:ORGANIZATION_TO_ACTOR]-(:Organization{alias:$tildaScaleAlias}) WHERE st.srcorgid = o.tildaid AND da.state <> ? AND sa.state <> ? AND $orgDelegatedTag IN apoc.text.split(coalesce(r.tags, ?), ?) return distinct r{.*} } WITH u, o, collect(distinct r.name) as roles, collect(distinct case when r.listed = true then r.displayName end) as displayRoles, ANY(n IN COLLECT(r.external) WHERE n = true) as external, ANY(n IN COLLECT(r.name) WHERE n = ?) as isPatient, ALL(n IN COLLECT(r.piiAccess) WHERE n = false) as hidePhi WITH u, o, {organization:o{.*}, external: external, isPatient: isPatient, hidePhi: hidePhi, roles: roles, displayRoles: displayRoles } as context CALL {WITH u, o MATCH (u)<-[:FOR_USER]-(a:Actor{delpending:false})<-[:STAFF_TO_ACTOR]-(si:Site{delpending:false})-[:SITE_TO_SMO]->(:Smo)-[:IS_AN_ORG]->(o) WHERE coalesce(a.state, ?) <> ? OPTIONAL MATCH (a)-[:APPOINTED_AS]->(r:Role) WITH u, o, si, a, r order by r.displayName WITH u, o, si, a, collect(distinct r.name) as roles, collect(distinct case when r.listed = true then r.displayName end) as displayRoles WITH CASE when not si is null then {siteId: si.tildaid, roles: roles, displayRoles: displayRoles} end as si return collect(si) as sites, apoc.coll.flatten(collect(si.roles)) as siteRoles } CALL {WITH u, o // WITH DISTINCT is a required pipeline barrier (see the studyMembership note // in scope.go): without it (u)<-[:FOR_USER]-(a) re-expands once per study in // the org — ?.0M -> 32k db hits. Splitting the MATCH without DISTINCT does // nothing; the barrier is what forbids the bad join order. Not applied to the // sites or org-roles subqueries, where it measured neutral or worse. // No longer OPTIONAL: the subquery ends in an ungrouped aggregation, so zero // matches still yield one row with empty collections. CALL {WITH u, o MATCH (u)<-[:FOR_USER]-(a:Actor{delpending:false, orgId:o.tildaid}) WHERE coalesce(a.state, ?) <> ? WITH DISTINCT u, o, a MATCH (a)<-[:STUDY_TO_ACTOR]-(s:Study{delpending:false})-[:STUDY_TO_ORG]->(o) OPTIONAL MATCH (a)-[:APPOINTED_AS]->(r:Role) RETURN s, a, r UNION // Delegated engagement Actors: orgId is TildaScale? roles. WITH s, r order by r.displayName WITH s, collect(distinct r.name) as roles, collect(distinct case when r.listed = true then r.displayName end) as displayRoles // Ordered so the studies array is a stable sequence for clients; the pipeline // that replaced the old (u,o,s,a) grouping otherwise leaves it plan-dependent. WITH s, CASE when not s is null then {studyId: s.tildaid, roles: roles, displayRoles: displayRoles, srcOrgId: s.srcorgid} end as st ORDER BY s.name, s.tildaid return collect(st) as studies, apoc.coll.flatten(collect(st.roles)) as studyRoles } with distinct context, studies, apoc.coll.toSet(apoc.coll.flatten(collect(studyRoles))) as allStudyRoles, apoc.coll.toSet(apoc.coll.flatten(collect(siteRoles))) as siRoles with context, studies, apoc.coll.toSet(apoc.coll.flatten([context.roles, allStudyRoles, siRoles])) as allRoles return context{.*, studies: studies, allRoles: allRoles}
schedsvc
1 1.75 s 1.95 s 1.75 s flat
MATCH (u:User {tildaid:$user}) OPTIONAL MATCH (o:Organization {alias:$org}) UNWIND $lists.checks AS c CALL { WITH u, o, c // scope=Study policies=study-config-edit MATCH (u)<-[:FOR_USER]-(a:Actor)-[:APPOINTED_AS]->(x:Role) WHERE a.state <>…
MATCH (u:User {tildaid:$user}) OPTIONAL MATCH (o:Organization {alias:$org}) UNWIND $lists.checks AS c CALL { WITH u, o, c // scope=Study policies=study-config-edit MATCH (u)<-[:FOR_USER]-(a:Actor)-[:APPOINTED_AS]->(x:Role) WHERE a.state <> ? AND a.delpending = false AND o.tildaid = a.orgId AND x.name IN $lists.roles_0 WITH DISTINCT u, o, a, c MATCH (a)<-[:STUDY_TO_ACTOR]-(st:Study) WHERE EXISTS { (st)-[:STUDY_TO_ORG]->(o) } AND ( size(c.studyIds) = ? OR st.tildaid IN c.studyIds ) RETURN DISTINCT c.idx AS checkIdx, u AS User, o AS Organization, st AS Study, null AS Site, null AS Patient UNION WITH u, o, c // scope=Study policies=study-config-edit MATCH (u)<-[:FOR_USER]-(da:Actor)<-[:STUDY_TO_DELEGATED_ACTOR]-(st:Study)-[:STUDY_TO_ORG]->(o), (da)-[:APPOINTED_AS]->(x:Role)<-[:APPOINTED_AS]-(sa:Actor), (da)-[:DELEGATED_FROM]->(sa)<-[:ORGANIZATION_TO_ACTOR]-(:Organization {alias:$tildaScaleAlias}) WHERE st.srcorgid = o.tildaid AND da.state <> ? AND da.delpending = false AND sa.state <> ? AND sa.delpending = false AND x.name IN $lists.roles_1 AND ? IN apoc.text.split(coalesce(x.tags, ?), ?) AND ( size(c.studyIds) = ? OR st.tildaid IN c.studyIds ) RETURN DISTINCT c.idx AS checkIdx, u AS User, o AS Organization, st AS Study, null AS Site, null AS Patient UNION WITH u, o, c // scope=Organization policies=org-study-read MATCH (u)<-[:FOR_USER]-(a:Actor)-[:APPOINTED_AS]->(x:Role), (o)-[:ORGANIZATION_TO_ACTOR]->(a) WHERE a.state <> ? AND a.delpending = false AND x.name IN $lists.roles_2 RETURN DISTINCT c.idx AS checkIdx, u AS User, o AS Organization, null AS Study, null AS Site, null AS Patient UNION WITH u, o, c // scope=Organization policies=org-study-read MATCH (u)<-[:FOR_USER]-(da:Actor)<-[:STUDY_TO_DELEGATED_ACTOR]-(st:Study)-[:STUDY_TO_ORG]->(o), (da)-[:APPOINTED_AS]->(x:Role)<-[:APPOINTED_AS]-(sa:Actor), (da)-[:DELEGATED_FROM]->(sa)<-[:ORGANIZATION_TO_ACTOR]-(:Organization {alias:$tildaScaleAlias}) WHERE st.srcorgid = o.tildaid AND da.state <> ? AND da.delpending = false AND sa.state <> ? AND sa.delpending = false AND x.name IN $lists.roles_3 AND ? IN apoc.text.split(coalesce(x.tags, ?), ?) RETURN DISTINCT c.idx AS checkIdx, u AS User, o AS Organization, null AS Study, null AS Site, null AS Patient } RETURN checkIdx, User, Organization, Study, Site, Patient
enrollsvc
2 984 ms 1.90 s 1.96 s flat
WITH ? as total, null as vector MATCH (doc:Document) WHERE doc.tildaid in $lists.mf0 MATCH (org:Organization{tildaid:$policyOrgId0}) CALL { RETURN {} AS studyById, [] AS studyIdsInScope } CALL { with org, doc WITH org, doc as doc0 match (o…
WITH ? as total, null as vector MATCH (doc:Document) WHERE doc.tildaid in $lists.mf0 MATCH (org:Organization{tildaid:$policyOrgId0}) CALL { RETURN {} AS studyById, [] AS studyIdsInScope } CALL { with org, doc WITH org, doc as doc0 match (org)<-[:DOC_TO_ORG]-(doc0:Document) RETURN doc0 as doc1, doc0 as docObj, null as docShare, true as owned, null as location union with org, doc WITH org, doc as doc0 match (org)<-[:DOC_SHARED_TO_ORG]-(docObj:DocumentShare)-[:REFERS_TO]->(doc0:Document) RETURN doc0 as doc1, docObj, docObj as docShare, false as owned, null as location union with org, doc WITH org, doc as doc0 match (:Organization {alias:?})-[:HAS_SYSTEM_TEMPLATE]->(doc0:Document) where not (doc0)-[:DOC_TO_ORG]->(org) RETURN doc0 as doc1, doc0 as docObj, null as docShare, false as owned, null as location } CALL { with org, doc1 OPTIONAL MATCH (study:Study{tildaid:doc1.studyId}) OPTIONAL MATCH (study)-[:STUDY_TO_ACTOR]-(studyActor:Actor{orgId:$pickOrgId0})-[:FOR_USER]->(:User{tildaid:$pickUserId0}) RETURN study, studyActor, [] as policies, [] as userSiteIds, [] as userCountryIds, ? as defaultAccessLevel } CALL { RETURN ? AS docAccessLevel } CALL { WITH doc1 RETURN EXISTS { (doc1)-[:HAS]-(:DocumentAnnotation)-[:ANNOTATION_SIGNER]-(:DocumentSigner{userId:$signerUserId0}) } AS isSigner } WITH total, vector, doc1 as doc, docObj, owned, study, org, isSigner, CASE WHEN $isNonMember0 AND docAccessLevel = ? THEN ? ELSE docAccessLevel END AS docAccessLevel WHERE (docAccessLevel <> ? OR isSigner) CALL { WITH doc OPTIONAL MATCH (doc)<-[:INCLUDES]-(:Binder{scope:?})-[]-(patient:Patient)-[:HAS_PROTECTED_DATA_IN]->(phi:Phi) OPTIONAL MATCH (patient)<-[:RESEARCH_SUBJECT]->(cp:CarePlan{studyId:doc.studyId})RETURN DISTINCT patient.tildaid as patientId, CASE WHEN $ctxPhi0 THEN trim(COALESCE(phi.firstname ,?) + ? + COALESCE(phi.lastname ,?)) ELSE ? END as patientName, cp.subjectid as subjectId}OPTIONAL MATCH (doc)<-[:INCLUDES]-(:Binder{scope:?})-[:BINDER_FOR]-(site:Site) CALL { WITH doc, site OPTIONAL MATCH (study0:Study{tildaid:doc.studyId})<-[:PLAN_DEFINITION_TO_STUDY]- (pd0:DslPlanDefinition{delpending:false,type:?})-[:PLAN_DEFINITION_TO_SITE]->(site) OPTIONAL MATCH (pd0)<-[:STUDYSITEACTOR_TO_PLAN_DEFINITION]-(ssa0:StudySiteActor{delpending:false})-[:STUDYSITEACTOR_TO_ACTOR]-(pi0:Actor)-[:FOR_USER]->(piu0:User) WHERE pi0.state <> ? AND piu0.status <> ? AND ANY(role IN ssa0.roles WHERE role = ?) AND EXISTS { (study0)-[:STUDY_TO_ACTOR]->(pi0) } WITH COALESCE(pd0.siteNumber, ?) AS siteNumber, [n IN collect(DISTINCT CASE WHEN piu0 IS NULL THEN NULL WHEN piu0.name IS NOT NULL AND piu0.name <> ? THEN piu0.name ELSE ? + piu0.email + ? END) WHERE n IS NOT NULL] AS piNames RETURN siteNumber, piNames } OPTIONAL MATCH (doc)<-[:INCLUDES]-(visitBinder:Binder)-[:BINDER_FOR]-(visit) where visitBinder.scope in [?, ?] OPTIONAL MATCH (doc)<-[:INCLUDES]-(:Binder{scope:?})-[:BINDER_FOR]-(user:User) CALL { WITH doc OPTIONAL MATCH (doc)-[:DOCUMENT_VERSION]->(version:DocumentVersion{tildaid: coalesce($ctxVersionId0, doc.primaryVersionId)}) OPTIONAL MATCH (doc)-[:DOCUMENT_VERSION]->(majorDv:DocumentVersion{majorVersion: version.majorVersion, minorVersion: ?}) WITH version, majorDv ORDER BY majorDv.versionNumber ASC LIMIT ? OPTIONAL MATCH (majorDv)-[:UPLOADED_BY]->(uploadedBy:User) RETURN uploadedBy } CALL { WITH doc OPTIONAL MATCH (docType:DocTypeDetails{name:doc.docTypeName}) return docType }CALL { with docObj, doc OPTIONAL MATCH (docObj) -[signedByRel:SIGNED_BY]-> (signedBy:User) WHERE (doc.docKind = ? OR coalesce(signedByRel.majorVersion, doc.majorVersion, ?) = coalesce(head([(doc)-[:DOCUMENT_VERSION]->(vv:DocumentVersion{tildaid: $reviewedVersionId0}) | vv.majorVersion]), doc.majorVersion, ?)) WITH COLLECT(DISTINCT({id: signedBy.tildaid, name: signedBy.name, profilePicURL: signedBy.profilePicURL})) as signedByUsers, count(signedBy) as signersCount, max(signedByRel.createdat) as reviewDate RETURN CASE WHEN signersCount<>? THEN signedByUsers ELSE [] END AS signedByUsers , reviewDate } WITH distinct total, doc, docObj, vector, owned, study, org, docAccessLevel, isSigner, patientId, patientName, subjectId, site, siteNumber, piNames, visit, user, uploadedBy, docType, signedByUsers, reviewDate CALL { WITH doc MATCH (doc)<-[r:WORK_ORDER_TO_DOCUMENT]-(wo:WorkOrder) WITH doc, {tildaid: wo.tildaid, work_order_id: wo.work_order_id, status: wo.status, documentStatus: COALESCE(r.status, ?)} as workOrder return collect (distinct workOrder) as workOrders} CALL { WITH doc RETURN EXISTS { MATCH (doc)-[:WORK_ORDER_TO_DOCUMENT]-(w:WorkOrder)-[:WORK_ORDER_TO_CONTACT]-(u:User {tildaid: $woContactId0}) WHERE w.deltimestamp = ? AND u.deltimestamp = ? } as woContact } CALL { with docObj optional match (latestAIRun:AIRun{run_type:?})-[:AI_RUN_TO_DOCUMENT_LATEST]->(docObj) with docObj, latestAIRun order by latestAIRun.createdat desc limit ? return case when latestAIRun is not null then {tildaid: latestAIRun.tildaid, run_type: latestAIRun.run_type, status: latestAIRun.status} when docObj.aiEnabled = true then {status: ?} end as latestAIRun } CALL { with docObj optional match (docObj)<-[:RECOMMENDATION_TO_DOCUMENT]-(rec:Recommendation) return count(DISTINCT CASE WHEN rec IS NOT NULL THEN rec END) AS findingCount, count(DISTINCT CASE WHEN rec.category IN [?, ?] THEN rec END) AS queriesCount, count(DISTINCT CASE WHEN rec.status = ? THEN rec END) AS confirmedCount, count(DISTINCT CASE WHEN rec.status = ? THEN rec END) AS resolvedCount } CALL { with doc OPTIONAL MATCH (doc)<-[:INCLUDES]-(b:Binder{binderType:?}) return apoc.text.join(collect (b.tag), ?) as tags } CALL { WITH doc, docObj OPTIONAL MATCH (fold:Folder{delpending:false, folderType:?})-[:INCLUDES]->(docObj) WHERE (fold.scope=? OR fold.scope=?) OPTIONAL MATCH path = (collection:Folder{level:?})-[:INCLUDES*?..?]->(fold) RETURN path, fold, collection, CASE WHEN COALESCE(doc.collection, ?) <> ? THEN [COALESCE(doc.collection, ?)] ELSE [] END as stateTags1 } CALL { WITH docObj, path, fold, collection OPTIONAL MATCH (fold)-[:HAS]->(foldFc:FolderConstraints) OPTIONAL MATCH (fold)-[:INCLUDES]->(subArtifact:SubArtifact)<-[:FILED_UNDER_SUBARTIFACT]-(docObj) OPTIONAL MATCH (subArtifact)-[:HAS]->(subFc:FolderConstraints) WITH collection, fold, subArtifact, [n IN nodes(path) | CASE WHEN n.number=? THEN n.name ELSE apoc.text.lpad(toString(COALESCE(n.number, ?)), ?, ?)+ ?+n.name END] AS nodeIds, CASE WHEN subFc IS NOT NULL THEN subFc ELSE foldFc END as folderConstraints WITH collection, fold, subArtifact, apoc.text.join(nodeIds, ?) as folderPath, folderConstraints RETURN {id: fold.tildaid, name: fold.name, number: fold.number, folderType: fold.folderType, folderScope: fold.scope, folderScopeId: fold.scopeId, path: folderPath, mandatoryFields: [], optionalFields: [], subArtifactId: COALESCE(subArtifact.tildaid, ?), subArtifactName: COALESCE(subArtifact.name, ?), constraints: CASE WHEN folderConstraints IS NOT NULL THEN folderConstraints{.*} ELSE null END} AS primaryFolder } CALL { WITH docObj optional match (pf:Folder{delpending:false})-[:INCLUDES]->(docObj) WHERE pf.scope=? OR pf.scope=? OR (pf.scope=? AND pf.scopeId=$listingScopeId0) optional match path = (:Folder{level:?})-[:INCLUDES*?..?]->(pf) with pf, [n IN nodes(path) | CASE WHEN n.number=? THEN n.name ELSE apoc.text.lpad(toString(COALESCE(n.number, ?)), ?, ?)+ ?+n.name END] AS nodeIds with pf, apoc.text.join(nodeIds, ?) as folderPath with count(pf) as folderCount, collect(distinct({id: pf.tildaid, name: pf.name, folderType: pf.folderType, folderScope: pf.scope, folderScopeId: pf.scopeId, path: folderPath, mandatoryFields: [], optionalFields: []})) as folders return case when folderCount=? THEN [] ELSE folders END as listingFolders }CALL { with doc WITH doc, [doc.stateTag] AS stateTags2 RETURN stateTags2, stateTags2 as stagingLabels } CALL { WITH docObj, doc OPTIONAL MATCH (docObj)-[:REVIEW_IN]->(rt:Task{category:?}) OPTIONAL MATCH (rt)-[:BELONGS_TO]->(i:Inbox{type:?})-[:OWNED_BY]-(assignee:User) WITH docObj, doc, rt, CASE WHEN COUNT(assignee) > ? THEN collect({tildaid: assignee.tildaid, email: assignee.email, name: assignee.name, profilePicURL: assignee.profilePicURL, inboxId: i.tildaid}) ELSE [] END as assignees CALL { WITH docObj, doc, rt OPTIONAL MATCH (docObj)-[sb:SIGNED_BY]->(reviewer:User) WHERE rt.tildaid IN coalesce(sb.taskIds, []) AND (doc.docKind = ? OR coalesce(sb.majorVersion, doc.majorVersion, ?) = coalesce(head([(doc)-[:DOCUMENT_VERSION]->(vv:DocumentVersion{tildaid: $reviewedVersionId1}) | vv.majorVersion]), doc.majorVersion, ?)) RETURN collect(DISTINCT reviewer.tildaid) as signedFor } CALL { WITH doc, assignees UNWIND assignees AS a WITH doc, a WHERE (EXISTS { (doc)-[:HAS]->(:DocumentAnnotation)-[:ANNOTATION_FIELD]-(:DocumentField{inputType: ?}) } AND EXISTS { (doc)-[:HAS]->(:DocumentAnnotation)-[:ANNOTATION_SIGNER]->(:DocumentSigner{userId: a.tildaid}) } AND NOT EXISTS { MATCH (doc)-[:HAS]->(:DocumentAnnotation)-[:ANNOTATION_SIGNER]->(slot:DocumentSigner{userId: a.tildaid}) WHERE coalesce(slot.status, ?) <> ? }) RETURN collect(a.tildaid) as slotsSigned } WITH docObj, rt, assignees, signedFor + [id IN slotsSigned WHERE NOT id IN signedFor] as reviewedBy WITH CASE WHEN rt IS NULL THEN NULL ELSE {createdat: rt.createdat, taskId: rt.tildaid, category: rt.category, status: rt.state, assignees: assignees, reviewedBy: reviewedBy, closedBy: rt.closedBy, title: rt.title, description: rt.description} END as review ORDER BY review.createdat DESC RETURN collect(distinct(review)) as reviews } CALL { WITH doc // A regular source an instance was made from (ENG-?) is not shown as its template. optional match (doc)-[templateUse:USES_TEMPLATE]->(template:Document {template: true})-[:DOC_TO_ORG]-(torg:Organization) return case when not template is null then {doc: template{.*}, org: torg{.*}, orgId: torg.tildaid, tildaid: template.tildaid, currentGeneration: toString(template.generation), generationInUse: toString(templateUse.templateGenerationUsed)} else null end as templateDetails } CALL { with doc, docObj CALL { with doc, docObj with doc, docObj where doc.primaryVersionId = ? or doc.primaryVersionId is null optional match (doc)-[:UPLOADED_BY]->(uploader:User) return {tildaid: doc.tildaid, fileName: doc.fileName, originalFileName: doc.originalFileName, contentType: doc.contentType, date: doc.date, dateType: doc.dateType, versionName: doc.versionName, rejectReason: doc.rejectReason, language: doc.language, languages: doc.languages, needsAttention: doc.needsAttention, needsAttentionReasons: doc.needsAttentionReasons, trackActiveDuplicates: doc.trackActiveDuplicates, versionNumber: doc.versionNumber, majorVersion: doc.majorVersion, minorVersion: doc.minorVersion, generation: toString(doc.generation), cksum: doc.cksum, size: doc.size, status: doc.status, stateTag: doc.stateTag, pages: doc.pages, uploadMethod: doc.uploadMethod, changeLog: [], createdAt: doc.createdat, renderedCompletedAt: doc.renderedCompletedAt, renderedFieldsRevision: doc.renderedFieldsRevision, renderedSignersRevision: doc.renderedSignersRevision, uploadedBy: case when uploader is null then null else {id: uploader.tildaid, name: uploader.name, profilePicURL: uploader.profilePicURL} end} as version union with doc optional match (doc)-[:DOCUMENT_VERSION]->(dv:DocumentVersion) where $versionsSeesPreRedaction0 or coalesce(dv.preRedaction, false) = false or dv.tildaid = doc.primaryVersionId optional match (doc)-[:DOCUMENT_TO_SOURCE]->(ds:DocumentSource)-[:DOCUMENT_SOURCE_TO_VERSION]->(dv) optional match (dv)-[:UPLOADED_BY]->(uploader:User) optional match (dv)-[:PROMOTED_FROM]->(psrc:Document) return case when dv is null then null else {tildaid: dv.tildaid, fileName: dv.fileName, originalFileName: dv.originalFileName, contentType: dv.contentType, date: dv.date, dateType: doc.dateType, versionName: dv.versionName, rejectReason: dv.rejectReason, language: dv.language, languages: dv.languages, needsAttention: dv.needsAttention, needsAttentionReasons: dv.needsAttentionReasons, trackActiveDuplicates: dv.trackActiveDuplicates, versionNumber: dv.versionNumber, majorVersion: dv.majorVersion, minorVersion: dv.minorVersion, documentSourceId: ds.tildaid, promotedFromDocumentId: psrc.tildaid, generation: toString(dv.generation), linearizedPdfUrl: dv.linearizedPdfUrl, linearizedPdfStatus: dv.linearizedPdfStatus, needsProcessedPdf: dv.needsProcessedPdf, langDetectionStatus: dv.langDetectionStatus, translatedPdfUrl: dv.translatedPdfUrl, translatedPdfStatus: dv.translatedPdfStatus, cksum: dv.cksum, size: dv.size, status: dv.status, stateTag: dv.stateTag, pages: dv.pages, uploadMethod: dv.uploadMethod, changeLog: [], url: dv.url, createdAt: dv.createdat, renderedCompletedAt: dv.renderedCompletedAt, renderedFieldsRevision: dv.renderedFieldsRevision, renderedSignersRevision: dv.renderedSignersRevision, preRedaction: coalesce(dv.preRedaction, false), uploadedBy: case when uploader is null then null else {id: uploader.tildaid, name: uploader.name, profilePicURL: uploader.profilePicURL} end} end as version // TODO: [Major/Minor Versioning] Once client supports minor version UX, update ordering to: // } with doc, version order by version.majorVersion, version.minorVersion // This will display versions as ?.?, ?.?, ?.? instead of flat ?, ?, ? } with doc, version order by version.versionNumber where $versionsVersionId0 IS NULL OR version.tildaid = $versionsVersionId0 return collect(version) as versions } CALL { with doc optional match (doc)-[:HAS]-(ann:DocumentAnnotation) optional match (ann)-[:ANNOTATION_SIGNER]-(ds:DocumentSigner) optional match (ann)-[:ANNOTATION_FIELD]-(df:DocumentField) optional match (ann)-[:ALL_CHANGELOG]->(cl:ChangeLog) with doc, ann, ds, df, cl order by cl.createdat asc with doc, ann, apoc.convert.fromJsonList(ann.signers) as signersOld, collect(distinct ds{.*}) as signers, collect(distinct df{.*}) as fields, collect(distinct cl{.*}) as auditLog with doc, ann, auditLog, case when size(signers) <> ? then signers when size(signers) = ? and signersOld is null then [] else signersOld end as signers1, case when fields is null then [] else fields end as fields1 with doc, ann{.*, signers: signers1, fields: fields1} as annotationSpec, case when doc.template = false then ann{.*, signers: signers1, fields: fields1} else null end as annotationVal return annotationSpec, annotationVal } CALL { with doc optional match (doc)-[p:HAS_QUERY]-(q:Query) WHERE (NOT $queriesNonMember0 OR q.externalFlag = true) AND (doc.ownerOrgId = $queryOrgId0 OR q.orgId = $queryOrgId0) with case when not q is null then {query: q{.*}} end as query return collect(distinct query) as queries } CALL { WITH docObj, owned OPTIONAL MATCH (docObj)<-[:REFERS_TO]-(docShare:DocumentShare)-[:DOC_SHARED_TO_ORG]->(otherOrg:Organization) WHERE owned CALL { WITH docShare, docObj OPTIONAL MATCH (docShare)-[signedByRel:SIGNED_BY]->(signedBy:User) WHERE (docObj.docKind = ? OR coalesce(signedByRel.majorVersion, docObj.majorVersion, ?) = coalesce(head([(docObj)-[:DOCUMENT_VERSION]->(vv:DocumentVersion{tildaid: $reviewedVersionId2}) | vv.majorVersion]), docObj.majorVersion, ?)) WITH COLLECT(DISTINCT({id: signedBy.tildaid, name: signedBy.name, profilePicURL: signedBy.profilePicURL})) as signedByUsers, count(signedBy) as signersCount, max(signedByRel.createdat) as reviewDate RETURN CASE WHEN signersCount<>? THEN signedByUsers ELSE [] END as signedByUsers, reviewDate } CALL { WITH docShare OPTIONAL MATCH (docShare)-[:ALL_CHANGELOG]->(c:ChangeLog) WHERE c.level IS NULL OR c.level = ? OPTIONAL MATCH (e:ESignature{tildaid:c.blob}) WITH CASE WHEN NOT c is NULL THEN {changeLog: c{.*}, eSignature: e{.*}} END as clog order by c.createdat asc RETURN collect(clog) as changeLog } WITH CASE WHEN NOT otherOrg is NULL THEN {readerOrg: otherOrg.name, readerOrgId: otherOrg.tildaid, readerOrgAlias: otherOrg.alias, status: docShare.ownerStatus, signedByUsers: signedByUsers, reviewDate: reviewDate, changeLog: changeLog} END as shareEntry RETURN collect(shareEntry) as sharedWith } CALL { WITH docObj RETURN CASE WHEN (docObj)-[:REFERS_TO]->(:Document) THEN docObj{.*} ELSE null END as currentShare } CALL { WITH doc MATCH (doc)-[:DOCUMENT_VERSION]->(dv:DocumentVersion{tildaid: coalesce($docAttrVersionId0, doc.primaryVersionId)}) MATCH (doc)-[:DOCUMENT_TO_SOURCE]->(ds:DocumentSource)-[:DOCUMENT_SOURCE_TO_VERSION]->(dv) OPTIONAL MATCH (ds)-[:HAS_ATTRIBUTE]->(da:DocAttribute) OPTIONAL MATCH (da)-[:HAS_ATTRIBUTE_DEFINITION]->(dad:DocAttributeDefinition) RETURN collect(DISTINCT da{.*, name: COALESCE(dad.name, ?), description: COALESCE(dad.description, ?), documentSourceId: ds.tildaid}) as docAttributes } CALL { WITH doc OPTIONAL MATCH (doc)-[:DOCUMENT_VERSION]->(dv:DocumentVersion{tildaid: coalesce($notesVersionId0, doc.primaryVersionId)})-[:HAS_NOTE]->(n:DocumentNote{archived: false}) RETURN count(n) AS notesCount } CALL { return null as eventId, null as eventName, null as deliverable, null as eventScope } CALL { WITH docObj, owned OPTIONAL MATCH (docObj)-[cf:COPIED_FROM]->(src:Document) WHERE owned OPTIONAL MATCH (srcFolder:Folder{delpending:false, folderType:?})-[:INCLUDES]->(src) WHERE (srcFolder.scope=? OR srcFolder.scope=?) OPTIONAL MATCH srcFolderPath = (:Folder{level:?})-[:INCLUDES*?..?]->(srcFolder) WITH cf, src, CASE WHEN srcFolder IS NOT NULL THEN apoc.text.join([n IN nodes(srcFolderPath) | CASE WHEN n.number=? THEN n.name ELSE apoc.text.lpad(toString(COALESCE(n.number, ?)), ?, ?)+ ?+n.name END], ?) ELSE ? END as srcFolderPath WITH cf, src, head(collect(srcFolderPath)) AS srcFolderPath RETURN CASE WHEN cf IS NULL THEN null ELSE { documentId: src.tildaid, collection: src.collection, folderPath: srcFolderPath, kind: cf.kind, stale: cf.sourceVersionId <> src.primaryVersionId, sourceVersion: COALESCE(src.versionName, toString(src.majorVersion)) } END as copiedFrom } CALL { WITH docObj, owned OPTIONAL MATCH (child:Document)-[ct:COPIED_FROM]->(docObj) WHERE owned OPTIONAL MATCH (childFolder:Folder{delpending:false, folderType:?})-[:INCLUDES]->(child) WHERE (childFolder.scope=? OR childFolder.scope=?) OPTIONAL MATCH childFolderPath = (:Folder{level:?})-[:INCLUDES*?..?]->(childFolder) OPTIONAL MATCH (st:Study{tildaid:child.studyId}) WITH docObj, ct, child, st, CASE WHEN childFolder IS NOT NULL THEN apoc.text.join([n IN nodes(childFolderPath) | CASE WHEN n.number=? THEN n.name ELSE apoc.text.lpad(toString(COALESCE(n.number, ?)), ?, ?)+ ?+n.name END], ?) ELSE ? END as childFolderPath WITH docObj, ct, child, st, head(collect(childFolderPath)) AS childFolderPath WITH child, CASE WHEN ct IS NULL THEN null ELSE { documentId: child.tildaid, studyId: COALESCE(child.studyId, ?), studyName: COALESCE(st.name, ?), folderPath: childFolderPath, kind: ct.kind, stale: ct.sourceVersionId <> docObj.primaryVersionId, version: COALESCE(child.versionName, toString(child.majorVersion)) } END as copiedToEntry RETURN collect(copiedToEntry) as copiedTo, count(DISTINCT child) as copiedToCount } CALL { WITH doc OPTIONAL MATCH (doc)<-[:PROMOTED_FROM]-(tv:DocumentVersion)<-[:DOCUMENT_VERSION]-(tgt:Document) WITH CASE WHEN tgt IS NULL THEN null ELSE { documentId: tgt.tildaid, targetVersionId: tv.tildaid, version: COALESCE(tv.versionName, toString(tv.majorVersion)) } END as promotedTo RETURN promotedTo LIMIT ? } CALL { return null AS docReviewStatus, null AS hasImportantComment, null AS discrepancyCount } CALL { WITH docObj OPTIONAL MATCH (docObj)<-[:INCLUDES]-(currentFolder:Folder{folderType:?}) WHERE currentFolder.scope IN [?, ?] OPTIONAL MATCH (docObj)-[:FILED_UNDER_SUBARTIFACT]->(currentSubArtifact:SubArtifact)<-[:INCLUDES]-(currentFolder) OPTIONAL MATCH (docObj)-[:HAS_STAGING_INFO]->(stagingInfo:DocumentStagingInfo) WITH CASE WHEN stagingInfo IS NOT NULL THEN {artifactId: stagingInfo.folderId, subArtifactId: stagingInfo.subArtifactId, stagingInfoId: stagingInfo.tildaid} WHEN currentFolder.level = ? THEN {artifactId: currentFolder.tildaid, subArtifactId: COALESCE(currentSubArtifact.tildaid, ?), stagingInfoId: ?} ELSE {artifactId: ?, subArtifactId: ?, stagingInfoId: ?} END as tmfInfo WITH tmfInfo.artifactId as artifactId, tmfInfo.subArtifactId as subArtifactId, tmfInfo.stagingInfoId as stagingInfoId OPTIONAL MATCH (artifact:Folder{tildaid:artifactId})<-[:INCLUDES]-(section:Folder)<-[:INCLUDES]-(zone:Folder)<-[:INCLUDES]-(collection:Folder{name:?}) OPTIONAL MATCH (artifact)-[:INCLUDES]->(allSubArtifacts:SubArtifact) OPTIONAL MATCH (artifact)-[:INCLUDES]->(subArtifact:SubArtifact{tildaid:subArtifactId}) OPTIONAL MATCH (subArtifact)-[:HAS]->(subArtifactConstraints:FolderConstraints) OPTIONAL MATCH (artifact)-[:HAS]->(artifactConstraints:FolderConstraints) WITH artifactId as folderId, subArtifactId, stagingInfoId, CASE WHEN zone.number IS NOT NULL THEN COALESCE(apoc.text.lpad(toString(zone.number), ?, ?)+ ? + zone.name, ?) ELSE ? END as zone, CASE WHEN section.number IS NOT NULL THEN COALESCE(apoc.text.lpad(toString(zone.number), ?, ?)+?+apoc.text.lpad(toString(section.number), ?, ?)+ ? + section.name, ?) ELSE ? END as section, CASE WHEN artifact.number IS NOT NULL THEN COALESCE(apoc.text.lpad(toString(zone.number), ?, ?)+?+apoc.text.lpad(toString(section.number), ?, ?)+?+apoc.text.lpad(toString(artifact.number), ?, ?)+ ? + artifact.name, ?) ELSE ? END as artifact, CASE WHEN subArtifact.number IS NOT NULL THEN COALESCE(apoc.text.lpad(toString(zone.number), ?, ?)+?+apoc.text.lpad(toString(section.number), ?, ?)+?+apoc.text.lpad(toString(artifact.number), ?, ?)+?+apoc.text.lpad(toString(subArtifact.number), ?, ?)+ ? + subArtifact.name, ?) ELSE ? END as subArtifact, COALESCE(subArtifact.name, ?) as subArtifactName, COALESCE(subArtifactConstraints, artifactConstraints) as constraints, NOT(COUNT(allSubArtifacts) > ? AND subArtifactId = ?) as subArtifactValid OPTIONAL MATCH (constraints)-[:HAS_ATTRIBUTE_CONSTRAINT]->(dac:DocAttributeConstraint) WITH folderId, subArtifactId, stagingInfoId, zone, section, artifact, subArtifact, subArtifactName, subArtifactValid, constraints, COLLECT(DISTINCT CASE WHEN dac IS NOT NULL THEN {id: dac.tildaid, key: dac.key, order: dac.order, isMandatory: dac.isMandatory, description: dac.description} ELSE NULL END) as attributeConstraintsList WITH folderId, subArtifactId, stagingInfoId, zone, section, artifact, subArtifact, subArtifactName, subArtifactValid, CASE WHEN constraints IS NOT NULL THEN { id: constraints.tildaid, mandatory: constraints.mandatory, tmfLevel: constraints.tmfLevel, attributeConstraints: [attr IN attributeConstraintsList WHERE attr IS NOT NULL | attr] } ELSE null END as constraints WITH {folderId: folderId, subArtifactId: subArtifactId, stagingInfoId: stagingInfoId, zone: zone, section: section, artifact: artifact, subArtifact: subArtifact, subArtifactName: subArtifactName, subArtifactValid: subArtifactValid, path: apoc.text.join([x IN [zone, section, artifact] WHERE x <> ? | x], ?), constraints: constraints} as tmfCategorization RETURN CASE WHEN tmfCategorization.folderId=? THEN null ELSE tmfCategorization END as tmfCategorization } with distinct doc{.*, status: docObj.status, stateTag: docObj.stateTag, orgAlias: org.alias, owned: owned, docTypeName: doc.docTypeName, userId: doc.userId, user: CASE WHEN user IS NOT NULL THEN {id: user.tildaid, name: user.name, profilePicURL: user.profilePicURL} ELSE NULL END, createdDate: doc.createdat, updatedDate: COALESCE(doc.updatedat, doc.createdat), externalUrl: doc.url, study: study.name, studyId: study.tildaid, site: site.name, siteId: doc.siteId, siteNumber: siteNumber, piNames: piNames, patient: patientName, patientId: doc.patientId, subjectId: subjectId, visit: visit.title, visitId: doc.visitId, reviewDate: reviewDate, assignedToUsers: [], uploadedBy: {id: uploadedBy.tildaid, name: uploadedBy.name, profilePicURL: uploadedBy.profilePicURL}, signedByUsers: signedByUsers, tags: tags, listingFolders: listingFolders, primaryFolder: primaryFolder, latestAIRun: latestAIRun, findingCount: findingCount, queriesCount: queriesCount, confirmedCount: confirmedCount, resolvedCount: resolvedCount, notesCount: notesCount, stagingLabels: stagingLabels, workOrders: workOrders, woContact: COALESCE(woContact, false), stateTags1: stateTags1, stateTags2: stateTags2, docAccessLevel: docAccessLevel, isSigner: isSigner, docReviewStatus: docReviewStatus, hasImportantComment: hasImportantComment, discrepancyCount: discrepancyCount , templateDetails: templateDetails, docTypeDetails: docType{.*}, queries: queries, annotationSpec: annotationSpec, annotationVal: annotationVal, completedAt: annotationVal.completedAt, versions: versions, reviews: reviews, sharedWith: sharedWith, currentShare: currentShare, tmfCategorization: tmfCategorization, docAttributes: docAttributes, eventId: eventId, eventName: eventName, deliverable: deliverable, eventScope: eventScope, provenance: CASE WHEN copiedFrom IS NULL AND size(copiedTo) = ? THEN null ELSE {copiedFrom: copiedFrom, copiedTo: [x IN copiedTo WHERE x IS NOT NULL | x], copiedToCount: copiedToCount} END, promotedTo: promotedTo} AS document, total return document, total
docsvc
2 741 ms 1.90 s 1.46 s flat
MATCH (u:User {tildaid:$user}) OPTIONAL MATCH (o:Organization {alias:$org}) UNWIND $lists.checks AS c CALL (u, o, c) { // scope=Organization policies=org-work-order-edit,org-work-order-read MATCH (u)<-[:FOR_USER]-(a:Actor)-[:APPOINTED_AS]-…
MATCH (u:User {tildaid:$user}) OPTIONAL MATCH (o:Organization {alias:$org}) UNWIND $lists.checks AS c CALL (u, o, c) { // scope=Organization policies=org-work-order-edit,org-work-order-read MATCH (u)<-[:FOR_USER]-(a:Actor)-[:APPOINTED_AS]->(x:Role), (o)-[:ORGANIZATION_TO_ACTOR]->(a) WHERE a.state <> ? AND a.delpending = false AND x.name IN $lists.roles_0 RETURN DISTINCT c.idx AS checkIdx, u AS User, o AS Organization, null AS Study, null AS Site, null AS Patient UNION // scope=Organization policies=org-work-order-edit,org-work-order-read MATCH (u)<-[:FOR_USER]-(da:Actor)<-[:STUDY_TO_DELEGATED_ACTOR]-(st:Study)-[:STUDY_TO_ORG]->(o), (da)-[:APPOINTED_AS]->(x:Role)<-[:APPOINTED_AS]-(sa:Actor), (da)-[:DELEGATED_FROM]->(sa)<-[:ORGANIZATION_TO_ACTOR]-(:Organization {alias:?}) WHERE st.srcorgid = o.tildaid AND da.state <> ? AND da.delpending = false AND sa.state <> ? AND sa.delpending = false AND x.name IN $lists.roles_1 AND ? IN apoc.text.split(coalesce(x.tags, ?), ?) RETURN DISTINCT c.idx AS checkIdx, u AS User, o AS Organization, null AS Study, null AS Site, null AS Patient } RETURN checkIdx, User, Organization, Study, Site, Patient
virtual-assistant
2 584 ms 1.90 s 1.17 s flat
MATCH (u:User {tildaid:$user}) OPTIONAL MATCH (o:Organization {alias:$org}) UNWIND $lists.checks AS c CALL (u, o, c) { // scope=Organization policies=org-work-order-edit,org-work-order-read MATCH (u)<-[:FOR_USER]-(a:Actor)-[:APPOINTED_AS]-…
MATCH (u:User {tildaid:$user}) OPTIONAL MATCH (o:Organization {alias:$org}) UNWIND $lists.checks AS c CALL (u, o, c) { // scope=Organization policies=org-work-order-edit,org-work-order-read MATCH (u)<-[:FOR_USER]-(a:Actor)-[:APPOINTED_AS]->(x:Role), (o)-[:ORGANIZATION_TO_ACTOR]->(a) WHERE a.state <> ? AND a.delpending = false AND x.name IN $lists.roles_0 RETURN DISTINCT c.idx AS checkIdx, u AS User, o AS Organization, null AS Study, null AS Site, null AS Patient UNION // scope=Organization policies=org-work-order-edit,org-work-order-read MATCH (u)<-[:FOR_USER]-(da:Actor)<-[:STUDY_TO_DELEGATED_ACTOR]-(st:Study)-[:STUDY_TO_ORG]->(o), (da)-[:APPOINTED_AS]->(x:Role)<-[:APPOINTED_AS]-(sa:Actor), (da)-[:DELEGATED_FROM]->(sa)<-[:ORGANIZATION_TO_ACTOR]-(:Organization {alias:?}) WHERE st.srcorgid = o.tildaid AND da.state <> ? AND da.delpending = false AND sa.state <> ? AND sa.delpending = false AND x.name IN $lists.roles_1 AND ? IN apoc.text.split(coalesce(x.tags, ?), ?) RETURN DISTINCT c.idx AS checkIdx, u AS User, o AS Organization, null AS Study, null AS Site, null AS Patient } RETURN checkIdx, User, Organization, Study, Site, Patient
virtual-assistant
2 653 ms 1.90 s 1.30 s flat
MATCH (study:Study )-[:MANAGED_BY]-(:Inbox)-[:BELONGS_TO]-(t:Task) WHERE NOT EXISTS ((t)-[:BELONGS_TO]-(:Inbox{type:?})) AND EXISTS((study)-[:STUDY_TO_ORG{inherited:false}]-(:Organization{orgType:?})) CALL { WITH t MATCH (t)<-[:CREATED_FRO…
MATCH (study:Study )-[:MANAGED_BY]-(:Inbox)-[:BELONGS_TO]-(t:Task) WHERE NOT EXISTS ((t)-[:BELONGS_TO]-(:Inbox{type:?})) AND EXISTS((study)-[:STUDY_TO_ORG{inherited:false}]-(:Organization{orgType:?})) CALL { WITH t MATCH (t)<-[:CREATED_FROM_SPEC]-(ptc:ParticipantTaskConfig)-[:PARTICIPANT_TASKCONFIG]-(:ParticipantTaskList)-[:PARTICIPANT_TASKLIST]-(:ParticipantControl)-[:PARTICIPANT_CONTROL]-(:ParticipantActivity)-[:PARTICIPANT_ACTIVITY]-(pw:ParticipantWorkflow) RETURN ptc, pw UNION ALL WITH t MATCH (t)<-[:CREATED_FROM_SPEC]-(ptc:ParticipantTaskConfig)-[:PARTICIPANT_TASKCONFIG]-(:ParticipantTaskList)-[:PARTICIPANT_TASKLIST]-(:ParticipantActivity)-[:PARTICIPANT_ACTIVITY]-(pw:ParticipantWorkflow) RETURN ptc, pw } WITH DISTINCT study, t, ptc, pw MATCH (t)-[:BELONGS_TO]-(:Inbox)-[:MANAGED_BY]-(o:Organization) MATCH (ptc)-[:BELONGS_TO_TASKCONFIG]-(tc:TaskConfig) OPTIONAL MATCH (t)-[:BELONGS_TO]-(taskInbox:Inbox{type:?})--(taskUser:User) OPTIONAL MATCH (pw)-[:PARTICIPANTWORKFLOW_TO_SCOPE]-(:StudySiteActor)-[:STUDYSITEACTOR_TO_ACTOR]-(:Actor{delpending:false})-[:FOR_USER]-(user:User) OPTIONAL MATCH (pw)-[:PARTICIPANTWORKFLOW_TO_SCOPE]-(:DslPlanDefinition)-[:PLAN_DEFINITION_TO_SITE]-(scopeSite:Site)-[:SITE_TO_SMO]-(:Smo)-[:IS_AN_ORG]-(o) WITH DISTINCT study, t, o, tc, taskInbox, taskUser, user, scopeSite SKIP $skip LIMIT $limit WITH collect({study:study, t:t, o:o, tc:tc, taskInbox:taskInbox, taskUser:taskUser, user:user, scopeSite:scopeSite}) AS rows, collect(DISTINCT study) AS studies, collect(DISTINCT o) AS orgs, collect(DISTINCT scopeSite) AS sites CALL { WITH studies UNWIND studies AS study OPTIONAL MATCH (study)-[:STUDY_TO_ACTOR]-(a:Actor{delpending:false})-[:FOR_USER]-(u:User), (a)-[:APPOINTED_AS]-(r:Role) WHERE r.name IN [?, ?, ?] RETURN study.tildaid AS studyId, collect(DISTINCT CASE WHEN r.name = ? THEN u.tildaid END) AS piTildaid, collect(DISTINCT CASE WHEN r.name = ? THEN u.tildaid END) AS smoTildaid, collect(DISTINCT CASE WHEN r.name = ? THEN u.tildaid END) AS raTildaid } WITH rows, orgs, sites, collect({studyId: studyId, pi: piTildaid, smo: smoTildaid, ra: raTildaid}) AS studyRoles CALL { WITH orgs UNWIND orgs AS o OPTIONAL MATCH (o)-[:ORGANIZATION_TO_ACTOR]-(a:Actor{delpending:false})-[:FOR_USER]-(u:User), (a)-[:APPOINTED_AS]-(:Role{name:?}) RETURN o.tildaid AS orgId, collect(DISTINCT u.tildaid) AS adminTildaid } WITH rows, sites, studyRoles, collect({orgId: orgId, admin: adminTildaid}) AS orgRoles CALL { WITH sites UNWIND (CASE WHEN size(sites) = ? THEN [null] ELSE sites END) AS scopeSite OPTIONAL MATCH (scopeSite)-[:STAFF_TO_ACTOR]-(a:Actor{delpending:false})-[:FOR_USER]-(u:User), (a)-[:APPOINTED_AS]-(:Role{name:?}) RETURN scopeSite.tildaid AS siteId, collect(DISTINCT u.tildaid) AS siteAdminTildaid } WITH rows, studyRoles, orgRoles, collect({siteId: siteId, admin: siteAdminTildaid}) AS siteRoles UNWIND rows AS row WITH row, [x IN studyRoles WHERE x.studyId = row.study.tildaid][?] AS sr, [x IN orgRoles WHERE x.orgId = row.o.tildaid][?] AS orr, [x IN siteRoles WHERE row.scopeSite IS NOT NULL AND x.siteId = row.scopeSite.tildaid][?] AS str RETURN DISTINCT row.t AS task, apoc.convert.toJson({userTildaid: row.user.tildaid, userName: row.user.name, PITildaid: sr.pi, studyOwnerTildaid: sr.smo, regAnalystTildaid: sr.ra, orgAdminTildaid: orr.admin, studyName: row.study.name, siteName: row.scopeSite.name, siteAdminTildaid: CASE WHEN row.scopeSite IS NULL THEN [] ELSE str.admin END}) AS details, row.tc.who AS dsnWho, row.o.alias AS orgAlias, row.taskInbox, row.taskUser.tildaid AS taskUserId
tusker
2 764 ms 1.90 s 1.40 s flat
MATCH (u:User {tildaid:$user}) OPTIONAL MATCH (o:Organization {alias:$org}) UNWIND $lists.checks AS c CALL (u, o, c) { // scope=Study policies=study-config-edit MATCH (u)<-[:FOR_USER]-(a:Actor)-[:APPOINTED_AS]->(x:Role) WHERE a.state <> ? …
MATCH (u:User {tildaid:$user}) OPTIONAL MATCH (o:Organization {alias:$org}) UNWIND $lists.checks AS c CALL (u, o, c) { // scope=Study policies=study-config-edit MATCH (u)<-[:FOR_USER]-(a:Actor)-[:APPOINTED_AS]->(x:Role) WHERE a.state <> ? AND a.delpending = false AND o.tildaid = a.orgId AND x.name IN $lists.roles_0 WITH DISTINCT u, o, a, c MATCH (a)<-[:STUDY_TO_ACTOR]-(st:Study) WHERE EXISTS { (st)-[:STUDY_TO_ORG]->(o) } AND ( size(c.studyIds) = ? OR st.tildaid IN c.studyIds ) RETURN DISTINCT c.idx AS checkIdx, u AS User, o AS Organization, st AS Study, null AS Site, null AS Patient UNION // scope=Study policies=study-config-edit MATCH (u)<-[:FOR_USER]-(da:Actor)<-[:STUDY_TO_DELEGATED_ACTOR]-(st:Study)-[:STUDY_TO_ORG]->(o), (da)-[:APPOINTED_AS]->(x:Role)<-[:APPOINTED_AS]-(sa:Actor), (da)-[:DELEGATED_FROM]->(sa)<-[:ORGANIZATION_TO_ACTOR]-(:Organization {alias:?}) WHERE st.srcorgid = o.tildaid AND da.state <> ? AND da.delpending = false AND sa.state <> ? AND sa.delpending = false AND x.name IN $lists.roles_1 AND ? IN apoc.text.split(coalesce(x.tags, ?), ?) AND ( size(c.studyIds) = ? OR st.tildaid IN c.studyIds ) RETURN DISTINCT c.idx AS checkIdx, u AS User, o AS Organization, st AS Study, null AS Site, null AS Patient UNION // scope=Organization policies=org-study-read MATCH (u)<-[:FOR_USER]-(a:Actor)-[:APPOINTED_AS]->(x:Role), (o)-[:ORGANIZATION_TO_ACTOR]->(a) WHERE a.state <> ? AND a.delpending = false AND x.name IN $lists.roles_2 RETURN DISTINCT c.idx AS checkIdx, u AS User, o AS Organization, null AS Study, null AS Site, null AS Patient UNION // scope=Organization policies=org-study-read MATCH (u)<-[:FOR_USER]-(da:Actor)<-[:STUDY_TO_DELEGATED_ACTOR]-(st:Study)-[:STUDY_TO_ORG]->(o), (da)-[:APPOINTED_AS]->(x:Role)<-[:APPOINTED_AS]-(sa:Actor), (da)-[:DELEGATED_FROM]->(sa)<-[:ORGANIZATION_TO_ACTOR]-(:Organization {alias:?}) WHERE st.srcorgid = o.tildaid AND da.state <> ? AND da.delpending = false AND sa.state <> ? AND sa.delpending = false AND x.name IN $lists.roles_3 AND ? IN apoc.text.split(coalesce(x.tags, ?), ?) RETURN DISTINCT c.idx AS checkIdx, u AS User, o AS Organization, null AS Study, null AS Site, null AS Patient } RETURN checkIdx, User, Organization, Study, Site, Patient
chat-agent
2 968 ms 1.90 s 1.93 s flat
MATCH (u:User{tildaid:$user}), (o:Organization{delpending:false, alias:$org}) CALL (u, o) { OPTIONAL MATCH (u)<-[:FOR_USER]-(a:Actor{delpending:false})<-[:ORGANIZATION_TO_ACTOR]-(o), (a)-[:APPOINTED_AS]->(r:Role) WHERE not r.name = ? AND c…
MATCH (u:User{tildaid:$user}), (o:Organization{delpending:false, alias:$org}) CALL (u, o) { OPTIONAL MATCH (u)<-[:FOR_USER]-(a:Actor{delpending:false})<-[:ORGANIZATION_TO_ACTOR]-(o), (a)-[:APPOINTED_AS]->(r:Role) WHERE not r.name = ? AND coalesce(a.state, ?) <> ? return r{.*} UNION MATCH (u)<-[:FOR_USER]-(da:Actor{delpending:false})<-[:STUDY_TO_DELEGATED_ACTOR]-(st:Study{delpending:false})-[:STUDY_TO_ORG]->(o), (da)-[:APPOINTED_AS]->(r:Role)<-[:APPOINTED_AS]-(sa:Actor{delpending:false}), (da)-[:DELEGATED_FROM]->(sa)<-[:ORGANIZATION_TO_ACTOR]-(:Organization{alias:?}) WHERE st.srcorgid = o.tildaid AND da.state <> ? AND sa.state <> ? AND ? IN apoc.text.split(coalesce(r.tags, ?), ?) return distinct r{.*} } WITH u, o, collect(distinct r.name) as roles, collect(distinct case when r.listed = true then r.displayName end) as displayRoles, ANY(n IN COLLECT(r.external) WHERE n = true) as external, ANY(n IN COLLECT(r.name) WHERE n = ?) as isPatient, ALL(n IN COLLECT(r.piiAccess) WHERE n = false) as hidePhi WITH u, o, {organization:o{.*}, external: external, isPatient: isPatient, hidePhi: hidePhi, roles: roles, displayRoles: displayRoles } as context CALL (u, o) { MATCH (u)<-[:FOR_USER]-(a:Actor{delpending:false})<-[:STAFF_TO_ACTOR]-(si:Site{delpending:false})-[:SITE_TO_SMO]->(:Smo)-[:IS_AN_ORG]->(o) WHERE coalesce(a.state, ?) <> ? OPTIONAL MATCH (a)-[:APPOINTED_AS]->(r:Role) WITH u, o, si, a, r order by r.displayName WITH u, o, si, a, collect(distinct r.name) as roles, collect(distinct case when r.listed = true then r.displayName end) as displayRoles WITH CASE when not si is null then {siteId: si.tildaid, roles: roles, displayRoles: displayRoles} end as si return collect(si) as sites, apoc.coll.flatten(collect(si.roles)) as siteRoles } CALL (u, o) { CALL (u, o) { MATCH (u)<-[:FOR_USER]-(a:Actor{delpending:false, orgId:o.tildaid}) WHERE coalesce(a.state, ?) <> ? // Required pipeline barrier: without it the actor match re-expands // once per study in the org (?.0M -> 32k db hits, measured in Go). WITH DISTINCT u, o, a MATCH (a)<-[:STUDY_TO_ACTOR]-(s:Study{delpending:false})-[:STUDY_TO_ORG]->(o) OPTIONAL MATCH (a)-[:APPOINTED_AS]->(r:Role) RETURN s, r UNION // Delegated engagement Actors: orgId is TildaScale? roles. WITH s, r order by r.displayName WITH s, collect(distinct r.name) as roles, collect(distinct case when r.listed = true then r.displayName end) as displayRoles // Ordered so the studies array is a stable sequence for clients. WITH s, {studyId: s.tildaid, roles: roles, displayRoles: displayRoles, srcOrgId: s.srcorgid} as st ORDER BY s.name, s.tildaid return collect(st) as studies, apoc.coll.flatten(collect(st.roles)) as studyRoles } with distinct context, studies, apoc.coll.toSet(apoc.coll.flatten(collect(studyRoles))) as allStudyRoles, apoc.coll.toSet(apoc.coll.flatten(collect(siteRoles))) as siRoles with context, studies, apoc.coll.toSet(apoc.coll.flatten([context.roles, allStudyRoles, siRoles])) as allRoles return context{.*, studies: studies, allRoles: allRoles} as rc
chat-agent
2 894 ms 1.90 s 1.78 s flat
MATCH (u:User {tildaid:$user}) OPTIONAL MATCH (o:Organization {alias:$org}) UNWIND $lists.checks AS c CALL { WITH u, o, c // scope=Organization policies=org-edit MATCH (u)<-[:FOR_USER]-(a:Actor)-[:APPOINTED_AS]->(x:Role), (o)-[:ORGANIZATIO…
MATCH (u:User {tildaid:$user}) OPTIONAL MATCH (o:Organization {alias:$org}) UNWIND $lists.checks AS c CALL { WITH u, o, c // scope=Organization policies=org-edit MATCH (u)<-[:FOR_USER]-(a:Actor)-[:APPOINTED_AS]->(x:Role), (o)-[:ORGANIZATION_TO_ACTOR]->(a) WHERE a.state <> ? AND a.delpending = false AND x.name IN $lists.roles_0 WITH * WHERE o.tildaid = c.id RETURN DISTINCT c.idx AS checkIdx, u AS User, o AS Organization, null AS Study, null AS Site, null AS Patient UNION WITH u, o, c // scope=Organization policies=org-edit MATCH (u)<-[:FOR_USER]-(da:Actor)<-[:STUDY_TO_DELEGATED_ACTOR]-(st:Study)-[:STUDY_TO_ORG]->(o), (da)-[:APPOINTED_AS]->(x:Role)<-[:APPOINTED_AS]-(sa:Actor), (da)-[:DELEGATED_FROM]->(sa)<-[:ORGANIZATION_TO_ACTOR]-(:Organization {alias:$tildaScaleAlias}) WHERE st.srcorgid = o.tildaid AND da.state <> ? AND da.delpending = false AND sa.state <> ? AND sa.delpending = false AND x.name IN $lists.roles_1 AND ? IN apoc.text.split(coalesce(x.tags, ?), ?) WITH * WHERE o.tildaid = c.id RETURN DISTINCT c.idx AS checkIdx, u AS User, o AS Organization, null AS Study, null AS Site, null AS Patient } RETURN checkIdx, User, Organization, Study, Site, Patient
onboardingsvc
3 444 ms 1.85 s 1.33 s flat
MATCH (org:Organization{tildaid:$scopeOrgId0}) CALL { WITH org UNWIND $lists.allowedStudies0 AS studyId OPTIONAL MATCH (study:Study) WHERE study.tildaid = studyId // An inactive actor carries no membership, so it is excluded here rather th…
MATCH (org:Organization{tildaid:$scopeOrgId0}) CALL { WITH org UNWIND $lists.allowedStudies0 AS studyId OPTIONAL MATCH (study:Study) WHERE study.tildaid = studyId // An inactive actor carries no membership, so it is excluded here rather than at each use: // the sites, countries and roles below all hang off it. OPTIONAL MATCH (study)-[:STUDY_TO_ACTOR]-(studyActor:Actor{orgId:$ctxOrgId0})-[:FOR_USER]->(:User{tildaid:$ctxUserId0}) WHERE studyActor.state <> ? // Collect sites where user has membership in this study OPTIONAL MATCH (studyActor)-[:STUDYSITEACTOR_TO_ACTOR]-(:StudySiteActor)-[:STUDYSITEACTOR_TO_PLAN_DEFINITION]-(pd:DslPlanDefinition)-[:PLAN_DEFINITION_TO_SITE]-(site:Site) WITH org, study, studyActor, collect(DISTINCT site.tildaid) as userSiteIds // Collect countries where user has membership in this study OPTIONAL MATCH (studyActor)<-[:STUDYCOUNTRYACTOR_TO_ACTOR]-(sca:StudyCountryActor) WITH org, study, studyActor, userSiteIds, collect(DISTINCT sca.country) as userCountryIds // Pre-collect policies for this user/role in this study OPTIONAL MATCH (org)<-[:DOC_ACCESS_POLICY_TO_ORG]-(policy:DocumentAccessPolicy{status:?})-[:POLICY_TO_STUDY]->(study) WHERE EXISTS { MATCH (policy)-[:POLICY_FOR_USER]->(:User{tildaid:$ctxUserId0}) } OR (studyActor IS NOT NULL AND EXISTS { MATCH (policy)-[:POLICY_FOR_ROLE]->(role:Role)<-[:APPOINTED_AS]-(studyActor) }) WITH study, studyActor, userSiteIds, userCountryIds, collect(policy) as policies WITH {study:study, studyActor:studyActor, userSiteIds:userSiteIds, userCountryIds:userCountryIds, policies:policies} AS st WITH collect(distinct st) as studies // studyById lets each document row look its context up by study id instead of scanning // the whole list. Entries whose study did not resolve share the ? key; they all carry // the same empty context, so which one wins does not matter. The node-bearing maps go no // further than this subquery; studyIdsInScope needs no lookup, since an id with no Study // node can never equal a matched study?Basic??ReadWrite?ReadOnly?s folder and ancestors (up to ? levels for TMF hierarchy) OPTIONAL MATCH (doc1)<-[:INCLUDES]-(docFolder:Folder) OPTIONAL MATCH (docFolder)<-[:INCLUDES*?..?]-(ancestorFolder:Folder) WITH doc1, policies, userSiteIds, userCountryIds, defaultAccessLevel, collect(DISTINCT docFolder) + collect(DISTINCT ancestorFolder) AS folderHierarchy // Check document ownership OPTIONAL MATCH (doc1)-[:UPLOADED_BY]->(uploader:User{tildaid:$policyUploaderId0}) WITH doc1, policies, userSiteIds, userCountryIds, defaultAccessLevel, folderHierarchy, uploader IS NOT NULL AS isOwnedByUser // Filter policies by: // ?. Folder: policy applies if folder is in hierarchy OR policy has no folder (study-wide). A folder-less // ownership policy is the role?Owned Documents?Non Owned Documents?Staging?Pre-Staging?Owned Documents?Non Owned Documents?My Sites Documents?Other Sites Documents?My Countries Documents?Other Countries Documents?Study Scope Documents?NoAccess?NoAccess?ReadOnly?ReadOnly?ReadWrite?ReadOnly?NoAccess??Inactive' AND sst.tildaid IN studyIdsInScope AND (doc1.siteId = ? OR (a)-[:STUDYSITEACTOR_TO_ACTOR]-(:StudySiteActor)- [:STUDYSITEACTOR_TO_PLAN_DEFINITION]-(:DslPlanDefinition{delpending:false,type:?})- [:PLAN_DEFINITION_TO_SITE]-(:Site{tildaid:doc1.siteId})) RETURN doc1 as doc UNION WITH doc1, studyIdsInScope, directAdmit WITH doc1, studyIdsInScope WHERE NOT directAdmit AND (NOT $nonSiteOnlyPatients0 OR doc1.patientId = ?) AND doc1.siteId <> ? MATCH (s:Site{tildaid:doc1.siteId, delpending:false})-[:PLAN_DEFINITION_TO_SITE]- (pd:DslPlanDefinition{delpending:false,type:?})-[:PLAN_DEFINITION_TO_STUDY]->(sst:Study) WHERE sst.tildaid IN studyIdsInScope RETURN doc1 as doc UNION WITH doc1, directAdmit WITH doc1 WHERE directAdmit RETURN doc1 as doc} WITH DISTINCT doc WITH doc, coalesce(doc.archived, false) as isArchived RETURN count(CASE WHEN NOT isArchived AND doc.stateTag = ? THEN ? END) as readyForTmf, count(CASE WHEN NOT isArchived AND doc.stateTag = ? THEN ? END) as needsCorrection, count(CASE WHEN NOT isArchived AND doc.stateTag = ? THEN ? END) as needsAttention, count(CASE WHEN NOT isArchived AND doc.stateTag = ? THEN ? END) as draft, count(CASE WHEN NOT isArchived AND doc.stateTag = ? THEN ? END) as aiReview, count(CASE WHEN NOT isArchived AND doc.stateTag = ? THEN ? END) as manual, count(CASE WHEN isArchived THEN ? END) as archived, count(CASE WHEN NOT isArchived AND coalesce(doc.stateTag, ?) <> ? THEN ? END) as all
docsvc
3 717 ms 1.85 s 1.59 s flat
MATCH (currentUser:User{deltimestamp:?,deltimestamp:?,email:$email}) WHERE (currentUser.isDummy IS NULL OR currentUser.isDummy <> true) OPTIONAL MATCH (supportUser:User{email:$supportUserEmail}) OPTIONAL MATCH (targetOrg:Organization{delpe…
MATCH (currentUser:User{deltimestamp:?,deltimestamp:?,email:$email}) WHERE (currentUser.isDummy IS NULL OR currentUser.isDummy <> true) OPTIONAL MATCH (supportUser:User{email:$supportUserEmail}) OPTIONAL MATCH (targetOrg:Organization{delpending:false, alias:$orgAlias}) // A deactivated (Inactive) org actor is not a membership (ENG-?). OPTIONAL MATCH (currentUser)-[:FOR_USER]-(orgActor:Actor{delpending:false})-[:ORGANIZATION_TO_ACTOR]-(targetOrg) WHERE coalesce(orgActor.state, ?) <> ? OPTIONAL MATCH (currentUser)-[supports:SUPPORTS_ORG]-(targetOrg) WHERE EXISTS { MATCH (currentUser)<-[:FOR_USER]-(scaleActor:Actor{delpending:false})<-[:ORGANIZATION_TO_ACTOR]-(:Organization{alias:$tildaScaleAlias}), (scaleActor)-[:APPOINTED_AS]->(scaleRole:Role) WHERE coalesce(scaleActor.state, ?) <> ? AND scaleRole.name <> ? } WITH *, false AS repOf // Evaluated only for non-members; members are decided by orgActor alone. WITH *, CASE WHEN orgActor IS NULL THEN EXISTS { MATCH (currentUser)<-[:FOR_USER]-(da:Actor{delpending:false})<-[:STUDY_TO_DELEGATED_ACTOR]-(st:Study{delpending:false})-[:STUDY_TO_ORG]->(targetOrg), (da)-[:APPOINTED_AS]->(dr:Role)<-[:APPOINTED_AS]-(sa:Actor{delpending:false}), (da)-[:DELEGATED_FROM]->(sa)<-[:ORGANIZATION_TO_ACTOR]-(:Organization{alias:$tildaScaleAlias}) WHERE st.srcorgid = targetOrg.tildaid AND da.state <> ? AND sa.state <> ? AND $orgDelegatedTag IN apoc.text.split(coalesce(dr.tags, ?), ?) } ELSE false END as delegated RETURN CASE WHEN orgActor is not null THEN currentUser WHEN delegated THEN currentUser WHEN repOf THEN currentUser WHEN supports is not null THEN coalesce(supportUser, currentUser) ELSE currentUser END as user, CASE WHEN orgActor is not null OR delegated OR repOf OR supports is not null THEN targetOrg ELSE null END as org, currentUser as tokenUser
authzd
3 399 ms 1.85 s 1.16 s flat
MATCH (u:User {tildaid:$user}) OPTIONAL MATCH (o:Organization {alias:$org}) UNWIND $lists.checks AS c CALL { WITH u, o, c // scope=Organization policies=org-resources MATCH (u)<-[:FOR_USER]-(a:Actor)-[:APPOINTED_AS]->(x:Role), (o)-[:ORGANI…
MATCH (u:User {tildaid:$user}) OPTIONAL MATCH (o:Organization {alias:$org}) UNWIND $lists.checks AS c CALL { WITH u, o, c // scope=Organization policies=org-resources MATCH (u)<-[:FOR_USER]-(a:Actor)-[:APPOINTED_AS]->(x:Role), (o)-[:ORGANIZATION_TO_ACTOR]->(a) WHERE a.state <> ? AND a.delpending = false AND x.name IN $lists.roles_0 MATCH (o)-[:ORGANIZATION_TO_PATIENT]->(p2:Patient {tildaid:c.id}) RETURN DISTINCT c.idx AS checkIdx, u AS User, o AS Organization, null AS Study, null AS Site, null AS Patient UNION WITH u, o, c // scope=Organization policies=org-resources MATCH (u)<-[:FOR_USER]-(da:Actor)<-[:STUDY_TO_DELEGATED_ACTOR]-(st:Study)-[:STUDY_TO_ORG]->(o), (da)-[:APPOINTED_AS]->(x:Role)<-[:APPOINTED_AS]-(sa:Actor), (da)-[:DELEGATED_FROM]->(sa)<-[:ORGANIZATION_TO_ACTOR]-(:Organization {alias:$tildaScaleAlias}) WHERE st.srcorgid = o.tildaid AND da.state <> ? AND da.delpending = false AND sa.state <> ? AND sa.delpending = false AND x.name IN $lists.roles_1 AND ? IN apoc.text.split(coalesce(x.tags, ?), ?) MATCH (o)-[:ORGANIZATION_TO_PATIENT]->(p2:Patient {tildaid:c.id}) RETURN DISTINCT c.idx AS checkIdx, u AS User, o AS Organization, null AS Study, null AS Site, null AS Patient } RETURN checkIdx, User, Organization, Study, Site, Patient
patientsvc
3 364 ms 1.85 s 1.07 s flat
MATCH (ctx:Study)<-[:PLAN_CONTEXT]-(ep:EventPlan {orgId: $orgId})-[:EVENTS]->(e:Event) WHERE ctx.tildaid in $studyIds WITH DISTINCT e MATCH (e)-[:REQUIRES_RESOLUTION_OF]->(d:Deliverable)-[tracksRel:TRACKS_PLACEHOLDER]->(ph:Document) MATCH …
MATCH (ctx:Study)<-[:PLAN_CONTEXT]-(ep:EventPlan {orgId: $orgId})-[:EVENTS]->(e:Event) WHERE ctx.tildaid in $studyIds WITH DISTINCT e MATCH (e)-[:REQUIRES_RESOLUTION_OF]->(d:Deliverable)-[tracksRel:TRACKS_PLACEHOLDER]->(ph:Document) MATCH (ph)-[:SCOPED_TO]->(es:EventScope)-[:PART_OF_EVENT]->(e) OPTIONAL MATCH (wo:WorkOrder)-[woClaim:WO_CLAIMS_PLACEHOLDER]->(ph) WHERE woClaim.is_current = true WITH e, ph, d, es, tracksRel, head(collect(wo)) AS wo OPTIONAL MATCH (ph)-[acceptedRel:ACCEPTED_DOCUMENT]->(acceptedDoc:Document) OPTIONAL MATCH (ph)-[matchRel:MATCHING_DOCUMENT]->(matchDoc:Document) WHERE acceptedDoc IS NULL OR matchDoc.tildaid <> acceptedDoc.tildaid WITH e, ph, d, es, tracksRel, acceptedDoc, acceptedRel, wo, collect(DISTINCT CASE WHEN matchDoc IS NOT NULL AND matchDoc.collection = ? THEN { documentId: matchDoc.tildaid, displayId: matchDoc.displayId, contentType: matchDoc.contentType, documentName: matchDoc.fileName, documentDate: CASE WHEN matchDoc.createdat IS NOT NULL THEN datetime({epochMillis: matchDoc.createdat}) ELSE null END, isAccepted: false, matchedBy: matchRel.matchedBy, matchedAt: CASE WHEN matchRel.createdat IS NOT NULL THEN datetime({epochMillis: matchRel.createdat}) ELSE null END, docAttributes: [ (matchDoc)-[:DOCUMENT_TO_SOURCE]->(daSrc:DocumentSource)-[:HAS_ATTRIBUTE]->(da:DocAttribute) WHERE (daSrc)-[:DOCUMENT_SOURCE_TO_VERSION]->(:DocumentVersion {tildaid: matchDoc.primaryVersionId}) | {key: da.key, value: da.value, type: da.type, name: COALESCE(head([ (da)-[:HAS_ATTRIBUTE_DEFINITION]->(dad:DocAttributeDefinition) | dad.name ]), ?), description: COALESCE(head([ (da)-[:HAS_ATTRIBUTE_DEFINITION]->(dad:DocAttributeDefinition) | dad.description ]), ?)} ] } END) as matchesExpectedCollected, collect(DISTINCT CASE WHEN matchDoc IS NOT NULL AND (matchDoc.collection IS NULL OR matchDoc.collection <> ?) THEN { documentId: matchDoc.tildaid, displayId: matchDoc.displayId, contentType: matchDoc.contentType, documentName: matchDoc.fileName, documentDate: CASE WHEN matchDoc.createdat IS NOT NULL THEN datetime({epochMillis: matchDoc.createdat}) ELSE null END, isAccepted: false, matchedBy: matchRel.matchedBy, matchedAt: CASE WHEN matchRel.createdat IS NOT NULL THEN datetime({epochMillis: matchRel.createdat}) ELSE null END, docAttributes: [ (matchDoc)-[:DOCUMENT_TO_SOURCE]->(daSrc:DocumentSource)-[:HAS_ATTRIBUTE]->(da:DocAttribute) WHERE (daSrc)-[:DOCUMENT_SOURCE_TO_VERSION]->(:DocumentVersion {tildaid: matchDoc.primaryVersionId}) | {key: da.key, value: da.value, type: da.type, name: COALESCE(head([ (da)-[:HAS_ATTRIBUTE_DEFINITION]->(dad:DocAttributeDefinition) | dad.name ]), ?), description: COALESCE(head([ (da)-[:HAS_ATTRIBUTE_DEFINITION]->(dad:DocAttributeDefinition) | dad.description ]), ?)} ] } END) as pendingMatchesCollected WITH e, ph, d, es, tracksRel, acceptedDoc, acceptedRel, wo, [m IN matchesExpectedCollected WHERE m IS NOT NULL] as matchesExpected, [m IN pendingMatchesCollected WHERE m IS NOT NULL] as pendingMatches WITH e, ph, d, es, tracksRel, acceptedDoc, acceptedRel, wo, matchesExpected, pendingMatches, CASE WHEN ph.status <> ? THEN ? WHEN acceptedDoc IS NOT NULL THEN ? WHEN SIZE(matchesExpected) > ? AND SIZE(pendingMatches) = ? THEN ? WHEN SIZE(matchesExpected) > ? OR SIZE(pendingMatches) > ? THEN ? ELSE ? END as matchStatus OPTIONAL MATCH (ph)-[renewalRel:RENEWAL_OF]->(renewalSrcCandidate:Document) WHERE coalesce(renewalRel.primary, false) = true AND coalesce(renewalSrcCandidate.archived, false) = false WITH e, ph, d, es, tracksRel, acceptedDoc, acceptedRel, wo, matchesExpected, pendingMatches, matchStatus, head(collect(renewalSrcCandidate)) AS renewalSrc OPTIONAL MATCH (e)<-[:EVENTS]-(:EventPlan)-[:PLAN_CONTEXT]->(study) OPTIONAL MATCH (site:Site {tildaid: es.scopeId}) OPTIONAL MATCH (site)-[:PLAN_DEFINITION_TO_SITE]-(pd:DslPlanDefinition {type: ?})-[:PLAN_DEFINITION_TO_STUDY]->(study) WITH e, ph, d, es, tracksRel, acceptedDoc, acceptedRel, wo, matchesExpected, pendingMatches, matchStatus, renewalSrc, COALESCE(head(collect(site.name)), ?) AS siteName, COALESCE(head(collect(pd.siteNumber)), ?) AS siteNumber OPTIONAL MATCH (e)<-[:EVENTS]-(:EventPlan)-[:PLAN_CONTEXT]->(ctxCandidate) WITH e, ph, d, es, tracksRel, acceptedDoc, acceptedRel, wo, matchesExpected, pendingMatches, matchStatus, renewalSrc, siteName, siteNumber, head(collect(ctxCandidate)) AS ctx ORDER BY e.name, CASE es.scopeType WHEN ? THEN ? WHEN ? THEN ? ELSE ? END, es.name, d.name ASC, ph.fileName ASC WITH collect({ eventId: e.tildaid, eventName: e.name, type: COALESCE(e.type, ?), scopeId: es.tildaid, scopeName: es.name, contextId: COALESCE(ctx.tildaid, ?), contextType: CASE WHEN ctx IS NULL THEN ? WHEN ? IN labels(ctx) THEN ? ELSE ? END, contextName: COALESCE(ctx.name, ?), placeholderId: ph.tildaid, placeholderName: ph.fileName, deliverableId: d.tildaid, deliverableName: d.name, eventScopeId: es.tildaid, scopeType: es.scopeType, country: CASE WHEN es.scopeType = ? THEN COALESCE(es.scopeId, ?) ELSE ? END, siteNumber: siteNumber, siteName: siteName, dueDate: es.dueDate, matchStatus: matchStatus, userDecision: COALESCE(tracksRel.state, ?), archived: coalesce(ph.archived, false) OR es.status = ?, origin: COALESCE(tracksRel.origin, ?), feedback: COALESCE(tracksRel.feedback, ?), reason: COALESCE(tracksRel.reason, ?), removalHasAcceptedDocument: COALESCE(tracksRel.removalHasAcceptedDocument, false), workOrder: CASE WHEN wo IS NOT NULL THEN {tildaid: wo.tildaid, work_order_id: wo.work_order_id, status: wo.status} ELSE null END, renewalSource: CASE WHEN renewalSrc IS NOT NULL THEN {documentId: renewalSrc.tildaid, documentName: renewalSrc.fileName} ELSE null END, acceptedMatch: CASE WHEN acceptedDoc IS NOT NULL THEN { documentId: acceptedDoc.tildaid, displayId: acceptedDoc.displayId, contentType: acceptedDoc.contentType, documentName: acceptedDoc.fileName, documentDate: CASE WHEN acceptedDoc.createdat IS NOT NULL THEN datetime({epochMillis: acceptedDoc.createdat}) ELSE null END, isAccepted: true, matchedBy: COALESCE(head([ (ph)-[amr:MATCHING_DOCUMENT]->(acceptedDoc) | amr.matchedBy ]), ?), matchedAt: head([ (ph)-[amr:MATCHING_DOCUMENT]->(acceptedDoc) | CASE WHEN amr.createdat IS NOT NULL THEN datetime({epochMillis: amr.createdat}) ELSE null END ]), acceptedBy: acceptedRel.acceptedBy, acceptedAt: CASE WHEN acceptedRel.createdat IS NOT NULL THEN datetime({epochMillis: acceptedRel.createdat}) ELSE null END, docAttributes: [ (acceptedDoc)-[:DOCUMENT_TO_SOURCE]->(daSrc:DocumentSource)-[:HAS_ATTRIBUTE]->(da:DocAttribute) WHERE (daSrc)-[:DOCUMENT_SOURCE_TO_VERSION]->(:DocumentVersion {tildaid: acceptedDoc.primaryVersionId}) | {key: da.key, value: da.value, type: da.type, name: COALESCE(head([ (da)-[:HAS_ATTRIBUTE_DEFINITION]->(dad:DocAttributeDefinition) | dad.name ]), ?), description: COALESCE(head([ (da)-[:HAS_ATTRIBUTE_DEFINITION]->(dad:DocAttributeDefinition) | dad.description ]), ?)} ] } ELSE null END, matchesExpected: matchesExpected, pendingMatches: pendingMatches }) as allRows WITH allRows, allRows as filteredRows WITH allRows, filteredRows, { total: size(allRows), pending: size([pp IN allRows WHERE pp.userDecision IN [?, ?]]), pendingForDelete: size([pp IN allRows WHERE pp.userDecision = ?]), accepted: size([pp IN allRows WHERE pp.userDecision = ?]), rejected: size([pp IN allRows WHERE pp.userDecision = ?]), incomplete: size([pp IN allRows WHERE pp.matchStatus = ?]), potentialMatchFound: size([pp IN allRows WHERE pp.matchStatus = ?]), matchExpected: size([pp IN allRows WHERE pp.matchStatus = ?]), matched: size([pp IN allRows WHERE pp.matchStatus = ?]), finalized: size([pp IN allRows WHERE pp.matchStatus = ?]), completion: {required: size([pp IN allRows WHERE NOT (pp.userDecision = ? OR coalesce(pp.archived, false)) AND (pp.userDecision IN [?, ?] OR pp.matchStatus = ?)]), completed: size([pp IN allRows WHERE NOT (pp.userDecision = ? OR coalesce(pp.archived, false)) AND (pp.userDecision IN [?, ?] OR pp.matchStatus = ?) AND pp.matchStatus IN [?, ?]]), aiSuggested: size([pp IN allRows WHERE NOT (pp.userDecision = ? OR coalesce(pp.archived, false)) AND (pp.userDecision IN [?, ?] OR pp.matchStatus = ?) AND pp.matchStatus = ?]), inStaging: size([pp IN allRows WHERE NOT (pp.userDecision = ? OR coalesce(pp.archived, false)) AND (pp.userDecision IN [?, ?] OR pp.matchStatus = ?) AND pp.matchStatus = ?]), noMatchFound: size([pp IN allRows WHERE NOT (pp.userDecision = ? OR coalesce(pp.archived, false)) AND (pp.userDecision IN [?, ?] OR pp.matchStatus = ?) AND pp.matchStatus = ?]), notConfirmed: size([pp IN allRows WHERE NOT (pp.userDecision = ? OR coalesce(pp.archived, false)) AND pp.userDecision = ? AND NOT pp.matchStatus = ?]), removed: size([pp IN allRows WHERE (pp.userDecision = ? OR coalesce(pp.archived, false))]), percentComplete: CASE WHEN size([pp IN allRows WHERE NOT (pp.userDecision = ? OR coalesce(pp.archived, false)) AND (pp.userDecision IN [?, ?] OR pp.matchStatus = ?)]) = ? THEN null ELSE toInteger(floor(?.? * size([pp IN allRows WHERE NOT (pp.userDecision = ? OR coalesce(pp.archived, false)) AND (pp.userDecision IN [?, ?] OR pp.matchStatus = ?) AND pp.matchStatus IN [?, ?]]) / size([pp IN allRows WHERE NOT (pp.userDecision = ? OR coalesce(pp.archived, false)) AND (pp.userDecision IN [?, ?] OR pp.matchStatus = ?)]))) END, isComplete: size([pp IN allRows WHERE NOT (pp.userDecision = ? OR coalesce(pp.archived, false)) AND (pp.userDecision IN [?, ?] OR pp.matchStatus = ?)]) > ? AND size([pp IN allRows WHERE NOT (pp.userDecision = ? OR coalesce(pp.archived, false)) AND (pp.userDecision IN [?, ?] OR pp.matchStatus = ?) AND pp.matchStatus IN [?, ?]]) = size([pp IN allRows WHERE NOT (pp.userDecision = ? OR coalesce(pp.archived, false)) AND (pp.userDecision IN [?, ?] OR pp.matchStatus = ?)])}, matchedWithNew: size([pp IN allRows WHERE pp.matchStatus = ? AND (size(pp.pendingMatches) > ? OR size(pp.matchesExpected) > ?)]) } as progress RETURN size(filteredRows) as total, progress, filteredRows[$pageSkip..$pageEnd] as items
docsvc
4 297 ms 1.80 s 1.17 s flat
MATCH (currentUser:User{deltimestamp:?,deltimestamp:?,email:$email}) WHERE (currentUser.isDummy IS NULL OR currentUser.isDummy <> true) OPTIONAL MATCH (supportUser:User{email:$supportUserEmail}) OPTIONAL MATCH (targetOrg:Organization{delpe…
MATCH (currentUser:User{deltimestamp:?,deltimestamp:?,email:$email}) WHERE (currentUser.isDummy IS NULL OR currentUser.isDummy <> true) OPTIONAL MATCH (supportUser:User{email:$supportUserEmail}) OPTIONAL MATCH (targetOrg:Organization{delpending:false, alias:$orgAlias}) // A deactivated (Inactive) org actor is not a membership (ENG-?). OPTIONAL MATCH (currentUser)-[:FOR_USER]-(orgActor:Actor{delpending:false})-[:ORGANIZATION_TO_ACTOR]-(targetOrg) WHERE coalesce(orgActor.state, ?) <> ? OPTIONAL MATCH (currentUser)-[supports:SUPPORTS_ORG]-(targetOrg) WHERE EXISTS { MATCH (currentUser)<-[:FOR_USER]-(scaleActor:Actor{delpending:false})<-[:ORGANIZATION_TO_ACTOR]-(:Organization{alias:$tildaScaleAlias}), (scaleActor)-[:APPOINTED_AS]->(scaleRole:Role) WHERE coalesce(scaleActor.state, ?) <> ? AND scaleRole.name <> ? } WITH *, false AS repOf // Evaluated only for non-members; members are decided by orgActor alone. WITH *, CASE WHEN orgActor IS NULL THEN EXISTS { MATCH (currentUser)<-[:FOR_USER]-(da:Actor{delpending:false})<-[:STUDY_TO_DELEGATED_ACTOR]-(st:Study{delpending:false})-[:STUDY_TO_ORG]->(targetOrg), (da)-[:APPOINTED_AS]->(dr:Role)<-[:APPOINTED_AS]-(sa:Actor{delpending:false}), (da)-[:DELEGATED_FROM]->(sa)<-[:ORGANIZATION_TO_ACTOR]-(:Organization{alias:$tildaScaleAlias}) WHERE st.srcorgid = targetOrg.tildaid AND da.state <> ? AND sa.state <> ? AND $orgDelegatedTag IN apoc.text.split(coalesce(dr.tags, ?), ?) } ELSE false END as delegated RETURN CASE WHEN orgActor is not null THEN currentUser WHEN delegated THEN currentUser WHEN repOf THEN currentUser WHEN supports is not null THEN coalesce(supportUser, currentUser) ELSE currentUser END as user, CASE WHEN orgActor is not null OR delegated OR repOf OR supports is not null THEN targetOrg ELSE null END as org, currentUser as tokenUser
authzd
8 286 ms 1.80 s 1.13 s flat
MATCH (u:User {tildaid:$user}) OPTIONAL MATCH (o:Organization {alias:$org}) UNWIND $lists.checks AS c CALL (u, o, c) { // scope=Organization policies=org-work-order-edit,org-work-order-read MATCH (u)<-[:FOR_USER]-(a:Actor)-[:APPOINTED_AS]-…
MATCH (u:User {tildaid:$user}) OPTIONAL MATCH (o:Organization {alias:$org}) UNWIND $lists.checks AS c CALL (u, o, c) { // scope=Organization policies=org-work-order-edit,org-work-order-read MATCH (u)<-[:FOR_USER]-(a:Actor)-[:APPOINTED_AS]->(x:Role), (o)-[:ORGANIZATION_TO_ACTOR]->(a) WHERE a.state <> ? AND a.delpending = false AND x.name IN $lists.roles_0 MATCH (wo:WorkOrder {tildaid:c.id}) WHERE wo.org_id = o.tildaid AND coalesce(wo.study_id, ?) = ? RETURN DISTINCT c.idx AS checkIdx, u AS User, o AS Organization, null AS Study, null AS Site, null AS Patient UNION // scope=Organization policies=org-work-order-edit,org-work-order-read MATCH (u)<-[:FOR_USER]-(da:Actor)<-[:STUDY_TO_DELEGATED_ACTOR]-(st:Study)-[:STUDY_TO_ORG]->(o), (da)-[:APPOINTED_AS]->(x:Role)<-[:APPOINTED_AS]-(sa:Actor), (da)-[:DELEGATED_FROM]->(sa)<-[:ORGANIZATION_TO_ACTOR]-(:Organization {alias:?}) WHERE st.srcorgid = o.tildaid AND da.state <> ? AND da.delpending = false AND sa.state <> ? AND sa.delpending = false AND x.name IN $lists.roles_1 AND ? IN apoc.text.split(coalesce(x.tags, ?), ?) MATCH (wo:WorkOrder {tildaid:c.id}) WHERE wo.org_id = o.tildaid AND coalesce(wo.study_id, ?) = ? RETURN DISTINCT c.idx AS checkIdx, u AS User, o AS Organization, null AS Study, null AS Site, null AS Patient } RETURN checkIdx, User, Organization, Study, Site, Patient
virtual-assistant
4 274 ms 1.80 s 1.04 s flat
MATCH (u:User {tildaid:$user}) OPTIONAL MATCH (o:Organization {alias:$org}) UNWIND $lists.checks AS c CALL (u, o, c) { // scope=Study policies=work-order-edit MATCH (u)<-[:FOR_USER]-(a:Actor)-[:APPOINTED_AS]->(x:Role) WHERE a.state <> ? AN…
MATCH (u:User {tildaid:$user}) OPTIONAL MATCH (o:Organization {alias:$org}) UNWIND $lists.checks AS c CALL (u, o, c) { // scope=Study policies=work-order-edit MATCH (u)<-[:FOR_USER]-(a:Actor)-[:APPOINTED_AS]->(x:Role) WHERE a.state <> ? AND a.delpending = false AND o.tildaid = a.orgId AND x.name IN $lists.roles_0 WITH DISTINCT u, o, a, c MATCH (a)<-[:STUDY_TO_ACTOR]-(st:Study) WHERE EXISTS { (st)-[:STUDY_TO_ORG]->(o) } AND ( size(c.studyIds) = ? OR st.tildaid IN c.studyIds ) RETURN DISTINCT c.idx AS checkIdx, u AS User, o AS Organization, st AS Study, null AS Site, null AS Patient UNION // scope=Study policies=work-order-edit MATCH (u)<-[:FOR_USER]-(da:Actor)<-[:STUDY_TO_DELEGATED_ACTOR]-(st:Study)-[:STUDY_TO_ORG]->(o), (da)-[:APPOINTED_AS]->(x:Role)<-[:APPOINTED_AS]-(sa:Actor), (da)-[:DELEGATED_FROM]->(sa)<-[:ORGANIZATION_TO_ACTOR]-(:Organization {alias:?}) WHERE st.srcorgid = o.tildaid AND da.state <> ? AND da.delpending = false AND sa.state <> ? AND sa.delpending = false AND x.name IN $lists.roles_1 AND ? IN apoc.text.split(coalesce(x.tags, ?), ?) AND ( size(c.studyIds) = ? OR st.tildaid IN c.studyIds ) RETURN DISTINCT c.idx AS checkIdx, u AS User, o AS Organization, st AS Study, null AS Site, null AS Patient } RETURN checkIdx, User, Organization, Study, Site, Patient
feedsvc
4 368 ms 1.80 s 1.40 s flat
MATCH (currentUser:User {deltimestamp:?}) WHERE (currentUser.isDummy IS NULL OR currentUser.isDummy <> true) AND currentUser.email = $ident OPTIONAL MATCH (supportUser:User {email:$supportEmail}) OPTIONAL MATCH (targetOrg:Organization {del…
MATCH (currentUser:User {deltimestamp:?}) WHERE (currentUser.isDummy IS NULL OR currentUser.isDummy <> true) AND currentUser.email = $ident OPTIONAL MATCH (supportUser:User {email:$supportEmail}) OPTIONAL MATCH (targetOrg:Organization {delpending:false, alias:$org}) OPTIONAL MATCH (currentUser)-[:FOR_USER]-(orgActor:Actor{delpending:false})-[:ORGANIZATION_TO_ACTOR]-(targetOrg) WHERE coalesce(orgActor.state, ?) <> ? OPTIONAL MATCH (currentUser)-[supports:SUPPORTS_ORG]-(targetOrg) WHERE EXISTS { MATCH (currentUser)<-[:FOR_USER]-(scaleActor:Actor{delpending:false})<-[:ORGANIZATION_TO_ACTOR]-(:Organization{alias:$tildaScaleAlias}), (scaleActor)-[:APPOINTED_AS]->(scaleRole:Role) WHERE coalesce(scaleActor.state, ?) <> ? AND scaleRole.name <> ? } WITH *, false AS repOf WITH *, CASE WHEN orgActor IS NULL THEN EXISTS { MATCH (currentUser)<-[:FOR_USER]-(da:Actor{delpending:false})<-[:STUDY_TO_DELEGATED_ACTOR]-(st:Study{delpending:false})-[:STUDY_TO_ORG]->(targetOrg), (da)-[:APPOINTED_AS]->(dr:Role)<-[:APPOINTED_AS]-(sa:Actor{delpending:false}), (da)-[:DELEGATED_FROM]->(sa)<-[:ORGANIZATION_TO_ACTOR]-(:Organization{alias:$tildaScaleAlias}) WHERE st.srcorgid = targetOrg.tildaid AND da.state <> ? AND sa.state <> ? AND $delegatedTag IN apoc.text.split(coalesce(dr.tags, ?), ?) } ELSE false END as delegated RETURN CASE WHEN orgActor is not null THEN currentUser WHEN delegated THEN currentUser WHEN repOf THEN currentUser WHEN supports is not null THEN coalesce(supportUser, currentUser) ELSE currentUser END as user, CASE WHEN orgActor is not null OR delegated OR repOf OR supports is not null THEN targetOrg ELSE null END as org, currentUser as tokenUser
ontologysvc
4 284 ms 1.80 s 1.04 s flat
MATCH (pa:ParticipantActivity{tildaid:$pmParticipantActivityId}) -[:BELONGS_TO_ACTIVITY]-(a:ActivityV2{tildaid:$pmActivityId}) WHERE NOT EXISTS { MATCH (sta:TrainingAssignment{tildaid:pa.carePlanId}) WHERE NOT coalesce(coalesce(sta.studyId…
MATCH (pa:ParticipantActivity{tildaid:$pmParticipantActivityId}) -[:BELONGS_TO_ACTIVITY]-(a:ActivityV2{tildaid:$pmActivityId}) WHERE NOT EXISTS { MATCH (sta:TrainingAssignment{tildaid:pa.carePlanId}) WHERE NOT coalesce(coalesce(sta.studyId, ?) = $scopeStudyId AND ((sta.ownerOrgId = $callerOrgId OR $callerOrgId IN coalesce(sta.deliveredOrgIds, [])) OR ($scopeStudyRunner AND EXISTS { MATCH (str:Training{tildaid:sta.trainingId}) WHERE str.scopeId = $scopeStudyId AND (NOT ((coalesce(str.siteScope, ?) = $studyTeamScope) OR (coalesce(str.scopeType, ?) = $orgScopeType)) OR (str.orgId <> ? AND str.orgId = $callerOrgId)) })), false) } // LEVEL ?: Participant objects (Questionnaire, DocumentSet, CheckList, TaskList) OPTIONAL MATCH (pa)-[:PARTICIPANT_QUESTIONNAIRE|PARTICIPANT_DOCUMENTSET|PARTICIPANT_CHECKLIST|PARTICIPANT_TASKLIST]-(pObj1)- [:BELONGS_TO_QUESTIONNAIRE|BELONGS_TO_DOCUMENTSET|BELONGS_TO_CHECKLIST|BELONGS_TO_TASKLIST]-(obj1) WHERE (pObj1.delpending is null or pObj1.delpending <> true) // LEVEL ?: Sub-objects (Questions, Tables, DocUploads, Todos, TaskConfigs, ESign, Timer, Media, DocOverlay) OPTIONAL MATCH (pObj1)-[:PARTICIPANT_QUESTION|PARTICIPANT_TABLE|PARTICIPANT_DOC_UPLOAD|PARTICIPANT_DOC_OVERLAY|PARTICIPANT_TODO|PARTICIPANT_TASKCONFIG|PARTICIPANT_ESIGN|PARTICIPANT_TIMER|PARTICIPANT_MEDIA]-(pSubObj1)- [:BELONGS_TO_QUESTION|BELONGS_TO_TABLE|BELONGS_TO_DOC_UPLOAD|BELONGS_TO_DOC_OVERLAY|BELONGS_TO_TODOV2|BELONGS_TO_TASKCONFIG|BELONGS_TO_ESIGN|BELONGS_TO_TIMER|BELONGS_TO_MEDIA]-(subObj1) WHERE (pSubObj1.delpending is null or pSubObj1.delpending <> true) // LEVEL ?: For tables, get their questions and docuploads (one more level deep) OPTIONAL MATCH (pSubObj1)-[:PARTICIPANT_QUESTION|PARTICIPANT_DOC_UPLOAD]-(pSubSubObj1)- [:BELONGS_TO_QUESTION|BELONGS_TO_DOC_UPLOAD]-(subSubObj1) WHERE pSubObj1:ParticipantTable and (pSubSubObj1.delpending is null or pSubSubObj1.delpending <> true) // Fetch metadata for Level ? (table sub-objects) - counts plus the latest changelog, // which the visit PDF prints as the answer?Draft? hdmObjId, so fall back to // that when no object has the row?s Object Access (freeze/lock) changelogs separately from the per-cell changeLogCount OPTIONAL MATCH (hdmObj)-[:ALL_CHANGELOG]-(oaClog:ChangeLog{type:?}) WITH pa, a, obj1, pObj1, pSubObj1, subObj1, hdmObj, creatorUser, fallbackUser, pSubSubObjs, count(distinct oaClog) as rowObjAccessCount // Collect hdmObj with pSubSubObjs into hdmpSubSubObj WITH DISTINCT pa, a, obj1, pObj1, pSubObj1, subObj1, CASE WHEN size(pSubSubObjs) > ? THEN { pSubSubObjs: pSubSubObjs, hdmObj: hdmObj, objectAccessCount: rowObjAccessCount } ELSE null END as hdmpSubSubObj WITH DISTINCT pa, a, obj1, pObj1, pSubObj1, subObj1,collect(hdmpSubSubObj) as hdmpSubSubObjs // Fetch metadata for Level ? OPTIONAL MATCH (pSubObj1)-[:ALL_CHANGELOG]-(cl2:ChangeLog) WHERE cl2.type IN $pdClogTypes OPTIONAL MATCH (pSubObj1)-[:HAS_QUERY]-(q2:Query) WHERE q2.delpending = false AND q2.state <> ? OPTIONAL MATCH (pSubObj1)-[:BELONGS_TO]-(doc2:Document{archived:false}) OPTIONAL MATCH (doc2)-[:TAIL_CHANGELOG]-(docCL2:ChangeLog) OPTIONAL MATCH (doc2)-[:HAS_QUERY]-(dq2:Query) WHERE NOT dq2.state IN [?] // Aggregate Level ? WITH DISTINCT pa, a, obj1, pObj1, pSubObj1, subObj1, hdmpSubSubObjs, COUNT(DISTINCT dq2) AS doc2QueryCount, COUNT(DISTINCT cl2) AS clog2Count, COUNT(DISTINCT q2) AS query2Count, reduce(l = null, c IN COLLECT(DISTINCT cl2) | CASE WHEN l IS NULL OR c.createdat > l.createdat THEN c ELSE l END) AS lastClog2, doc2, docCL2 ORDER BY docCL2.createdat DESC WITH pa, a, obj1.tildaid AS obj1Id, obj1.title as obj1Title, pObj1, pSubObj1, subObj1, hdmpSubSubObjs, clog2Count, query2Count, lastClog2, CASE WHEN doc2 IS NOT NULL THEN { id: doc2.tildaid, docKind: doc2.docKind, versionNumber: doc2.versionNumber, fileName: doc2.fileName, uploadedBy: docCL2.who, uploadedAt: docCL2.createdat, size: doc2.size, status: doc2.status, pages: doc2.pages, docType: doc2.docTypeName, contentType: doc2.contentType, queryCount: doc2QueryCount, orgRelation: case when (doc2)-[:DOC_TO_ORG]->(:Organization{tildaid:$orgRelationOrgId}) then ? when (:Organization{tildaid:$orgRelationOrgId})<-[:DOC_SHARED_TO_ORG]-(:DocumentShare)-[:REFERS_TO]->(doc2) then ? else ? end } END as opDoc2 With pa, a, obj1Id, obj1Title, pObj1, pSubObj1, subObj1, hdmpSubSubObjs, clog2Count, query2Count, lastClog2, COLLECT(opDoc2) as opdocs2 WITH pa, a, obj1Id, obj1Title, pObj1, COLLECT({ subObj1Id: subObj1.tildaid, subObj1Title: subObj1.title, pSubObj1: pSubObj1, label: labels(pSubObj1)[?], hdmpSubSubObjs: hdmpSubSubObjs, docs: opdocs2, changeLogCount: clog2Count, changeLogs: CASE WHEN lastClog2 IS NULL THEN [] ELSE [lastClog2] END, queryCount: query2Count }) AS pSubObjs WITH DISTINCT pa, a, pObj1, obj1Id, obj1Title, pSubObjs RETURN {pa:pa, a:a, pObj1:pObj1, obj1Id:obj1Id, obj1Title:obj1Title, pSubObjs:pSubObjs}
write execsvc
5 212 ms 1.75 s 1.04 s flat
MATCH (currentUser:User {deltimestamp:?}) WHERE (currentUser.isDummy IS NULL OR currentUser.isDummy <> true) AND currentUser.email = $ident OPTIONAL MATCH (supportUser:User {email:$supportEmail}) OPTIONAL MATCH (targetOrg:Organization {del…
MATCH (currentUser:User {deltimestamp:?}) WHERE (currentUser.isDummy IS NULL OR currentUser.isDummy <> true) AND currentUser.email = $ident OPTIONAL MATCH (supportUser:User {email:$supportEmail}) OPTIONAL MATCH (targetOrg:Organization {delpending:false, alias:$org}) OPTIONAL MATCH (currentUser)-[:FOR_USER]-(orgActor:Actor{delpending:false})-[:ORGANIZATION_TO_ACTOR]-(targetOrg) WHERE coalesce(orgActor.state, ?) <> ? OPTIONAL MATCH (currentUser)-[supports:SUPPORTS_ORG]-(targetOrg) WITH *, false AS repOf WITH *, CASE WHEN orgActor IS NULL THEN EXISTS { MATCH (currentUser)<-[:FOR_USER]-(da:Actor{delpending:false})<-[:STUDY_TO_DELEGATED_ACTOR]-(st:Study{delpending:false})-[:STUDY_TO_ORG]->(targetOrg), (da)-[:APPOINTED_AS]->(dr:Role)<-[:APPOINTED_AS]-(sa:Actor{delpending:false}), (da)-[:DELEGATED_FROM]->(sa)<-[:ORGANIZATION_TO_ACTOR]-(:Organization{alias:$scaleAlias}) WHERE st.srcorgid = targetOrg.tildaid AND da.state <> ? AND sa.state <> ? AND $delegatedTag IN apoc.text.split(coalesce(dr.tags, ?), ?) } ELSE false END as delegated RETURN CASE WHEN orgActor is not null THEN currentUser WHEN delegated THEN currentUser WHEN repOf THEN currentUser WHEN supports is not null THEN coalesce(supportUser, currentUser) ELSE currentUser END as user, CASE WHEN orgActor is not null OR delegated OR repOf OR supports is not null THEN targetOrg ELSE null END as org, currentUser as tokenUser
feedsvc
5 263 ms 1.75 s 1.31 s flat
MATCH (currentUser:User {deltimestamp:?}) WHERE (currentUser.isDummy IS NULL OR currentUser.isDummy <> true) AND currentUser.email = $ident OPTIONAL MATCH (supportUser:User {email:$supportEmail}) OPTIONAL MATCH (targetOrg:Organization {del…
MATCH (currentUser:User {deltimestamp:?}) WHERE (currentUser.isDummy IS NULL OR currentUser.isDummy <> true) AND currentUser.email = $ident OPTIONAL MATCH (supportUser:User {email:$supportEmail}) OPTIONAL MATCH (targetOrg:Organization {delpending:false, alias:$org}) OPTIONAL MATCH (currentUser)-[:FOR_USER]-(orgActor:Actor{delpending:false})-[:ORGANIZATION_TO_ACTOR]-(targetOrg) WHERE coalesce(orgActor.state, ?) <> ? OPTIONAL MATCH (currentUser)-[supports:SUPPORTS_ORG]-(targetOrg) WHERE EXISTS { MATCH (currentUser)<-[:FOR_USER]-(scaleActor:Actor{delpending:false})<-[:ORGANIZATION_TO_ACTOR]-(:Organization{alias:$tildaScaleAlias}), (scaleActor)-[:APPOINTED_AS]->(scaleRole:Role) WHERE coalesce(scaleActor.state, ?) <> ? AND scaleRole.name <> ? } WITH *, false AS repOf WITH *, CASE WHEN orgActor IS NULL THEN EXISTS { MATCH (currentUser)<-[:FOR_USER]-(da:Actor{delpending:false})<-[:STUDY_TO_DELEGATED_ACTOR]-(st:Study{delpending:false})-[:STUDY_TO_ORG]->(targetOrg), (da)-[:APPOINTED_AS]->(dr:Role)<-[:APPOINTED_AS]-(sa:Actor{delpending:false}), (da)-[:DELEGATED_FROM]->(sa)<-[:ORGANIZATION_TO_ACTOR]-(:Organization{alias:$tildaScaleAlias}) WHERE st.srcorgid = targetOrg.tildaid AND da.state <> ? AND sa.state <> ? AND $delegatedTag IN apoc.text.split(coalesce(dr.tags, ?), ?) } ELSE false END as delegated RETURN CASE WHEN orgActor is not null THEN currentUser WHEN delegated THEN currentUser WHEN repOf THEN currentUser WHEN supports is not null THEN coalesce(supportUser, currentUser) ELSE currentUser END as user, CASE WHEN orgActor is not null OR delegated OR repOf OR supports is not null THEN targetOrg ELSE null END as org, currentUser as tokenUser
ontologysvc
5 227 ms 1.75 s 1.12 s flat
MATCH (currentUser:User{deltimestamp:?,deltimestamp:?,email:$email}) WHERE (currentUser.isDummy IS NULL OR currentUser.isDummy <> true) OPTIONAL MATCH (supportUser:User{email:$supportUserEmail}) OPTIONAL MATCH (targetOrg:Organization{delpe…
MATCH (currentUser:User{deltimestamp:?,deltimestamp:?,email:$email}) WHERE (currentUser.isDummy IS NULL OR currentUser.isDummy <> true) OPTIONAL MATCH (supportUser:User{email:$supportUserEmail}) OPTIONAL MATCH (targetOrg:Organization{delpending:false, alias:$orgAlias}) // A deactivated (Inactive) org actor is not a membership (ENG-?). OPTIONAL MATCH (currentUser)-[:FOR_USER]-(orgActor:Actor{delpending:false})-[:ORGANIZATION_TO_ACTOR]-(targetOrg) WHERE coalesce(orgActor.state, ?) <> ? OPTIONAL MATCH (currentUser)-[supports:SUPPORTS_ORG]-(targetOrg) WHERE EXISTS { MATCH (currentUser)<-[:FOR_USER]-(scaleActor:Actor{delpending:false})<-[:ORGANIZATION_TO_ACTOR]-(:Organization{alias:$tildaScaleAlias}), (scaleActor)-[:APPOINTED_AS]->(scaleRole:Role) WHERE coalesce(scaleActor.state, ?) <> ? AND scaleRole.name <> ? } WITH *, false AS repOf // Evaluated only for non-members; members are decided by orgActor alone. WITH *, CASE WHEN orgActor IS NULL THEN EXISTS { MATCH (currentUser)<-[:FOR_USER]-(da:Actor{delpending:false})<-[:STUDY_TO_DELEGATED_ACTOR]-(st:Study{delpending:false})-[:STUDY_TO_ORG]->(targetOrg), (da)-[:APPOINTED_AS]->(dr:Role)<-[:APPOINTED_AS]-(sa:Actor{delpending:false}), (da)-[:DELEGATED_FROM]->(sa)<-[:ORGANIZATION_TO_ACTOR]-(:Organization{alias:$tildaScaleAlias}) WHERE st.srcorgid = targetOrg.tildaid AND da.state <> ? AND sa.state <> ? AND $orgDelegatedTag IN apoc.text.split(coalesce(dr.tags, ?), ?) } ELSE false END as delegated RETURN CASE WHEN orgActor is not null THEN currentUser WHEN delegated THEN currentUser WHEN repOf THEN currentUser WHEN supports is not null THEN coalesce(supportUser, currentUser) ELSE currentUser END as user, CASE WHEN orgActor is not null OR delegated OR repOf OR supports is not null THEN targetOrg ELSE null END as org, currentUser as tokenUser
authzd
5 238 ms 1.75 s 1.12 s flat
MATCH (currentUser:User{deltimestamp:?,deltimestamp:?,email:$email}) WHERE (currentUser.isDummy IS NULL OR currentUser.isDummy <> true) OPTIONAL MATCH (supportUser:User{email:$supportUserEmail}) OPTIONAL MATCH (targetOrg:Organization{delpe…
MATCH (currentUser:User{deltimestamp:?,deltimestamp:?,email:$email}) WHERE (currentUser.isDummy IS NULL OR currentUser.isDummy <> true) OPTIONAL MATCH (supportUser:User{email:$supportUserEmail}) OPTIONAL MATCH (targetOrg:Organization{delpending:false, alias:$orgAlias}) // A deactivated (Inactive) org actor is not a membership (ENG-?). OPTIONAL MATCH (currentUser)-[:FOR_USER]-(orgActor:Actor{delpending:false})-[:ORGANIZATION_TO_ACTOR]-(targetOrg) WHERE coalesce(orgActor.state, ?) <> ? OPTIONAL MATCH (currentUser)-[supports:SUPPORTS_ORG]-(targetOrg) WHERE EXISTS { MATCH (currentUser)<-[:FOR_USER]-(scaleActor:Actor{delpending:false})<-[:ORGANIZATION_TO_ACTOR]-(:Organization{alias:$tildaScaleAlias}), (scaleActor)-[:APPOINTED_AS]->(scaleRole:Role) WHERE coalesce(scaleActor.state, ?) <> ? AND scaleRole.name <> ? } WITH *, false AS repOf // Evaluated only for non-members; members are decided by orgActor alone. WITH *, CASE WHEN orgActor IS NULL THEN EXISTS { MATCH (currentUser)<-[:FOR_USER]-(da:Actor{delpending:false})<-[:STUDY_TO_DELEGATED_ACTOR]-(st:Study{delpending:false})-[:STUDY_TO_ORG]->(targetOrg), (da)-[:APPOINTED_AS]->(dr:Role)<-[:APPOINTED_AS]-(sa:Actor{delpending:false}), (da)-[:DELEGATED_FROM]->(sa)<-[:ORGANIZATION_TO_ACTOR]-(:Organization{alias:$tildaScaleAlias}) WHERE st.srcorgid = targetOrg.tildaid AND da.state <> ? AND sa.state <> ? AND $orgDelegatedTag IN apoc.text.split(coalesce(dr.tags, ?), ?) } ELSE false END as delegated RETURN CASE WHEN orgActor is not null THEN currentUser WHEN delegated THEN currentUser WHEN repOf THEN currentUser WHEN supports is not null THEN coalesce(supportUser, currentUser) ELSE currentUser END as user, CASE WHEN orgActor is not null OR delegated OR repOf OR supports is not null THEN targetOrg ELSE null END as org, currentUser as tokenUser
authzd
6 215 ms 1.70 s 1.17 s 0.0× ↓
match (pv:ParticipantVisit)-[:BELONGS_TO_PARTICIPANT_VISIT]-(v:VisitAppointment)-[:VISIT_APPOINTMENT_TO_CARE_PLAN]-(c:CarePlan)-[:RESEARCH_SUBJECT] -(p:Patient)-[:HAS_PROTECTED_DATA_IN]-(phi:Phi) where c.status IN [?,?] and v.startTime >= …
match (pv:ParticipantVisit)-[:BELONGS_TO_PARTICIPANT_VISIT]-(v:VisitAppointment)-[:VISIT_APPOINTMENT_TO_CARE_PLAN]-(c:CarePlan)-[:RESEARCH_SUBJECT] -(p:Patient)-[:HAS_PROTECTED_DATA_IN]-(phi:Phi) where c.status IN [?,?] and v.startTime >= datetime({epochMillis:$day1Start}) and v.startTime <= datetime({epochMillis:$day1End}) and coalesce(v.reminderStatus, ?) = ? match (c)-[:EXECUTE_SOA]-(s:ScheduleOfActivities)-[:SOA_TO_PLAN_DEFINITION] -(pd:DslPlanDefinition)-[:PLAN_DEFINITION_TO_SITE]-(si:Site)-[:SITE_TO_SMO]->(smo:Smo)-[:IS_AN_ORG]->(o:Organization) return v,phi,si,p,o
schedsvc
6 218 ms 1.70 s 1.30 s flat
match (pv:ParticipantVisit)-[:BELONGS_TO_PARTICIPANT_VISIT]-(v:VisitAppointment)-[:VISIT_APPOINTMENT_TO_CARE_PLAN]-(c:CarePlan)-[:RESEARCH_SUBJECT] -(p:Patient)-[:HAS_PROTECTED_DATA_IN]-(phi:Phi) where c.status IN [?,?] and v.startTime >= …
match (pv:ParticipantVisit)-[:BELONGS_TO_PARTICIPANT_VISIT]-(v:VisitAppointment)-[:VISIT_APPOINTMENT_TO_CARE_PLAN]-(c:CarePlan)-[:RESEARCH_SUBJECT] -(p:Patient)-[:HAS_PROTECTED_DATA_IN]-(phi:Phi) where c.status IN [?,?] and v.startTime >= datetime({epochMillis:$day1Start}) and v.startTime <= datetime({epochMillis:$day1End}) and coalesce(v.reminderStatus, ?) = ? match (c)-[:EXECUTE_SOA]-(s:ScheduleOfActivities)-[:SOA_TO_PLAN_DEFINITION] -(pd:DslPlanDefinition)-[:PLAN_DEFINITION_TO_SITE]-(si:Site)-[:SITE_TO_SMO]->(smo:Smo)-[:IS_AN_ORG]->(o:Organization) return v,phi,si,p,o
schedsvc
6 180 ms 1.70 s 1.07 s flat
MATCH (o:Organization {tildaid: $org_id})<-[:WORK_ORDER_CONFIG_TO_ORGANIZATION]-(b:WorkOrderConfig) WHERE b.delpending = false AND (b.study_id IN $lists.accessible_study_ids OR coalesce(b.study_id, ?) = ?) AND b.status <> ? OPTIONAL MATCH …
MATCH (o:Organization {tildaid: $org_id})<-[:WORK_ORDER_CONFIG_TO_ORGANIZATION]-(b:WorkOrderConfig) WHERE b.delpending = false AND (b.study_id IN $lists.accessible_study_ids OR coalesce(b.study_id, ?) = ?) AND b.status <> ? OPTIONAL MATCH (b)-[:WORK_ORDER_CONFIG_TO_CHILD_WORK_ORDER]->(wc:WorkOrder) WHERE wc.delpending = false AND wc.status <> ? AND wc.status IN $lists.child_statuses WITH b, count(wc) AS _match_count WHERE _match_count > ? OPTIONAL MATCH (b)-[:WORK_ORDER_CONFIG_TO_STUDY]->(study:Study) OPTIONAL MATCH (b)-[:WORK_ORDER_CONFIG_TO_CREATOR]->(creator:User) OPTIONAL MATCH (b)-[:WORK_ORDER_CONFIG_TO_TEMPLATE]->(tmpl:WorkOrderTemplate) WITH b, study, creator, tmpl, b.createdat AS _sort_key ORDER BY (CASE WHEN _sort_key IS NULL THEN ? ELSE ? END) ASC, _sort_key DESC, b.tildaid DESC LIMIT $fetch_limit WITH b, study, creator, tmpl, _sort_key // Resolve WorkPlanInstance id/name for workplan-created configs (wp_object_id set). // Mirrors get_workplan_info_for_work_order_config: cfg.wp_object_id -> milestone item // (by tildaid or cfgMilestoneItemId) -> WorkPlanInstance. Non-workplan configs yield null. OPTIONAL MATCH (wpInstance:WorkPlanInstance)-[:WORKPLAN_INSTANCE_TO_MILESTONE]->(:WorkPlanMilestone) -[:REL_WORKPLAN_INSTANCE_MILESTONE_TO_ITEM]->(wpItem:WorkplanInstanceMilestoneItem) WHERE coalesce(b.wp_object_id, ?) <> ? AND (wpItem.tildaid = b.wp_object_id OR wpItem.cfgMilestoneItemId = b.wp_object_id) WITH b, study, creator, tmpl, _sort_key, head(collect(wpInstance.tildaid)) AS workplan_id, head(collect(wpInstance.name)) AS workplan_name OPTIONAL MATCH (b)-[:WORK_ORDER_CONFIG_TO_CHILD_WORK_ORDER]->(w:WorkOrder) WHERE w.delpending = false AND w.status <> ? AND w.status IN $lists.child_statuses OPTIONAL MATCH (w)-[:WORK_ORDER_TO_STUDY]->(wStudy:Study) OPTIONAL MATCH (w)-[:WORK_ORDER_TO_SITE]->(wSite:Site) OPTIONAL MATCH (w)-[:WORK_ORDER_TO_CREATOR]->(wCreator:User) OPTIONAL MATCH (w)-[:WORK_ORDER_TO_ASSIGNEE]->(wAssignee:User) // Resolve EventScope for Event-type child WOs (null for Standard-type) OPTIONAL MATCH (w)-[:WORK_ORDER_TO_EVENT_SCOPE]->(wES:EventScope) // Look up the Site node only for Site-scoped events; guards against null wES and non-Site scopes. // wES.scopeId is a site tildaid (UUID) for Site scopes, country name for Country, ? for Trial. OPTIONAL MATCH (wES_Site:Site {tildaid: wES.scopeId}) WHERE wES.scopeType = ? OPTIONAL MATCH (wPartner:Partner {tildaid: w.recipient_key}) OPTIONAL MATCH (:Actor {tildaid: w.recipient_key})-[:FOR_USER]->(wMember:User) OPTIONAL MATCH (w)-[:WORK_ORDER_TO_TASK]->(wTask:WorkOrderTask) WITH b, study, creator, tmpl, workplan_id, workplan_name, _sort_key, w, wStudy, wSite, wCreator, wAssignee, wES, wES_Site, wPartner, wMember, sum(CASE WHEN wTask.status = ? THEN ? ELSE ? END) AS w_pending_count, sum(CASE WHEN wTask.status = ? THEN ? ELSE ? END) AS w_resolved_count // ENG-?: order children in the DB so children_limit keeps the first N in // DISPLAY order. collect() below preserves incoming row order. // The PARENT keyset terms MUST lead. This ORDER BY runs in a WITH stage AFTER // the parent ORDER BY/LIMIT, and a later ORDER BY re-sorts the whole row stream // — ordering on the child value alone silently re-ranked the CONFIGS by their // child?s QUERY order, not display order: the backward // reversal happens later in Python. ORDER BY (CASE WHEN _sort_key IS NULL THEN ? ELSE ? END) ASC, _sort_key DESC, b.tildaid DESC, (w.createdat IS NULL), w.createdat DESC, w.tildaid WITH b, study, creator, tmpl, workplan_id, workplan_name, _sort_key, collect(DISTINCT CASE WHEN w IS NOT NULL THEN { tildaid: w.tildaid, work_order_id: w.work_order_id, title: w.title, work_order_type: w.work_order_type, status: w.status, priority: w.priority, creator_id: w.creator_id, assigned_to_id: w.assigned_to_id, site_id: w.site_id, study_id: w.study_id, document_ids: w.document_ids, contact_list: w.contact_list, cc_list: w.cc_list, goal: w.goal, due_date: w.due_date, last_reachout: w.last_reachout, last_response: w.last_response, resolved_at: w.resolved_at, need_attention_reason: w.need_attention_reason, accepted_count: w.accepted_count, pending_count: w_pending_count, resolved_count: w_resolved_count, // Mandatory documents this child WO still expects to accept. Pattern // comprehension (like site_number below) keeps the task→subtask // traversal out of the children collect()/count aggregation. Predicate // MUST stay in sync with WorkOrderRepository._count_expected_documents. expected_documents_count: size([(w)-[:WORK_ORDER_TO_TASK]->(t2:WorkOrderTask)-[:TASK_HAS_SUBTASK]->(s:WorkOrderSubtask) WHERE coalesce(t2.status, ?) <> ? AND coalesce(s.is_optional, false) = false AND coalesce(s.status, ?) <> ? AND (coalesce(s.expects_document, false) = true OR s.expects_document IS NULL OR s.placeholder_id IS NOT NULL OR s.sent_doc_id IS NOT NULL OR s.received_doc_id IS NOT NULL) | s]), createdat: w.createdat, updatedat: w.updatedat, thread_id: w.thread_id, rfc_msgid: w.rfc_msgid, parent_id: w.parent_id, // The child? ?Unknown User? ?Unknown User?site?Site?country?Country?trial?Trial?study?Trial???Organization??partner?Partner??studyteam?Study Team?Site?Site?Country?partner??Partner?studyTeam?? ???? ????Study Team?Non-site?s // `late_reply`: that field is projected only when include_late_reply AND a // child_status filter are both supplied, so reading it here reported False // for every unfiltered list (Codex review, ENG-?). collect(DISTINCT CASE WHEN w IS NOT NULL AND (w.status = ? AND w.last_response IS NOT NULL AND coalesce(w.resolved_at, w.status_updated_at) IS NOT NULL AND w.last_response > coalesce(w.resolved_at, w.status_updated_at) AND w.last_response > coalesce(w.late_reply_ack_at, ?)) THEN true ELSE null END) AS _late_flags // Aggregates are computed over the FULL matching child set, BEFORE the // children_limit slice, so a truncated page still renders a correct parent row // (ENG-?). Without these the client can only derive them from `children`, // which is exactly what stops it asking for fewer. WITH b, study, creator, tmpl, workplan_id, workplan_name, _sort_key, _late_flags, [child IN _children_raw WHERE child IS NOT NULL] AS _children WITH b, study, creator, tmpl, workplan_id, workplan_name, _sort_key, _children, size(_children) AS _child_total, reduce(acc = ?, c IN _children | acc + coalesce(c.pending_count, ?)) AS _agg_pending, reduce(acc = ?, c IN _children | acc + coalesce(c.resolved_count, ?)) AS _agg_resolved, size([f IN _late_flags WHERE f = true]) > ? AS _has_late_reply, (size(_children) > ? AND all(c IN _children WHERE c.status = ?)) AS _all_draft RETURN { tildaid: b.tildaid, work_order_config_id: COALESCE(b.work_order_config_id, substring(b.tildaid, ?, ?)), study_id: b.study_id, title: b.title, email_subject: b.email_subject, instructions: b.instructions, email: b.email, recipients: b.recipients, nonsite_recipients: b.nonsite_recipients, site_recipients: b.site_recipients, event_scope_recipients: b.event_scope_recipients, scope_recipients: b.scope_recipients, tasks: b.tasks, // ENG-?: without this, GET /work-order-configs returns plan_steps: [] // for every config and _raw_plan_steps() is dead code. plan_steps: b.plan_steps, plan_instructions: b.plan_instructions, status: b.status, work_order_config_type: b.work_order_config_type, entity_type: b.entity_type, event_id: b.event_id, progress: b.progress, child_count: b.child_count, sent_count: b.sent_count, pending_count: b.pending_count, child_creation_pending: coalesce(b.child_creation_pending, false), // ENG-?: the client recomputes child_creation_pending from these two // (isChildCreationPending), so an unprojected pair reads as ? // and kills the row spinner and the spawn poll. Both, or neither. activated_at: b.activated_at, children_created_at: b.children_created_at, creator_id: b.creator_id, org_id: b.org_id, document_ids: b.document_ids, context_document_ids: COALESCE(b.context_document_ids, []), reasoning: b.reasoning, reasoning_summary: b.reasoning_summary, warning: b.warning, error: b.error, createdat: b.createdat, updatedat: b.updatedat, studyName: CASE WHEN coalesce(b.study_id, ?) = ? THEN ? ELSE COALESCE(study.name, ?) END, creatorName: COALESCE(creator.firstName + ? + creator.lastName, creator.email, ?), // $children_limit < ? is the ? sentinel: a null upper bound makes // the whole slice null in Cypher, so the unlimited case takes the CASE branch. children: CASE WHEN $children_limit < ? THEN _children ELSE _children[?..$children_limit] END, // ENG-? additive aggregates. Always over the full matching child set. child_total: _child_total, children_pending_count: _agg_pending, children_resolved_count: _agg_resolved, has_late_reply: _has_late_reply, all_children_draft: _all_draft, template_id: tmpl.tildaid, template_title: tmpl.title, workplan_id: workplan_id, workplan_name: workplan_name } as work_order_config_with_children, _sort_key // Re-assert the parent order AFTER the child aggregation. The child ORDER BY // above leads with these same terms, but group emission order out of an // aggregation is not guaranteed by Cypher — and the Python loop trims the // lookahead by position, so a re-ordered stream drops the WRONG config and // builds cursors from the wrong boundary. Query order, not display order: // the backward reversal happens later in Python. ORDER BY (CASE WHEN _sort_key IS NULL THEN ? ELSE ? END) ASC, _sort_key DESC, b.tildaid DESC
write virtual-assistant
7 159 ms 1.65 s 1.07 s flat
MATCH (pa:ParticipantActivity{tildaid:$pmParticipantActivityId}) -[:BELONGS_TO_ACTIVITY]-(a:ActivityV2{tildaid:$pmActivityId}) WHERE NOT EXISTS { MATCH (sta:TrainingAssignment{tildaid:pa.carePlanId}) WHERE NOT coalesce(coalesce(sta.studyId…
MATCH (pa:ParticipantActivity{tildaid:$pmParticipantActivityId}) -[:BELONGS_TO_ACTIVITY]-(a:ActivityV2{tildaid:$pmActivityId}) WHERE NOT EXISTS { MATCH (sta:TrainingAssignment{tildaid:pa.carePlanId}) WHERE NOT coalesce(coalesce(sta.studyId, ?) = $scopeStudyId AND ((sta.ownerOrgId = $callerOrgId OR $callerOrgId IN coalesce(sta.deliveredOrgIds, [])) OR ($scopeStudyRunner AND EXISTS { MATCH (str:Training{tildaid:sta.trainingId}) WHERE str.scopeId = $scopeStudyId AND (NOT ((coalesce(str.siteScope, ?) = $studyTeamScope) OR (coalesce(str.scopeType, ?) = $orgScopeType)) OR (str.orgId <> ? AND str.orgId = $callerOrgId)) })), false) } // LEVEL ?: Participant objects (Questionnaire, DocumentSet, CheckList, TaskList) OPTIONAL MATCH (pa)-[:PARTICIPANT_QUESTIONNAIRE|PARTICIPANT_DOCUMENTSET|PARTICIPANT_CHECKLIST|PARTICIPANT_TASKLIST]-(pObj1)- [:BELONGS_TO_QUESTIONNAIRE|BELONGS_TO_DOCUMENTSET|BELONGS_TO_CHECKLIST|BELONGS_TO_TASKLIST]-(obj1) WHERE (pObj1.delpending is null or pObj1.delpending <> true) AND obj1.tildaid=$pdSubObjectId // LEVEL ?: Sub-objects (Questions, Tables, DocUploads, Todos, TaskConfigs, ESign, Timer, Media, DocOverlay) OPTIONAL MATCH (pObj1)-[:PARTICIPANT_QUESTION|PARTICIPANT_TABLE|PARTICIPANT_DOC_UPLOAD|PARTICIPANT_DOC_OVERLAY|PARTICIPANT_TODO|PARTICIPANT_TASKCONFIG|PARTICIPANT_ESIGN|PARTICIPANT_TIMER|PARTICIPANT_MEDIA]-(pSubObj1)- [:BELONGS_TO_QUESTION|BELONGS_TO_TABLE|BELONGS_TO_DOC_UPLOAD|BELONGS_TO_DOC_OVERLAY|BELONGS_TO_TODOV2|BELONGS_TO_TASKCONFIG|BELONGS_TO_ESIGN|BELONGS_TO_TIMER|BELONGS_TO_MEDIA]-(subObj1) WHERE (pSubObj1.delpending is null or pSubObj1.delpending <> true) // LEVEL ?: For tables, get their questions and docuploads (one more level deep) OPTIONAL MATCH (pSubObj1)-[:PARTICIPANT_QUESTION|PARTICIPANT_DOC_UPLOAD]-(pSubSubObj1)- [:BELONGS_TO_QUESTION|BELONGS_TO_DOC_UPLOAD]-(subSubObj1) WHERE pSubObj1:ParticipantTable and (pSubSubObj1.delpending is null or pSubSubObj1.delpending <> true) // Fetch metadata for Level ? (table sub-objects) - counts plus the latest changelog, // which the visit PDF prints as the answer?Draft? hdmObjId, so fall back to // that when no object has the row?s Object Access (freeze/lock) changelogs separately from the per-cell changeLogCount OPTIONAL MATCH (hdmObj)-[:ALL_CHANGELOG]-(oaClog:ChangeLog{type:?}) WITH pa, a, obj1, pObj1, pSubObj1, subObj1, hdmObj, creatorUser, fallbackUser, pSubSubObjs, count(distinct oaClog) as rowObjAccessCount // Collect hdmObj with pSubSubObjs into hdmpSubSubObj WITH DISTINCT pa, a, obj1, pObj1, pSubObj1, subObj1, CASE WHEN size(pSubSubObjs) > ? THEN { pSubSubObjs: pSubSubObjs, hdmObj: hdmObj, objectAccessCount: rowObjAccessCount } ELSE null END as hdmpSubSubObj WITH DISTINCT pa, a, obj1, pObj1, pSubObj1, subObj1,collect(hdmpSubSubObj) as hdmpSubSubObjs // Fetch metadata for Level ? OPTIONAL MATCH (pSubObj1)-[:ALL_CHANGELOG]-(cl2:ChangeLog) WHERE cl2.type IN $pdClogTypes OPTIONAL MATCH (pSubObj1)-[:HAS_QUERY]-(q2:Query) WHERE q2.delpending = false AND q2.state <> ? OPTIONAL MATCH (pSubObj1)-[:BELONGS_TO]-(doc2:Document{archived:false}) OPTIONAL MATCH (doc2)-[:TAIL_CHANGELOG]-(docCL2:ChangeLog) OPTIONAL MATCH (doc2)-[:HAS_QUERY]-(dq2:Query) WHERE NOT dq2.state IN [?] // Aggregate Level ? WITH DISTINCT pa, a, obj1, pObj1, pSubObj1, subObj1, hdmpSubSubObjs, COUNT(DISTINCT dq2) AS doc2QueryCount, COUNT(DISTINCT cl2) AS clog2Count, COUNT(DISTINCT q2) AS query2Count, reduce(l = null, c IN COLLECT(DISTINCT cl2) | CASE WHEN l IS NULL OR c.createdat > l.createdat THEN c ELSE l END) AS lastClog2, doc2, docCL2 ORDER BY docCL2.createdat DESC WITH pa, a, obj1.tildaid AS obj1Id, obj1.title as obj1Title, pObj1, pSubObj1, subObj1, hdmpSubSubObjs, clog2Count, query2Count, lastClog2, CASE WHEN doc2 IS NOT NULL THEN { id: doc2.tildaid, docKind: doc2.docKind, versionNumber: doc2.versionNumber, fileName: doc2.fileName, uploadedBy: docCL2.who, uploadedAt: docCL2.createdat, size: doc2.size, status: doc2.status, pages: doc2.pages, docType: doc2.docTypeName, contentType: doc2.contentType, queryCount: doc2QueryCount, orgRelation: case when (doc2)-[:DOC_TO_ORG]->(:Organization{tildaid:$orgRelationOrgId}) then ? when (:Organization{tildaid:$orgRelationOrgId})<-[:DOC_SHARED_TO_ORG]-(:DocumentShare)-[:REFERS_TO]->(doc2) then ? else ? end } END as opDoc2 With pa, a, obj1Id, obj1Title, pObj1, pSubObj1, subObj1, hdmpSubSubObjs, clog2Count, query2Count, lastClog2, COLLECT(opDoc2) as opdocs2 WITH pa, a, obj1Id, obj1Title, pObj1, COLLECT({ subObj1Id: subObj1.tildaid, subObj1Title: subObj1.title, pSubObj1: pSubObj1, label: labels(pSubObj1)[?], hdmpSubSubObjs: hdmpSubSubObjs, docs: opdocs2, changeLogCount: clog2Count, changeLogs: CASE WHEN lastClog2 IS NULL THEN [] ELSE [lastClog2] END, queryCount: query2Count }) AS pSubObjs WITH DISTINCT pa, a, pObj1, obj1Id, obj1Title, pSubObjs RETURN {pa:pa, a:a, pObj1:pObj1, obj1Id:obj1Id, obj1Title:obj1Title, pSubObjs:pSubObjs}
write execsvc
7 152 ms 1.65 s 1.05 s flat
MATCH (currentUser:User {deltimestamp:?}) WHERE (currentUser.isDummy IS NULL OR currentUser.isDummy <> true) AND currentUser.email = $ident OPTIONAL MATCH (supportUser:User {email:$supportEmail}) OPTIONAL MATCH (targetOrg:Organization {del…
MATCH (currentUser:User {deltimestamp:?}) WHERE (currentUser.isDummy IS NULL OR currentUser.isDummy <> true) AND currentUser.email = $ident OPTIONAL MATCH (supportUser:User {email:$supportEmail}) OPTIONAL MATCH (targetOrg:Organization {delpending:false, alias:$org}) OPTIONAL MATCH (currentUser)-[:FOR_USER]-(orgActor:Actor{delpending:false})-[:ORGANIZATION_TO_ACTOR]-(targetOrg) WHERE coalesce(orgActor.state, ?) <> ? OPTIONAL MATCH (currentUser)-[supports:SUPPORTS_ORG]-(targetOrg) WHERE EXISTS { MATCH (currentUser)<-[:FOR_USER]-(scaleActor:Actor{delpending:false})<-[:ORGANIZATION_TO_ACTOR]-(:Organization{alias:$tildaScaleAlias}), (scaleActor)-[:APPOINTED_AS]->(scaleRole:Role) WHERE coalesce(scaleActor.state, ?) <> ? AND scaleRole.name <> ? } WITH *, false AS repOf WITH *, CASE WHEN orgActor IS NULL THEN EXISTS { MATCH (currentUser)<-[:FOR_USER]-(da:Actor{delpending:false})<-[:STUDY_TO_DELEGATED_ACTOR]-(st:Study{delpending:false})-[:STUDY_TO_ORG]->(targetOrg), (da)-[:APPOINTED_AS]->(dr:Role)<-[:APPOINTED_AS]-(sa:Actor{delpending:false}), (da)-[:DELEGATED_FROM]->(sa)<-[:ORGANIZATION_TO_ACTOR]-(:Organization{alias:$tildaScaleAlias}) WHERE st.srcorgid = targetOrg.tildaid AND da.state <> ? AND sa.state <> ? AND $delegatedTag IN apoc.text.split(coalesce(dr.tags, ?), ?) } ELSE false END as delegated RETURN CASE WHEN orgActor is not null THEN currentUser WHEN delegated THEN currentUser WHEN repOf THEN currentUser WHEN supports is not null THEN coalesce(supportUser, currentUser) ELSE currentUser END as user, CASE WHEN orgActor is not null OR delegated OR repOf OR supports is not null THEN targetOrg ELSE null END as org, currentUser as tokenUser
ontologysvc
7 201 ms 1.65 s 1.38 s flat
OPTIONAL MATCH (u:User {tildaid: $userId}) CALL { WITH u MATCH (u)<-[:FOR_USER]-(:Actor {delpending: false})<-[:ORGANIZATION_TO_ACTOR]-(o:Organization {delpending: false}) RETURN o UNION WITH u MATCH (u)-[:SUPPORTS_ORG]-(o:Organization {de…
OPTIONAL MATCH (u:User {tildaid: $userId}) CALL { WITH u MATCH (u)<-[:FOR_USER]-(:Actor {delpending: false})<-[:ORGANIZATION_TO_ACTOR]-(o:Organization {delpending: false}) RETURN o UNION WITH u MATCH (u)-[:SUPPORTS_ORG]-(o:Organization {delpending: false}) RETURN o UNION WITH u MATCH (u)<-[:FOR_USER]-(da:Actor {delpending: false})<-[:STUDY_TO_DELEGATED_ACTOR]-(dst:Study {delpending: false})-[:STUDY_TO_ORG]->(o:Organization {delpending: false}), (da)-[:APPOINTED_AS]->(dr:Role)<-[:APPOINTED_AS]-(sa:Actor {delpending: false}), (da)-[:DELEGATED_FROM]->(sa)<-[:ORGANIZATION_TO_ACTOR]-(:Organization {alias: $tildaScaleAlias}) WHERE dst.srcorgid = o.tildaid AND da.state <> ? AND sa.state <> ? AND $orgDelegatedTag IN apoc.text.split(coalesce(dr.tags, ?), ?) RETURN o UNION WITH u MATCH (o:Organization {alias: $activeAlias, delpending: false}) RETURN o } OPTIONAL MATCH (st:Study {delpending: false})-[:STUDY_TO_ORG]->(o) RETURN collect(DISTINCT o.alias) AS aliases, collect(DISTINCT o.tildaid) AS orgIds, collect(DISTINCT st.tildaid) AS studyIds
dashql
7 242 ms 1.65 s 1.66 s flat
MATCH (root:GraphNode{tildaid:$graphId}) OPTIONAL MATCH (root)-[:GRAPH_TO_VARIABLE{graphid:root.tildaid}]-(var:VariableV2) WITH root, collect(DISTINCT var) as graphVars MATCH (root)-[rr:GRAPH_NEXT*?..{graphid:root.tildaid}]->(gnode:GraphNo…
MATCH (root:GraphNode{tildaid:$graphId}) OPTIONAL MATCH (root)-[:GRAPH_TO_VARIABLE{graphid:root.tildaid}]-(var:VariableV2) WITH root, collect(DISTINCT var) as graphVars MATCH (root)-[rr:GRAPH_NEXT*?..{graphid:root.tildaid}]->(gnode:GraphNode) WHERE size(rr) = ? OR rr[-?].path[?] = root.tildaid OPTIONAL MATCH (gnode)-[:GRAPH_NODE_TO_PAGE{graphid:root.tildaid}]->(page:GraphPage) OPTIONAL MATCH (gnode)-[:GRAPH_NODE_REF_TO_GRAPH_NODE{graphid:$relPropId}]->(refNode:GraphNode) WHERE gnode.objtype = ? OPTIONAL MATCH (gnode)-[:GRAPH_NODE_REF_TO_QUESTION{graphid:$relPropId}]->(question:QuestionV2) WHERE refNode.objtype = ? WITH root, gnode, page, refNode, case when refNode.objtype = ? then question when refNode.objtype = ? then refNode else null end as question, rr, graphVars OPTIONAL MATCH (question)-[:QUESTION_TO_QUESTION_SPEC]->(questionSpec:QuestionSpec) OPTIONAL MATCH (gnode)-[:BRANCH_CFG_TO_GRAPH_NODE_REF{graphid:$relPropId}]- (nodeBranchCfg:BranchConfig)-[:BRANCH_TO_BRANCH_CONFIG{graphid:$relPropId}]- (nodeBranch:BranchV2) OPTIONAL MATCH (gnode)-[cfgRel:BRANCH_CFG_TO_GRAPH_NODE_REF{graphid:$relPropId}]- (:BranchConfig)-[:ACTIVATION_RULE_TO_BRANCH_CONFIG{graphid:cfgRel.graphid}]- (:ActivationRule)-[:ACTIVATION_RULE_TO_CHAIN{graphid:cfgRel.graphid}]- (nodeChain:ActivationRuleChain) OPTIONAL MATCH (gnode)-[:BRANCH_TO_BRANCH_CONFIG{graphid:root.tildaid, graphid:$relPropId}]->(cfg:BranchConfig) WHERE gnode.objtype = ? OPTIONAL MATCH (cfg)-[:BRANCH_CFG_TO_GRAPH_NODE_REF{graphid:$relPropId}]->(cfgRef:GraphNodeRef) OPTIONAL MATCH (gnode)-[rel:QUESTION_TO_AUTO_COMPUTE_CFG|QUESTION_TO_CORRECTNESS_CHECK{graphid:$relPropId}]->(acc:AutoComputeConfig) OPTIONAL MATCH (acc)-[:AUTO_COMPUTE_TO_BRANCH_CONFIG]->(acBranchCfg:BranchConfig) OPTIONAL MATCH (acBranchCfg)-[:BRANCH_CFG_TO_GRAPH_NODE_REF{graphid:$relPropId}]->(acCfgRef:GraphNodeRef) OPTIONAL MATCH (gnode)-[aqRel:QUESTION_TO_AUTO_QUERY{graphid:$relPropId}]->(aqcfg:AutoQueryConfig{enabled:true}) WHERE aqRel.sourceprotocolid IS NULL OPTIONAL MATCH (aqcfg)-[:AUTO_QUERY_TO_BRANCH_CONFIG]->(aqBranchCfg:BranchConfig) WITH gnode, page, refNode, cfg, rr, questionSpec, question, CASE WHEN size(rr) > ? THEN rr[-?].path ELSE [root.tildaid] END as nodePath, CASE WHEN size(rr) > ? THEN rr[-?].flags ELSE ? END as nodeFlags, CASE WHEN size(rr) > ? THEN rr[-?].who ELSE [] END as nodeWho, CASE WHEN type(rel) = ? THEN true ELSE false END as isCorrectnessCheckConfig, collect(DISTINCT cfgRef.tildaid) as cfgRefIds, collect(DISTINCT nodeBranch.tildaid) as branchIds, collect(DISTINCT nodeChain.tildaid) as activationChainIds, acc, acBranchCfg, collect(DISTINCT acCfgRef.tildaid) as autoComputeBranchRefIds, graphVars, collect(DISTINCT CASE WHEN aqcfg IS NOT NULL THEN {aqcfg: aqcfg, aqBranchCfg: aqBranchCfg} END) as autoQueryConfigs WITH gnode as node, page, refNode, cfg as branchCfg, cfgRefIds as branchRefIds, questionSpec, question, branchIds, activationChainIds, nodePath as path, gnode.objtype as objType, nodeFlags as flags, nodeWho as who, acc as autoComputeConfig, acBranchCfg as autoComputeBranchCfg, autoComputeBranchRefIds, autoQueryConfigs, isCorrectnessCheckConfig, graphVars RETURN {node:node, page:page, refNode:refNode, questionSpec:questionSpec, question:question, branchCfg:branchCfg, branchRefIds:branchRefIds, path:path, objType:objType, flags:flags, who:who, branchIds:branchIds, activationChainIds:activationChainIds, autoComputeConfig:autoComputeConfig, autoComputeBranchCfg:autoComputeBranchCfg, autoComputeBranchRefIds:autoComputeBranchRefIds, autoQueryConfigs:autoQueryConfigs, isCorrectnessCheckConfig:isCorrectnessCheckConfig, graphVars:graphVars}
execsvc
8 135 ms 1.60 s 1.06 s flat
WITH ? as total, null as vector MATCH (doc:Document) WHERE doc.tildaid in $lists.mf0 MATCH (org:Organization{tildaid:$policyOrgId0}) CALL { WITH org, doc UNWIND [doc.studyId] AS studyId OPTIONAL MATCH (study:Study) WHERE study.tildaid = st…
WITH ? as total, null as vector MATCH (doc:Document) WHERE doc.tildaid in $lists.mf0 MATCH (org:Organization{tildaid:$policyOrgId0}) CALL { WITH org, doc UNWIND [doc.studyId] AS studyId OPTIONAL MATCH (study:Study) WHERE study.tildaid = studyId // An inactive actor carries no membership, so it is excluded here rather than at each use: // the sites, countries and roles below all hang off it. OPTIONAL MATCH (study)-[:STUDY_TO_ACTOR]-(studyActor:Actor{orgId:$ctxOrgId0})-[:FOR_USER]->(:User{tildaid:$ctxUserId0}) WHERE studyActor.state <> ? // Collect sites where user has membership in this study OPTIONAL MATCH (studyActor)-[:STUDYSITEACTOR_TO_ACTOR]-(:StudySiteActor)-[:STUDYSITEACTOR_TO_PLAN_DEFINITION]-(pd:DslPlanDefinition)-[:PLAN_DEFINITION_TO_SITE]-(site:Site) WITH org, study, studyActor, collect(DISTINCT site.tildaid) as userSiteIds // Collect countries where user has membership in this study OPTIONAL MATCH (studyActor)<-[:STUDYCOUNTRYACTOR_TO_ACTOR]-(sca:StudyCountryActor) WITH org, study, studyActor, userSiteIds, collect(DISTINCT sca.country) as userCountryIds // Pre-collect policies for this user/role in this study OPTIONAL MATCH (org)<-[:DOC_ACCESS_POLICY_TO_ORG]-(policy:DocumentAccessPolicy{status:?})-[:POLICY_TO_STUDY]->(study) WHERE EXISTS { MATCH (policy)-[:POLICY_FOR_USER]->(:User{tildaid:$ctxUserId0}) } OR (studyActor IS NOT NULL AND EXISTS { MATCH (policy)-[:POLICY_FOR_ROLE]->(role:Role)<-[:APPOINTED_AS]-(studyActor) }) WITH study, studyActor, userSiteIds, userCountryIds, collect(policy) as policies WITH {study:study, studyActor:studyActor, userSiteIds:userSiteIds, userCountryIds:userCountryIds, policies:policies} AS st WITH collect(distinct st) as studies // studyById lets each document row look its context up by study id instead of scanning // the whole list. Entries whose study did not resolve share the ? key; they all carry // the same empty context, so which one wins does not matter. The node-bearing maps go no // further than this subquery; studyIdsInScope needs no lookup, since an id with no Study // node can never equal a matched study?tildaScale?ReadWrite?ReadOnly?s folder and ancestors (up to ? levels for TMF hierarchy) OPTIONAL MATCH (doc1)<-[:INCLUDES]-(docFolder:Folder) OPTIONAL MATCH (docFolder)<-[:INCLUDES*?..?]-(ancestorFolder:Folder) WITH doc1, policies, userSiteIds, userCountryIds, defaultAccessLevel, collect(DISTINCT docFolder) + collect(DISTINCT ancestorFolder) AS folderHierarchy // Check document ownership OPTIONAL MATCH (doc1)-[:UPLOADED_BY]->(uploader:User{tildaid:$policyUploaderId0}) WITH doc1, policies, userSiteIds, userCountryIds, defaultAccessLevel, folderHierarchy, uploader IS NOT NULL AS isOwnedByUser // Filter policies by: // ?. Folder: policy applies if folder is in hierarchy OR policy has no folder (study-wide). A folder-less // ownership policy is the role?Owned Documents?Non Owned Documents?Staging?Pre-Staging?Owned Documents?Non Owned Documents?My Sites Documents?Other Sites Documents?My Countries Documents?Other Countries Documents?Study Scope Documents?NoAccess?NoAccess?ReadOnly?ReadOnly?ReadWrite?ReadOnly?NoAccess? ?Received?Quality Control?PHI Issues???/???/???/???/') ELSE ? END as childFolderPath WITH docObj, ct, child, st, head(collect(childFolderPath)) AS childFolderPath WITH child, CASE WHEN ct IS NULL THEN null ELSE { documentId: child.tildaid, studyId: COALESCE(child.studyId, ?), studyName: COALESCE(st.name, ?), folderPath: childFolderPath, kind: ct.kind, stale: ct.sourceVersionId <> docObj.primaryVersionId, version: COALESCE(child.versionName, toString(child.majorVersion)) } END as copiedToEntry RETURN collect(copiedToEntry) as copiedTo, count(DISTINCT child) as copiedToCount } CALL { WITH doc OPTIONAL MATCH (doc)<-[:PROMOTED_FROM]-(tv:DocumentVersion)<-[:DOCUMENT_VERSION]-(tgt:Document) WITH CASE WHEN tgt IS NULL THEN null ELSE { documentId: tgt.tildaid, targetVersionId: tv.tildaid, version: COALESCE(tv.versionName, toString(tv.majorVersion)) } END as promotedTo RETURN promotedTo LIMIT ? } CALL { return null AS docReviewStatus, null AS hasImportantComment, null AS discrepancyCount } CALL { WITH docObj OPTIONAL MATCH (docObj)<-[:INCLUDES]-(currentFolder:Folder{folderType:?}) WHERE currentFolder.scope IN [?, ?] OPTIONAL MATCH (docObj)-[:FILED_UNDER_SUBARTIFACT]->(currentSubArtifact:SubArtifact)<-[:INCLUDES]-(currentFolder) OPTIONAL MATCH (docObj)-[:HAS_STAGING_INFO]->(stagingInfo:DocumentStagingInfo) WITH CASE WHEN stagingInfo IS NOT NULL THEN {artifactId: stagingInfo.folderId, subArtifactId: stagingInfo.subArtifactId, stagingInfoId: stagingInfo.tildaid} WHEN currentFolder.level = ? THEN {artifactId: currentFolder.tildaid, subArtifactId: COALESCE(currentSubArtifact.tildaid, ?), stagingInfoId: ?} ELSE {artifactId: ?, subArtifactId: ?, stagingInfoId: ?} END as tmfInfo WITH tmfInfo.artifactId as artifactId, tmfInfo.subArtifactId as subArtifactId, tmfInfo.stagingInfoId as stagingInfoId OPTIONAL MATCH (artifact:Folder{tildaid:artifactId})<-[:INCLUDES]-(section:Folder)<-[:INCLUDES]-(zone:Folder)<-[:INCLUDES]-(collection:Folder{name:?}) OPTIONAL MATCH (artifact)-[:INCLUDES]->(allSubArtifacts:SubArtifact) OPTIONAL MATCH (artifact)-[:INCLUDES]->(subArtifact:SubArtifact{tildaid:subArtifactId}) OPTIONAL MATCH (subArtifact)-[:HAS]->(subArtifactConstraints:FolderConstraints) OPTIONAL MATCH (artifact)-[:HAS]->(artifactConstraints:FolderConstraints) WITH artifactId as folderId, subArtifactId, stagingInfoId, CASE WHEN zone.number IS NOT NULL THEN COALESCE(apoc.text.lpad(toString(zone.number), ?, ?)+ ? + zone.name, ?) ELSE ? END as zone, CASE WHEN section.number IS NOT NULL THEN COALESCE(apoc.text.lpad(toString(zone.number), ?, ?)+?+apoc.text.lpad(toString(section.number), ?, ?)+ ? + section.name, ?) ELSE ? END as section, CASE WHEN artifact.number IS NOT NULL THEN COALESCE(apoc.text.lpad(toString(zone.number), ?, ?)+?+apoc.text.lpad(toString(section.number), ?, ?)+?+apoc.text.lpad(toString(artifact.number), ?, ?)+ ? + artifact.name, ?) ELSE ? END as artifact, CASE WHEN subArtifact.number IS NOT NULL THEN COALESCE(apoc.text.lpad(toString(zone.number), ?, ?)+?+apoc.text.lpad(toString(section.number), ?, ?)+?+apoc.text.lpad(toString(artifact.number), ?, ?)+?+apoc.text.lpad(toString(subArtifact.number), ?, ?)+ ? + subArtifact.name, ?) ELSE ? END as subArtifact, COALESCE(subArtifact.name, ?) as subArtifactName, COALESCE(subArtifactConstraints, artifactConstraints) as constraints, NOT(COUNT(allSubArtifacts) > ? AND subArtifactId = ?) as subArtifactValid OPTIONAL MATCH (constraints)-[:HAS_ATTRIBUTE_CONSTRAINT]->(dac:DocAttributeConstraint) WITH folderId, subArtifactId, stagingInfoId, zone, section, artifact, subArtifact, subArtifactName, subArtifactValid, constraints, COLLECT(DISTINCT CASE WHEN dac IS NOT NULL THEN {id: dac.tildaid, key: dac.key, order: dac.order, isMandatory: dac.isMandatory, description: dac.description} ELSE NULL END) as attributeConstraintsList WITH folderId, subArtifactId, stagingInfoId, zone, section, artifact, subArtifact, subArtifactName, subArtifactValid, CASE WHEN constraints IS NOT NULL THEN { id: constraints.tildaid, mandatory: constraints.mandatory, tmfLevel: constraints.tmfLevel, attributeConstraints: [attr IN attributeConstraintsList WHERE attr IS NOT NULL | attr] } ELSE null END as constraints WITH {folderId: folderId, subArtifactId: subArtifactId, stagingInfoId: stagingInfoId, zone: zone, section: section, artifact: artifact, subArtifact: subArtifact, subArtifactName: subArtifactName, subArtifactValid: subArtifactValid, path: apoc.text.join([x IN [zone, section, artifact] WHERE x <> ? | x], ?), constraints: constraints} as tmfCategorization RETURN CASE WHEN tmfCategorization.folderId=? THEN null ELSE tmfCategorization END as tmfCategorization } with distinct doc{.*, status: docObj.status, stateTag: docObj.stateTag, orgAlias: org.alias, owned: owned, docTypeName: doc.docTypeName, userId: doc.userId, user: CASE WHEN user IS NOT NULL THEN {id: user.tildaid, name: user.name, profilePicURL: user.profilePicURL} ELSE NULL END, createdDate: doc.createdat, updatedDate: COALESCE(doc.updatedat, doc.createdat), externalUrl: doc.url, study: study.name, studyId: study.tildaid, site: site.name, siteId: doc.siteId, siteNumber: siteNumber, piNames: piNames, patient: patientName, patientId: doc.patientId, subjectId: subjectId, visit: visit.title, visitId: doc.visitId, reviewDate: reviewDate, assignedToUsers: [], uploadedBy: {id: uploadedBy.tildaid, name: uploadedBy.name, profilePicURL: uploadedBy.profilePicURL}, signedByUsers: signedByUsers, tags: tags, listingFolders: listingFolders, primaryFolder: primaryFolder, latestAIRun: latestAIRun, findingCount: findingCount, queriesCount: queriesCount, confirmedCount: confirmedCount, resolvedCount: resolvedCount, notesCount: notesCount, stagingLabels: stagingLabels, workOrders: workOrders, woContact: COALESCE(woContact, false), stateTags1: stateTags1, stateTags2: stateTags2, docAccessLevel: docAccessLevel, isSigner: isSigner, docReviewStatus: docReviewStatus, hasImportantComment: hasImportantComment, discrepancyCount: discrepancyCount , templateDetails: templateDetails, docTypeDetails: docType{.*}, queries: queries, annotationSpec: annotationSpec, annotationVal: annotationVal, completedAt: annotationVal.completedAt, versions: versions, reviews: reviews, sharedWith: sharedWith, currentShare: currentShare, tmfCategorization: tmfCategorization, docAttributes: docAttributes, eventId: eventId, eventName: eventName, deliverable: deliverable, eventScope: eventScope, provenance: CASE WHEN copiedFrom IS NULL AND size(copiedTo) = ? THEN null ELSE {copiedFrom: copiedFrom, copiedTo: [x IN copiedTo WHERE x IS NOT NULL | x], copiedToCount: copiedToCount} END, promotedTo: promotedTo} AS document, total return document, total
docsvc
9 143 ms 1.55 s 1.17 s flat
MATCH (currentUser:User{deltimestamp:?,deltimestamp:?,email:$email}) WHERE (currentUser.isDummy IS NULL OR currentUser.isDummy <> true) OPTIONAL MATCH (supportUser:User{email:$supportUserEmail}) OPTIONAL MATCH (targetOrg:Organization{delpe…
MATCH (currentUser:User{deltimestamp:?,deltimestamp:?,email:$email}) WHERE (currentUser.isDummy IS NULL OR currentUser.isDummy <> true) OPTIONAL MATCH (supportUser:User{email:$supportUserEmail}) OPTIONAL MATCH (targetOrg:Organization{delpending:false, alias:$orgAlias}) // A deactivated (Inactive) org actor is not a membership (ENG-?). OPTIONAL MATCH (currentUser)-[:FOR_USER]-(orgActor:Actor{delpending:false})-[:ORGANIZATION_TO_ACTOR]-(targetOrg) WHERE coalesce(orgActor.state, ?) <> ? OPTIONAL MATCH (currentUser)-[supports:SUPPORTS_ORG]-(targetOrg) WHERE EXISTS { MATCH (currentUser)<-[:FOR_USER]-(scaleActor:Actor{delpending:false})<-[:ORGANIZATION_TO_ACTOR]-(:Organization{alias:$tildaScaleAlias}), (scaleActor)-[:APPOINTED_AS]->(scaleRole:Role) WHERE coalesce(scaleActor.state, ?) <> ? AND scaleRole.name <> ? } WITH *, false AS repOf // Evaluated only for non-members; members are decided by orgActor alone. WITH *, CASE WHEN orgActor IS NULL THEN EXISTS { MATCH (currentUser)<-[:FOR_USER]-(da:Actor{delpending:false})<-[:STUDY_TO_DELEGATED_ACTOR]-(st:Study{delpending:false})-[:STUDY_TO_ORG]->(targetOrg), (da)-[:APPOINTED_AS]->(dr:Role)<-[:APPOINTED_AS]-(sa:Actor{delpending:false}), (da)-[:DELEGATED_FROM]->(sa)<-[:ORGANIZATION_TO_ACTOR]-(:Organization{alias:$tildaScaleAlias}) WHERE st.srcorgid = targetOrg.tildaid AND da.state <> ? AND sa.state <> ? AND $orgDelegatedTag IN apoc.text.split(coalesce(dr.tags, ?), ?) } ELSE false END as delegated RETURN CASE WHEN orgActor is not null THEN currentUser WHEN delegated THEN currentUser WHEN repOf THEN currentUser WHEN supports is not null THEN coalesce(supportUser, currentUser) ELSE currentUser END as user, CASE WHEN orgActor is not null OR delegated OR repOf OR supports is not null THEN targetOrg ELSE null END as org, currentUser as tokenUser
authzd
9 115 ms 1.55 s 1.02 s flat
MATCH (root:GraphNode{tildaid:$graphId}) OPTIONAL MATCH (root)-[:GRAPH_TO_VARIABLE{graphid:root.tildaid}]-(var:VariableV2) WITH root, collect(DISTINCT var) as graphVars MATCH (root)-[rr:GRAPH_NEXT*?..{graphid:root.tildaid}]->(gnode:GraphNo…
MATCH (root:GraphNode{tildaid:$graphId}) OPTIONAL MATCH (root)-[:GRAPH_TO_VARIABLE{graphid:root.tildaid}]-(var:VariableV2) WITH root, collect(DISTINCT var) as graphVars MATCH (root)-[rr:GRAPH_NEXT*?..{graphid:root.tildaid}]->(gnode:GraphNode) WHERE size(rr) = ? OR rr[-?].path[?] = root.tildaid OPTIONAL MATCH (gnode)-[:GRAPH_NODE_TO_PAGE{graphid:root.tildaid}]->(page:GraphPage) OPTIONAL MATCH (gnode)-[:GRAPH_NODE_REF_TO_GRAPH_NODE{protocolid:$relPropId}]->(refNode:GraphNode) WHERE gnode.objtype = ? OPTIONAL MATCH (gnode)-[:GRAPH_NODE_REF_TO_QUESTION{protocolid:$relPropId}]->(question:QuestionV2) WHERE refNode.objtype = ? WITH root, gnode, page, refNode, case when refNode.objtype = ? then question when refNode.objtype = ? then refNode else null end as question, rr, graphVars OPTIONAL MATCH (question)-[:QUESTION_TO_QUESTION_SPEC]->(questionSpec:QuestionSpec) OPTIONAL MATCH (gnode)-[:BRANCH_CFG_TO_GRAPH_NODE_REF{protocolid:$relPropId}]- (nodeBranchCfg:BranchConfig)-[:BRANCH_TO_BRANCH_CONFIG{protocolid:$relPropId}]- (nodeBranch:BranchV2) OPTIONAL MATCH (gnode)-[cfgRel:BRANCH_CFG_TO_GRAPH_NODE_REF{protocolid:$relPropId}]- (:BranchConfig)-[:ACTIVATION_RULE_TO_BRANCH_CONFIG{graphid:cfgRel.graphid}]- (:ActivationRule)-[:ACTIVATION_RULE_TO_CHAIN{graphid:cfgRel.graphid}]- (nodeChain:ActivationRuleChain) OPTIONAL MATCH (gnode)-[:BRANCH_TO_BRANCH_CONFIG{graphid:root.tildaid, protocolid:$relPropId}]->(cfg:BranchConfig) WHERE gnode.objtype = ? OPTIONAL MATCH (cfg)-[:BRANCH_CFG_TO_GRAPH_NODE_REF{protocolid:$relPropId}]->(cfgRef:GraphNodeRef) OPTIONAL MATCH (gnode)-[rel:QUESTION_TO_AUTO_COMPUTE_CFG|QUESTION_TO_CORRECTNESS_CHECK{protocolid:$relPropId}]->(acc:AutoComputeConfig) OPTIONAL MATCH (acc)-[:AUTO_COMPUTE_TO_BRANCH_CONFIG]->(acBranchCfg:BranchConfig) OPTIONAL MATCH (acBranchCfg)-[:BRANCH_CFG_TO_GRAPH_NODE_REF{protocolid:$relPropId}]->(acCfgRef:GraphNodeRef) OPTIONAL MATCH (gnode)-[aqRel:QUESTION_TO_AUTO_QUERY{protocolid:$relPropId}]->(aqcfg:AutoQueryConfig{enabled:true}) WHERE aqRel.sourceprotocolid IS NULL OPTIONAL MATCH (aqcfg)-[:AUTO_QUERY_TO_BRANCH_CONFIG]->(aqBranchCfg:BranchConfig) WITH gnode, page, refNode, cfg, rr, questionSpec, question, CASE WHEN size(rr) > ? THEN rr[-?].path ELSE [root.tildaid] END as nodePath, CASE WHEN size(rr) > ? THEN rr[-?].flags ELSE ? END as nodeFlags, CASE WHEN size(rr) > ? THEN rr[-?].who ELSE [] END as nodeWho, CASE WHEN type(rel) = ? THEN true ELSE false END as isCorrectnessCheckConfig, collect(DISTINCT cfgRef.tildaid) as cfgRefIds, collect(DISTINCT nodeBranch.tildaid) as branchIds, collect(DISTINCT nodeChain.tildaid) as activationChainIds, acc, acBranchCfg, collect(DISTINCT acCfgRef.tildaid) as autoComputeBranchRefIds, graphVars, collect(DISTINCT CASE WHEN aqcfg IS NOT NULL THEN {aqcfg: aqcfg, aqBranchCfg: aqBranchCfg} END) as autoQueryConfigs WITH gnode as node, page, refNode, cfg as branchCfg, cfgRefIds as branchRefIds, questionSpec, question, branchIds, activationChainIds, nodePath as path, gnode.objtype as objType, nodeFlags as flags, nodeWho as who, acc as autoComputeConfig, acBranchCfg as autoComputeBranchCfg, autoComputeBranchRefIds, autoQueryConfigs, isCorrectnessCheckConfig, graphVars RETURN {node:node, page:page, refNode:refNode, questionSpec:questionSpec, question:question, branchCfg:branchCfg, branchRefIds:branchRefIds, path:path, objType:objType, flags:flags, who:who, branchIds:branchIds, activationChainIds:activationChainIds, autoComputeConfig:autoComputeConfig, autoComputeBranchCfg:autoComputeBranchCfg, autoComputeBranchRefIds:autoComputeBranchRefIds, autoQueryConfigs:autoQueryConfigs, isCorrectnessCheckConfig:isCorrectnessCheckConfig, graphVars:graphVars}
execsvc
10 127 ms 1.50 s 1.24 s flat
MATCH (currentUser:User {deltimestamp:?}) WHERE (currentUser.isDummy IS NULL OR currentUser.isDummy <> true) AND currentUser.email = $ident OPTIONAL MATCH (supportUser:User {email:$supportEmail}) OPTIONAL MATCH (targetOrg:Organization {del…
MATCH (currentUser:User {deltimestamp:?}) WHERE (currentUser.isDummy IS NULL OR currentUser.isDummy <> true) AND currentUser.email = $ident OPTIONAL MATCH (supportUser:User {email:$supportEmail}) OPTIONAL MATCH (targetOrg:Organization {delpending:false, alias:$org}) OPTIONAL MATCH (currentUser)-[:FOR_USER]-(orgActor:Actor{delpending:false})-[:ORGANIZATION_TO_ACTOR]-(targetOrg) WHERE coalesce(orgActor.state, ?) <> ? OPTIONAL MATCH (currentUser)-[supports:SUPPORTS_ORG]-(targetOrg) WITH *, false AS repOf WITH *, CASE WHEN orgActor IS NULL THEN EXISTS { MATCH (currentUser)<-[:FOR_USER]-(da:Actor{delpending:false})<-[:STUDY_TO_DELEGATED_ACTOR]-(st:Study{delpending:false})-[:STUDY_TO_ORG]->(targetOrg), (da)-[:APPOINTED_AS]->(dr:Role)<-[:APPOINTED_AS]-(sa:Actor{delpending:false}), (da)-[:DELEGATED_FROM]->(sa)<-[:ORGANIZATION_TO_ACTOR]-(:Organization{alias:$scaleAlias}) WHERE st.srcorgid = targetOrg.tildaid AND da.state <> ? AND sa.state <> ? AND $delegatedTag IN apoc.text.split(coalesce(dr.tags, ?), ?) } ELSE false END as delegated RETURN CASE WHEN orgActor is not null THEN currentUser WHEN delegated THEN currentUser WHEN repOf THEN currentUser WHEN supports is not null THEN coalesce(supportUser, currentUser) ELSE currentUser END as user, CASE WHEN orgActor is not null OR delegated OR repOf OR supports is not null THEN targetOrg ELSE null END as org, currentUser as tokenUser
chat-agent
10 139 ms 1.50 s 1.33 s flat
MATCH (currentUser:User{deltimestamp:?,deltimestamp:?,email:$email}) WHERE (currentUser.isDummy IS NULL OR currentUser.isDummy <> true) OPTIONAL MATCH (supportUser:User{email:$supportUserEmail}) OPTIONAL MATCH (targetOrg:Organization{delpe…
MATCH (currentUser:User{deltimestamp:?,deltimestamp:?,email:$email}) WHERE (currentUser.isDummy IS NULL OR currentUser.isDummy <> true) OPTIONAL MATCH (supportUser:User{email:$supportUserEmail}) OPTIONAL MATCH (targetOrg:Organization{delpending:false, alias:$orgAlias}) // A deactivated (Inactive) org actor is not a membership (ENG-?). OPTIONAL MATCH (currentUser)-[:FOR_USER]-(orgActor:Actor{delpending:false})-[:ORGANIZATION_TO_ACTOR]-(targetOrg) WHERE coalesce(orgActor.state, ?) <> ? OPTIONAL MATCH (currentUser)-[supports:SUPPORTS_ORG]-(targetOrg) WHERE EXISTS { MATCH (currentUser)<-[:FOR_USER]-(scaleActor:Actor{delpending:false})<-[:ORGANIZATION_TO_ACTOR]-(:Organization{alias:$tildaScaleAlias}), (scaleActor)-[:APPOINTED_AS]->(scaleRole:Role) WHERE coalesce(scaleActor.state, ?) <> ? AND scaleRole.name <> ? } WITH *, false AS repOf // Evaluated only for non-members; members are decided by orgActor alone. WITH *, CASE WHEN orgActor IS NULL THEN EXISTS { MATCH (currentUser)<-[:FOR_USER]-(da:Actor{delpending:false})<-[:STUDY_TO_DELEGATED_ACTOR]-(st:Study{delpending:false})-[:STUDY_TO_ORG]->(targetOrg), (da)-[:APPOINTED_AS]->(dr:Role)<-[:APPOINTED_AS]-(sa:Actor{delpending:false}), (da)-[:DELEGATED_FROM]->(sa)<-[:ORGANIZATION_TO_ACTOR]-(:Organization{alias:$tildaScaleAlias}) WHERE st.srcorgid = targetOrg.tildaid AND da.state <> ? AND sa.state <> ? AND $orgDelegatedTag IN apoc.text.split(coalesce(dr.tags, ?), ?) } ELSE false END as delegated RETURN CASE WHEN orgActor is not null THEN currentUser WHEN delegated THEN currentUser WHEN repOf THEN currentUser WHEN supports is not null THEN coalesce(supportUser, currentUser) ELSE currentUser END as user, CASE WHEN orgActor is not null OR delegated OR repOf OR supports is not null THEN targetOrg ELSE null END as org, currentUser as tokenUser
authzd
10 125 ms 1.50 s 1.00 s flat
WITH ? as total, null as vector MATCH (doc:Document) WHERE doc.tildaid in $lists.mf0 MATCH (org:Organization{tildaid:$policyOrgId0}) CALL { WITH org, doc UNWIND [doc.studyId] AS studyId OPTIONAL MATCH (study:Study) WHERE study.tildaid = st…
WITH ? as total, null as vector MATCH (doc:Document) WHERE doc.tildaid in $lists.mf0 MATCH (org:Organization{tildaid:$policyOrgId0}) CALL { WITH org, doc UNWIND [doc.studyId] AS studyId OPTIONAL MATCH (study:Study) WHERE study.tildaid = studyId // An inactive actor carries no membership, so it is excluded here rather than at each use: // the sites, countries and roles below all hang off it. OPTIONAL MATCH (study)-[:STUDY_TO_ACTOR]-(studyActor:Actor{orgId:$ctxOrgId0})-[:FOR_USER]->(:User{tildaid:$ctxUserId0}) WHERE studyActor.state <> ? // Collect sites where user has membership in this study OPTIONAL MATCH (studyActor)-[:STUDYSITEACTOR_TO_ACTOR]-(:StudySiteActor)-[:STUDYSITEACTOR_TO_PLAN_DEFINITION]-(pd:DslPlanDefinition)-[:PLAN_DEFINITION_TO_SITE]-(site:Site) WITH org, study, studyActor, collect(DISTINCT site.tildaid) as userSiteIds // Collect countries where user has membership in this study OPTIONAL MATCH (studyActor)<-[:STUDYCOUNTRYACTOR_TO_ACTOR]-(sca:StudyCountryActor) WITH org, study, studyActor, userSiteIds, collect(DISTINCT sca.country) as userCountryIds // Pre-collect policies for this user/role in this study OPTIONAL MATCH (org)<-[:DOC_ACCESS_POLICY_TO_ORG]-(policy:DocumentAccessPolicy{status:?})-[:POLICY_TO_STUDY]->(study) WHERE EXISTS { MATCH (policy)-[:POLICY_FOR_USER]->(:User{tildaid:$ctxUserId0}) } OR (studyActor IS NOT NULL AND EXISTS { MATCH (policy)-[:POLICY_FOR_ROLE]->(role:Role)<-[:APPOINTED_AS]-(studyActor) }) WITH study, studyActor, userSiteIds, userCountryIds, collect(policy) as policies WITH {study:study, studyActor:studyActor, userSiteIds:userSiteIds, userCountryIds:userCountryIds, policies:policies} AS st WITH collect(distinct st) as studies // studyById lets each document row look its context up by study id instead of scanning // the whole list. Entries whose study did not resolve share the ? key; they all carry // the same empty context, so which one wins does not matter. The node-bearing maps go no // further than this subquery; studyIdsInScope needs no lookup, since an id with no Study // node can never equal a matched study?tildaScale?ReadWrite?ReadOnly?s folder and ancestors (up to ? levels for TMF hierarchy) OPTIONAL MATCH (doc1)<-[:INCLUDES]-(docFolder:Folder) OPTIONAL MATCH (docFolder)<-[:INCLUDES*?..?]-(ancestorFolder:Folder) WITH doc1, policies, userSiteIds, userCountryIds, defaultAccessLevel, collect(DISTINCT docFolder) + collect(DISTINCT ancestorFolder) AS folderHierarchy // Check document ownership OPTIONAL MATCH (doc1)-[:UPLOADED_BY]->(uploader:User{tildaid:$policyUploaderId0}) WITH doc1, policies, userSiteIds, userCountryIds, defaultAccessLevel, folderHierarchy, uploader IS NOT NULL AS isOwnedByUser // Filter policies by: // ?. Folder: policy applies if folder is in hierarchy OR policy has no folder (study-wide). A folder-less // ownership policy is the role?Owned Documents?Non Owned Documents?Staging?Pre-Staging?Owned Documents?Non Owned Documents?My Sites Documents?Other Sites Documents?My Countries Documents?Other Countries Documents?Study Scope Documents?NoAccess?NoAccess?ReadOnly?ReadOnly?ReadWrite?ReadOnly?NoAccess? ?Received?Quality Control?PHI Issues???/???/???/???/') ELSE ? END as childFolderPath WITH docObj, ct, child, st, head(collect(childFolderPath)) AS childFolderPath WITH child, CASE WHEN ct IS NULL THEN null ELSE { documentId: child.tildaid, studyId: COALESCE(child.studyId, ?), studyName: COALESCE(st.name, ?), folderPath: childFolderPath, kind: ct.kind, stale: ct.sourceVersionId <> docObj.primaryVersionId, version: COALESCE(child.versionName, toString(child.majorVersion)) } END as copiedToEntry RETURN collect(copiedToEntry) as copiedTo, count(DISTINCT child) as copiedToCount } CALL { WITH doc OPTIONAL MATCH (doc)<-[:PROMOTED_FROM]-(tv:DocumentVersion)<-[:DOCUMENT_VERSION]-(tgt:Document) WITH CASE WHEN tgt IS NULL THEN null ELSE { documentId: tgt.tildaid, targetVersionId: tv.tildaid, version: COALESCE(tv.versionName, toString(tv.majorVersion)) } END as promotedTo RETURN promotedTo LIMIT ? } CALL { return null AS docReviewStatus, null AS hasImportantComment, null AS discrepancyCount } CALL { WITH docObj OPTIONAL MATCH (docObj)<-[:INCLUDES]-(currentFolder:Folder{folderType:?}) WHERE currentFolder.scope IN [?, ?] OPTIONAL MATCH (docObj)-[:FILED_UNDER_SUBARTIFACT]->(currentSubArtifact:SubArtifact)<-[:INCLUDES]-(currentFolder) OPTIONAL MATCH (docObj)-[:HAS_STAGING_INFO]->(stagingInfo:DocumentStagingInfo) WITH CASE WHEN stagingInfo IS NOT NULL THEN {artifactId: stagingInfo.folderId, subArtifactId: stagingInfo.subArtifactId, stagingInfoId: stagingInfo.tildaid} WHEN currentFolder.level = ? THEN {artifactId: currentFolder.tildaid, subArtifactId: COALESCE(currentSubArtifact.tildaid, ?), stagingInfoId: ?} ELSE {artifactId: ?, subArtifactId: ?, stagingInfoId: ?} END as tmfInfo WITH tmfInfo.artifactId as artifactId, tmfInfo.subArtifactId as subArtifactId, tmfInfo.stagingInfoId as stagingInfoId OPTIONAL MATCH (artifact:Folder{tildaid:artifactId})<-[:INCLUDES]-(section:Folder)<-[:INCLUDES]-(zone:Folder)<-[:INCLUDES]-(collection:Folder{name:?}) OPTIONAL MATCH (artifact)-[:INCLUDES]->(allSubArtifacts:SubArtifact) OPTIONAL MATCH (artifact)-[:INCLUDES]->(subArtifact:SubArtifact{tildaid:subArtifactId}) OPTIONAL MATCH (subArtifact)-[:HAS]->(subArtifactConstraints:FolderConstraints) OPTIONAL MATCH (artifact)-[:HAS]->(artifactConstraints:FolderConstraints) WITH artifactId as folderId, subArtifactId, stagingInfoId, CASE WHEN zone.number IS NOT NULL THEN COALESCE(apoc.text.lpad(toString(zone.number), ?, ?)+ ? + zone.name, ?) ELSE ? END as zone, CASE WHEN section.number IS NOT NULL THEN COALESCE(apoc.text.lpad(toString(zone.number), ?, ?)+?+apoc.text.lpad(toString(section.number), ?, ?)+ ? + section.name, ?) ELSE ? END as section, CASE WHEN artifact.number IS NOT NULL THEN COALESCE(apoc.text.lpad(toString(zone.number), ?, ?)+?+apoc.text.lpad(toString(section.number), ?, ?)+?+apoc.text.lpad(toString(artifact.number), ?, ?)+ ? + artifact.name, ?) ELSE ? END as artifact, CASE WHEN subArtifact.number IS NOT NULL THEN COALESCE(apoc.text.lpad(toString(zone.number), ?, ?)+?+apoc.text.lpad(toString(section.number), ?, ?)+?+apoc.text.lpad(toString(artifact.number), ?, ?)+?+apoc.text.lpad(toString(subArtifact.number), ?, ?)+ ? + subArtifact.name, ?) ELSE ? END as subArtifact, COALESCE(subArtifact.name, ?) as subArtifactName, COALESCE(subArtifactConstraints, artifactConstraints) as constraints, NOT(COUNT(allSubArtifacts) > ? AND subArtifactId = ?) as subArtifactValid OPTIONAL MATCH (constraints)-[:HAS_ATTRIBUTE_CONSTRAINT]->(dac:DocAttributeConstraint) WITH folderId, subArtifactId, stagingInfoId, zone, section, artifact, subArtifact, subArtifactName, subArtifactValid, constraints, COLLECT(DISTINCT CASE WHEN dac IS NOT NULL THEN {id: dac.tildaid, key: dac.key, order: dac.order, isMandatory: dac.isMandatory, description: dac.description} ELSE NULL END) as attributeConstraintsList WITH folderId, subArtifactId, stagingInfoId, zone, section, artifact, subArtifact, subArtifactName, subArtifactValid, CASE WHEN constraints IS NOT NULL THEN { id: constraints.tildaid, mandatory: constraints.mandatory, tmfLevel: constraints.tmfLevel, attributeConstraints: [attr IN attributeConstraintsList WHERE attr IS NOT NULL | attr] } ELSE null END as constraints WITH {folderId: folderId, subArtifactId: subArtifactId, stagingInfoId: stagingInfoId, zone: zone, section: section, artifact: artifact, subArtifact: subArtifact, subArtifactName: subArtifactName, subArtifactValid: subArtifactValid, path: apoc.text.join([x IN [zone, section, artifact] WHERE x <> ? | x], ?), constraints: constraints} as tmfCategorization RETURN CASE WHEN tmfCategorization.folderId=? THEN null ELSE tmfCategorization END as tmfCategorization } with distinct doc{.*, status: docObj.status, stateTag: docObj.stateTag, orgAlias: org.alias, owned: owned, docTypeName: doc.docTypeName, userId: doc.userId, user: CASE WHEN user IS NOT NULL THEN {id: user.tildaid, name: user.name, profilePicURL: user.profilePicURL} ELSE NULL END, createdDate: doc.createdat, updatedDate: COALESCE(doc.updatedat, doc.createdat), externalUrl: doc.url, study: study.name, studyId: study.tildaid, site: site.name, siteId: doc.siteId, siteNumber: siteNumber, piNames: piNames, patient: patientName, patientId: doc.patientId, subjectId: subjectId, visit: visit.title, visitId: doc.visitId, reviewDate: reviewDate, assignedToUsers: [], uploadedBy: {id: uploadedBy.tildaid, name: uploadedBy.name, profilePicURL: uploadedBy.profilePicURL}, signedByUsers: signedByUsers, tags: tags, listingFolders: listingFolders, primaryFolder: primaryFolder, latestAIRun: latestAIRun, findingCount: findingCount, queriesCount: queriesCount, confirmedCount: confirmedCount, resolvedCount: resolvedCount, notesCount: notesCount, stagingLabels: stagingLabels, workOrders: workOrders, woContact: COALESCE(woContact, false), stateTags1: stateTags1, stateTags2: stateTags2, docAccessLevel: docAccessLevel, isSigner: isSigner, docReviewStatus: docReviewStatus, hasImportantComment: hasImportantComment, discrepancyCount: discrepancyCount , templateDetails: templateDetails, docTypeDetails: docType{.*}, queries: queries, annotationSpec: annotationSpec, annotationVal: annotationVal, completedAt: annotationVal.completedAt, versions: versions, reviews: reviews, sharedWith: sharedWith, currentShare: currentShare, tmfCategorization: tmfCategorization, docAttributes: docAttributes, eventId: eventId, eventName: eventName, deliverable: deliverable, eventScope: eventScope, provenance: CASE WHEN copiedFrom IS NULL AND size(copiedTo) = ? THEN null ELSE {copiedFrom: copiedFrom, copiedTo: [x IN copiedTo WHERE x IS NOT NULL | x], copiedToCount: copiedToCount} END, promotedTo: promotedTo} AS document, total return document, total
docsvc
13 98 ms 1.35 s 1.10 s flat
UNWIND $rows AS row MATCH (a:Folder{tildaid:row.fromId}) MATCH (b:DocTypeDetails{tildaid:row.toId}) MERGE (a)-[r:CONTAINS]->(b) ON CREATE SET r += row.props, r.tildaid = randomUUID(), r.createdat = timestamp() ON MATCH SET r.updatedat = ti…
UNWIND $rows AS row MATCH (a:Folder{tildaid:row.fromId}) MATCH (b:DocTypeDetails{tildaid:row.toId}) MERGE (a)-[r:CONTAINS]->(b) ON CREATE SET r += row.props, r.tildaid = randomUUID(), r.createdat = timestamp() ON MATCH SET r.updatedat = timestamp() RETURN count(r)
write docsvc
101 251 ms 998 ms 1.43 s flat
OPTIONAL MATCH (u:User {tildaid: $userId}) CALL { WITH u MATCH (u)<-[:FOR_USER]-(:Actor {delpending: false})<-[:ORGANIZATION_TO_ACTOR]-(o:Organization {delpending: false}) RETURN o UNION WITH u MATCH (u)-[:SUPPORTS_ORG]-(o:Organization {de…
OPTIONAL MATCH (u:User {tildaid: $userId}) CALL { WITH u MATCH (u)<-[:FOR_USER]-(:Actor {delpending: false})<-[:ORGANIZATION_TO_ACTOR]-(o:Organization {delpending: false}) RETURN o UNION WITH u MATCH (u)-[:SUPPORTS_ORG]-(o:Organization {delpending: false}) RETURN o UNION WITH u MATCH (u)<-[:FOR_USER]-(da:Actor {delpending: false})<-[:STUDY_TO_DELEGATED_ACTOR]-(dst:Study {delpending: false})-[:STUDY_TO_ORG]->(o:Organization {delpending: false}), (da)-[:APPOINTED_AS]->(dr:Role)<-[:APPOINTED_AS]-(sa:Actor {delpending: false}), (da)-[:DELEGATED_FROM]->(sa)<-[:ORGANIZATION_TO_ACTOR]-(:Organization {alias: $tildaScaleAlias}) WHERE dst.srcorgid = o.tildaid AND da.state <> ? AND sa.state <> ? AND $orgDelegatedTag IN apoc.text.split(coalesce(dr.tags, ?), ?) RETURN o UNION WITH u MATCH (o:Organization {alias: $activeAlias, delpending: false}) RETURN o } OPTIONAL MATCH (st:Study {delpending: false})-[:STUDY_TO_ORG]->(o) RETURN collect(DISTINCT o.alias) AS aliases, collect(DISTINCT o.tildaid) AS orgIds, collect(DISTINCT st.tildaid) AS studyIds
dashql
1 803 ms 975 ms 803 ms flat
MATCH (n:GraphNode)-[r:GRAPH_NEXT]->(n) DELETE r
MATCH (n:GraphNode)-[r:GRAPH_NEXT]->(n) DELETE r
write studiosvc
1 758 ms 975 ms 758 ms flat
MATCH (currentUser:User {deltimestamp:?}) WHERE (currentUser.isDummy IS NULL OR currentUser.isDummy <> true) AND currentUser.email = $ident OPTIONAL MATCH (supportUser:User {email:$supportEmail}) OPTIONAL MATCH (targetOrg:Organization {del…
MATCH (currentUser:User {deltimestamp:?}) WHERE (currentUser.isDummy IS NULL OR currentUser.isDummy <> true) AND currentUser.email = $ident OPTIONAL MATCH (supportUser:User {email:$supportEmail}) OPTIONAL MATCH (targetOrg:Organization {delpending:false, alias:$org}) OPTIONAL MATCH (currentUser)-[:FOR_USER]-(orgActor:Actor{delpending:false})-[:ORGANIZATION_TO_ACTOR]-(targetOrg) WHERE coalesce(orgActor.state, ?) <> ? OPTIONAL MATCH (currentUser)-[supports:SUPPORTS_ORG]-(targetOrg) WHERE EXISTS { MATCH (currentUser)<-[:FOR_USER]-(scaleActor:Actor{delpending:false})<-[:ORGANIZATION_TO_ACTOR]-(:Organization{alias:$tildaScaleAlias}), (scaleActor)-[:APPOINTED_AS]->(scaleRole:Role) WHERE coalesce(scaleActor.state, ?) <> ? AND scaleRole.name <> ? } WITH *, false AS repOf WITH *, CASE WHEN orgActor IS NULL THEN EXISTS { MATCH (currentUser)<-[:FOR_USER]-(da:Actor{delpending:false})<-[:STUDY_TO_DELEGATED_ACTOR]-(st:Study{delpending:false})-[:STUDY_TO_ORG]->(targetOrg), (da)-[:APPOINTED_AS]->(dr:Role)<-[:APPOINTED_AS]-(sa:Actor{delpending:false}), (da)-[:DELEGATED_FROM]->(sa)<-[:ORGANIZATION_TO_ACTOR]-(:Organization{alias:$tildaScaleAlias}) WHERE st.srcorgid = targetOrg.tildaid AND da.state <> ? AND sa.state <> ? AND $delegatedTag IN apoc.text.split(coalesce(dr.tags, ?), ?) } ELSE false END as delegated RETURN CASE WHEN orgActor is not null THEN currentUser WHEN delegated THEN currentUser WHEN repOf THEN currentUser WHEN supports is not null THEN coalesce(supportUser, currentUser) ELSE currentUser END as user, CASE WHEN orgActor is not null OR delegated OR repOf OR supports is not null THEN targetOrg ELSE null END as org, currentUser as tokenUser
ontologysvc
1 787 ms 975 ms 787 ms flat
MATCH (ctx:Study)<-[:PLAN_CONTEXT]-(ep:EventPlan {orgId: $orgId})-[:EVENTS]->(e:Event) WHERE ctx.tildaid IN $contextIds WITH DISTINCT e WHERE e.isTemplate = $isTemplate AND e.status = $status WITH DISTINCT e ORDER BY e.createdat DESC SKIP …
MATCH (ctx:Study)<-[:PLAN_CONTEXT]-(ep:EventPlan {orgId: $orgId})-[:EVENTS]->(e:Event) WHERE ctx.tildaid IN $contextIds WITH DISTINCT e WHERE e.isTemplate = $isTemplate AND e.status = $status WITH DISTINCT e ORDER BY e.createdat DESC SKIP $skip LIMIT $limit OPTIONAL MATCH (e)<-[:EVENTS]-(ep:EventPlan)-[:PLAN_CONTEXT]->(study) WITH e, study CALL { WITH e, study // Get details for each scope in the event OPTIONAL MATCH (e)<-[:PART_OF_EVENT]-(scope:EventScope) OPTIONAL MATCH (site:Site {tildaid: scope.scopeId}) OPTIONAL MATCH (site)-[:PLAN_DEFINITION_TO_SITE]-(pd:DslPlanDefinition{type:?})-[:PLAN_DEFINITION_TO_STUDY]->(study) WITH scope, CASE WHEN scope.scopeType = ? THEN site.name ELSE ? END as siteName, CASE WHEN scope.scopeType = ? THEN COALESCE(pd.siteNumber, ?) ELSE ? END as siteNumber OPTIONAL MATCH (scope)-[:APPLICABLE_TO]->(scopeDeliverable:Deliverable) CALL { // Get details of each deliverable applicable to the scope WITH scope, scopeDeliverable OPTIONAL MATCH (scopeDeliverable)-[tracksRel:TRACKS_PLACEHOLDER]->(ph:Document)-[:SCOPED_TO]->(scope) CALL { // Get match status for each placeholder WITH ph, tracksRel, scope OPTIONAL MATCH (ph)-[acceptedRel:ACCEPTED_DOCUMENT]->(acceptedDoc:Document) OPTIONAL MATCH (ph)-[matchRel:MATCHING_DOCUMENT]->(matchDoc:Document) WHERE acceptedDoc IS NULL OR matchDoc.tildaid <> acceptedDoc.tildaid WITH ph, tracksRel, scope, acceptedDoc, [m IN collect(matchDoc) WHERE m IS NOT NULL] as matchDocs WITH ph, tracksRel, scope, acceptedDoc, CASE WHEN ph.status <> ? THEN ? WHEN acceptedDoc IS NOT NULL THEN ? WHEN SIZE(matchDocs) > ? AND all(m IN matchDocs WHERE m.collection = ?) THEN ? WHEN SIZE(matchDocs) > ? THEN ? ELSE ? END as matchStatus RETURN CASE WHEN ph IS NULL THEN null ELSE {tildaid: ph.tildaid, fileName: ph.fileName, status: matchStatus, placeholderState: COALESCE(tracksRel.state, ?), archived: coalesce(ph.archived, false) OR scope.status = ?} END as deliverablePlaceholder } WITH collect(DISTINCT deliverablePlaceholder) as deliverablePlaceholders WITH [d IN deliverablePlaceholders WHERE d IS NOT NULL] as allPlaceholders RETURN allPlaceholders as deliverablePlaceholders, { total: size(allPlaceholders), pending: size([pp IN allPlaceholders WHERE pp.placeholderState IN [?, ?]]), pendingForDelete: size([pp IN allPlaceholders WHERE pp.placeholderState = ?]), accepted: size([pp IN allPlaceholders WHERE pp.placeholderState = ?]), rejected: size([pp IN allPlaceholders WHERE pp.placeholderState = ?]), incomplete: size([pp IN allPlaceholders WHERE pp.status = ?]), potentialMatchFound: size([pp IN allPlaceholders WHERE pp.status = ?]), matchExpected: size([pp IN allPlaceholders WHERE pp.status = ?]), matched: size([pp IN allPlaceholders WHERE pp.status = ?]), finalized: size([pp IN allPlaceholders WHERE pp.status = ?]), completion: {required: size([pp IN allPlaceholders WHERE NOT (pp.placeholderState = ? OR coalesce(pp.archived, false)) AND (pp.placeholderState IN [?, ?] OR pp.status = ?)]), completed: size([pp IN allPlaceholders WHERE NOT (pp.placeholderState = ? OR coalesce(pp.archived, false)) AND (pp.placeholderState IN [?, ?] OR pp.status = ?) AND pp.status IN [?, ?]]), aiSuggested: size([pp IN allPlaceholders WHERE NOT (pp.placeholderState = ? OR coalesce(pp.archived, false)) AND (pp.placeholderState IN [?, ?] OR pp.status = ?) AND pp.status = ?]), inStaging: size([pp IN allPlaceholders WHERE NOT (pp.placeholderState = ? OR coalesce(pp.archived, false)) AND (pp.placeholderState IN [?, ?] OR pp.status = ?) AND pp.status = ?]), noMatchFound: size([pp IN allPlaceholders WHERE NOT (pp.placeholderState = ? OR coalesce(pp.archived, false)) AND (pp.placeholderState IN [?, ?] OR pp.status = ?) AND pp.status = ?]), notConfirmed: size([pp IN allPlaceholders WHERE NOT (pp.placeholderState = ? OR coalesce(pp.archived, false)) AND pp.placeholderState = ? AND NOT pp.status = ?]), removed: size([pp IN allPlaceholders WHERE (pp.placeholderState = ? OR coalesce(pp.archived, false))]), percentComplete: CASE WHEN size([pp IN allPlaceholders WHERE NOT (pp.placeholderState = ? OR coalesce(pp.archived, false)) AND (pp.placeholderState IN [?, ?] OR pp.status = ?)]) = ? THEN null ELSE toInteger(floor(?.? * size([pp IN allPlaceholders WHERE NOT (pp.placeholderState = ? OR coalesce(pp.archived, false)) AND (pp.placeholderState IN [?, ?] OR pp.status = ?) AND pp.status IN [?, ?]]) / size([pp IN allPlaceholders WHERE NOT (pp.placeholderState = ? OR coalesce(pp.archived, false)) AND (pp.placeholderState IN [?, ?] OR pp.status = ?)]))) END, isComplete: size([pp IN allPlaceholders WHERE NOT (pp.placeholderState = ? OR coalesce(pp.archived, false)) AND (pp.placeholderState IN [?, ?] OR pp.status = ?)]) > ? AND size([pp IN allPlaceholders WHERE NOT (pp.placeholderState = ? OR coalesce(pp.archived, false)) AND (pp.placeholderState IN [?, ?] OR pp.status = ?) AND pp.status IN [?, ?]]) = size([pp IN allPlaceholders WHERE NOT (pp.placeholderState = ? OR coalesce(pp.archived, false)) AND (pp.placeholderState IN [?, ?] OR pp.status = ?)])} } as deliverableStats } // Aggregate all deliverables in the scope WITH scope, siteName, siteNumber, deliverableStats WITH distinct scope, siteName, siteNumber, { total: sum(deliverableStats.total), pending: sum(deliverableStats.pending), pendingForDelete: sum(deliverableStats.pendingForDelete), accepted: sum(deliverableStats.accepted), rejected: sum(deliverableStats.rejected), incomplete: sum(deliverableStats.incomplete), potentialMatchFound: sum(deliverableStats.potentialMatchFound), matchExpected: sum(deliverableStats.matchExpected), matched: sum(deliverableStats.matched), finalized: sum(deliverableStats.finalized), completion: {required: sum(deliverableStats.completion.required), completed: sum(deliverableStats.completion.completed), aiSuggested: sum(deliverableStats.completion.aiSuggested), inStaging: sum(deliverableStats.completion.inStaging), noMatchFound: sum(deliverableStats.completion.noMatchFound), notConfirmed: sum(deliverableStats.completion.notConfirmed), removed: sum(deliverableStats.completion.removed), percentComplete: CASE WHEN sum(deliverableStats.completion.required) = ? THEN null ELSE toInteger(floor(?.? * sum(deliverableStats.completion.completed) / sum(deliverableStats.completion.required))) END, isComplete: sum(deliverableStats.completion.required) > ? AND sum(deliverableStats.completion.completed) = sum(deliverableStats.completion.required)} } as scopeStats RETURN distinct scope{.*, siteName: siteName, siteNumber: siteNumber} as scope, scopeStats } CALL { // Collect summary for all deliverable in the event WITH e OPTIONAL MATCH (e)-[:REQUIRES_RESOLUTION_OF]->(eventDel:Deliverable) WITH collect(eventDel) as deliverables, [d IN collect(distinct eventDel) WHERE d.warning IS NOT NULL AND d.warning <> ? | ??\? + d.warning] as deliverableWarnings RETURN { trialDeliverables: SIZE([d in deliverables WHERE d.applyToTrial = true]), countryDeliverables: SIZE([d in deliverables WHERE d.applyToCountries = true]), siteDeliverables: SIZE([d in deliverables WHERE d.applyToSites = true]) } as deliverableCounts, deliverableWarnings } CALL { // Fetch createdBy WITH e OPTIONAL MATCH (e)-[:ALL_CHANGELOG]->(cl:ChangeLog{operation:?}) WITH cl ORDER BY cl.createdat ASC limit ? OPTIONAL MATCH (u:User{tildaid:cl.changedBy}) return {id: u.tildaid, name: u.name, profilePicURL: u.profilePicURL} as createdBy } // Aggregate all scopes and all deliverables in the event WITH e, study, createdBy, deliverableCounts, deliverableWarnings, collect(scope) as eventScopes, { total: sum(scopeStats.total), pending: sum(scopeStats.pending), pendingForDelete: sum(scopeStats.pendingForDelete), accepted: sum(scopeStats.accepted), rejected: sum(scopeStats.rejected), incomplete: sum(scopeStats.incomplete), potentialMatchFound: sum(scopeStats.potentialMatchFound), matchExpected: sum(scopeStats.matchExpected), matched: sum(scopeStats.matched), finalized: sum(scopeStats.finalized), completion: {required: sum(scopeStats.completion.required), completed: sum(scopeStats.completion.completed), aiSuggested: sum(scopeStats.completion.aiSuggested), inStaging: sum(scopeStats.completion.inStaging), noMatchFound: sum(scopeStats.completion.noMatchFound), notConfirmed: sum(scopeStats.completion.notConfirmed), removed: sum(scopeStats.completion.removed), percentComplete: CASE WHEN sum(scopeStats.completion.required) = ? THEN null ELSE toInteger(floor(?.? * sum(scopeStats.completion.completed) / sum(scopeStats.completion.required))) END, isComplete: sum(scopeStats.completion.required) > ? AND sum(scopeStats.completion.completed) = sum(scopeStats.completion.required)} } as eventProgress WITH e, study, createdBy, deliverableCounts, deliverableWarnings, eventProgress, eventScopes, { totalCountries: SIZE([s IN eventScopes WHERE s.scopeType = ?]), totalSites: SIZE([s IN eventScopes WHERE s.scopeType = ?]), countries: [s IN eventScopes WHERE s.scopeType = ? | {name: s.scopeId, id: s.scopeId}], sites: [s IN eventScopes WHERE s.scopeType = ? | {name: s.siteName, id: s.scopeId, siteNumber: s.siteNumber}] } as scopeSummary CALL { WITH e OPTIONAL MATCH (woc:WorkOrderConfig)-[:WORK_ORDER_CONFIG_TO_EVENT]->(e) RETURN woc.tildaid as workOrderConfigId LIMIT ? } RETURN e{.*, createdBy: createdBy, warnings: deliverableWarnings, scopeSummary: scopeSummary, progress: eventProgress, workOrderConfigId: workOrderConfigId, contextId: COALESCE(study.tildaid, ?), contextType: CASE WHEN study IS NULL THEN ? ELSE head(labels(study)) END, contextName: COALESCE(study.name, ?), aiState: CASE WHEN SIZE(eventScopes) = ? THEN ? WHEN SIZE([s IN eventScopes WHERE s.aiState <> ? AND s.aiState IS NOT NULL]) = ? THEN ? ELSE ? END, trialDeliverables: deliverableCounts.trialDeliverables, countryDeliverables: deliverableCounts.countryDeliverables, siteDeliverables: deliverableCounts.siteDeliverables} as result
write docsvc
1 547 ms 975 ms 547 ms flat
MATCH (ctx:Study)<-[:PLAN_CONTEXT]-(ep:EventPlan {orgId: $orgId})-[:EVENTS]->(e:Event) WHERE ctx.tildaid IN $contextIds WITH DISTINCT e WHERE e.isTemplate = $isTemplate AND e.status = $status WITH DISTINCT e ORDER BY e.createdat DESC SKIP …
MATCH (ctx:Study)<-[:PLAN_CONTEXT]-(ep:EventPlan {orgId: $orgId})-[:EVENTS]->(e:Event) WHERE ctx.tildaid IN $contextIds WITH DISTINCT e WHERE e.isTemplate = $isTemplate AND e.status = $status WITH DISTINCT e ORDER BY e.createdat DESC SKIP $skip LIMIT $limit OPTIONAL MATCH (e)<-[:EVENTS]-(ep:EventPlan)-[:PLAN_CONTEXT]->(study) WITH e, study CALL { WITH e, study // Get details for each scope in the event OPTIONAL MATCH (e)<-[:PART_OF_EVENT]-(scope:EventScope) OPTIONAL MATCH (site:Site {tildaid: scope.scopeId}) OPTIONAL MATCH (site)-[:PLAN_DEFINITION_TO_SITE]-(pd:DslPlanDefinition{type:?})-[:PLAN_DEFINITION_TO_STUDY]->(study) WITH scope, CASE WHEN scope.scopeType = ? THEN site.name ELSE ? END as siteName, CASE WHEN scope.scopeType = ? THEN COALESCE(pd.siteNumber, ?) ELSE ? END as siteNumber OPTIONAL MATCH (scope)-[:APPLICABLE_TO]->(scopeDeliverable:Deliverable) CALL { // Get details of each deliverable applicable to the scope WITH scope, scopeDeliverable OPTIONAL MATCH (scopeDeliverable)-[tracksRel:TRACKS_PLACEHOLDER]->(ph:Document)-[:SCOPED_TO]->(scope) CALL { // Get match status for each placeholder WITH ph, tracksRel, scope OPTIONAL MATCH (ph)-[acceptedRel:ACCEPTED_DOCUMENT]->(acceptedDoc:Document) OPTIONAL MATCH (ph)-[matchRel:MATCHING_DOCUMENT]->(matchDoc:Document) WHERE acceptedDoc IS NULL OR matchDoc.tildaid <> acceptedDoc.tildaid WITH ph, tracksRel, scope, acceptedDoc, [m IN collect(matchDoc) WHERE m IS NOT NULL] as matchDocs WITH ph, tracksRel, scope, acceptedDoc, CASE WHEN ph.status <> ? THEN ? WHEN acceptedDoc IS NOT NULL THEN ? WHEN SIZE(matchDocs) > ? AND all(m IN matchDocs WHERE m.collection = ?) THEN ? WHEN SIZE(matchDocs) > ? THEN ? ELSE ? END as matchStatus RETURN CASE WHEN ph IS NULL THEN null ELSE {tildaid: ph.tildaid, fileName: ph.fileName, status: matchStatus, placeholderState: COALESCE(tracksRel.state, ?), archived: coalesce(ph.archived, false) OR scope.status = ?} END as deliverablePlaceholder } WITH collect(DISTINCT deliverablePlaceholder) as deliverablePlaceholders WITH [d IN deliverablePlaceholders WHERE d IS NOT NULL] as allPlaceholders RETURN allPlaceholders as deliverablePlaceholders, { total: size(allPlaceholders), pending: size([pp IN allPlaceholders WHERE pp.placeholderState IN [?, ?]]), pendingForDelete: size([pp IN allPlaceholders WHERE pp.placeholderState = ?]), accepted: size([pp IN allPlaceholders WHERE pp.placeholderState = ?]), rejected: size([pp IN allPlaceholders WHERE pp.placeholderState = ?]), incomplete: size([pp IN allPlaceholders WHERE pp.status = ?]), potentialMatchFound: size([pp IN allPlaceholders WHERE pp.status = ?]), matchExpected: size([pp IN allPlaceholders WHERE pp.status = ?]), matched: size([pp IN allPlaceholders WHERE pp.status = ?]), finalized: size([pp IN allPlaceholders WHERE pp.status = ?]), completion: {required: size([pp IN allPlaceholders WHERE NOT (pp.placeholderState = ? OR coalesce(pp.archived, false)) AND (pp.placeholderState IN [?, ?] OR pp.status = ?)]), completed: size([pp IN allPlaceholders WHERE NOT (pp.placeholderState = ? OR coalesce(pp.archived, false)) AND (pp.placeholderState IN [?, ?] OR pp.status = ?) AND pp.status IN [?, ?]]), aiSuggested: size([pp IN allPlaceholders WHERE NOT (pp.placeholderState = ? OR coalesce(pp.archived, false)) AND (pp.placeholderState IN [?, ?] OR pp.status = ?) AND pp.status = ?]), inStaging: size([pp IN allPlaceholders WHERE NOT (pp.placeholderState = ? OR coalesce(pp.archived, false)) AND (pp.placeholderState IN [?, ?] OR pp.status = ?) AND pp.status = ?]), noMatchFound: size([pp IN allPlaceholders WHERE NOT (pp.placeholderState = ? OR coalesce(pp.archived, false)) AND (pp.placeholderState IN [?, ?] OR pp.status = ?) AND pp.status = ?]), notConfirmed: size([pp IN allPlaceholders WHERE NOT (pp.placeholderState = ? OR coalesce(pp.archived, false)) AND pp.placeholderState = ? AND NOT pp.status = ?]), removed: size([pp IN allPlaceholders WHERE (pp.placeholderState = ? OR coalesce(pp.archived, false))]), percentComplete: CASE WHEN size([pp IN allPlaceholders WHERE NOT (pp.placeholderState = ? OR coalesce(pp.archived, false)) AND (pp.placeholderState IN [?, ?] OR pp.status = ?)]) = ? THEN null ELSE toInteger(floor(?.? * size([pp IN allPlaceholders WHERE NOT (pp.placeholderState = ? OR coalesce(pp.archived, false)) AND (pp.placeholderState IN [?, ?] OR pp.status = ?) AND pp.status IN [?, ?]]) / size([pp IN allPlaceholders WHERE NOT (pp.placeholderState = ? OR coalesce(pp.archived, false)) AND (pp.placeholderState IN [?, ?] OR pp.status = ?)]))) END, isComplete: size([pp IN allPlaceholders WHERE NOT (pp.placeholderState = ? OR coalesce(pp.archived, false)) AND (pp.placeholderState IN [?, ?] OR pp.status = ?)]) > ? AND size([pp IN allPlaceholders WHERE NOT (pp.placeholderState = ? OR coalesce(pp.archived, false)) AND (pp.placeholderState IN [?, ?] OR pp.status = ?) AND pp.status IN [?, ?]]) = size([pp IN allPlaceholders WHERE NOT (pp.placeholderState = ? OR coalesce(pp.archived, false)) AND (pp.placeholderState IN [?, ?] OR pp.status = ?)])} } as deliverableStats } // Aggregate all deliverables in the scope WITH scope, siteName, siteNumber, deliverableStats WITH distinct scope, siteName, siteNumber, { total: sum(deliverableStats.total), pending: sum(deliverableStats.pending), pendingForDelete: sum(deliverableStats.pendingForDelete), accepted: sum(deliverableStats.accepted), rejected: sum(deliverableStats.rejected), incomplete: sum(deliverableStats.incomplete), potentialMatchFound: sum(deliverableStats.potentialMatchFound), matchExpected: sum(deliverableStats.matchExpected), matched: sum(deliverableStats.matched), finalized: sum(deliverableStats.finalized), completion: {required: sum(deliverableStats.completion.required), completed: sum(deliverableStats.completion.completed), aiSuggested: sum(deliverableStats.completion.aiSuggested), inStaging: sum(deliverableStats.completion.inStaging), noMatchFound: sum(deliverableStats.completion.noMatchFound), notConfirmed: sum(deliverableStats.completion.notConfirmed), removed: sum(deliverableStats.completion.removed), percentComplete: CASE WHEN sum(deliverableStats.completion.required) = ? THEN null ELSE toInteger(floor(?.? * sum(deliverableStats.completion.completed) / sum(deliverableStats.completion.required))) END, isComplete: sum(deliverableStats.completion.required) > ? AND sum(deliverableStats.completion.completed) = sum(deliverableStats.completion.required)} } as scopeStats RETURN distinct scope{.*, siteName: siteName, siteNumber: siteNumber} as scope, scopeStats } CALL { // Collect summary for all deliverable in the event WITH e OPTIONAL MATCH (e)-[:REQUIRES_RESOLUTION_OF]->(eventDel:Deliverable) WITH collect(eventDel) as deliverables, [d IN collect(distinct eventDel) WHERE d.warning IS NOT NULL AND d.warning <> ? | ??\? + d.warning] as deliverableWarnings RETURN { trialDeliverables: SIZE([d in deliverables WHERE d.applyToTrial = true]), countryDeliverables: SIZE([d in deliverables WHERE d.applyToCountries = true]), siteDeliverables: SIZE([d in deliverables WHERE d.applyToSites = true]) } as deliverableCounts, deliverableWarnings } CALL { // Fetch createdBy WITH e OPTIONAL MATCH (e)-[:ALL_CHANGELOG]->(cl:ChangeLog{operation:?}) WITH cl ORDER BY cl.createdat ASC limit ? OPTIONAL MATCH (u:User{tildaid:cl.changedBy}) return {id: u.tildaid, name: u.name, profilePicURL: u.profilePicURL} as createdBy } // Aggregate all scopes and all deliverables in the event WITH e, study, createdBy, deliverableCounts, deliverableWarnings, collect(scope) as eventScopes, { total: sum(scopeStats.total), pending: sum(scopeStats.pending), pendingForDelete: sum(scopeStats.pendingForDelete), accepted: sum(scopeStats.accepted), rejected: sum(scopeStats.rejected), incomplete: sum(scopeStats.incomplete), potentialMatchFound: sum(scopeStats.potentialMatchFound), matchExpected: sum(scopeStats.matchExpected), matched: sum(scopeStats.matched), finalized: sum(scopeStats.finalized), completion: {required: sum(scopeStats.completion.required), completed: sum(scopeStats.completion.completed), aiSuggested: sum(scopeStats.completion.aiSuggested), inStaging: sum(scopeStats.completion.inStaging), noMatchFound: sum(scopeStats.completion.noMatchFound), notConfirmed: sum(scopeStats.completion.notConfirmed), removed: sum(scopeStats.completion.removed), percentComplete: CASE WHEN sum(scopeStats.completion.required) = ? THEN null ELSE toInteger(floor(?.? * sum(scopeStats.completion.completed) / sum(scopeStats.completion.required))) END, isComplete: sum(scopeStats.completion.required) > ? AND sum(scopeStats.completion.completed) = sum(scopeStats.completion.required)} } as eventProgress WITH e, study, createdBy, deliverableCounts, deliverableWarnings, eventProgress, eventScopes, { totalCountries: SIZE([s IN eventScopes WHERE s.scopeType = ?]), totalSites: SIZE([s IN eventScopes WHERE s.scopeType = ?]), countries: [s IN eventScopes WHERE s.scopeType = ? | {name: s.scopeId, id: s.scopeId}], sites: [s IN eventScopes WHERE s.scopeType = ? | {name: s.siteName, id: s.scopeId, siteNumber: s.siteNumber}] } as scopeSummary CALL { WITH e OPTIONAL MATCH (woc:WorkOrderConfig)-[:WORK_ORDER_CONFIG_TO_EVENT]->(e) RETURN woc.tildaid as workOrderConfigId LIMIT ? } RETURN e{.*, createdBy: createdBy, warnings: deliverableWarnings, scopeSummary: scopeSummary, progress: eventProgress, workOrderConfigId: workOrderConfigId, contextId: COALESCE(study.tildaid, ?), contextType: CASE WHEN study IS NULL THEN ? ELSE head(labels(study)) END, contextName: COALESCE(study.name, ?), aiState: CASE WHEN SIZE(eventScopes) = ? THEN ? WHEN SIZE([s IN eventScopes WHERE s.aiState <> ? AND s.aiState IS NOT NULL]) = ? THEN ? ELSE ? END, trialDeliverables: deliverableCounts.trialDeliverables, countryDeliverables: deliverableCounts.countryDeliverables, siteDeliverables: deliverableCounts.siteDeliverables} as result
write docsvc
2 871 ms 975 ms 872 ms flat
MATCH (d:Document)-[:DOCUMENT_VERSION]->(ver:DocumentVersion {status: $pending}) WHERE ver.createdat <= $cutoff RETURN d.tildaid, ver.tildaid ORDER BY ver.createdat LIMIT $limit
MATCH (d:Document)-[:DOCUMENT_VERSION]->(ver:DocumentVersion {status: $pending}) WHERE ver.createdat <= $cutoff RETURN d.tildaid, ver.tildaid ORDER BY ver.createdat LIMIT $limit
docsvc
1 882 ms 975 ms 882 ms flat
OPTIONAL MATCH (u:User {tildaid: $userId}) CALL { WITH u MATCH (u)<-[:FOR_USER]-(:Actor {delpending: false})<-[:ORGANIZATION_TO_ACTOR]-(o:Organization {delpending: false}) RETURN o UNION WITH u MATCH (u)-[:SUPPORTS_ORG]-(o:Organization {de…
OPTIONAL MATCH (u:User {tildaid: $userId}) CALL { WITH u MATCH (u)<-[:FOR_USER]-(:Actor {delpending: false})<-[:ORGANIZATION_TO_ACTOR]-(o:Organization {delpending: false}) RETURN o UNION WITH u MATCH (u)-[:SUPPORTS_ORG]-(o:Organization {delpending: false}) RETURN o UNION WITH u MATCH (u)<-[:FOR_USER]-(da:Actor {delpending: false})<-[:STUDY_TO_DELEGATED_ACTOR]-(dst:Study {delpending: false})-[:STUDY_TO_ORG]->(o:Organization {delpending: false}), (da)-[:APPOINTED_AS]->(dr:Role)<-[:APPOINTED_AS]-(sa:Actor {delpending: false}), (da)-[:DELEGATED_FROM]->(sa)<-[:ORGANIZATION_TO_ACTOR]-(:Organization {alias: $tildaScaleAlias}) WHERE dst.srcorgid = o.tildaid AND da.state <> ? AND sa.state <> ? AND $orgDelegatedTag IN apoc.text.split(coalesce(dr.tags, ?), ?) RETURN o UNION WITH u MATCH (o:Organization {alias: $activeAlias, delpending: false}) RETURN o } OPTIONAL MATCH (st:Study {delpending: false})-[:STUDY_TO_ORG]->(o) RETURN collect(DISTINCT o.alias) AS aliases, collect(DISTINCT o.tildaid) AS orgIds, collect(DISTINCT st.tildaid) AS studyIds
dashql
1 745 ms 975 ms 745 ms flat
OPTIONAL MATCH (u:User {tildaid: $userId}) CALL { WITH u MATCH (u)<-[:FOR_USER]-(:Actor {delpending: false})<-[:ORGANIZATION_TO_ACTOR]-(o:Organization {delpending: false}) RETURN o UNION WITH u MATCH (u)-[:SUPPORTS_ORG]-(o:Organization {de…
OPTIONAL MATCH (u:User {tildaid: $userId}) CALL { WITH u MATCH (u)<-[:FOR_USER]-(:Actor {delpending: false})<-[:ORGANIZATION_TO_ACTOR]-(o:Organization {delpending: false}) RETURN o UNION WITH u MATCH (u)-[:SUPPORTS_ORG]-(o:Organization {delpending: false}) RETURN o UNION WITH u MATCH (u)<-[:FOR_USER]-(da:Actor {delpending: false})<-[:STUDY_TO_DELEGATED_ACTOR]-(dst:Study {delpending: false})-[:STUDY_TO_ORG]->(o:Organization {delpending: false}), (da)-[:APPOINTED_AS]->(dr:Role)<-[:APPOINTED_AS]-(sa:Actor {delpending: false}), (da)-[:DELEGATED_FROM]->(sa)<-[:ORGANIZATION_TO_ACTOR]-(:Organization {alias: $tildaScaleAlias}) WHERE dst.srcorgid = o.tildaid AND da.state <> ? AND sa.state <> ? AND $orgDelegatedTag IN apoc.text.split(coalesce(dr.tags, ?), ?) RETURN o UNION WITH u MATCH (o:Organization {alias: $activeAlias, delpending: false}) RETURN o } OPTIONAL MATCH (st:Study {delpending: false})-[:STUDY_TO_ORG]->(o) RETURN collect(DISTINCT o.alias) AS aliases, collect(DISTINCT o.tildaid) AS orgIds, collect(DISTINCT st.tildaid) AS studyIds
dashql
1 867 ms 975 ms 867 ms flat
MATCH (org:Organization{tildaid:$scopeOrgId0}) CALL { WITH org UNWIND $lists.allowedStudies0 AS studyId OPTIONAL MATCH (study:Study) WHERE study.tildaid = studyId // An inactive actor carries no membership, so it is excluded here rather th…
MATCH (org:Organization{tildaid:$scopeOrgId0}) CALL { WITH org UNWIND $lists.allowedStudies0 AS studyId OPTIONAL MATCH (study:Study) WHERE study.tildaid = studyId // An inactive actor carries no membership, so it is excluded here rather than at each use: // the sites, countries and roles below all hang off it. OPTIONAL MATCH (study)-[:STUDY_TO_ACTOR]-(studyActor:Actor{orgId:$ctxOrgId0})-[:FOR_USER]->(:User{tildaid:$ctxUserId0}) WHERE studyActor.state <> ? // Collect sites where user has membership in this study OPTIONAL MATCH (studyActor)-[:STUDYSITEACTOR_TO_ACTOR]-(:StudySiteActor)-[:STUDYSITEACTOR_TO_PLAN_DEFINITION]-(pd:DslPlanDefinition)-[:PLAN_DEFINITION_TO_SITE]-(site:Site) WITH org, study, studyActor, collect(DISTINCT site.tildaid) as userSiteIds // Collect countries where user has membership in this study OPTIONAL MATCH (studyActor)<-[:STUDYCOUNTRYACTOR_TO_ACTOR]-(sca:StudyCountryActor) WITH org, study, studyActor, userSiteIds, collect(DISTINCT sca.country) as userCountryIds // Pre-collect policies for this user/role in this study OPTIONAL MATCH (org)<-[:DOC_ACCESS_POLICY_TO_ORG]-(policy:DocumentAccessPolicy{status:?})-[:POLICY_TO_STUDY]->(study) WHERE EXISTS { MATCH (policy)-[:POLICY_FOR_USER]->(:User{tildaid:$ctxUserId0}) } OR (studyActor IS NOT NULL AND EXISTS { MATCH (policy)-[:POLICY_FOR_ROLE]->(role:Role)<-[:APPOINTED_AS]-(studyActor) }) WITH study, studyActor, userSiteIds, userCountryIds, collect(policy) as policies WITH {study:study, studyActor:studyActor, userSiteIds:userSiteIds, userCountryIds:userCountryIds, policies:policies} AS st WITH collect(distinct st) as studies // studyById lets each document row look its context up by study id instead of scanning // the whole list. Entries whose study did not resolve share the ? key; they all carry // the same empty context, so which one wins does not matter. The node-bearing maps go no // further than this subquery; studyIdsInScope needs no lookup, since an id with no Study // node can never equal a matched study??ReadWrite?ReadOnly?s folder and ancestors (up to ? levels for TMF hierarchy) OPTIONAL MATCH (doc1)<-[:INCLUDES]-(docFolder:Folder) OPTIONAL MATCH (docFolder)<-[:INCLUDES*?..?]-(ancestorFolder:Folder) WITH doc1, policies, userSiteIds, userCountryIds, defaultAccessLevel, collect(DISTINCT docFolder) + collect(DISTINCT ancestorFolder) AS folderHierarchy // Check document ownership OPTIONAL MATCH (doc1)-[:UPLOADED_BY]->(uploader:User{tildaid:$policyUploaderId0}) WITH doc1, policies, userSiteIds, userCountryIds, defaultAccessLevel, folderHierarchy, uploader IS NOT NULL AS isOwnedByUser // Filter policies by: // ?. Folder: policy applies if folder is in hierarchy OR policy has no folder (study-wide). A folder-less // ownership policy is the role?Owned Documents?Non Owned Documents?Staging?Pre-Staging?Owned Documents?Non Owned Documents?My Sites Documents?Other Sites Documents?My Countries Documents?Other Countries Documents?Study Scope Documents?NoAccess?NoAccess?ReadOnly?ReadOnly?ReadWrite?ReadOnly?NoAccess??Inactive? ?Received?Quality Control?PHI Issues???/???/???/') ELSE ? END as childFolderPath WITH docObj, ct, child, st, head(collect(childFolderPath)) AS childFolderPath WITH child, CASE WHEN ct IS NULL THEN null ELSE { documentId: child.tildaid, studyId: COALESCE(child.studyId, ?), studyName: COALESCE(st.name, ?), folderPath: childFolderPath, kind: ct.kind, stale: ct.sourceVersionId <> docObj.primaryVersionId, version: COALESCE(child.versionName, toString(child.majorVersion)) } END as copiedToEntry RETURN collect(copiedToEntry) as copiedTo, count(DISTINCT child) as copiedToCount } CALL { return null as promotedTo } CALL { return null AS docReviewStatus, null AS hasImportantComment, null AS discrepancyCount } CALL { return null as tmfCategorization } with distinct doc{.*, status: docObj.status, stateTag: docObj.stateTag, orgAlias: org.alias, owned: owned, docTypeName: doc.docTypeName, userId: doc.userId, user: CASE WHEN user IS NOT NULL THEN {id: user.tildaid, name: user.name, profilePicURL: user.profilePicURL} ELSE NULL END, createdDate: doc.createdat, updatedDate: COALESCE(doc.updatedat, doc.createdat), externalUrl: doc.url, study: study.name, studyId: study.tildaid, site: site.name, siteId: doc.siteId, siteNumber: siteNumber, piNames: piNames, patient: patientName, patientId: doc.patientId, subjectId: subjectId, visit: visit.title, visitId: doc.visitId, reviewDate: reviewDate, assignedToUsers: [], uploadedBy: {id: uploadedBy.tildaid, name: uploadedBy.name, profilePicURL: uploadedBy.profilePicURL}, signedByUsers: signedByUsers, tags: tags, listingFolders: listingFolders, primaryFolder: primaryFolder, latestAIRun: latestAIRun, findingCount: findingCount, queriesCount: queriesCount, confirmedCount: confirmedCount, resolvedCount: resolvedCount, notesCount: notesCount, stagingLabels: stagingLabels, workOrders: workOrders, woContact: COALESCE(woContact, false), stateTags1: stateTags1, stateTags2: stateTags2, docAccessLevel: docAccessLevel, isSigner: isSigner, docReviewStatus: docReviewStatus, hasImportantComment: hasImportantComment, discrepancyCount: discrepancyCount , templateDetails: templateDetails, docTypeDetails: docType{.*}, queries: queries, annotationSpec: annotationSpec, annotationVal: annotationVal, completedAt: annotationVal.completedAt, versions: versions, reviews: reviews, sharedWith: sharedWith, currentShare: currentShare, tmfCategorization: tmfCategorization, docAttributes: docAttributes, eventId: eventId, eventName: eventName, deliverable: deliverable, eventScope: eventScope, provenance: CASE WHEN copiedFrom IS NULL AND size(copiedTo) = ? THEN null ELSE {copiedFrom: copiedFrom, copiedTo: [x IN copiedTo WHERE x IS NOT NULL | x], copiedToCount: copiedToCount} END, promotedTo: promotedTo} AS document, total return document, total
docsvc
1 775 ms 975 ms 775 ms flat
MATCH (dv:DocumentVersion {tildaid: $id})<-[:DOCUMENT_VERSION]-(d:Document) OPTIONAL MATCH (d)-[:DOC_TO_ORG]->(o:Organization) OPTIONAL MATCH (d)<-[:INCLUDES]-(b:Binder)-[:BINDER_FOR]->(study:Study) OPTIONAL MATCH (d)<-[:INCLUDES]-(b2:Bind…
MATCH (dv:DocumentVersion {tildaid: $id})<-[:DOCUMENT_VERSION]-(d:Document) OPTIONAL MATCH (d)-[:DOC_TO_ORG]->(o:Organization) OPTIONAL MATCH (d)<-[:INCLUDES]-(b:Binder)-[:BINDER_FOR]->(study:Study) OPTIONAL MATCH (d)<-[:INCLUDES]-(b2:Binder)-[:BINDER_FOR]->(site:Site) OPTIONAL MATCH (fm:FolderManager{scopeId:d.studyId})-[:HAS]->(dad:DocAttributeDefinition) where dad.name = ? or dad.name = ? OPTIONAL MATCH (dv)<-[:DOCUMENT_SOURCE_TO_VERSION]-(ds:DocumentSource)-[:HAS_ATTRIBUTE]->(da: DocAttribute{key: dad.code}) OPTIONAL MATCH (dv) - [:UPLOADED_BY] - (u: User) OPTIONAL MATCH (d)<-[:INCOMING_EMAIL_TO_DOCUMENT]-(ie:IncomingEmail) OPTIONAL MATCH (d)<-[:INCLUDES]-(currentFolder:Folder{folderType:?, delpending: FALSE}) WHERE currentFolder.scope IN [?, ?] OPTIONAL MATCH (d)-[:FILED_UNDER_SUBARTIFACT]->(currentSubArtifact:SubArtifact)<-[:INCLUDES]-(currentFolder) OPTIONAL MATCH (d)-[:HAS_STAGING_INFO]->(stagingInfo:DocumentStagingInfo) OPTIONAL MATCH (artifact:Folder{tildaid:coalesce(stagingInfo.folderId, currentFolder.tildaid, ?)})<-[:INCLUDES]-(section:Folder)<-[:INCLUDES]-(zone:Folder)<-[:INCLUDES]-(collection:Folder{level:?}) OPTIONAL MATCH (artifact)-[:INCLUDES]->(subArtifact:SubArtifact{tildaid:coalesce(stagingInfo.subArtifactId, currentSubArtifact.tildaid, ?)}) CALL { WITH dv OPTIONAL MATCH (dv)-[:ALL_CHANGELOG]-(dvcl:ChangeLog) WHERE dvcl.type IN [?, ?] WITH dvcl ORDER BY dvcl.createdat DESC LIMIT ? OPTIONAL MATCH (changer:User {tildaid: dvcl.changedBy}) WHERE dvcl IS NOT NULL RETURN coalesce(apoc.convert.fromJsonMap(coalesce(dvcl.newValue, ?)).stagingStatus, apoc.convert.fromJsonMap(coalesce(dvcl.newValue, ?)).stateTag, ?) as newStatus, coalesce(apoc.convert.fromJsonMap(coalesce(dvcl.oldValue, ?)).stagingStatus, apoc.convert.fromJsonMap(coalesce(dvcl.oldValue, ?)).stateTag, ?) as previousStatus, coalesce(dvcl.changedBy, ?) as changedBy, coalesce(changer.name, ?) as changedByName } CALL { WITH dv OPTIONAL MATCH (dv)<-[:DOCUMENT_SOURCE_TO_VERSION]-(ds:DocumentSource)-[:HAS_ATTRIBUTE]->(docAttr: DocAttribute) WITH collect([coalesce(docAttr.key, ?), coalesce(docAttr.value, ?)]) AS attributePairs WITH apoc.map.fromPairs(attributePairs) AS attributesMap WITH apoc.convert.toJson(attributesMap) AS attributesJson RETURN attributesJson } WITH d, dv, o, study, site, u, ie, zone, section, artifact, subArtifact, da, newStatus, previousStatus, changedBy, changedByName, attributesJson CALL apoc.create.vNode([?], { tildaid: dv.tildaid, documentId: d.tildaid, displayId: d.displayId, status: d.status, docTypeName: d.docTypeName, tmfLevel: d.tmfLevel, pages: d.pages, versionNumber: dv.versionNumber, versionId: dv.tildaid, userId: d.userId, uploadedByName: u.name, uploadedById: u.tildaid, uploadedAt: toString(d.createdat), archived: d.archived, aiEnabled: d.aiEnabled, language: d.language, uploadMethod: coalesce(NULLIF(d.uploadMethod, ?), dv.uploadMethod), country: d.country, orgId: o.tildaid, orgName: o.name, orgAlias: o.alias, studyId: study.tildaid, studyName: study.name, siteId: site.tildaid, siteName: site.name, createdat: d.createdat, updatedat: d.updatedat, zone: zone.name, zoneId: zone.tildaid, section: section.name, sectionId: section.tildaid, artifact: artifact.name, artifactId: artifact.tildaid, subArtifact: subArtifact.name, subArtifactId: subArtifact.tildaid, artifactNumber: apoc.text.lpad(toString(COALESCE(zone.number, ?)), ?, ?) + ? + apoc.text.lpad(toString(COALESCE(section.number, ?)), ?, ?) + ? + apoc.text.lpad(toString(COALESCE(artifact.number, ?)), ?, ?), subArtifactNumber: case when subArtifact.number is null then null else apoc.text.lpad(toString(COALESCE(zone.number, ?)), ?, ?) + ? + apoc.text.lpad(toString(COALESCE(section.number, ?)), ?, ?) + ? + apoc.text.lpad(toString(COALESCE(artifact.number, ?)), ?, ?) + ? + apoc.text.lpad(toString(COALESCE(subArtifact.number, ?)), ?, ?) end, docDate: da.value, submissionDelayDays: CASE WHEN da.value IS NULL THEN NULL ELSE toString( toInteger(ceil((d.createdat - datetime(da.value).epochMillis)/?)) ) END, collection: d.collection, stateTag: dv.stateTag, needsAttentionReasons: dv.needsAttentionReasons, previousStatus: previousStatus, newStatus: newStatus, changedBy: changedBy, changedByName: changedByName, patientId: d.patientId, fileName: d.fileName, documentMetadata: attributesJson, emailSubject: ie.subject, emailMessageId: ie.message_id } ) YIELD node RETURN node
write dashrsvc
1 933 ms 975 ms 933 ms flat
MATCH (currentUser:User {deltimestamp:?}) WHERE (currentUser.isDummy IS NULL OR currentUser.isDummy <> true) AND currentUser.email = $ident OPTIONAL MATCH (supportUser:User {email:$supportEmail}) OPTIONAL MATCH (targetOrg:Organization {del…
MATCH (currentUser:User {deltimestamp:?}) WHERE (currentUser.isDummy IS NULL OR currentUser.isDummy <> true) AND currentUser.email = $ident OPTIONAL MATCH (supportUser:User {email:$supportEmail}) OPTIONAL MATCH (targetOrg:Organization {delpending:false, alias:$org}) OPTIONAL MATCH (currentUser)-[:FOR_USER]-(orgActor:Actor{delpending:false})-[:ORGANIZATION_TO_ACTOR]-(targetOrg) WHERE coalesce(orgActor.state, ?) <> ? OPTIONAL MATCH (currentUser)-[supports:SUPPORTS_ORG]-(targetOrg) WHERE EXISTS { MATCH (currentUser)<-[:FOR_USER]-(scaleActor:Actor{delpending:false})<-[:ORGANIZATION_TO_ACTOR]-(:Organization{alias:$tildaScaleAlias}), (scaleActor)-[:APPOINTED_AS]->(scaleRole:Role) WHERE coalesce(scaleActor.state, ?) <> ? AND scaleRole.name <> ? } WITH *, false AS repOf WITH *, CASE WHEN orgActor IS NULL THEN EXISTS { MATCH (currentUser)<-[:FOR_USER]-(da:Actor{delpending:false})<-[:STUDY_TO_DELEGATED_ACTOR]-(st:Study{delpending:false})-[:STUDY_TO_ORG]->(targetOrg), (da)-[:APPOINTED_AS]->(dr:Role)<-[:APPOINTED_AS]-(sa:Actor{delpending:false}), (da)-[:DELEGATED_FROM]->(sa)<-[:ORGANIZATION_TO_ACTOR]-(:Organization{alias:$tildaScaleAlias}) WHERE st.srcorgid = targetOrg.tildaid AND da.state <> ? AND sa.state <> ? AND $delegatedTag IN apoc.text.split(coalesce(dr.tags, ?), ?) } ELSE false END as delegated RETURN CASE WHEN orgActor is not null THEN currentUser WHEN delegated THEN currentUser WHEN repOf THEN currentUser WHEN supports is not null THEN coalesce(supportUser, currentUser) ELSE currentUser END as user, CASE WHEN orgActor is not null OR delegated OR repOf OR supports is not null THEN targetOrg ELSE null END as org, currentUser as tokenUser
ontologysvc
7 542 ms 971 ms 635 ms flat

p95 drift compares the query's p95 in the recent half of the window to the earlier half — ≥1.2× means it's slowing down. Click a row for its p50/p95 latency trend over time. Latency percentiles come from per-bucket histograms (no individual queries stored).