D
Dr. Momo
Hi, SO I want to make a pregnancy wheel:
(LMP(Date) - 3months, +7d)= Estimated Date of Delivery (it also has to
advance to the next year if >April.
Also, I want to be able to automaticallt update the current Gestational
age(#weeks/days since LMP to current date) based on today's date and the LMP.
I found this code online at a website that calculates Gestational age in
online calculator. Can it be converted for use in access?
Thanks!
<script>
// current equation code
function PregDates() {
var lmpid = $("#lmp").val();
var ddid = $("#duedates").val();
if (ddid && lmpid) {alert('Please clear either the LMP or EDC box so we know
which one you\'re using. Thanks!'); return false;}
if (ddid) {
var today = Date.today();
var dd = Date.parse(ddid);
var lmp = Date.parse(ddid).add(-40).weeks();
lmps=lmp.toString("ddd M/d/yyyy");
var conception = Date.parse(ddid).add(-38).weeks();
conception = conception.toString("ddd M/d/yyyy");
var ega=today-lmp;
ega=ega/86400000;
var weeks = parseInt(ega/7);
if (weeks > 42) {alert("Either the pregnancy is past 42 weeks and that baby
needs to come out NOW, or the LMP is wrong or you've entered it wrong.
Double-check."); return false;}
var days = ega %7;
days = Math.round(days*1)/1;
if (days == 7) {
weeks=weeks+1;
var result = weeks + ' weeks exactly';
}
else {
var result = weeks + ' weeks and ' + days + '/7 days';
}
Done('#result',result);
Done('#result2',lmps);
Done('#result3',' ');
Done('#result4',conception);
}
if (lmpid) {
var today = Date.today();
var lmp = Date.parse(lmpid);
if (lmp > today) {alert("Hmm. The LMP shouldn't be after today. Check the
year.");return false;}
var edd = Date.parse(lmpid).add(40).weeks();
edd= edd.toString("ddd M/d/yyyy");
var conception = Date.parse(lmpid).add(14).days();
conception = conception.toString("ddd M/d/yyyy");
var ega=today-lmp;
ega=ega/86400000;
var weeks = parseInt(ega/7);
if (weeks > 42) {alert("Either the pregnancy is past 42 weeks and that baby
needs to come out NOW, or the LMP is wrong or you've entered it wrong.
Double-check."); return false;}
var days = ega %7;
days = Math.round(days*1)/1;
if (days == 7) {
weeks=weeks+1;
var result = weeks + ' weeks exactly';
}
else {
var result = weeks + ' weeks and ' + days + '/7 days';
}
Done('#result',result);
Done('#result2',' ');
Done('#result3',edd);
Done('#result4',conception);
}
}// end current equation code
</script>
(LMP(Date) - 3months, +7d)= Estimated Date of Delivery (it also has to
advance to the next year if >April.
Also, I want to be able to automaticallt update the current Gestational
age(#weeks/days since LMP to current date) based on today's date and the LMP.
I found this code online at a website that calculates Gestational age in
online calculator. Can it be converted for use in access?
Thanks!
<script>
// current equation code
function PregDates() {
var lmpid = $("#lmp").val();
var ddid = $("#duedates").val();
if (ddid && lmpid) {alert('Please clear either the LMP or EDC box so we know
which one you\'re using. Thanks!'); return false;}
if (ddid) {
var today = Date.today();
var dd = Date.parse(ddid);
var lmp = Date.parse(ddid).add(-40).weeks();
lmps=lmp.toString("ddd M/d/yyyy");
var conception = Date.parse(ddid).add(-38).weeks();
conception = conception.toString("ddd M/d/yyyy");
var ega=today-lmp;
ega=ega/86400000;
var weeks = parseInt(ega/7);
if (weeks > 42) {alert("Either the pregnancy is past 42 weeks and that baby
needs to come out NOW, or the LMP is wrong or you've entered it wrong.
Double-check."); return false;}
var days = ega %7;
days = Math.round(days*1)/1;
if (days == 7) {
weeks=weeks+1;
var result = weeks + ' weeks exactly';
}
else {
var result = weeks + ' weeks and ' + days + '/7 days';
}
Done('#result',result);
Done('#result2',lmps);
Done('#result3',' ');
Done('#result4',conception);
}
if (lmpid) {
var today = Date.today();
var lmp = Date.parse(lmpid);
if (lmp > today) {alert("Hmm. The LMP shouldn't be after today. Check the
year.");return false;}
var edd = Date.parse(lmpid).add(40).weeks();
edd= edd.toString("ddd M/d/yyyy");
var conception = Date.parse(lmpid).add(14).days();
conception = conception.toString("ddd M/d/yyyy");
var ega=today-lmp;
ega=ega/86400000;
var weeks = parseInt(ega/7);
if (weeks > 42) {alert("Either the pregnancy is past 42 weeks and that baby
needs to come out NOW, or the LMP is wrong or you've entered it wrong.
Double-check."); return false;}
var days = ega %7;
days = Math.round(days*1)/1;
if (days == 7) {
weeks=weeks+1;
var result = weeks + ' weeks exactly';
}
else {
var result = weeks + ' weeks and ' + days + '/7 days';
}
Done('#result',result);
Done('#result2',' ');
Done('#result3',edd);
Done('#result4',conception);
}
}// end current equation code
</script>