Remember to always back up your data before making any changes to it.
Always try out your customizations on a test server first, NOT the live one.
The following customization was tested in PowerSchool 7.11.1, so it might not work in the newer versions.
The following customization was not tested in Internet Explorer.
For this customization you will also need an icon/image (preferably square and less or about 12×12 pixels) for the “info” functionality (show details on hover).
With more than 100 visits to the Health Office a day, our two nurses asked me if I could somehow help them save some time when filling in the details on the Health Office Visits page.
They wanted to know if some of the fields on the page could be pre-populated (such as the Provider Name, Visit Date and Visit Time In/Out) and if I could somehow make their job of getting in touch with the parents on their children’s health issues easier.
This is what I came up with:
In order to achieve the above result you’ll need to start by editing home_officevisit.html file in the /admin/students/health folder (I assume that you already have a copy of the file in your PowerSchool customization folder).
- Open the file in a text editor and locate the closing head tag (</head>).
- The customization is based on JavaScript/jQuery code but has some CSS added to it too. We’ll start with the latter first.
- Add the following piece of CSS code just above you </head> tag.
<style>
/* the info image */
#imgInfo{
/* set the size */
width: 12px;
height: 12px;
}
</style> - Just between the ending </style> and </head> tags add a pair of script tags (<script></script>). All the code to follow on this page will be placed in between those <script> tags.
- Define a function that will get today’s date in MM/DD/YYYY format.
function getTodaysDate(){
var fullDate = new Date();
var twoDigitMonth = (fullDate.getMonth() + 1) + “”;
if(twoDigitMonth.length==1) twoDigitMonth = “0” + twoDigitMonth;
var twoDigitDate = fullDate.getDate() + “”;
if(twoDigitDate.length==1) twoDigitDate = “0” + twoDigitDate;
var currentDate = twoDigitMonth + “/” + twoDigitDate + “/” + fullDate.getFullYear();
return currentDate;
} - Define a function that will get the current time (if delayMins is specified than it adds delayMins minutes to the current time).
function getCurrentTime(delayMins){
var today=new Date();
var todayGetTime = today.getTime();
if (delayMins != “” && typeof delayMins != “undefined”) today.setTime(todayGetTime + delayMins * 60 * 1000);
var h=today.getHours();
var m=today.getMinutes();
var s=today.getSeconds();
var ampm=h >= 12 ? ‘PM’ : ‘AM’;
h = h % 12;
h= h ? h : 12;
h = h < 10 ? ‘0’+h : h;
m = m < 10 ? ‘0’+m : m;
var currentTime = h + “:” + m + ” ” + ampm;
return currentTime;
} - The following function will pre-populate several fields on the page.
function prePopulateFields(){
//Provider Name = Username
$j(“#officevisits_screenerName”).val(“~[x:username]”);
//Provider Type = “Nurse” (value = 10029 in my system – it might differ in yours!)
$j(“#officevisits_officeVisitScreenerTypeLUID”).val(“10029”);
//Visit Date is today’s date
$j(“#officevisits_visitDate”).val(getTodaysDate());
//Visit Time In is the current time
$j(“#officevisits_visitTimeIni18”).val(getCurrentTime());
//Visit Time Out is the current time + 15 min
$j(“#officevisits_visitTimeOuti18”).val(getCurrentTime(15));
} - The next function creates the email button (defined by btnName and btnText) and adds it after element defined by afterWhichElem (as HTML Object).
function createEmailBtn(btnName, btnText, afterWhichElem){
var btnEmail = “<div id='” + btnName + “_officevisits_button’ class=’floatrt’><span id=’screeningtable-” + btnName + “-officevisits’ class=’yui-button yui-link-button’><span class=’first-child’><a id=’screeningtable-” + btnName + “-officevisits-button’>” + btnText + “</a></span></span></div>”;
afterWhichElem.after(btnEmail);
} - The following three functions build the email’s recipient(s), subject and body (the way the nurses wanted the email to look like).
//builds the email’s recipient(s)
function createEmailTo(){
var sEmailTo = “~(GuardianEmail)”;
return sEmailTo;
}
//builds the email’s subject
function createEmailSubject(){
var sSubject = “~(LastFirst) – Health Office visit on ” + $j(“#officevisits_visitDate”).val() + ” at ” + $j(“#officevisits_visitTimeIni18”).val();
return sSubject;
}
//builds the email’s body
function createEmailBody(){
var sBody = “Visit details:\n”;
if ($j(‘#officevisits_visitTypeLUID :selected’).val() != “”) sBody += “\tVisit Type: \n\t\t” + $j(‘#officevisits_visitTypeLUID :selected’).text() + “\n”;
if ($j(“#officevisits_screenerName”).val() != “”){
sBody += “\tProvider Name: \n\t\t” + $j(“#officevisits_screenerName”).val();
if ($j(“#officevisits_officeVisitScreenerTypeLUID :selected”).val() != “”) sBody += ” (” + $j(“#officevisits_officeVisitScreenerTypeLUID :selected”).text() + “)”;
sBody += “\n”;
}
sBody += “\nVisit reasons:\n”;
if ($j(“#officevisits_visitReasonDesc”).val() != “”) sBody += “\tIssue: \n\t\t” + $j(“#officevisits_visitReasonDesc”).val().replace(/\n/g,”\n\t\t”) + “\n”;
if ($j(“#officevisits_assessment”).val() != “”) sBody += “\tAssessment: \n\t\t” + $j(“#officevisits_assessment”).val().replace(/\n/g,”\n\t\t”) + “\n”;
sBody += “\nOutcome and Actions:\n”;
if ($j(“#officevisits_visitOutcomeLUID :selected”).val() != “”) sBody += “\tVisit outcome: \n\t\t” + $j(“#officevisits_visitOutcomeLUID :selected”).text() + “\n”;
if ($j(“#officevisits_actions”).val().replace(/\n/g,”\n\t\t”) != “”) sBody += “\tActions: \n\t\t” + $j(“#officevisits_actions”).val().replace(/\n/g,”\n\t\t”) + “\n\n”;
return sBody;
} - This function opens a new email message in the default email client with the parameters specified by msgEmail, msgSubj and msgBody.
function openEmailMessage(msgEmail,msgSubj,msgBody){
var msgMail = “mailto:” + escape(msgEmail) + “?subject=” + escape(msgSubj) + “&body=” + escape(msgBody);
window.location.href = msgMail;
} - Define a function that checks if the “Contact with Parent” check box is checked or not, and if it isn’t then checks it.
function checkContact(chkGuardCntct){
if (chkGuardCntct.not(“:checked”)) chkGuardCntct.attr(‘checked’, ‘checked’);
} - Inside the “on document ready” jQuery function $j(document).ready(function() { …… } (if there isn’t one, add it) add the following piece of code:
//on clicking on the “+Add” button on the page
$j(“#add_screening_button”).click(function() {
//pre-populate fields
prePopulateFields();
//add the Info icon (displaying the student’s parent details)
$j(“#officevisits_isGuardianContacted”).after(“<img src=’/images/moreinfo.png’ id=’imgInfo’ />”);
//build the image’s title
var imgTitle = “~([01]father) (~(ISB_contact1_relationship;if.blank.then=Contact 1;smartcase)): ~([01]fatherdayphone)\n~([01]mother) (~(ISB_contact2_relationship;if.blank.then=Contact 2;smartcase)): ~([01]motherdayphone)”;
//assign the title to the image
$j(“#imgInfo”).attr(“title”,imgTitle);
});
//define variables
//button’s name and text
var btnName = “email”;
var btnText = “Email Guardian(s)”;
//the element you want the Email Button inserted after (here: the Cancel button at the bottom of the page)
var afterWhichElem = $j(“#cancel_officevisits_button”);
//”Contact with Parent” checkbox
var chkGuardCntct = $j(“#officevisits_isGuardianContacted”);
//create the actual Email Button
createEmailBtn(btnName,btnText,afterWhichElem);
//on clicking on the freshly-created Email Button
$j(“#screeningtable-email-officevisits-button”).on(“click”,function(){
//check the checkbox
checkContact(chkGuardCntct);
//open the email message
openEmailMessage(createEmailTo(),createEmailSubject(),createEmailBody());
});
Now you see how easy it is to make your Health Office staff happy? 😀