Skip to content
Open
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
18 changes: 18 additions & 0 deletions doc/manual/wordkeys.rst
Original file line number Diff line number Diff line change
Expand Up @@ -985,6 +985,22 @@ LogComments
LogCreatedBy
The person who created the log entry

Condition Keys
--------

You must use a qualifier suffix to access these records.

ConditionName
The name of the condition
ConditionTypeName
The name of the condition type
ConditionStartDatetime
When the condition started
ConditionEndDatetime
When the condition ended
ConditionComments
Any comments on the condition

Movement Keys
-------------

Expand Down Expand Up @@ -1625,6 +1641,8 @@ AnimalLogs
Inserts a table containing all of the animal's log entries
AnimalLogsTYPE
Inserts a table containing all of the animal's log entries of TYPE
AnimalConditions
Inserts a table containing all of the animal's recorded conditions
IncidentLogs
Inserts a table containing all of the incident's log entries
LitterMates
Expand Down
1 change: 0 additions & 1 deletion src/asm3/animal.py
Original file line number Diff line number Diff line change
Expand Up @@ -4911,7 +4911,6 @@ def update_animalcondition_from_form(dbo: Database, username: str, post: PostedD
Updates an animalcondition record from posted form data
"""
dbo.update("animalcondition", post.integer("animalconditionid"), {
"AnimalID": post.integer("animalid"),
"ConditionID": post.integer("conditionid"),
"StartDatetime": post.datetime("startdate", "starttime"),
"EndDatetime": post.datetime("enddate", "endtime"),
Expand Down
2 changes: 1 addition & 1 deletion src/asm3/dbupdates/35108.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
fields = ",".join([
dbo.ddl_add_table_column("ID", dbo.type_integer, False, pk=True),
dbo.ddl_add_table_column("StartDatetime", dbo.type_datetime, False),
dbo.ddl_add_table_column("EndDatetime", dbo.type_integer, True),
dbo.ddl_add_table_column("EndDatetime", dbo.type_datetime, True),
dbo.ddl_add_table_column("AnimalID", dbo.type_integer, False),
dbo.ddl_add_table_column("ConditionID", dbo.type_integer, False),
dbo.ddl_add_table_column("Comments", dbo.type_longtext, False)
Expand Down
18 changes: 18 additions & 0 deletions src/asm3/wordprocessor.py
Original file line number Diff line number Diff line change
Expand Up @@ -860,6 +860,24 @@ def animal_tags(dbo: Database, a: ResultRow, includeAdditional=True, includeCost
tags[tagname] = mt["MEDICALTYPENAME"].upper()
tags[tagname + "GIVEN"] = python2display(l, mt["DATEGIVEN"])
tags[tagname + "DUE"] = python2display(l, mt["DATEREQUIRED"])

# Conditions
d = {
"CONDITIONNAME": "CONDITIONNAME",
"CONDITIONTYPENAME": "CONDITIONTYPENAME",
"CONDITIONSTARTDATETIME": "d:STARTDATETIME",
"CONDITIONENDDATETIME": "d:ENDDATETIME",
"CONDITIONCOMMENTS": "COMMENTS"
}
conditions = asm3.animal.get_animalconditions(dbo, a["ID"])
tags.update(table_tags(dbo, d, conditions, "CONDITIONNAME"))
tags["ANIMALCONDITIONS"] = html_table(l, conditions, (
( "CONDITIONNAME", _("Condition", l) ),
( "CONDITIONTYPENAME", _("ConditionType", l) ),
( "STARTDATETIME", _("From", l) ),
( "ENDDATETIME", _("To", l) ),
( "COMMENTS", _("Comments", l) )
))

# Diary
if includeDiary:
Expand Down
40 changes: 35 additions & 5 deletions src/static/js/animal_condition.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,16 @@ $(function() {
rows: controller.rows,
idcolumn: "ID",
edit: async function(row) {
await tableform.dialog_show_edit(dialog, row);
await tableform.dialog_show_edit(dialog, row, {
onvalidate: function() {
if (!$("#starttime").val()) { $("#starttime").val("00:00:00"); }
let enddate = $("#enddate").val();
let endtime = $("#endtime").val();
if (enddate && !endtime) { $("#endtime").val("00:00:00"); }
return true;
}
}
);
tableform.fields_update_row(dialog.fields, row);
row.CONDITIONNAME = common.get_field(controller.conditions, row.CONDITIONID, "CONDITIONNAME");
await tableform.fields_post(dialog.fields, "mode=update&animalconditionid=" + row.ID, "animal_condition");
Expand All @@ -35,16 +44,37 @@ $(function() {
},
columns: [
{ field: "CONDITIONNAME", display: _("Condition") },
{ field: "STARTDATETIME", display: _("Start"), formatter: tableform.format_datetime },
{ field: "ENDDATETIME", display: _("End"), formatter: tableform.format_datetime },
{ field: "STARTDATETIME", display: _("Start"),
formatter: function(row, v) {
return format.date(v) + " " + format.time(v, "%H:%M:%S", true);
}
},
{ field: "ENDDATETIME", display: _("End"),
formatter: function(row, v) {
return format.date(v) + " " + format.time(v, "%H:%M:%S", true);
}
},
{ field: "COMMENTS", display: _("Comments"), formatter: tableform.format_comments }
]
};

const buttons = [
{ id: "new", text: _("New Condition"), icon: "new", enabled: "always", perm: "aaco",
click: async function() {
await tableform.dialog_show_add(dialog);
click: async function() {
await tableform.dialog_show_add(dialog, {
onvalidate: function() {
if (!$("#starttime").val()) { $("#starttime").val("00:00:00"); }
let enddate = $("#enddate").val();
let endtime = $("#endtime").val();
if (enddate && !endtime) { $("#endtime").val("00:00:00"); }
return true;
},
onload: function() {
// Reset the date fields
$("#startdate").datepicker("setDate", new Date());
$("#starttime, #enddate, #endtime").val("");
}
});
let response = await tableform.fields_post(dialog.fields, "mode=create&animalid=" + controller.animal.ID, "animal_condition");
let row = {};
row.ID = response;
Expand Down