diff --git a/nirc_ehr/resources/queries/study/AcquisitionReport.sql b/nirc_ehr/resources/queries/study/AcquisitionReport.sql new file mode 100644 index 00000000..52bbfd2b --- /dev/null +++ b/nirc_ehr/resources/queries/study/AcquisitionReport.sql @@ -0,0 +1,9 @@ +SELECT d.Id, + d.gender, + d.species, + d.Birth, + d.Id.MostRecentArrival.Center_Arrival, + cpp.project +FROM study.demographics d + LEFT JOIN CurrentProtocolProjectReport cpp ON cpp.Id = d.Id +ORDER BY d.Id ASC \ No newline at end of file diff --git a/nirc_ehr/resources/queries/study/AcquisitionReportBySpecies.sql b/nirc_ehr/resources/queries/study/AcquisitionReportBySpecies.sql new file mode 100644 index 00000000..5fbe7a7d --- /dev/null +++ b/nirc_ehr/resources/queries/study/AcquisitionReportBySpecies.sql @@ -0,0 +1,13 @@ +PARAMETERS(StartDate TIMESTAMP, EndDate TIMESTAMP, Project VARCHAR) + +SELECT s.species, s.project, s.speciesName, COUNT(*) as Total FROM + ( + SELECT + species, + species.scientific_name AS speciesName, + Center_Arrival, + project + FROM study.AcquisitionReport ar + WHERE CAST(COALESCE(StartDate, '1900-01-01') as date) <= ar.Center_Arrival AND CAST(COALESCE(EndDate, curdate()) as date) >= CAST(ar.Center_Arrival as date) AND Project = ar.project + ) s +GROUP BY s.species, s.project, s.speciesName \ No newline at end of file diff --git a/nirc_ehr/resources/queries/study/CurrentProtocolProjectReport.sql b/nirc_ehr/resources/queries/study/CurrentProtocolProjectReport.sql new file mode 100644 index 00000000..ff4c24ce --- /dev/null +++ b/nirc_ehr/resources/queries/study/CurrentProtocolProjectReport.sql @@ -0,0 +1,12 @@ + +SELECT DISTINCT Id, protocol.title as protocol, project FROM + ( + SELECT DISTINCT d.Id, + a.project.name as project, a.enddate AS projectenddate, + pa.protocol, pa.enddate AS protocolenddate + FROM study.demographics d + JOIN study.assignment a ON a.Id = d.Id + JOIN study.protocolAssignment pa ON pa.Id = d.Id + WHERE a.enddate IS NULL + ) sub +WHERE sub.protocolenddate IS NULL \ No newline at end of file diff --git a/nirc_ehr/resources/queries/study/activeProjectsFromHousing.sql b/nirc_ehr/resources/queries/study/activeProjectsFromHousing.sql new file mode 100644 index 00000000..3387bce9 --- /dev/null +++ b/nirc_ehr/resources/queries/study/activeProjectsFromHousing.sql @@ -0,0 +1,5 @@ +SELECT + Id.activeProjectAssignments.project, + COUNT(*) as Total +FROM housing +GROUP BY Id.activeProjectAssignments.project \ No newline at end of file diff --git a/nirc_ehr/resources/queries/study/deaths.js b/nirc_ehr/resources/queries/study/deaths.js index 99ef0498..626223e7 100644 --- a/nirc_ehr/resources/queries/study/deaths.js +++ b/nirc_ehr/resources/queries/study/deaths.js @@ -152,17 +152,24 @@ EHR.Server.TriggerManager.registerHandlerForQuery(EHR.Server.TriggerManager.Even }); EHR.Server.TriggerManager.registerHandlerForQuery(EHR.Server.TriggerManager.Events.COMPLETE, 'study', 'Deaths', function(event, errors, helper){ - var deaths = helper.getDeaths(); - - if (deaths) { - var ids = []; - for (var id in deaths){ - ids.push(id); - } - if (!helper.isETL() && event === 'insert') { - triggerHelper.sendDeathNotification(ids[0]); + var rows = helper.getRows() || []; + for (var i = 0; i < rows.length; i++) { + var row = rows[i].row; + var oldRow = rows[i].oldRow; + + // Notification will get sent when: + // 1) a brand-new row saved directly as 'Request: Pending' (i.e., when a user clicks 'Submit Death'), or + // 2) a draft death record moving from 'In Progress' to 'Request: Pending'. + if (!helper.isETL() && + row && row.Id && + row.QCStateLabel && + row.QCStateLabel.toUpperCase() === 'REQUEST: PENDING' && + (!oldRow || !oldRow.QCStateLabel || oldRow.QCStateLabel.toUpperCase() === 'IN PROGRESS')) { + console.log("Sending NIRC Death Notification") + triggerHelper.sendDeathNotification(row.Id); + + console.log("Updating Procedure Orders to Completed for Animal: " + row.Id + "") + triggerHelper.updateProcedureOrdersToCompleted([row.Id]); } - - triggerHelper.updateProcedureOrdersToCompleted(ids); } }); \ No newline at end of file diff --git a/nirc_ehr/resources/views/acquisitionReport.html b/nirc_ehr/resources/views/acquisitionReport.html new file mode 100644 index 00000000..8834f92b --- /dev/null +++ b/nirc_ehr/resources/views/acquisitionReport.html @@ -0,0 +1,217 @@ + + +
+
+ + +
+ +
+ + +
+ +
+ + +
+ + +
+ +
+
+
+ + diff --git a/nirc_ehr/resources/views/acquisitionReport.view.xml b/nirc_ehr/resources/views/acquisitionReport.view.xml new file mode 100644 index 00000000..bbbab5f4 --- /dev/null +++ b/nirc_ehr/resources/views/acquisitionReport.view.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/nirc_ehr/resources/views/clinicalHistoryExport.html b/nirc_ehr/resources/views/clinicalHistoryExport.html index 8e15e246..d5470b84 100644 --- a/nirc_ehr/resources/views/clinicalHistoryExport.html +++ b/nirc_ehr/resources/views/clinicalHistoryExport.html @@ -1,3 +1,8 @@ +
+ ULL Logo + The University of Louisiana at Lafayette New Iberia Research Center
Animal Record
+
+