From 483234b7de2f9cfbf13a42be93f8ba76c35f83d8 Mon Sep 17 00:00:00 2001 From: Binal Patel Date: Fri, 29 Aug 2025 10:47:16 -0700 Subject: [PATCH 1/2] Use container to get cache key instead of study (study is not present when trying to populate lookup but goes through this code path when using registering and unregistering lookups trigger script). --- .../labkey/ehr/security/EHRSecurityManager.java | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/ehr/src/org/labkey/ehr/security/EHRSecurityManager.java b/ehr/src/org/labkey/ehr/security/EHRSecurityManager.java index 48fe8c006..55779d2f4 100644 --- a/ehr/src/org/labkey/ehr/security/EHRSecurityManager.java +++ b/ehr/src/org/labkey/ehr/security/EHRSecurityManager.java @@ -224,29 +224,25 @@ public Map getQCStateInfo(Container c) if (targetContainer == null) return Collections.emptyMap(); - Study study = StudyService.get().getStudy(targetContainer); - if (study == null) - return Collections.emptyMap(); - - String cacheKey = getCacheKey(study, QCSTATE_CACHE_ID); + String cacheKey = getCacheKey(c, QCSTATE_CACHE_ID); Map qcStates = (Map) DataEntryManager.get().getCache().get(cacheKey); if (qcStates != null) return qcStates; qcStates = new HashMap<>(); - for (EHRQCState qc : EHRManager.get().getQCStates(study.getContainer())) + for (EHRQCState qc : EHRManager.get().getQCStates(c)) { qcStates.put(qc.getLabel(), qc); } qcStates = Collections.unmodifiableMap(qcStates); - DataEntryManager.get().getCache().put(getCacheKey(study, QCSTATE_CACHE_ID), qcStates); + DataEntryManager.get().getCache().put(getCacheKey(c, QCSTATE_CACHE_ID), qcStates); return qcStates; } - private String getCacheKey(Study s, String suffix) + private String getCacheKey(Container c, String suffix) { - return getClass().getName() + "||" + s.getEntityId() + "||" + suffix; + return getClass().getName() + "||" + c.getEntityId() + "||" + suffix; } } From b3b83005a73b3c7a28bc73388e6daf3f7b81e255 Mon Sep 17 00:00:00 2001 From: Binal Patel Date: Sun, 31 Aug 2025 21:35:42 -0700 Subject: [PATCH 2/2] Use EHR Study container --- ehr/src/org/labkey/ehr/security/EHRSecurityManager.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ehr/src/org/labkey/ehr/security/EHRSecurityManager.java b/ehr/src/org/labkey/ehr/security/EHRSecurityManager.java index 55779d2f4..62e20f167 100644 --- a/ehr/src/org/labkey/ehr/security/EHRSecurityManager.java +++ b/ehr/src/org/labkey/ehr/security/EHRSecurityManager.java @@ -224,19 +224,19 @@ public Map getQCStateInfo(Container c) if (targetContainer == null) return Collections.emptyMap(); - String cacheKey = getCacheKey(c, QCSTATE_CACHE_ID); + String cacheKey = getCacheKey(targetContainer, QCSTATE_CACHE_ID); Map qcStates = (Map) DataEntryManager.get().getCache().get(cacheKey); - if (qcStates != null) + if (qcStates != null && !qcStates.isEmpty()) return qcStates; qcStates = new HashMap<>(); - for (EHRQCState qc : EHRManager.get().getQCStates(c)) + for (EHRQCState qc : EHRManager.get().getQCStates(targetContainer)) { qcStates.put(qc.getLabel(), qc); } qcStates = Collections.unmodifiableMap(qcStates); - DataEntryManager.get().getCache().put(getCacheKey(c, QCSTATE_CACHE_ID), qcStates); + DataEntryManager.get().getCache().put(getCacheKey(targetContainer, QCSTATE_CACHE_ID), qcStates); return qcStates; }