2 include_once("{$GLOBALS['srcdir']}/sql.inc");
3 require_once(dirname(__FILE__) . "/classes/WSWrapper.class.php");
5 function getPatientData($pid, $given = "*, DATE_FORMAT(DOB,'%m/%d/%Y') as DOB_TS") {
6 $sql = "select $given from patient_data where pid='$pid' order by date DESC limit 0,1";
10 function getLanguages() {
11 $returnval = array('','english');
12 $sql = "select distinct lower(language) as language from patient_data";
13 $rez = sqlStatement($sql);
14 for($iter=0; $row=sqlFetchArray($rez); $iter++) {
15 if (($row["language"] != "english") && ($row["language"] != "")) {
16 array_push($returnval, $row["language"]);
24 function getInsuranceProviders() {
28 $sql = "select name, id from insurance_companies order by name, id";
29 $rez = sqlStatement($sql);
30 for($iter=0; $row=sqlFetchArray($rez); $iter++) {
31 $returnval[$row['id']] = $row['name'];
35 // Please leave this here. I have a user who wants to see zip codes and PO
36 // box numbers listed along with the insurance company names, as many companies
37 // have different billing addresses for different plans. -- Rod Roark
40 $sql = "select insurance_companies.name, insurance_companies.id, " .
41 "addresses.zip, addresses.line1 " .
42 "from insurance_companies, addresses " .
43 "where addresses.foreign_id = insurance_companies.id " .
44 "order by insurance_companies.name, addresses.zip";
46 $rez = sqlStatement($sql);
48 for($iter=0; $row=sqlFetchArray($rez); $iter++) {
49 preg_match("/\d+/", $row['line1'], $matches);
50 $returnval[$row['id']] = $row['name'] . " (" . $row['zip'] .
51 "," . $matches[0] . ")";
61 function getProviders() {
62 $returnval = array("");
63 $sql = "select fname,lname from users where authorized=1";
64 $rez = sqlStatement($sql);
65 for($iter=0; $row=sqlFetchArray($rez); $iter++) {
66 if (($row["fname"] != "") && ($row["lname"] != "")) {
67 array_push($returnval, $row["fname"] . " " . $row["lname"]);
75 function getProviderInfo($providerID = "%", $providers_only = true) {
77 if ($providers_only) {
78 $param1 = "AND authorized=1";
81 if ($providerID == "%") {
84 $query = "select distinct id,username,lname,fname, authorized, info, facility from users where id $command '" . mysql_real_escape_string($providerID) . "' " . $param1;
85 $rez = sqlStatement($query);
86 for($iter=0; $row=sqlFetchArray($rez); $iter++)
87 $returnval[$iter]=$row;
89 //if only one result returned take the key/value pairs in array [0] and merge them down the the base array so that $resultval[0]['key'] is also
90 //accessible from $resultval['key']
93 $akeys = array_keys($returnval[0]);
94 foreach($akeys as $key) {
96 $returnval[0][$key] = $returnval[0][$key];
102 //same as above but does not reduce if only 1 row returned
103 function getCalendarProviderInfo($providerID = "%", $providers_only = true) {
105 if ($providers_only) {
106 $param1 = "AND authorized=1";
109 if ($providerID == "%") {
112 $query = "select distinct id,username,lname,fname, authorized, info, facility from users where id $command '" . mysql_real_escape_string($providerID) . "' " . $param1;
114 $rez = sqlStatement($query);
115 for($iter=0; $row=sqlFetchArray($rez); $iter++)
116 $returnval[$iter]=$row;
123 function getProviderName($providerID) {
125 $pi = getProviderInfo($providerID);
127 if (strlen($pi[0]["lname"]) > 0) {
128 return $pi[0]['fname'] . " " . $pi[0]['lname'];
134 function getProviderId($providerName) {
135 $query = "select id from users where username = '". mysql_real_escape_string($providerName)."'";
137 $rez = sqlStatement($query);
138 for($iter=0; $row=sqlFetchArray($rez); $iter++)
139 $returnval[$iter]=$row;
144 function getEthnoRacials() {
145 $returnval = array("");
146 $sql = "select distinct lower(ethnoracial) as ethnoracial from patient_data";
147 $rez = sqlStatement($sql);
148 for($iter=0; $row=sqlFetchArray($rez); $iter++) {
149 if (($row["ethnoracial"] != "")) {
150 array_push($returnval, $row["ethnoracial"]);
158 function getHistoryData($pid, $given = "*")
160 $sql = "select $given from history_data where pid='$pid' order by date DESC limit 0,1";
161 return sqlQuery($sql);
164 function getInsuranceData($pid, $type = "primary", $given = "insd.*, DATE_FORMAT(subscriber_DOB,'%m/%d/%Y') as subscriber_DOB, ic.name as provider_name")
166 $sql = "select $given from insurance_data as insd left join insurance_companies as ic on ic.id = insd.provider where pid='$pid' and type='$type' order by date DESC limit 0,1";
167 return sqlQuery($sql);
170 function getInsuranceDataByDate( $pid, $date, $type, $given = "insd.*, DATE_FORMAT(subscriber_DOB,'%m/%d/%Y') as subscriber_DOB, ic.name as provider_name")
171 { //this must take the date in the following manner: YYYY-MM-DD
172 //this function recalls the insurance value that was most recently enterred from the
173 //given date. it will call up most recent records up to and on the date given,
174 //but not records enterred after the given date
175 $sql = "select $given from insurance_data as insd left join insurance_companies as ic on ic.id = provider where pid='$pid' and date_format(date,'%Y-%m-%d')<='$date' and type='$type' order by date DESC limit 0,1";
176 return sqlQuery($sql);
180 function getEmployerData($pid, $given = "*")
182 $sql = "select $given from employer_data where pid='$pid' order by date DESC limit 0,1";
183 return sqlQuery($sql);
186 function getPatientLnames($lname = "%", $given = "pid, id, lname, fname, mname, providerID, DATE_FORMAT(DOB,'%m/%d/%Y') as DOB_TS", $orderby = "lname ASC, fname ASC", $limit="all", $start="0")
189 $sql="select pid, MAX(id) as id from patient_data group by pid DESC order by pid ASC";
190 $res = sqlStatement($sql);
191 $sql="select $given from patient_data where lname like '$lname%' and (";
192 for ($iter = 0;$row = sqlFetchArray($res);$iter++)
193 $sql.=" id='{$row['id']}' or";
195 $sql = substr($sql, 0, -3) . ") order by $orderby";
197 $sql = substr($sql, 0, -5)."order by $orderby";
200 // WTF? That was a good way to create a 200KB sql statement.
202 $sql="select $given from patient_data where lname like '$lname%' " .
206 $sql .= " limit $start, $limit";
207 $rez = sqlStatement($sql);
209 for($iter=0; $row=sqlFetchArray($rez); $iter++)
210 $returnval[$iter]=$row;
215 function getPatientId($pid = "%", $given = "pid, id, lname, fname, mname, providerID, DATE_FORMAT(DOB,'%m/%d/%Y') as DOB_TS", $orderby = "lname ASC, fname ASC", $limit="all", $start="0")
218 $sql="select pid, MAX(id) as id from patient_data group by pid DESC order by pid ASC";
219 $res = sqlStatement($sql);
220 $sql="select $given from patient_data where pubpid like '$pid%' and (";
221 for ($iter = 0;$row = sqlFetchArray($res);$iter++)
222 $sql.=" id='{$row['id']}' or";
224 $sql = substr($sql, 0, -3) . ") order by $orderby";
226 $sql = substr($sql, 0, -5)."order by $orderby";
229 $sql = "select $given from patient_data where pubpid like '$pid%' " .
233 $sql .= " limit $start, $limit";
234 $rez = sqlStatement($sql);
235 for($iter=0; $row=sqlFetchArray($rez); $iter++)
236 $returnval[$iter]=$row;
241 function getPatientPID($pid = "%", $given = "pid, id, lname, fname, mname, providerID, DATE_FORMAT(DOB,'%m/%d/%Y') as DOB_TS", $orderby = "lname ASC, fname ASC", $limit="all", $start="0")
249 if (strstr($pid,"%"))
252 $sql="select $given from patient_data where pid $command '$pid' order by $orderby";
255 $sql .= " limit $start, $limit";
257 $rez = sqlStatement($sql);
258 for($iter=0; $row=sqlFetchArray($rez); $iter++)
259 $returnval[$iter]=$row;
265 function getPatientName($pid) {
268 $patientData = getPatientPID($pid);
269 if (empty($patientData[0]['lname']))
271 $patientName = $patientData[0]['lname'] . ", " . $patientData[0]['fname'];
276 function getPatientDOB($DOB = "%", $given = "pid, id, lname, fname, mname", $orderby = "lname ASC, fname ASC", $limit="all", $start="0")
279 $sql="select pid, MAX(id) as id from patient_data group by pid DESC order by pid ASC";
280 $res = sqlStatement($sql);
281 $sql="select $given from patient_data where DOB like '$DOB%' and (";
282 for ($iter = 0;$row = sqlFetchArray($res);$iter++)
283 $sql.=" id='{$row['id']}' or";
285 $sql = substr($sql, 0, -3) . ") order by $orderby";
287 $sql = substr($sql, 0, -5)."order by $orderby";
290 $DOB = fixDate($DOB, $DOB);
292 $sql="select $given from patient_data where DOB like '$DOB%' " .
296 $sql .= " limit $start, $limit";
298 $rez = sqlStatement($sql);
299 for($iter=0; $row=sqlFetchArray($rez); $iter++)
300 $returnval[$iter]=$row;
305 function getPatientSSN($ss = "%", $given = "pid, id, lname, fname, mname, providerID", $orderby = "lname ASC, fname ASC", $limit="all", $start="0")
308 $sql="select pid, MAX(id) as id from patient_data group by pid DESC order by pid ASC";
309 $res = sqlStatement($sql);
310 $sql="select $given from patient_data where ss like '$ss%' and (";
311 for ($iter = 0;$row = sqlFetchArray($res);$iter++)
312 $sql.=" id='{$row['id']}' or";
314 $sql = substr($sql, 0, -3) . ") order by $orderby";
316 $sql = substr($sql, 0, -5)."order by $orderby";
319 $sql="select $given from patient_data where ss like '$ss%' " .
323 $sql .= " limit $start, $limit";
325 $rez = sqlStatement($sql);
326 for($iter=0; $row=sqlFetchArray($rez); $iter++)
327 $returnval[$iter]=$row;
332 function getPatientIds($given = "pid, id, lname, fname, mname", $orderby = "id ASC", $limit="all", $start="0")
335 $sql="select pid, MAX(id) as id from patient_data group by pid DESC order by pid ASC";
336 $res = sqlStatement($sql);
337 $sql="select $given from patient_data where ";
338 for ($iter = 0;$row = sqlFetchArray($res);$iter++)
339 $sql.="id='{$row['id']}' or ";
340 $sql = substr($sql, 0, -3) . "order by $orderby";
343 $sql="select $given from patient_data order by $orderby";
346 $sql .= " limit $start, $limit";
348 $rez = sqlStatement($sql);
349 for($iter=0; $row=sqlFetchArray($rez); $iter++)
350 $returnval[$iter]=$row;
355 //----------------------input functions
356 function newPatientData( $db_id="",
374 $contact_relationship = "",
381 $migrantseasonal = "",
383 $monthly_income = "",
385 $financial_review = "",
396 $DOB = fixDate($DOB);
398 // Looking for problems... suspecting that $pid might be clobbered.
401 $rez = sqlQuery("select id from patient_data where pid = $pid");
402 if ($db_id != $rez['id']) {
403 $errmsg = "Internal error: Attempt to change patient_data.id from '" .
404 $rez['id'] . "' to '$db_id' for pid '$pid'";
409 $query = ("replace into patient_data set
418 postal_code='$postal_code',
421 country_code='$country_code',
423 occupation='$occupation',
424 phone_home='$phone_home',
425 phone_biz='$phone_biz',
426 phone_contact='$phone_contact',
428 contact_relationship='$contact_relationship',
429 referrer='$referrer',
430 referrerID='$referrerID',
432 language='$language',
433 ethnoracial='$ethnoracial',
434 interpretter='$interpretter',
435 migrantseasonal='$migrantseasonal',
436 family_size='$family_size',
437 monthly_income='$monthly_income',
438 homeless='$homeless',
439 financial_review='$financial_review',
442 providerID = '$providerID',
443 genericname1 = '$genericname1',
444 genericval1 = '$genericval1',
445 genericname2 = '$genericname2',
446 genericval2 = '$genericval2',
447 phone_cell = '$phone_cell',
451 $id = sqlInsert($query);
452 $foo = sqlQuery("select pid from patient_data where id='$id' order by date limit 0,1");
454 sync_patient($id,$fname,$lname,$street,$city,$postal_code,$state,$phone_home,
460 // Supported input date formats are:
462 // mm/dd/yy (assumes 19yy)
464 // also mm-dd-yyyy, etc. and mm.dd.yyyy, etc.
466 function fixDate($date, $default="0000-00-00") {
467 $fixed_date = $default;
469 if (preg_match("'^[0-9]{1,4}[/.-][0-9]{1,2}[/.-][0-9]{1,4}$'", $date)) {
470 $dmy = preg_split("'[/.-]'", $date);
472 $fixed_date = sprintf("%04u-%02u-%02u", $dmy[0], $dmy[1], $dmy[2]);
474 if ($dmy[2] < 1000) $dmy[2] += 1900;
475 $fixed_date = sprintf("%04u-%02u-%02u", $dmy[2], $dmy[0], $dmy[1]);
483 function updatePatientData($pid,$new)
485 $real = getPatientData($pid);
486 $new['DOB'] = fixDate($new['DOB']);
487 while(list($key, $value) = each ($new))
488 $real[$key] = $value;
489 $real['date'] = "'+NOW()+'";
492 $sql = "insert into patient_data set ";
493 while(list($key, $value) = each($real))
494 $sql .= $key." = '$value', ";
495 $sql = substr($sql, 0, -2);
498 return sqlInsert($sql);
502 function newEmployerData( $pid,
511 return sqlInsert("insert into employer_data set
514 postal_code='$postal_code',
523 function updateEmployerData($pid,$new)
525 $real = getEmployerData($pid);
526 while(list($key, $value) = each ($new))
527 $real[$key] = $value;
528 $real['date'] = "'+NOW()+'";
531 $sql = "insert into employer_data set ";
532 while(list($key, $value) = each($real))
533 $sql .= $key." = '$value', ";
534 $sql = substr($sql, 0, -2);
537 return sqlInsert($sql);
540 function newInsuranceData( $pid,
546 $subscriber_lname = "",
547 $subscriber_mname = "",
548 $subscriber_fname = "",
549 $subscriber_relationship = "",
551 $subscriber_DOB = "",
552 $subscriber_street = "",
553 $subscriber_postal_code = "",
554 $subscriber_city = "",
555 $subscriber_state = "",
556 $subscriber_country = "",
557 $subscriber_phone = "",
558 $subscriber_employer = "",
559 $subscriber_employer_street = "",
560 $subscriber_employer_city = "",
561 $subscriber_employer_postal_code = "",
562 $subscriber_employer_state = "",
563 $subscriber_employer_country = "",
568 if (strlen($type) > 0) {
569 $query = "select * from insurance_data where type='" . $type . "' and pid = " . $pid . " limit 1";
574 $res = sqlQuery ($query);
577 $data['type'] = $type;
578 $data['provider'] = $provider;
579 $data['policy_number']=$policy_number;
580 $data['group_number']=$group_number;
581 $data['plan_name']=$plan_name;
582 $data['subscriber_lname']=$subscriber_lname;
583 $data['subscriber_mname']=$subscriber_mname;
584 $data['subscriber_fname']=$subscriber_fname;
585 $data['subscriber_relationship']=$subscriber_relationship;
586 $data['subscriber_ss']=$subscriber_ss;
587 $data['subscriber_DOB']=$subscriber_DOB;
588 $data['subscriber_street']=$subscriber_street;
589 $data['subscriber_postal_code']=$subscriber_postal_code;
590 $data['subscriber_city']=$subscriber_city;
591 $data['subscriber_state']=$subscriber_state;
592 $data['subscriber_country']=$subscriber_country;
593 $data['subscriber_phone']=$subscriber_phone;
594 $data['subscriber_employer']=$subscriber_employer;
595 $data['subscriber_employer_city']=$subscriber_employer_city;
596 $data['subscriber_employer_street']=$subscriber_employer_street;
597 $data['subscriber_employer_postal_code']=$subscriber_employer_postal_code;
598 $data['subscriber_employer_state']=$subscriber_employer_state;
599 $data['subscriber_employer_country']=$subscriber_employer_country;
600 $data['copay']=$copay;
601 $data['subscriber_sex']=$subscriber_sex;
603 $data['date']="NOW()";
604 // echo "updating<br><br>";
606 return updateInsuranceData($pid,$data);
609 return sqlInsert("insert into insurance_data set
611 provider='$provider',
612 policy_number='$policy_number',
613 group_number='$group_number',
614 plan_name='$plan_name',
615 subscriber_lname='$subscriber_lname',
616 subscriber_mname='$subscriber_mname',
617 subscriber_fname='$subscriber_fname',
618 subscriber_relationship='$subscriber_relationship',
619 subscriber_ss='$subscriber_ss',
620 subscriber_DOB='$subscriber_DOB',
621 subscriber_street='$subscriber_street',
622 subscriber_postal_code='$subscriber_postal_code',
623 subscriber_city='$subscriber_city',
624 subscriber_state='$subscriber_state',
625 subscriber_country='$subscriber_country',
626 subscriber_phone='$subscriber_phone',
627 subscriber_employer = '$subscriber_employer',
628 subscriber_employer_city='$subscriber_employer_city',
629 subscriber_employer_street='$subscriber_employer_street',
630 subscriber_employer_postal_code='$subscriber_employer_postal_code',
631 subscriber_employer_state='$subscriber_employer_state',
632 subscriber_employer_country='$subscriber_employer_country',
634 subscriber_sex='$subscriber_sex',
641 function updateInsuranceData($pid,$new)
643 $fields = sqlListFields("insurance_data");
645 $real = getInsuranceData($pid);
647 while(list($key, $value) = each ($new)) {
648 if (in_array($key,$fields)){
652 $real['date'] = "'+NOW()+'";
655 $sql = "replace into insurance_data set ";
656 while(list($key, $value) = each($use))
657 $sql .= $key." = '$value', ";
660 $sql = substr($sql, 0, -2);
664 return sqlInsert($sql);
668 function newHistoryData( $pid,
672 $sleep_patterns = "",
673 $exercise_patterns = "",
676 $hazardous_activities = "",
677 $last_breast_exam = "",
678 $last_mammogram = "",
679 $last_gynocological_exam = "",
680 $last_rectal_exam = "",
681 $last_prostate_exam = "",
682 $last_physical_exam = "",
683 $last_sigmoidoscopy_colonoscopy = "",
684 $history_mother = "",
685 $history_father = "",
686 $history_siblings = "",
687 $history_offspring = "",
688 $history_spouse = "",
689 $relatives_cancer = "",
690 $relatives_tuberculosis = "",
691 $relatives_diabetes = "",
692 $relatives_high_blood_pressure = "",
693 $relatives_heart_problems = "",
694 $relatives_stroke = "",
695 $relatives_epilepsy = "",
696 $relatives_mental_illness = "",
697 $relatives_suicide = "",
698 $cataract_surgery = "",
701 $cholecystestomy = "",
705 $hip_replacement = "",
706 $knee_replacement = "",
711 $additional_history = ""
714 return sqlInsert("insert into history_data set
718 sleep_patterns='$sleep_patterns',
719 exercise_patterns='$exercise_patterns',
720 seatbelt_use='$seatbelt_use',
721 counseling='$counseling',
722 hazardous_activities='$hazardous_activities',
723 last_breast_exam='$last_breast_exam',
724 last_mammogram='$last_mammogram',
725 last_gynocological_exam='$last_gynocological_exam',
726 last_rectal_exam='$last_rectal_exam',
727 last_prostate_exam='$last_prostate_exam',
728 last_physical_exam='$last_physical_exam',
729 last_sigmoidoscopy_colonoscopy='$last_sigmoidoscopy_colonoscopy',
730 history_mother='$history_mother',
731 history_father='$history_father',
732 history_siblings='$history_siblings',
733 history_offspring='$history_offspring',
734 history_spouse='$history_spouse',
735 relatives_cancer='$relatives_cancer',
736 relatives_tuberculosis ='$relatives_tuberculosis',
737 relatives_diabetes='$relatives_diabetes',
738 relatives_high_blood_pressure='$relatives_high_blood_pressure',
739 relatives_heart_problems='$relatives_heart_problems',
740 relatives_stroke='$relatives_stroke',
741 relatives_epilepsy='$relatives_epilepsy',
742 relatives_mental_illness='$relatives_mental_illness',
743 relatives_suicide='$relatives_suicide',
744 cataract_surgery='$cataract_surgery',
745 tonsillectomy='$tonsillectomy',
746 appendectomy='$appendectomy',
747 cholecystestomy='$cholecystestomy',
748 heart_surgery='$heart_surgery',
749 hysterectomy='$hysterectomy',
750 hernia_repair='$hernia_repair',
751 hip_replacement='$hip_replacement',
752 knee_replacement='$knee_replacement',
754 value_1 = '$value_1',
756 value_2 = '$value_2',
757 additional_history = '$additional_history',
763 function updateHistoryData($pid,$new)
765 $real = getHistoryData($pid);
766 while(list($key, $value) = each ($new))
767 $real[$key] = $value;
768 $real['date'] = "'+NOW()+'";
771 $sql = "insert into history_data set ";
772 while(list($key, $value) = each($real))
773 $sql .= $key." = '$value', ";
774 $sql = substr($sql, 0, -2);
777 return sqlInsert($sql);
780 function sync_patient($id,$fname,$lname,$street,$city,$postal_code,$state,$phone_home,
783 $db = $GLOBALS['adodb']['db'];
784 $customer_info = array();
786 $sql = "SELECT foreign_id,foreign_table FROM integration_mapping where local_table = 'patient_data' and local_id = '" . $id . "'";
787 $result = $db->Execute($sql);
788 if ($result && !$result->EOF) {
789 $customer_info['foreign_update'] = true;
790 $customer_info['foreign_id'] = $result->fields['foreign_id'];
791 $customer_info['foreign_table'] = $result->fields['foreign_table'];
794 ///xml rpc code to connect to accounting package and add user to it
795 $customer_info['firstname'] = $fname;
796 $customer_info['lastname'] = $lname;
797 $customer_info['address'] = $street;
798 $customer_info['suburb'] = $city;
799 $customer_info['state'] = $state;
800 $customer_info['postcode'] = $postal_code;
802 //ezybiz wants state as a code rather than abbreviation
803 $customer_info['geo_zone_id'] = "";
804 $sql = "SELECT zone_id from geo_zone_reference where zone_code = '" . strtoupper($state) . "'";
805 $db = $GLOBALS['adodb']['db'];
806 $result = $db->Execute($sql);
807 if ($result && !$result->EOF) {
808 $customer_info['geo_zone_id'] = $result->fields['zone_id'];
811 //ezybiz wants country as a code rather than abbreviation
812 $customer_info['geo_country_id'] = "";
813 $sql = "SELECT countries_id from geo_country_reference where countries_iso_code_2 = '" . strtoupper($country_code) . "'";
814 $db = $GLOBALS['adodb']['db'];
815 $result = $db->Execute($sql);
816 if ($result && !$result->EOF) {
817 $customer_info['geo_country_id'] = $result->fields['countries_id'];
821 $customer_info['phone1'] = $phone_home;
822 $customer_info['phone1comment'] = "Home Phone";
823 $customer_info['phone2'] = $phone_biz;
824 $customer_info['phone2comment'] = "Business Phone";
825 $customer_info['email'] = $email;
827 $function['ezybiz.add_customer'] = array(new xmlrpcval($customer_info,"struct"));
828 $ws = new WSWrapper($function);
830 // if the remote patient was added make an entry in the local mapping table to that updates can be made correctly
831 if (is_numeric($ws->value)) {
832 $sql = "REPLACE INTO integration_mapping set id = '" . $db->GenID("sequences") . "', foreign_id ='" . $ws->value . "', foreign_table ='customer', local_id = '" . $id . "', local_table = 'patient_data' ";
833 $db->Execute($sql) or die ("error: " . $db->ErrorMsg());
837 // Returns Date of Birth given YYYYMMDD from MySQL DATE_FORMAT(DOB,'%Y%m%d')
838 function getPatientAge($dobYMD)
841 $yearDiff = substr($tdyYMD,0,4) - substr($dobYMD,0,4);
842 $ageInMonths = ((substr($tdyYMD,0,4)*12)+substr($tdyYMD,4,2)) -
843 ((substr($dobYMD,0,4)*12)+substr($dobYMD,4,2));
844 $dayDiff = substr($tdyYMD,6,2) - substr($dobYMD,6,2);
845 if ( $dayDiff < 0 ) {
848 if ( $ageInMonths > 24 ) {
849 $age = intval($ageInMonths/12);
852 $age = "$ageInMonths month";
857 function dateToDB ($date)
859 $date=substr ($date,6,4)."-".substr ($date,3,2)."-".substr($date, 0,2);
866 function DBToDate ($date)
868 $date=substr ($date,5,2)."/".substr ($date,8,2)."/".substr($date, 0,4);