diff --git a/snprc_ehr/resources/queries/study/CulturePivot.query.xml b/snprc_ehr/resources/queries/study/CulturePivot.query.xml
index f0f663990..733b7c629 100644
--- a/snprc_ehr/resources/queries/study/CulturePivot.query.xml
+++ b/snprc_ehr/resources/queries/study/CulturePivot.query.xml
@@ -21,7 +21,7 @@
study
ClinpathRuns
- message_id
+ objectid
diff --git a/snprc_ehr/resources/queries/study/CulturePivot.sql b/snprc_ehr/resources/queries/study/CulturePivot.sql
index 2c20d003e..bcbebe482 100644
--- a/snprc_ehr/resources/queries/study/CulturePivot.sql
+++ b/snprc_ehr/resources/queries/study/CulturePivot.sql
@@ -24,6 +24,7 @@ SELECT
p.date,
p.serviceTestId.testName as TestName,
p.runId.serviceRequested as PanelName,
+ p.remark,
GROUP_CONCAT(p.qualresult) as QResults
FROM study.labworkResults as p
@@ -32,7 +33,7 @@ FROM study.labworkResults as p
and lt.ServiceId.Dataset='Culture'
where p.id is not null
- group by p.runid, p.Id, p.date,p.serviceTestId.testName, p.runId.serviceRequested
+ group by p.runid, p.Id, p.date,p.serviceTestId.testName, p.remark, p.runId.serviceRequested
PIVOT QResults by TestName IN
(select t.testName from snprc_ehr.labwork_panels t
where t.includeInPanel = true
diff --git a/snprc_ehr/resources/queries/study/ParasitologyPivot.query.xml b/snprc_ehr/resources/queries/study/ParasitologyPivot.query.xml
index 403eda07d..484397090 100644
--- a/snprc_ehr/resources/queries/study/ParasitologyPivot.query.xml
+++ b/snprc_ehr/resources/queries/study/ParasitologyPivot.query.xml
@@ -21,7 +21,7 @@
study
ClinpathRuns
- message_id
+ objectid
diff --git a/snprc_ehr/resources/queries/study/ParasitologyPivot.sql b/snprc_ehr/resources/queries/study/ParasitologyPivot.sql
index 75c0afd84..bc3b2aaf1 100644
--- a/snprc_ehr/resources/queries/study/ParasitologyPivot.sql
+++ b/snprc_ehr/resources/queries/study/ParasitologyPivot.sql
@@ -22,6 +22,7 @@ SELECT
p.runid,
p.Id,
p.date,
+ p.remark,
p.serviceTestId.testName as TestName,
p.runId.serviceRequested as PanelName,
GROUP_CONCAT(p.qualresult) as QResults
@@ -33,7 +34,7 @@ FROM study.labworkResults as p
where p.id is not null
and p.runId.serviceRequested not in ('OVA & PARASITES','OVA & PARASITES, URINE')
-group by p.runid, p.Id, p.date,p.serviceTestId.testName, p.runId.serviceRequested
+group by p.runid, p.Id, p.date,p.serviceTestId.testName, p.runId.serviceRequested, p.remark
PIVOT QResults by TestName IN
(select TestName from snprc_ehr.labwork_panels t
where t.includeInPanel = true
diff --git a/snprc_ehr/resources/queries/study/ParasitologyPivotOP.query.xml b/snprc_ehr/resources/queries/study/ParasitologyPivotOP.query.xml
index 77d271bd2..b3886b305 100644
--- a/snprc_ehr/resources/queries/study/ParasitologyPivotOP.query.xml
+++ b/snprc_ehr/resources/queries/study/ParasitologyPivotOP.query.xml
@@ -27,7 +27,7 @@
study
ClinpathRuns
- message_id
+ objectid
diff --git a/snprc_ehr/resources/queries/study/ParasitologyPivotOP.sql b/snprc_ehr/resources/queries/study/ParasitologyPivotOP.sql
index 0dde51474..667ca0798 100644
--- a/snprc_ehr/resources/queries/study/ParasitologyPivotOP.sql
+++ b/snprc_ehr/resources/queries/study/ParasitologyPivotOP.sql
@@ -25,6 +25,7 @@ SELECT
p.date,
p.serviceTestId.testName as TestName,
p.runId.serviceRequested as PanelName,
+ p.remark,
GROUP_CONCAT(p.qualresult) as QResults
FROM study.labworkResults as p
@@ -34,7 +35,7 @@ FROM study.labworkResults as p
where p.id is not null
and p.runId.serviceRequested in ('OVA & PARASITES' ,'OVA & PARASITES, URINE')
-group by p.runid, p.Id, p.date, p.serviceTestId.testName, p.runId.serviceRequested
+group by p.runid, p.Id, p.date,p.remark, p.serviceTestId.testName, p.runId.serviceRequested
PIVOT QResults by TestName IN
(select TestName from snprc_ehr.labwork_panels t
where t.includeInPanel = true
diff --git a/snprc_ehr/resources/queries/study/chemPivot.sql b/snprc_ehr/resources/queries/study/chemPivot.sql
index 7f35ad8eb..55329ed5d 100644
--- a/snprc_ehr/resources/queries/study/chemPivot.sql
+++ b/snprc_ehr/resources/queries/study/chemPivot.sql
@@ -19,11 +19,12 @@ b.date,
b.runId,
b.panelName,
b.TestName,
+b.remark,
MAX(b.result) as results
FROM chemPivotInner b
-GROUP BY b.runid,b.id, b.date, b.TestName, b.panelName
+GROUP BY b.runid,b.id, b.date, b.TestName, b.panelName, b.remark
PIVOT results BY TestName IN
(select TestName from snprc_ehr.labwork_panels t
diff --git a/snprc_ehr/resources/queries/study/chemPivotInner.sql b/snprc_ehr/resources/queries/study/chemPivotInner.sql
index b1a0b8435..92c804c7f 100644
--- a/snprc_ehr/resources/queries/study/chemPivotInner.sql
+++ b/snprc_ehr/resources/queries/study/chemPivotInner.sql
@@ -20,6 +20,7 @@ SELECT
b.serviceTestId.testName AS TestName,
coalesce(b.runId, b.objectid) as runId,
+ b.remark,
b.resultoorindicator,
CASE
WHEN b.result IS NULL THEN b.qualresult
diff --git a/snprc_ehr/resources/queries/study/hematologyPivot.query.xml b/snprc_ehr/resources/queries/study/hematologyPivot.query.xml
index fc35e3110..1c97f72c2 100644
--- a/snprc_ehr/resources/queries/study/hematologyPivot.query.xml
+++ b/snprc_ehr/resources/queries/study/hematologyPivot.query.xml
@@ -27,7 +27,7 @@
study
ClinpathRuns
- message_id
+ objectid
diff --git a/snprc_ehr/resources/queries/study/hematologyPivot.sql b/snprc_ehr/resources/queries/study/hematologyPivot.sql
index 92404fec1..8141a936e 100644
--- a/snprc_ehr/resources/queries/study/hematologyPivot.sql
+++ b/snprc_ehr/resources/queries/study/hematologyPivot.sql
@@ -19,11 +19,12 @@ b.date,
b.runid,
b.panelName,
b.TestName,
+b.remark,
MAX(b.result) as results
FROM hematologyPivotInner b
-GROUP BY b.runid, b.panelName, b.id, b.date, b.TestName
+GROUP BY b.runid, b.panelName, b.id, b.date, b.TestName, b.remark
PIVOT results BY TestName IN
(select TestName from snprc_ehr.labwork_panels t
diff --git a/snprc_ehr/resources/queries/study/hematologyPivotInner.sql b/snprc_ehr/resources/queries/study/hematologyPivotInner.sql
index d33cf01c7..65c46c5ca 100644
--- a/snprc_ehr/resources/queries/study/hematologyPivotInner.sql
+++ b/snprc_ehr/resources/queries/study/hematologyPivotInner.sql
@@ -19,6 +19,7 @@ SELECT
b.runId.serviceRequested as panelName,
b.serviceTestId.testName AS TestName,
coalesce(b.runId, b.objectid) as runId,
+ b.remark,
b.resultoorindicator,
CASE
WHEN b.result IS NULL THEN b.qualresult
diff --git a/snprc_ehr/resources/queries/study/miscPivot.query.xml b/snprc_ehr/resources/queries/study/miscPivot.query.xml
index 82c22a9e6..af387c9e1 100644
--- a/snprc_ehr/resources/queries/study/miscPivot.query.xml
+++ b/snprc_ehr/resources/queries/study/miscPivot.query.xml
@@ -27,7 +27,7 @@
study
ClinpathRuns
- message_id
+ objectid
diff --git a/snprc_ehr/resources/queries/study/miscPivot.sql b/snprc_ehr/resources/queries/study/miscPivot.sql
index c9711eaea..529b59bb0 100644
--- a/snprc_ehr/resources/queries/study/miscPivot.sql
+++ b/snprc_ehr/resources/queries/study/miscPivot.sql
@@ -19,12 +19,12 @@ SELECT
b.runId,
b.panelName,
b.TestName,
+ b.remark,
MAX(b.result) as results,
- (select group_concat(a.remark) from study.labworkResults as a where a.runId = b.runId) as remark
FROM miscPivotInner b
-GROUP BY b.runid,b.id, b.date, b.TestName, b.panelName
+GROUP BY b.runid,b.id, b.date, b.TestName, b.panelName, b.remark
PIVOT results BY TestName IN
(select TestName from snprc_ehr.labwork_panels t
diff --git a/snprc_ehr/resources/queries/study/miscPivotInner.sql b/snprc_ehr/resources/queries/study/miscPivotInner.sql
index d02d0b04b..baf255c3c 100644
--- a/snprc_ehr/resources/queries/study/miscPivotInner.sql
+++ b/snprc_ehr/resources/queries/study/miscPivotInner.sql
@@ -18,7 +18,7 @@ SELECT
b.date,
b.runId.serviceRequested as panelName,
b.serviceTestId.testName AS TestName,
-
+ b.remark,
coalesce(b.runId, b.objectid) as runId,
b.resultoorindicator,
CASE
diff --git a/snprc_ehr/resources/queries/study/surveillancePivot.query.xml b/snprc_ehr/resources/queries/study/surveillancePivot.query.xml
index 8edccfc0e..b0b00a033 100644
--- a/snprc_ehr/resources/queries/study/surveillancePivot.query.xml
+++ b/snprc_ehr/resources/queries/study/surveillancePivot.query.xml
@@ -27,7 +27,7 @@
study
ClinpathRuns
- message_id
+ objectid
diff --git a/snprc_ehr/resources/queries/study/surveillancePivot.sql b/snprc_ehr/resources/queries/study/surveillancePivot.sql
index 07a1e08d5..143bb8318 100644
--- a/snprc_ehr/resources/queries/study/surveillancePivot.sql
+++ b/snprc_ehr/resources/queries/study/surveillancePivot.sql
@@ -19,11 +19,12 @@ b.date,
b.runid,
b.panelName,
b.TestName,
+b.remark,
MAX(b.result) as results
FROM surveillancePivotInner b
-GROUP BY b.runid, b.panelName, b.id, b.date, b.TestName
+GROUP BY b.runid, b.panelName, b.id, b.date, b.TestName, b.remark
PIVOT results BY TestName IN
(select TestName from snprc_ehr.labwork_panels t
diff --git a/snprc_ehr/resources/queries/study/surveillancePivotInner.sql b/snprc_ehr/resources/queries/study/surveillancePivotInner.sql
index c146fb112..d0cc20e76 100644
--- a/snprc_ehr/resources/queries/study/surveillancePivotInner.sql
+++ b/snprc_ehr/resources/queries/study/surveillancePivotInner.sql
@@ -24,6 +24,7 @@ SELECT
b.serviceTestId.testName AS TestName,
coalesce(b.runId, b.objectid) as runId,
b.resultoorindicator,
+ b.remark,
CASE
WHEN b.result IS NULL THEN b.qualresult
ELSE CAST(CAST(b.result AS float) AS VARCHAR)
@@ -40,6 +41,7 @@ SELECT
b.serviceTestId.testName AS TestName,
coalesce(b.runId, b.objectid) as runId,
b.resultoorindicator,
+ b.remark,
CASE
WHEN b.result IS NULL THEN b.qualresult
ELSE CAST(CAST(b.result AS float) AS VARCHAR)
@@ -56,6 +58,7 @@ SELECT
b.serviceTestId.testName AS TestName,
coalesce(b.runId, cast(b.Sequencenum as varchar)) as runId,
b.resultoorindicator,
+ b.remark,
CASE
WHEN b.result IS NULL THEN b.qualresult
ELSE CAST(CAST(b.result AS float) AS VARCHAR)
diff --git a/snprc_ehr/resources/queries/study/urinalysisPivot.query.xml b/snprc_ehr/resources/queries/study/urinalysisPivot.query.xml
index 12625d953..b528d3668 100644
--- a/snprc_ehr/resources/queries/study/urinalysisPivot.query.xml
+++ b/snprc_ehr/resources/queries/study/urinalysisPivot.query.xml
@@ -27,7 +27,7 @@
study
ClinpathRuns
- message_id
+ objectid
diff --git a/snprc_ehr/resources/queries/study/urinalysisPivot.sql b/snprc_ehr/resources/queries/study/urinalysisPivot.sql
index 4a09df99f..7e41a1ecc 100644
--- a/snprc_ehr/resources/queries/study/urinalysisPivot.sql
+++ b/snprc_ehr/resources/queries/study/urinalysisPivot.sql
@@ -19,11 +19,12 @@ SELECT
b.runId,
b.panelName,
b.TestName,
+ b.remark,
MAX(b.result) as results
FROM urinalysisPivotInner b
-GROUP BY b.runid,b.id, b.date, b.TestName, b.panelName
+GROUP BY b.runid,b.id, b.date, b.TestName, b.panelName, b.remark
PIVOT results BY TestName IN
(select TestName from snprc_ehr.labwork_panels t
diff --git a/snprc_ehr/resources/queries/study/urinalysisPivotInner.sql b/snprc_ehr/resources/queries/study/urinalysisPivotInner.sql
index d1f6a51bc..d35203c70 100644
--- a/snprc_ehr/resources/queries/study/urinalysisPivotInner.sql
+++ b/snprc_ehr/resources/queries/study/urinalysisPivotInner.sql
@@ -21,6 +21,7 @@ SELECT
coalesce(b.runId, b.objectid) as runId,
b.resultoorindicator,
+ b.remark,
CASE
WHEN b.result IS NULL THEN b.qualresult
ELSE CAST(CAST(b.result AS float) AS VARCHAR)