Widget:VisitSchedulerRedux: Difference between revisions

Jump to navigation Jump to search
No edit summary
No edit summary
Line 6: Line 6:
$.noConflict();
$.noConflict();
jQuery( document ).ready(function( $ ) {
jQuery( document ).ready(function( $ ) {
$( "#appointments" ).hide();
$( "#indexEvent" ).datepicker({minDate: new Date()});
$( "#indexEvent" ).datepicker({minDate: new Date()});
$( "#indexEvent" ).change(function(){
$( "#visit-1" ).datepicker({minDate: new Date()});
$( "#appointments" ).html("<tr><th>Visit Number</th><th>Visit Date</th><th>Visit Time</th><th>Delayed Infusion?</th><th>Visit Description</th></tr>");
$( "#visit-1" ).change(function(){
$( "#appointments" ).show();
 
var schedule = visitSchedule($("patientID").val(),$("#assigned").val(),new Date($( "#indexEvent" ).val()));
var schedule = visitSchedule($("patientID").val(),$("#assigned").val(),new Date($( "#indexEvent" ).val()));
});
});
Line 29: Line 28:
this.patientID = patient;
this.patientID = patient;
this.assigned = assigned;
this.assigned = assigned;
if(!$("#visit-2").length){
$.each(timeConstraints, function(key, value){
$.each(timeConstraints, function(key, value){
if(key == 1){
if(key == 1){
currentAppointment = new Date($( "#indexEvent" ).val());
currentAppointment = new Date($("#visit-1").val());
} else {
} else {
currentAppointment = new Date($("#visit-"+(key-1)).val());
currentAppointment = new Date($("#visit-"+(key-1)).val());
}
}
currentAppointment = new Date(currentAppointment.getFullYear(), currentAppointment.getMonth(), currentAppointment.getDate()+value[0]);
currentAppointment = new Date(currentAppointment.getFullYear(), currentAppointment.getMonth(), currentAppointment.getDate()+value[0]);
if(key <= 4){
if(key ==1 ){}
else if(key <= 4){
$("#appointments").append("<tr><td>"+value[5]+"</td><td><input type='text' class='appointment' id='visit-"+key+"' value='"+currentAppointment.toDateString()+"' /></td><td><input type='time' id='visitTime-"+key+"' value='"+$("#indexEventTime").val()+"'></td><td><input type='checkbox' class='delayedInfusion' value='"+key+"' /></td><td>"+value[6]+"</td></tr>");
$("#appointments").append("<tr><td>"+value[5]+"</td><td><input type='text' class='appointment' id='visit-"+key+"' value='"+currentAppointment.toDateString()+"' /></td><td><input type='time' id='visitTime-"+key+"' value='"+$("#indexEventTime").val()+"'></td><td><input type='checkbox' class='delayedInfusion' value='"+key+"' /></td><td>"+value[6]+"</td></tr>");
} else {
} else {
Line 42: Line 43:
}
}
$("#visit-"+key).datepicker({minDate: new Date(currentAppointment.getFullYear(), currentAppointment.getMonth(), currentAppointment.getDate()-value[2]), maxDate:new Date(currentAppointment.getFullYear(), currentAppointment.getMonth(), currentAppointment.getDate()+value[1])});
$("#visit-"+key).datepicker({minDate: new Date(currentAppointment.getFullYear(), currentAppointment.getMonth(), currentAppointment.getDate()-value[2]), maxDate:new Date(currentAppointment.getFullYear(), currentAppointment.getMonth(), currentAppointment.getDate()+value[1])});
});
})};
validateConstraints();
validateConstraints();
$(".appointment").change(function(){
$(".appointment").change(function(){
Line 67: Line 68:
});
});
$(".delayedInfusion").change(function(){
$(".delayedInfusion").change(function(){
if($(this).prop('checked')){
$("#visit-"+$(this).val()).datepicker('destroy');
$("#visit-"+$(this).val()).datepicker('destroy');
$("#visit-"+$(this).val()).datepicker();
var prevAppointment = new Date($("#visit-"+($(this).val()-1)).val());
$("#visit-"+$(this).val()).datepicker({minDate: new Date(prevAppointment.getFullYear(), prevAppointment.getMonth(), prevAppointment.getDate()+5)});
} else {
fixDateRanges();
}
});
});
$("#visitTime-1").change(function(){validateConstraints();});
$("#visitTime-1").change(function(){validateConstraints();});
$( "#indexEventTime" ).change(function(){validateConstraints();});
$( "#indexEventTime" ).change(function(){validateConstraints();});
 
function fixDateRanges(){
$.each(timeConstraints, function(key, value){
var updatedAppointment = new Date($("#visit-"+key).val());
                $("#visit-"+key).css("border", "0px solid white");
if(key > 1 && key <= 4){
updatedAppointment = new Date(updatedAppointment.getFullYear(), updatedAppointment.getMonth(), updatedAppointment.getDate()+value[0]);
$("#visit-"+key).val(updatedAppointment.toDateString());
$("#visit-"+key).datepicker('destroy');
$("#visit-"+key).datepicker({minDate: new Date(updatedAppointment.getFullYear(), updatedAppointment.getMonth(), updatedAppointment.getDate()-value[2]), maxDate:new Date(updatedAppointment.getFullYear(), updatedAppointment.getMonth(), updatedAppointment.getDate()+value[1])});
}
});
}
function validateConstraints(){
function validateConstraints(){
var errorFlag = false;
var errorFlag = false;
Line 127: Line 144:
<input type="time" id="indexEventTime" name="indexEvent" /><br />
<input type="time" id="indexEventTime" name="indexEvent" /><br />
<table id="appointments">
<table id="appointments">
<tr><th>Visit Number</th><th>Visit Date</th><th>Visit Time</th><th>Delayed Infusion?</th><th>Visit Description</th></tr>
<tr><td>Visit 2</td><td><input type="text" class="appointment" id="visit-1" value=""></td><td><input type="time" id="visitTime-1" value=""></td><td></td><td>Infusion 1 of investigational product should occur <b>no earlier than 12 h after IV contrast or first medical contact</b> and be dosed within 5 days of First Medical Contact.  Subjects who are to undergo angiography and, therefore, receive IV contrast agent must have stable renal function.</td></tr>
</table>
</table>
<form action="http://www.wikidoc.org/calendar.php" method="post">
<form action="http://www.wikidoc.org/calendar.php" method="post">

Revision as of 19:07, 15 January 2019