diff --git a/nirc_ehr/resources/data/housing_reason.tsv b/nirc_ehr/resources/data/housing_reason.tsv
index a1b3a169..356ba3f0 100644
--- a/nirc_ehr/resources/data/housing_reason.tsv
+++ b/nirc_ehr/resources/data/housing_reason.tsv
@@ -21,6 +21,5 @@ Sale Sale
Scientific Scientific
Social group introduction breeding Social group introduction breeding
Social group introduction non-breeding Social group introduction non-breeding
-Veterinary Veterinary
-Veterinary social wounding Veterinary social wounding
+Veterinary Treatment Veterinary Treatment
Weaning Weaning
\ No newline at end of file
diff --git a/nirc_ehr/resources/data/observation_types.tsv b/nirc_ehr/resources/data/observation_types.tsv
index fb1ee28b..0be54d2c 100644
--- a/nirc_ehr/resources/data/observation_types.tsv
+++ b/nirc_ehr/resources/data/observation_types.tsv
@@ -11,7 +11,7 @@ Environmental Change Behavior {"xtype":"ehr-simplecombo","schemaName":"ehr_looku
Special Enrichment Behavior {"xtype":"ehr-simplecombo","schemaName":"ehr_lookups","queryName":"yes_no_order","forceSelection":true,"displayField":"value","valueField":"value","sortFields":"sort_order"} ehr_lookups yes_no_order value
Preferences Behavior {"xtype":"ehr-simplecombo","schemaName":"ehr_lookups","queryName":"preferences","displayField":"value","valueField":"value"} ehr_lookups preferences value
Temperament Behavior {"xtype":"ehr-simplecombo","schemaName":"ehr_lookups","queryName":"temperament","displayField":"value","valueField":"value"} ehr_lookups temperament value
-BCS {"xtype":"ehr-simplecombo","schemaName":"ehr_lookups","queryName":"bcs_score","forceSelection":true,"displayField":"value","valueField":"value"} ehr_lookups bcs_score value
+BCS {"xtype":"ehr-simplecombo","schemaName":"ehr_lookups","queryName":"bcs_score","forceSelection":true,"displayField":"value","valueField":"value","sortFields":"sort_order"} ehr_lookups bcs_score value
CRT {"xtype":"textfield","defaultValue":"1-2"}
Mucous Membrane {"xtype":"textfield","defaultValue":"Pink"}
Pain Score {"xtype":"ldk-numberfield","minValue":0,"maxValue":12}
diff --git a/nirc_ehr/resources/data/problem_list_category.tsv b/nirc_ehr/resources/data/problem_list_category.tsv
index 50aa7287..67fcf34c 100644
--- a/nirc_ehr/resources/data/problem_list_category.tsv
+++ b/nirc_ehr/resources/data/problem_list_category.tsv
@@ -1,21 +1,14 @@
value description
Behavioral Behavioral issue or concern. Examples include SIB and fecal smearing.
-Cardiac Abnormality Abnormalities associated with the cardiac system. Examples include murmurs and dilated cardiomyopathy.
-Dermatopathy Abnormalities associated with the dermal system. Examples include alopecia and moist dermatitis.
-Endocrinopathy Abnormalities associated with the endocrine system. Diabetes is an example.
-GI-Diarrhea Clinical cases presenting for diarrhea, with or without dehydration.
-GI-Other Abnormalities associated with the digestive system, excluding diarrhea. Examples include dental extractions, vomiting, and adenocarcinoma.
-MS Abnormality Abnormalities associated with the musculoskeletal system. Examples include osteoarthritis, reactive arthritis, and fractures.
-Neurologic Abnormality Abnormalities associated with the neurologic system. Seizures are an example.
-OBGYN Condition Abnormalities associated with the female reproductive system. Examples include dystocia, vaginal prolapse, and heavy mense.
-Ophthalmic Abnormality Abnormalities associated with the ophthalmic system. Examples include blepharospasm and corneal abrasion.
-Other For conditions not covered by any other Master Problem. Uncommonly used.
-Protocol Associated The primary abnormality is the result of experimental manipulation. Examples include implant abscess, induced anemia, and induced diabetes mellitus.
-Research Support The case was opened for a surgery or activity supporting a research project. Examples include lymph node biopsy and BAL.
-Respiratory Abnormality Abnormalities associated with the respiratory system. Examples include URI and pneumonia.
-Routine or Preventative care Cases opened for routine or preventative care. Physical exam is an example.
-Urogenital Abnormalities associated with the urogenital system. Examples include cystitis, testicular or vulvar trauma, or renal amyloidosis.
-Weight Loss Cases opened for weight loss, when the etiology is unknown.
-Weight Management
-Wound Cases opened for a wound.
-Monitoring This is used to track animals that need additional monitoring after the initial problem has resolved. This allows the initial problem to be closed while still keeping an active case open.
\ No newline at end of file
+Trauma Case opened for some type of trauma.
+GI abnormality Abnormalities associated with the digestive system.
+Neurologic abnormality Abnormalities associated with the neurologic system.
+Dermatologic abnormality Abnormalities associated with the dermal system.
+Genitourinary abnormality Abnormalities associated with the genitourinary system.
+Circulatory abnormality Abnormalities associated with the circulatory system.
+Ocular abnormality Abnormalities associated with the ocular system.
+Respiratory abnormality Abnormalities associated with the respiratory system.
+Oral abnormality Abnormalities associated with the oral cavity.
+Musculoskeletal abnormality Abnormalities associated with the musculoskeletal system.
+General abnormality Abnormalities that do not fit into any other category.
+Study-related surgery Case opened for a surgery or activity supporting a research project.
\ No newline at end of file
diff --git a/nirc_ehr/resources/data/problem_list_subcategory.tsv b/nirc_ehr/resources/data/problem_list_subcategory.tsv
index 9eacc006..69bdab03 100644
--- a/nirc_ehr/resources/data/problem_list_subcategory.tsv
+++ b/nirc_ehr/resources/data/problem_list_subcategory.tsv
@@ -1,19 +1,75 @@
value category
-Weight Loss Weight Management
-Weight Gain Weight Management
-Dental GI-Other
-Vomiting GI-Other
-Liver GI-Other
Alopecia Behavioral
SIB Behavioral
-Other Behavioral
+Other behavioral Behavioral
Stereotypy Behavioral
Fecal smear Behavioral
Eye poking Behavioral
Urine drinking Behavioral
Copraphagy Behavioral
-Minor Laceration/Abrasion Wound
-Digit Amputation Wound
-Muscle Wound, Minor Wound
-Muscle Wound, Major Wound
-Rhabdomyolysis Wound
\ No newline at end of file
+Skin laceration(s) Trauma
+Muscle laceration(s) Trauma
+Crushing wounds Trauma
+Abrasions Trauma
+Fracture(s) Trauma
+Puncture wounds Trauma
+Traumatic amputation(s) Trauma
+SIB (self-injurious behavior) Trauma
+Other trauma Trauma
+Diarrhea GI abnormality
+Undercondition GI abnormality
+Dehydration GI abnormality
+Bloody Stool GI abnormality
+Anorexia GI abnormality
+Rectal prolapse GI abnormality
+Hepatomegaly GI abnormality
+Other GI abnormality GI abnormality
+Ataxia Neurologic abnormality
+Paralysis/Paresis Neurologic abnormality
+Head tilt Neurologic abnormality
+Other neurologic abnormality Neurologic abnormality
+Penile/preputial lesions Dermatologic abnormality
+Dermatitis Dermatologic abnormality
+Abscess Dermatologic abnormality
+Incisional infection Dermatologic abnormality
+Skin mass Dermatologic abnormality
+Skin lesion(s) Dermatologic abnormality
+Other dermatologic abnormality Dermatologic abnormality
+Dystocia Genitourinary abnormality
+Vaginal prolapse Genitourinary abnormality
+Uterine enlargement Genitourinary abnormality
+Endometriosis Genitourinary abnormality
+Retained placenta Genitourinary abnormality
+Hematuria (bloody urine) Genitourinary abnormality
+Other genitourinary abnormality Genitourinary abnormality
+AV fistula Circulatory abnormality
+Heart murmur Circulatory abnormality
+Other circulatory abnormality Circulatory abnormality
+Conjunctivitis/ocular discharge Ocular abnormality
+Blepharospasm Ocular abnormality
+Corneal ulcer Ocular abnormality
+Other ocular abnormality Ocular abnormality
+Dyspnea/Labored breathing Respiratory abnormality
+Purulent nasal discharge Respiratory abnormality
+Epistaxis/bloody nasal discharge Respiratory abnormality
+Other respiratory abnormality Respiratory abnormality
+Tooth abscess Oral abnormality
+Gingivitis/periodontal disease Oral abnormality
+Foreign body in cheek pouch Oral abnormality
+Oral mass Oral abnormality
+Other oral abnormality Oral abnormality
+Lameness Musculoskeletal abnormality
+Other musculoskeletal abnormality Musculoskeletal abnormality
+Weight loss General abnormality
+Edema General abnormality
+Abdominal mass General abnormality
+Unresponsive/Down General abnormality
+Lethargy General abnormality
+Orphan/dam neglect General abnormality
+Anemia General abnormality
+Thrombocytopenia General abnormality
+Other general abnormality General abnormality
+Jejunal resection Study-related surgery
+Liver biopsy Study-related surgery
+Spleen biopsy Study-related surgery
+Other study-related surgery Study-related surgery
diff --git a/nirc_ehr/resources/queries/study/cases.js b/nirc_ehr/resources/queries/study/cases.js
index 874ab0ab..02e895b3 100644
--- a/nirc_ehr/resources/queries/study/cases.js
+++ b/nirc_ehr/resources/queries/study/cases.js
@@ -42,7 +42,7 @@ EHR.Server.TriggerManager.registerHandlerForQuery(EHR.Server.TriggerManager.Even
if (ordersInTransaction && ordersInTransaction.length) {
oit = ordersInTransaction;
}
- triggerHelper.ensureDailyClinicalObservationOrders(row.Id, row.caseid, row.performedby, qc.RowId, row.taskid, oit);
+ triggerHelper.ensureDailyClinicalObservationOrders(row.Id, row.caseid, row.date, row.performedby, qc.RowId, row.taskid, oit);
}
}
}
diff --git a/nirc_ehr/resources/queries/study/housing.js b/nirc_ehr/resources/queries/study/housing.js
index 0a5fab09..2e919eda 100644
--- a/nirc_ehr/resources/queries/study/housing.js
+++ b/nirc_ehr/resources/queries/study/housing.js
@@ -17,6 +17,15 @@ EHR.Server.TriggerManager.registerHandlerForQuery(EHR.Server.TriggerManager.Even
prevAnimalId = row.Id;
prevDate = row.date;
}
+ else {
+ if (row.reason === 'Veterinary Treatment' && !row.remark) {
+ EHR.Server.Utils.addError(scriptErrors, 'remark', 'Reason For Move - Veterinary Treatment requires a remark.', 'ERROR');
+ }
+
+ if (!helper.isValidateOnly() && row.reason === 'Veterinary Treatment' && (!oldRow || oldRow.reason !== 'Veterinary Treatment')) {
+ triggerHelper.clinicalMoveNotification(row.Id, row.date);
+ }
+ }
});
function onComplete(event, errors, helper){
@@ -34,7 +43,6 @@ function onComplete(event, errors, helper){
var idsToClose = [];
for (var i = 0; i < updateRows.length; i++) {
if (EHR.Server.Security.getQCStateByLabel(updateRows[i].row.QCStateLabel).PublicData && updateRows[i].row.date) {
- updateRows[i].row.date.setHours(12); // Necessary to clear EHR warning
idsToClose.push({
Id: updateRows[i].row.Id,
date: EHR.Server.Utils.datetimeToString(updateRows[i].row.date), //stringify to serialize properly
diff --git a/nirc_ehr/resources/referenceStudy/study/datasets/datasets_metadata.xml b/nirc_ehr/resources/referenceStudy/study/datasets/datasets_metadata.xml
index 8c32956e..8e0564de 100644
--- a/nirc_ehr/resources/referenceStudy/study/datasets/datasets_metadata.xml
+++ b/nirc_ehr/resources/referenceStudy/study/datasets/datasets_metadata.xml
@@ -915,6 +915,10 @@
integer
+
+ Ordered By
+ varchar
+
diff --git a/nirc_ehr/resources/web/nirc_ehr/model/sources/BehaviorDefaults.js b/nirc_ehr/resources/web/nirc_ehr/model/sources/BehaviorDefaults.js
index 75e9e960..e4c9e53b 100644
--- a/nirc_ehr/resources/web/nirc_ehr/model/sources/BehaviorDefaults.js
+++ b/nirc_ehr/resources/web/nirc_ehr/model/sources/BehaviorDefaults.js
@@ -58,22 +58,12 @@ EHR.model.DataModelManager.registerMetadata('BehaviorDefaults', {
},
},
'study.clinical_observations': {
- category: {
- lookup: {
- filterArray: [LABKEY.Filter.create('category', 'Behavior')]
- }
- },
type: {
hidden: true,
defaultValue: 'Behavior'
}
},
'study.observation_order': {
- category: {
- lookup: {
- filterArray: [LABKEY.Filter.create('category', 'Behavior')]
- }
- },
type: {
hidden: true,
defaultValue: 'Behavior'
diff --git a/nirc_ehr/resources/web/nirc_ehr/model/sources/BulkBehavior.js b/nirc_ehr/resources/web/nirc_ehr/model/sources/BulkBehavior.js
index d0ce9a04..54b40f57 100644
--- a/nirc_ehr/resources/web/nirc_ehr/model/sources/BulkBehavior.js
+++ b/nirc_ehr/resources/web/nirc_ehr/model/sources/BulkBehavior.js
@@ -58,11 +58,6 @@ EHR.model.DataModelManager.registerMetadata('BulkBehavior', {
},
},
'study.clinical_observations': {
- category: {
- lookup: {
- filterArray: [LABKEY.Filter.create('category', 'Behavior')]
- }
- },
type: {
hidden: true,
defaultValue: 'Behavior'
diff --git a/nirc_ehr/src/org/labkey/nirc_ehr/NIRC_EHRModule.java b/nirc_ehr/src/org/labkey/nirc_ehr/NIRC_EHRModule.java
index ffacf6d6..84cd1b47 100644
--- a/nirc_ehr/src/org/labkey/nirc_ehr/NIRC_EHRModule.java
+++ b/nirc_ehr/src/org/labkey/nirc_ehr/NIRC_EHRModule.java
@@ -54,6 +54,8 @@
import org.labkey.nirc_ehr.demographics.NecropsyStatusDemographicsProvider;
import org.labkey.nirc_ehr.demographics.ProtocolAssignmentDemographicsProvider;
import org.labkey.nirc_ehr.history.*;
+import org.labkey.nirc_ehr.notification.NIRCClinicalMoveNotification;
+import org.labkey.nirc_ehr.notification.NIRCDeathNotification;
import org.labkey.nirc_ehr.query.NIRC_EHRUserSchema;
import org.labkey.nirc_ehr.security.NIRCEHRVetTechRole;
import org.labkey.nirc_ehr.table.NIRC_EHRCustomizer;
@@ -186,6 +188,7 @@ protected void doStartupAfterSpringConfig(ModuleContext moduleContext)
registerDataEntry();
NotificationService.get().registerNotification(new NIRCDeathNotification());
+ NotificationService.get().registerNotification(new NIRCClinicalMoveNotification());
// Ensure N: is mounted if it's configured, as it's being mapped in via a symlink/shortcut, so we can't
// recognize paths using it based solely on their drive letter and mount just-in-time
diff --git a/nirc_ehr/src/org/labkey/nirc_ehr/dataentry/form/NIRCBulkClinicalFormType.java b/nirc_ehr/src/org/labkey/nirc_ehr/dataentry/form/NIRCBulkClinicalFormType.java
index e9d281e0..5d18ce52 100644
--- a/nirc_ehr/src/org/labkey/nirc_ehr/dataentry/form/NIRCBulkClinicalFormType.java
+++ b/nirc_ehr/src/org/labkey/nirc_ehr/dataentry/form/NIRCBulkClinicalFormType.java
@@ -34,12 +34,12 @@ public NIRCBulkClinicalFormType(DataEntryFormContext ctx, Module owner)
new NIRCClinicalRemarksFormSection(ctx.getContainer().hasPermission(ctx.getUser(), NIRCEHRVetTechPermission.class),
ctx.getContainer().hasPermission(ctx.getUser(), EHRVeterinarianPermission.class),
ctx.getContainer().hasPermission(ctx.getUser(), AdminPermission.class)),
- new NIRCProcedureFormSection(),
+ new NIRCWeightFormSection(true, true),
new NIRCClinicalObservationsFormSection(false, null),
new NIRCObservationOrdersFormSection("NIRC_DAILY_CLINICAL_OBS_ORDERS", false, null),
+ new NIRCProcedureFormSection(),
new NIRCTreatmentGivenFormSection(),
new NIRCTreatmentOrderFormSection(),
- new NIRCWeightFormSection(true, true),
new NIRCVitalsFormSection(),
new NIRCBloodDrawFormSection(true, true, true)
));
diff --git a/nirc_ehr/src/org/labkey/nirc_ehr/dataentry/form/NIRCCasesFormType.java b/nirc_ehr/src/org/labkey/nirc_ehr/dataentry/form/NIRCCasesFormType.java
index c4e52015..8686552e 100644
--- a/nirc_ehr/src/org/labkey/nirc_ehr/dataentry/form/NIRCCasesFormType.java
+++ b/nirc_ehr/src/org/labkey/nirc_ehr/dataentry/form/NIRCCasesFormType.java
@@ -40,15 +40,15 @@ public NIRCCasesFormType(DataEntryFormContext ctx, Module owner)
new NIRCCaseTemplateFormSection("Case Template", "Case Template", "nirc_ehr-casetemplatepanel", Arrays.asList(ClientDependency.supplierFromPath("nirc_ehr/panel/CaseTemplatePanel.js"))),
new NIRCCasesFormPanelSection("Clinical Case", ctx, false),
new NIRCClinicalRemarksFormPanelSection(true, "cases", "Clinical Remarks", ctx, false),
- new NIRCProcedureFormSection(true, "cases"),
+ new NIRCWeightFormSection(true, false, true, "cases"),
new NIRCClinicalObservationsFormSection(true, "cases"),
new NIRCObservationOrdersFormSection(null, true, "cases"),
+ new NIRCProcedureFormSection(true, "cases"),
new NIRCTreatmentGivenFormSection(true, "cases"),
new NIRCTreatmentOrderFormSection(true, "cases"),
- new NIRCWeightFormSection(true, false, true, "cases"),
new NIRCVitalsFormSection(true, "cases"),
- new NIRCHousingFormSection(true, true, true, "cases"),
- new NIRCBloodDrawFormSection(true, "cases")
+ new NIRCBloodDrawFormSection(true, "cases"),
+ new NIRCHousingFormSection(true, true, true, "cases")
));
setTemplateMode(AbstractFormSection.TEMPLATE_MODE.NO_ID);
diff --git a/nirc_ehr/src/org/labkey/nirc_ehr/dataentry/form/NIRCClinicalRoundsFormType.java b/nirc_ehr/src/org/labkey/nirc_ehr/dataentry/form/NIRCClinicalRoundsFormType.java
index bec9ece0..a8ec8785 100644
--- a/nirc_ehr/src/org/labkey/nirc_ehr/dataentry/form/NIRCClinicalRoundsFormType.java
+++ b/nirc_ehr/src/org/labkey/nirc_ehr/dataentry/form/NIRCClinicalRoundsFormType.java
@@ -36,16 +36,16 @@ public NIRCClinicalRoundsFormType(DataEntryFormContext ctx, Module owner)
new NIRCAnimalDetailsFormSection(),
new NIRCCaseTemplateFormSection("Case Template", "Case Template", "nirc_ehr-casetemplatepanel", Arrays.asList(ClientDependency.supplierFromPath("nirc_ehr/panel/CaseTemplatePanel.js"))),
new NIRCCasesFormPanelSection("Clinical Case", ctx, false),
- new NIRCProcedureFormSection(true, "cases"),
+ new NIRCWeightFormSection(true, false, true, "cases"),
new NIRCClinicalObservationsFormSection(true, "cases"),
new NIRCObservationOrdersFormSection(null, true, "cases"),
+ new NIRCProcedureFormSection(true, "cases"),
new NIRCTreatmentGivenFormSection(true, "cases"),
new NIRCTreatmentOrderFormSection(true,
"cases"),
- new NIRCWeightFormSection(true, false, true, "cases"),
new NIRCVitalsFormSection(true, "cases"),
- new NIRCHousingFormSection(true, true, true, "cases"),
- new NIRCBloodDrawFormSection(true, "cases")
+ new NIRCBloodDrawFormSection(true, "cases"),
+ new NIRCHousingFormSection(true, true, true, "cases")
));
setTemplateMode(AbstractFormSection.TEMPLATE_MODE.NO_ID);
diff --git a/nirc_ehr/src/org/labkey/nirc_ehr/demographics/HousingDemographicsProvider.java b/nirc_ehr/src/org/labkey/nirc_ehr/demographics/HousingDemographicsProvider.java
index ee290b20..d6d16da3 100644
--- a/nirc_ehr/src/org/labkey/nirc_ehr/demographics/HousingDemographicsProvider.java
+++ b/nirc_ehr/src/org/labkey/nirc_ehr/demographics/HousingDemographicsProvider.java
@@ -40,7 +40,7 @@ protected Collection getFieldKeys()
keys.add(FieldKey.fromString("cage/cage"));
keys.add(FieldKey.fromString("date"));
keys.add(FieldKey.fromString("reason"));
-
+ keys.add(FieldKey.fromString("remark"));
keys.add(FieldKey.fromString("location"));
return keys;
diff --git a/nirc_ehr/src/org/labkey/nirc_ehr/notification/NIRCClinicalMoveNotification.java b/nirc_ehr/src/org/labkey/nirc_ehr/notification/NIRCClinicalMoveNotification.java
new file mode 100644
index 00000000..57b56984
--- /dev/null
+++ b/nirc_ehr/src/org/labkey/nirc_ehr/notification/NIRCClinicalMoveNotification.java
@@ -0,0 +1,41 @@
+package org.labkey.nirc_ehr.notification;
+
+import org.jetbrains.annotations.Nullable;
+import org.labkey.api.data.Container;
+import org.labkey.api.ehr.notification.AbstractEHRNotification;
+import org.labkey.api.security.User;
+
+import java.util.Date;
+
+public class NIRCClinicalMoveNotification extends AbstractEHRNotification
+{
+ @Override
+ public String getName()
+ {
+ return "Clinical Move Notification";
+ }
+
+ @Override
+ public String getScheduleDescription()
+ {
+ return "Sent immediately when a housing transfer is recorded with the reason 'Veterinary Treatment'";
+ }
+
+ @Override
+ public @Nullable String getMessageBodyHTML(Container c, User u)
+ {
+ return "";
+ }
+
+ @Override
+ public String getDescription()
+ {
+ return "The report sends an alert whenever an animal has a housing transfer and the reason for the move is 'Veterinary Treatment'.";
+ }
+
+ @Override
+ public String getEmailSubject(Container c)
+ {
+ return "Clinical Move Alert: " + getDateTimeFormat(c).format(new Date());
+ }
+}
diff --git a/nirc_ehr/src/org/labkey/nirc_ehr/NIRCDeathNotification.java b/nirc_ehr/src/org/labkey/nirc_ehr/notification/NIRCDeathNotification.java
similarity index 97%
rename from nirc_ehr/src/org/labkey/nirc_ehr/NIRCDeathNotification.java
rename to nirc_ehr/src/org/labkey/nirc_ehr/notification/NIRCDeathNotification.java
index 0c4919b2..ce6cf21e 100644
--- a/nirc_ehr/src/org/labkey/nirc_ehr/NIRCDeathNotification.java
+++ b/nirc_ehr/src/org/labkey/nirc_ehr/notification/NIRCDeathNotification.java
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.labkey.nirc_ehr;
+package org.labkey.nirc_ehr.notification;
import org.labkey.api.data.Container;
import org.labkey.api.ehr.notification.AbstractEHRNotification;
diff --git a/nirc_ehr/src/org/labkey/nirc_ehr/query/NIRC_EHRTriggerHelper.java b/nirc_ehr/src/org/labkey/nirc_ehr/query/NIRC_EHRTriggerHelper.java
index ec0bf599..48e71bf9 100644
--- a/nirc_ehr/src/org/labkey/nirc_ehr/query/NIRC_EHRTriggerHelper.java
+++ b/nirc_ehr/src/org/labkey/nirc_ehr/query/NIRC_EHRTriggerHelper.java
@@ -37,14 +37,16 @@
import org.labkey.api.util.GUID;
import org.labkey.api.util.JobRunner;
import org.labkey.api.util.PageFlowUtil;
-import org.labkey.api.util.Pair;
-import org.labkey.nirc_ehr.NIRCDeathNotification;
import org.labkey.nirc_ehr.NIRCOrchardFileGenerator;
import org.labkey.nirc_ehr.NIRC_EHRManager;
+import org.labkey.nirc_ehr.notification.NIRCClinicalMoveNotification;
+import org.labkey.nirc_ehr.notification.NIRCDeathNotification;
import org.labkey.nirc_ehr.notification.TriggerScriptNotification;
import java.sql.SQLException;
import java.text.SimpleDateFormat;
+import java.time.LocalDateTime;
+import java.time.ZoneId;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
@@ -335,6 +337,53 @@ public void upsertWeightRecord(Map row) throws QueryUpdateServic
throw errors;
}
+ public void clinicalMoveNotification(final String animalId, final String date)
+ {
+ //check whether Death Notification is enabled
+ if (!NotificationService.get().isActive(new NIRCClinicalMoveNotification(), _container) || !NotificationService.get().isServiceEnabled())
+ {
+ _log.info("NIRC Clinical Move notification service is not enabled, will not send clinical move notification.");
+ return;
+ }
+
+ try (DbScope.Transaction transaction = StudyService.get().getDatasetSchema().getScope().ensureTransaction())
+ {
+ // Add a post commit task to run provider update in another thread once this transaction is complete.
+ transaction.addCommitTask(() ->
+ JobRunner.getDefault().execute(() -> {
+ final Container container = _container;
+ final User user = _user;
+ NIRCClinicalMoveNotification notification = new NIRCClinicalMoveNotification();
+ String subject = "Clinical Move Notification: " + animalId;
+
+ // get recipients
+ Set recipients = NotificationService.get().getRecipients(notification, container);
+ if (recipients.size() == 0)
+ {
+ _log.warn("No NIRC recipients set, skipping clinical move notification");
+ return;
+ }
+
+ String remark = (String) EHRDemographicsService.get().getAnimal(container, animalId).getActiveHousing().get(0).get("remark");
+
+ //construct html for email notification
+ final StringBuilder html = new StringBuilder();
+ html.append("Animal ").append(PageFlowUtil.filter(animalId)).append(" has been moved for Veterinary Treatment on ").append(date).append(".
");
+ if (remark != null)
+ html.append("Remark: ").append(PageFlowUtil.filter(remark)).append("
");
+
+ //append animal details
+ appendAnimalDetails(html, animalId, container);
+
+ // send Clinical Move Notification
+ _log.debug("NIRC Clinical Move notification job sending email for animal " + animalId + " in container " + container.getPath());
+ TriggerScriptNotification.sendMessage(subject, html.toString(), recipients, container, user);
+ }), DbScope.CommitTaskOption.POSTCOMMIT);
+
+ transaction.commit();
+ }
+ }
+
public void sendDeathNotification(final String animalId) throws Exception
{
//check whether Death Notification is enabled
@@ -413,8 +462,32 @@ public void generateOrchardFile(final String taskid) throws Exception
private void appendAnimalDetails(StringBuilder html, String id, final Container container)
{
String url = AppProps.getInstance().getBaseServerUrl() + AppProps.getInstance().getContextPath() + "/ehr" + container.getPath() + "/participantView.view?participantId=" + id;
- html.append("Project: ").append(PageFlowUtil.filter(getProject(id))).append("
");
- html.append("Protocol: ").append(PageFlowUtil.filter(getProtocol(id))).append("
");
+
+ String tdFieldStyle = "\"border: 1px solid #000000;padding:5px;background-color:lightgray\"";
+ String tdValueStyle = "\"border: 1px solid #000000;padding:5px;\"";
+
+ String tableStyle = "\"" +
+ " border-collapse: collapse;" +
+ " border: 1px solid #000000;\"";
+
+ String cage;
+ List