Widget:VisitSchedulerRedux: Difference between revisions
Jump to navigation
Jump to search
Matt Pijoan (talk | contribs) No edit summary |
Matt Pijoan (talk | contribs) No edit summary |
||
Line 11: | Line 11: | ||
$( "#patientID, #assigned, #indexEvent, #indexEventTime").css({"display":"flex","flex-direction":"column","align-items":"flex-end"}); | $( "#patientID, #assigned, #indexEvent, #indexEventTime").css({"display":"flex","flex-direction":"column","align-items":"flex-end"}); | ||
$( "#indexEvent, #indexEventTime, #visit-1, #visitTime-1" ).val(""); | $( "#indexEvent, #indexEventTime, #visit-1, #visitTime-1" ).val(""); | ||
$( "#indexEvent" ).datepicker( | $( "#indexEvent" ).datepicker(); | ||
$( "#visit-1" ).datepicker({minDate: new Date()}); | $( "#visit-1" ).datepicker({minDate: new Date()}); | ||
$( "# | $( "#indexEvent" ).change(function(){ | ||
$( "#appointments" ).html("<tr><th>Visit Number</th><th>Visit Date</th><th>Visit Time</th><th>Delayed Infusion?</th><th>Visit Description</th></tr>"); | |||
$( "#appointments" ).show(); | |||
var schedule = visitSchedule($("patientID").val(),$("#assigned").val(),new Date($( "#indexEvent" ).val())); | var schedule = visitSchedule($("patientID").val(),$("#assigned").val(),new Date($( "#indexEvent" ).val())); | ||
}); | }); | ||
function visitSchedule(patient, assigned, index){ | function visitSchedule(patient, assigned, index){ | ||
var timeConstraints = { | var timeConstraints = { | ||
// VisitNum : [Days from Infusion 1, Window + Days, Window - Days, Window + Hours, Window - Hours, Visit, Visit Description, Short Visit Description] | // VisitNum : [Days from Infusion 1, Window + Days, Window - Days, Window + Hours, Window - Hours, Visit, Visit Description, Short Visit Description] | ||
Line 34: | Line 34: | ||
this.patientID = patient; | this.patientID = patient; | ||
this.assigned = assigned; | this.assigned = assigned; | ||
$.each(timeConstraints, function(key, value){ | $.each(timeConstraints, function(key, value){ | ||
if(key == 1){ | if(key == 1){ | ||
currentAppointment = new Date($("# | currentAppointment = new Date($( "#indexEvent" ).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){ | |||
$("#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 51: | Line 47: | ||
} | } | ||
$("#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 58: | Line 54: | ||
$(this).val(updatedAppointment); | $(this).val(updatedAppointment); | ||
$.each(timeConstraints, function(key, value){ | $.each(timeConstraints, function(key, value){ | ||
$("#visit-"+key).css("border", " | $("#visit-"+key).css("border", "5px solid white"); | ||
if(key > modId && key <= 4){ | if(key > modId && key <= 4){ | ||
updatedAppointment = new Date(updatedAppointment.getFullYear(), updatedAppointment.getMonth(), updatedAppointment.getDate()+value[0]); | updatedAppointment = new Date(updatedAppointment.getFullYear(), updatedAppointment.getMonth(), updatedAppointment.getDate()+value[0]); | ||
Line 68: | Line 64: | ||
} | } | ||
}); | }); | ||
validateConstraints(); | validateConstraints(); | ||
}); | }); | ||
$( "#indexEventTime | $( "#indexEventTime" ).change(function(){ | ||
$.each(timeConstraints, function(key, value){ | $.each(timeConstraints, function(key, value){ | ||
$("#visitTime-"+key).val($("#indexEventTime").val()); | $("#visitTime-"+key).val($("#indexEventTime").val()); | ||
Line 77: | Line 72: | ||
}); | }); | ||
$(".delayedInfusion").change(function(){ | $(".delayedInfusion").change(function(){ | ||
$("#visit-"+$(this).val()).datepicker('destroy'); | $("#visit-"+$(this).val()).datepicker('destroy'); | ||
$("#visit-"+$(this).val()).datepicker(); | |||
$("#visit-"+$(this).val()).datepicker | |||
}); | }); | ||
$("#visitTime-1").change(function(){validateConstraints();}); | $("#visitTime-1").change(function(){validateConstraints();}); | ||
$( "#indexEventTime" ).change(function(){validateConstraints();}); | $( "#indexEventTime" ).change(function(){validateConstraints();}); | ||
function validateConstraints(){ | function validateConstraints(){ | ||
var errorFlag = false; | var errorFlag = false; |