2 ***********************************************************************
4 * Description: An Obstetric Calculator
5 * Author: Agnibho Mondal
6 * Website: http://code.agnibho.com
7 **********************************************************************
8 Copyright (c) 2016 Agnibho Mondal
10 **********************************************************************
11 This file is part of ObsCalc.
13 ObsCalc is free software: you can redistribute it and/or modify
14 it under the terms of the GNU General Public License as published by
15 the Free Software Foundation, either version 3 of the License, or
16 (at your option) any later version.
18 ObsCalc is distributed in the hope that it will be useful,
19 but WITHOUT ANY WARRANTY; without even the implied warranty of
20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 GNU General Public License for more details.
23 You should have received a copy of the GNU General Public License
24 along with Obscalc. If not, see <http://www.gnu.org/licenses/>.
25 ***********************************************************************
29 <div class="panel panel-default">
30 <div class="panel-heading">
31 <p><strong>Calculate by Date</strong></p>
33 <div class="panel panel-body">
34 <ul class="nav nav-tabs">
35 <li class="active"><a href="#panel-lmp" aria-controls="panel-lmp" data-toggle="tab">Enter L.M.P.</a></li>
36 <li><a href="#panel-edd" aria-controls="panel-edd" data-toggle="tab">Enter E.D.D.</a></li>
38 <div class="tab-content">
39 <div class="panel panel-default tab-pane active" id="panel-lmp">
40 <div class="panel-body">
41 <form data-toggle="validator">
42 <div class="form-group">
43 <label>Enter L.M.P.:</label>
45 <div class="col-sm-8">
46 <div v-show="settings.dstyle=='cal'">
47 <div class="form-group"><input class="form-control datepicker" type="date" v-model="lmpDt" placeholder="YYYY-MM-DD" autocomplete="off" v-on:input="eddUpdt"><div class="help-block with-errors"></div></div>
49 <div v-show="settings.dstyle=='txt'">
51 <div class="col-md-4 form-group"><input class="form-control jump-focus" type="number" min="1" max="31" maxlength="2" v-model.number="lmpDD" placeholder="DD" required autocomplete="off" v-on:input="eddUpdt"><div class="help-block with-errors"></div></div>
52 <div class="col-md-4 form-group"><input class="form-control jump-focus" type="number" min="1" max="12" maxlength="2" v-model.number="lmpMM" placeholder="MM" required autocomplete="off" v-on:input="eddUpdt"><div class="help-block with-errors"></div></div>
53 <div class="col-md-4 form-group"><input class="form-control stop-focus" type="number" min="0" max="99" maxlength="2" v-model.number="lmpYY" placeholder="YY" required autocomplete="off" v-on:input="eddUpdt" data-ref="#datemat"><div class="help-block with-errors"></div></div>
55 <div><p class="text-danger text-center">{{lmpErr}}</p></div>
58 <div class="col-sm-4">
59 <input type="reset" class="btn btn-default">
66 <div class="panel panel-default tab-pane" id="panel-edd">
67 <div class="panel-body">
68 <form data-toggle="validator">
69 <div class="form-group">
70 <label>Enter E.D.D.:</label>
72 <div class="col-sm-8">
73 <div v-show="settings.dstyle=='cal'">
74 <div class="form-group"><input class="form-control datepicker" type="date" v-model="eddDt" placeholder="YYYY-MM-DD" autocomplete="off" v-on:input="lmpUpdt"><div class="help-block with-errors"></div></div>
76 <div v-show="settings.dstyle=='txt'">
78 <div class="col-md-4 form-group"><input class="form-control jump-focus" type="number" min="1" max="31" maxlength="2" v-model.number="eddDD" placeholder="DD" required autocomplete="off" v-on:input="lmpUpdt"><div class="help-block with-errors"></div></div>
79 <div class="col-md-4 form-group"><input class="form-control jump-focus" type="number" min="1" max="12" maxlength="2" v-model.number="eddMM" placeholder="MM" required autocomplete="off" v-on:input="lmpUpdt"><div class="help-block with-errors"></div></div>
80 <div class="col-md-4 form-group"><input class="form-control stop-focus" type="number" min="0" max="99" maxlength="2" v-model.number="eddYY" placeholder="YY" required autocomplete="off" v-on:input="lmpUpdt" data-ref="#datemat"><div class="help-block with-errors"></div></div>
82 <div><p class="text-danger text-center">{{eddErr}}</p></div>
85 <div class="col-sm-4">
86 <input type="reset" class="btn">
95 <table class="table table-bordered" v-if="lmpVal">
97 <tr class="active"><th>L.M.P.</th><th>E.D.D.</th></tr>
98 <tr><th vbind="lmpDt">{{lmpVal}}</th><th>{{eddVal}}</th></tr>
102 <table class="table" v-if="dateMat">
104 <tr><th class="active">Maturation by Date at present</th><th>{{dateMat}}</th></tr>
113 import moment from "moment";
118 lmpDt:"",eddDt:"",lmpVal:"",eddVal:"",lmpUpdt:"",eddUpdt:"",usgDt:"",usgWk:"",usgDy:"",lmpErr:"",eddErr:"",usgErr:""
124 var dt=moment(this.lmpDt, "YYYY-MM-DD", true);
126 return dt.format("DD/MM/YYYY");
130 var dt=moment(this.eddDt, "YYYY-MM-DD", true);
132 return dt.format("DD/MM/YYYY");
136 var dt=moment(this.lmpDt, "YYYY-MM-DD", true);
139 var days=today.diff(dt, "days");
140 if(days>0 && days<364){
141 return Math.floor(days/7)+" weeks "+days%7+" days";
149 if(this.settings.dstyle=="txt"){
151 var strYY=""+this.eddYY;
154 var strYY="0"+this.eddYY;
156 var dt=moment(this.eddDD+"-"+this.eddMM+"-"+strYY, "D-M-YY", true);
159 var dt=moment(this.eddDt, "YYYY-MM-DD", true);
162 if(this.settings.dstyle=="txt"){
163 this.eddDt=dt.format("YYYY-MM-DD");
166 this.eddDD=dt.format("DD");
167 this.eddMM=dt.format("MM");
168 this.eddYY=dt.format("YY");
170 dt.subtract(9, "months");
171 dt.subtract(7, "days");
172 this.lmpDt=dt.format("YYYY-MM-DD");
173 this.lmpDD=dt.format("DD");
174 this.lmpMM=dt.format("MM");
175 this.lmpYY=dt.format("YY");
182 if(this.settings.dstyle=="txt" && this.eddDD && this.eddMM && this.eddYY){
184 this.eddErr="The date you have entered is invalid.";
190 if(this.settings.dstyle=="txt"){
192 var strYY=""+this.lmpYY;
195 var strYY="0"+this.lmpYY;
197 var dt=moment(this.lmpDD+"-"+this.lmpMM+"-"+strYY, "D-M-YY", true);
200 var dt=moment(this.lmpDt, "YYYY-MM-DD", true);
203 if(this.settings.dstyle=="txt"){
204 this.lmpDt=dt.format("YYYY-MM-DD");
207 this.lmpDD=dt.format("DD");
208 this.lmpMM=dt.format("MM");
209 this.lmpYY=dt.format("YY");
213 this.eddDt=dt.format("YYYY-MM-DD");
214 this.eddDD=dt.format("DD");
215 this.eddMM=dt.format("MM");
216 this.eddYY=dt.format("YY");
223 if(this.settings.dstyle=="txt" && this.lmpDD && this.lmpMM && this.lmpYY){
225 this.lmpErr="The date you have entered is invalid.";