Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions nirc_ehr/resources/queries/study/arrival.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,12 @@ function onInit(event, helper){
});
}

EHR.Server.TriggerManager.registerHandlerForQuery(EHR.Server.TriggerManager.Events.BEFORE_INSERT, 'study', 'Arrival', function(helper, scriptErrors, row, oldRow) {
EHR.Server.TriggerManager.registerHandlerForQuery(EHR.Server.TriggerManager.Events.BEFORE_UPSERT, 'study', 'Arrival', function(helper, scriptErrors, row, oldRow) {

if (triggerHelper.animalIdExists(row.Id)) {
// Due to order of operation, this needs to be done in upsert instead of insert
if (helper.getEvent() == 'insert' && row.Id && triggerHelper.animalIdExists(row.Id)) {
EHR.Server.Utils.addError(scriptErrors, 'Id', 'Animal Id ' + row.Id + ' is already in use. Please use a different Id.', 'ERROR');
}
});

EHR.Server.TriggerManager.registerHandlerForQuery(EHR.Server.TriggerManager.Events.BEFORE_UPSERT, 'study', 'Arrival', function(helper, scriptErrors, row, oldRow) {

if (row.eventDate) {
row.date = row.eventDate;
Expand Down
8 changes: 6 additions & 2 deletions nirc_ehr/resources/queries/study/deaths.query.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,12 @@
<fkDisplayColumnName>title</fkDisplayColumnName>
</fk>
</column>
<column columnName="remark"/>
<column columnName="performedby" />
<column columnName="remark">
<isHidden>true</isHidden>
</column>
<column columnName="performedby">
<isHidden>true</isHidden>
</column>
<column columnName="description">
<isHidden>true</isHidden>
</column>
Expand Down
2 changes: 0 additions & 2 deletions nirc_ehr/resources/queries/study/deaths/.qview.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,5 @@
<column name="Id/Demographics/species"/>
<column name="date"/>
<column name="reason"/>
<column name="remark"/>
<column name="performedBy"/>
</columns>
</customView>
2 changes: 1 addition & 1 deletion nirc_ehr/resources/views/necropsy.html
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
schemaName: 'study',
queryName: 'deaths',
filterArray: filterArray,
columns: 'Id,Id/demographics/species,date,reason,remark,performedby,Id/lastProtocol/protocol,Id/lastProject/project',
columns: 'Id,Id/demographics/species,date,reason,Id/lastProtocol/protocol,Id/lastProject/project',
},
title: 'Death',
renderTo: 'animalDeath',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ EHR.model.DataModelManager.registerMetadata('DeathNecropsy', {
dateFormat: 'Y-m-d',
timeFormat: 'H:i'
},
},
remark: {
hidden: true
},
performedby: {
hidden: true
}
},
'study.necropsy': {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public List<String> getTbarButtons()
List<String> defaults = super.getTbarButtons();
defaults.remove("ADDANIMALS");
defaults.remove("TEMPLATE");
defaults.add("TEMPLATE_NO_ID_NO_DATE");
return defaults;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -267,13 +267,9 @@ public String saveBirthRecord(String id, Map<String, Object> row) throws QueryUp
public boolean animalIdExists(String id)
{
TableInfo ti = getTableInfo("study", "demographics");
if (ti != null)
{
SimpleFilter filter = new SimpleFilter(FieldKey.fromString("Id"), id);
TableSelector ts = new TableSelector(ti, PageFlowUtil.set("lsid"), filter, null);
return ts.exists();
}
return false;
SimpleFilter filter = new SimpleFilter(FieldKey.fromString("Id"), id);
TableSelector ts = new TableSelector(ti, PageFlowUtil.set("lsid"), filter, null);
return ts.exists();
}

public boolean birthExists(String id)
Expand Down