2 require_once("DataObjectBase.class.php");
3 require_once("xmlrpc.inc");
5 class Diagnosis
Extends DataObjectBase
{
8 $this->_addFunc("relatedtohcfa", array( "name" => "FreeB.FBDiagnosis.RelatedToHCFA",
9 "sig" => array(XMLRPCSTRING
,XMLRPCINT
),
11 $this->_addFunc("isrelatedtootheraccident", array( "name" => "FreeB.FBDiagnosis.isRelatedToOtherAccident",
12 "sig" => array(XMLRPCSTRING
,XMLRPCINT
),
14 $this->_addFunc("dateofencounter", array("name" => "FreeB.FBDiagnosis.DateOfEncounter",
15 "sig" => array(XMLRPCSTRING
,XMLRPCINT
),
17 $this->_addFunc("dateofonset", array( "name" => "FreeB.FBDiagnosis.DateOfOnset",
18 "sig" => array(XMLRPCSTRING
,XMLRPCINT
),
20 $this->_addFunc("dateoffirstsymptom", array( "name" => "FreeB.FBDiagnosis.DateOfFirstSymptom",
21 "sig" => array(XMLRPCSTRING
,XMLRPCINT
),
23 $this->_addFunc("isfirstoccurence", array( "name" => "FreeB.FBDiagnosis.isFirstOccurrence",
24 "sig" => array(XMLRPCSTRING
,XMLRPCINT
),
26 $this->_addFunc("dateoffirstoccurence", array( "name" => "FreeB.FBDiagnosis.DateOfFirstOccurrence",
27 "sig" => array(XMLRPCSTRING
,XMLRPCINT
),
29 $this->_addFunc("iscantwork", array( "name" => "FreeB.FBDiagnosis.isCantWork",
30 "sig" => array(XMLRPCSTRING
,XMLRPCINT
),
32 $this->_addFunc("dateofcantworkstart", array( "name" => "FreeB.FBDiagnosis.DateOfCantWorkStart",
33 "sig" => array(XMLRPCSTRING
,XMLRPCINT
),
35 $this->_addFunc("dateofcantworkend", array( "name" => "FreeB.FBDiagnosis.DateOfCantWorkEnd",
36 "sig" => array(XMLRPCSTRING
,XMLRPCINT
),
38 $this->_addFunc("isrelatedtoemployment", array( "name" => "FreeB.FBDiagnosis.isRelatedToEmployment",
39 "sig" => array(XMLRPCSTRING
,XMLRPCINT
),
41 $this->_addFunc("isrelatedtoautoaccident", array( "name" => "FreeB.FBDiagnosis.isRelatedToAutoAccident",
42 "sig" => array(XMLRPCSTRING
,XMLRPCINT
),
44 $this->_addFunc("autoaccidentstate", array( "name" => "FreeB.FBDiagnosis.AutoAccidentState",
45 "sig" => array(XMLRPCSTRING
,XMLRPCINT
),
47 $this->_addFunc("icd10code", array( "name" => "FreeB.FBDiagnosis.ICD10Code",
48 "sig" => array(XMLRPCSTRING
,XMLRPCINT
),
50 $this->_addFunc("icd9code", array( "name" => "FreeB.FBDiagnosis.ICD9Code",
51 "sig" => array(XMLRPCSTRING
,XMLRPCINT
),
53 $this->_addFunc("dateoflastvisit", array( "name" => "FreeB.FBDiagnosis.DateOfLastVisit",
54 "sig" => array(XMLRPCSTRING
,XMLRPCINT
),
56 $this->_addFunc("comment", array( "name" => "FreeB.FBDiagnosis.Comment",
57 "sig" => array(XMLRPCSTRING
,XMLRPCINT
),
61 function relatedtohcfa($m) {
65 //unimplemented by OpenEMR
68 // if we generated an error, create an error return response
70 return $this->_handleError($err);
73 // otherwise, we create the right response
74 // with the state name
75 return new xmlrpcresp(new xmlrpcval($retval,"string"));
79 function isrelatedtootheraccident($m) {
81 //Now implemented by OpenEMR with Form: Misc Billing Options
84 $obj= $m->getparam(0);
85 $key = $obj->getval();
87 $sql = "SELECT * FROM forms JOIN form_misc_billing_options as fpa on fpa.id = forms.form_id where forms.encounter = '" . $_SESSION['billkey'] . "' and forms.pid = '" . $_SESSION['patient_id'] . "' and forms.formdir = 'misc_billing_options' order by forms.date";
89 $db = $GLOBALS['adodb']['db'];
90 $results = $db->Execute($sql);
93 $err = $db->ErrorMsg();
97 $retval = $results->fields
['other_accident'];
98 if ($retval == "1") {$pkey = true;};
101 // if we generated an error, create an error return response
103 return $this->_handleError($err);
106 // otherwise, we create the right response
107 // with the state name
108 return new xmlrpcresp(new xmlrpcval($pkey,"i4"));
112 function dateofencounter($m) {
115 $obj= $m->getparam(0);
116 $key = $obj->getval();
118 $sql = "SELECT * FROM form_encounter where encounter = '" . $_SESSION['billkey'] .
119 "' and pid = '" . $_SESSION['patient_id'] ."' order by date DESC";
120 $db = $GLOBALS['adodb']['db'];
121 $results = $db->Execute($sql);
124 $err = $db->ErrorMsg();
127 if (!$results->EOF
) {
128 $retval = $results->fields
['date'];
131 $retval = date("Y-m-d",strtotime($retval));
132 $retval = $this->_isodate($retval);
134 // if we generated an error, create an error return response
136 return $this->_handleError($err);
139 // otherwise, we create the right response
140 // with the state name
141 return new xmlrpcresp(new xmlrpcval($retval,XMLRPCDATETIME
));
145 function dateofonset($m) {
150 $obj= $m->getparam(0);
151 $key = $obj->getval();
153 $sql = "SELECT * FROM form_encounter where encounter = '" . $_SESSION['billkey'] ."' and pid = '" . $_SESSION['patient_id'] ."' order by date DESC";
155 $db = $GLOBALS['adodb']['db'];
156 $results = $db->Execute($sql);
159 $err = $db->ErrorMsg();
162 if (!$results->EOF
) {
163 $retval = $results->fields
['onset_date'];
166 $retval = date("Y-m-d",strtotime($retval));
167 $retval = $this->_isodate($retval);
169 // if we generated an error, create an error return response
171 return $this->_handleError($err);
174 // otherwise, we create the right response
175 // with the state name
176 return new xmlrpcresp(new xmlrpcval($retval,XMLRPCDATETIME
));
180 function dateoffirstsymptom($m) {
185 $obj= $m->getparam(0);
186 $key = $obj->getval();
188 $sql = "SELECT * FROM form_encounter where encounter = '" . $_SESSION['billkey'] ."' and pid = '" . $_SESSION['patient_id'] ."' order by date DESC";
190 $db = $GLOBALS['adodb']['db'];
191 $results = $db->Execute($sql);
194 $err = $db->ErrorMsg();
197 if (!$results->EOF
) {
198 $retval = $results->fields
['onset_date'];
201 $retval = date("Y-m-d",strtotime($retval));
202 $retval = $this->_isodate($retval);
204 // if we generated an error, create an error return response
206 return $this->_handleError($err);
209 // otherwise, we create the right response
210 // with the state name
211 return new xmlrpcresp(new xmlrpcval($pkey,XMLRPCDATETIME
));
215 function isfirstoccurence($m) {
219 //unimplemented by OpenEMR
222 // if we generated an error, create an error return response
224 return $this->_handleError($err);
227 // otherwise, we create the right response
228 // with the state name
229 return new xmlrpcresp(new xmlrpcval($pkey,"i4"));
233 function dateoffirstoccurence($m) {
238 $obj= $m->getparam(0);
239 $key = $obj->getval();
241 $sql = "SELECT * FROM form_encounter where encounter = '" . $_SESSION['billkey'] ."' and pid = '" . $_SESSION['patient_id'] ."' order by date DESC";
243 $db = $GLOBALS['adodb']['db'];
244 $results = $db->Execute($sql);
247 $err = $db->ErrorMsg();
250 if (!$results->EOF
) {
251 $retval = $results->fields
['onset_date'];
254 $retval = date("Y-m-d",strtotime($retval));
255 $retval = $this->_isodate($retval);
257 // if we generated an error, create an error return response
259 return $this->_handleError($err);
262 // otherwise, we create the right response
263 // with the state name
264 return new xmlrpcresp(new xmlrpcval($pkey,XMLRPCDATETIME
));
268 function iscantwork($m) {
270 //Now implemented by OpenEMR with Form: Misc Billing Options
273 $obj= $m->getparam(0);
274 $key = $obj->getval();
276 $sql = "SELECT * FROM forms JOIN form_misc_billing_options as fpa on fpa.id = forms.form_id where forms.encounter = '" . $_SESSION['billkey'] . "' and forms.pid = '" . $_SESSION['patient_id'] . "' and forms.formdir = 'misc_billing_options' order by forms.date";
278 $db = $GLOBALS['adodb']['db'];
279 $results = $db->Execute($sql);
282 $err = $db->ErrorMsg();
285 if (!$results->EOF
) {
286 $retval = $results->fields
['is_unable_to_work'];
287 if ($retval == "1") {$pkey = true;};
290 // if we generated an error, create an error return response
292 return $this->_handleError($err);
295 // otherwise, we create the right response
296 // with the state name
297 return new xmlrpcresp(new xmlrpcval($pkey,"i4"));
301 function dateofcantworkstart($m) {
303 //Now implemented by OpenEMR with Form: Misc Billing Options
305 $obj= $m->getparam(0);
306 $key = $obj->getval();
308 $sql = "SELECT * FROM forms JOIN form_misc_billing_options as fpa on fpa.id = forms.form_id where forms.encounter = '" . $_SESSION['billkey'] . "' and forms.pid = '" . $_SESSION['patient_id'] . "' and forms.formdir = 'misc_billing_options' order by forms.date";
310 $db = $GLOBALS['adodb']['db'];
311 $results = $db->Execute($sql);
314 $err = $db->ErrorMsg();
317 if (!$results->EOF
) {
318 $retval = $results->fields
['off_work_from'];
321 $retval = date("Y-m-d",strtotime($retval));
322 $retval = $this->_isodate($retval);
323 // if we generated an error, create an error return response
325 return $this->_handleError($err);
328 // otherwise, we create the right response
329 // with the state name
330 return new xmlrpcresp(new xmlrpcval($retval,XMLRPCDATETIME
));
335 function dateofcantworkend($m) {
337 //Now implemented by OpenEMR with Form: Misc Billing Options
339 $obj= $m->getparam(0);
340 $key = $obj->getval();
342 $sql = "SELECT * FROM forms JOIN form_misc_billing_options as fpa on fpa.id = forms.form_id where forms.encounter = '" . $_SESSION['billkey'] . "' and forms.pid = '" . $_SESSION['patient_id'] . "' and forms.formdir = 'misc_billing_options' order by forms.date";
344 $db = $GLOBALS['adodb']['db'];
345 $results = $db->Execute($sql);
348 $err = $db->ErrorMsg();
351 if (!$results->EOF
) {
352 $retval = $results->fields
['off_work_to'];
355 $retval = date("Y-m-d",strtotime($retval));
356 $retval = $this->_isodate($retval);
357 // if we generated an error, create an error return response
359 return $this->_handleError($err);
362 // otherwise, we create the right response
363 // with the state name
364 return new xmlrpcresp(new xmlrpcval($retval,XMLRPCDATETIME
));
368 function isrelatedtoemployment($m) {
370 //Now implemented by OpenEMR with Form: Misc Billing Options
373 $obj= $m->getparam(0);
374 $key = $obj->getval();
376 $sql = "SELECT * FROM forms JOIN form_misc_billing_options as fpa on fpa.id = forms.form_id where forms.encounter = '" . $_SESSION['billkey'] . "' and forms.pid = '" . $_SESSION['patient_id'] . "' and forms.formdir = 'misc_billing_options' order by forms.date";
378 $db = $GLOBALS['adodb']['db'];
379 $results = $db->Execute($sql);
382 $err = $db->ErrorMsg();
385 if (!$results->EOF
) {
386 $retval = $results->fields
['employment_related'];
387 if ($retval == "1") {$pkey = true;};
390 // if we generated an error, create an error return response
392 return $this->_handleError($err);
395 // otherwise, we create the right response
396 // with the state name
397 return new xmlrpcresp(new xmlrpcval($pkey,"i4"));
401 function isrelatedtoautoaccident($m) {
403 //Now implemented by OpenEMR with Form: Misc Billing Options
406 $obj= $m->getparam(0);
407 $key = $obj->getval();
409 $sql = "SELECT * FROM forms JOIN form_misc_billing_options as fpa on fpa.id = forms.form_id where forms.encounter = '" . $_SESSION['billkey'] . "' and forms.pid = '" . $_SESSION['patient_id'] . "' and forms.formdir = 'misc_billing_options' order by forms.date";
411 $db = $GLOBALS['adodb']['db'];
412 $results = $db->Execute($sql);
415 $err = $db->ErrorMsg();
418 if (!$results->EOF
) {
419 $retval = $results->fields
['auto_accident'];
420 if ($retval == "1") {$pkey = true;};
423 // if we generated an error, create an error return response
425 return $this->_handleError($err);
428 // otherwise, we create the right response
429 // with the state name
430 return new xmlrpcresp(new xmlrpcval($pkey,"i4"));
434 function autoaccidentstate($m) {
438 $obj= $m->getparam(0);
439 $key = $obj->getval();
440 //Now implemented by OpenEMR with Form: Misc_billing_options
441 $sql = "SELECT * FROM forms JOIN form_misc_billing_options as fpa on fpa.id = forms.form_id where forms.encounter = '" . $_SESSION['billkey'] . "' and forms.pid = '" . $_SESSION['patient_id'] . "' and forms.formdir = 'misc_billing_options' order by forms.date";
443 $db = $GLOBALS['adodb']['db'];
444 $results = $db->Execute($sql);
447 $err = $db->ErrorMsg();
450 if (!$results->EOF
) {
451 $retval = $results->fields
['accident_state'];
454 // if we generated an error, create an error return response
456 return $this->_handleError($err);
459 // otherwise, we create the right response
460 // with the state name
461 return new xmlrpcresp(new xmlrpcval($retval,"string"));
466 function icd10code($m) {
469 //unimplemented by OpenEMR
472 // if we generated an error, create an error return response
474 return $this->_handleError($err);
477 // otherwise, we create the right response
478 // with the state name
479 return new xmlrpcresp(new xmlrpcval($pkey));
482 function icd9code($m) {
486 $obj= $m->getparam(0);
487 $key = $obj->getval();
489 $sql = "SELECT * FROM billing where id = '" . $key . "'";
491 $db = $GLOBALS['adodb']['db'];
492 $results = $db->Execute($sql);
495 $err = $db->ErrorMsg();
498 if (!$results->EOF
) {
499 $retval = $results->fields
['code'];
502 $retval = str_replace("."," ", $retval);
504 // if we generated an error, create an error return response
506 return $this->_handleError($err);
509 // otherwise, we create the right response
510 // with the state name
511 return new xmlrpcresp(new xmlrpcval($retval,"string"));
514 function dateoflastvisit($m){
518 $obj= $m->getparam(0);
519 $key = $obj->getval();
521 $sql = "SELECT * FROM form_encounter where encounter = '" . $_SESSION['billkey'] ."' and pid = '" . $_SESSION['patient_id'] ."' order by date DESC";
523 $db = $GLOBALS['adodb']['db'];
524 $results = $db->Execute($sql);
527 $err = $db->ErrorMsg();
530 if (!$results->EOF
) {
531 $retval = $results->fields
['date'];
534 $retval = date("Y-m-d",strtotime($retval));
535 $retval = $this->_isodate($retval);
537 // if we generated an error, create an error return response
539 return $this->_handleError($err);
542 // otherwise, we create the right response
543 // with the state name
544 return new xmlrpcresp(new xmlrpcval($retval,XMLRPCDATETIME
));
547 function comment($m){
551 $obj= $m->getparam(0);
552 $key = $obj->getval();
554 $sql = "SELECT reason FROM form_encounter where encounter = '" . $_SESSION['billkey'] ."' and pid = '" . $_SESSION['patient_id'] ."'";
556 $db = $GLOBALS['adodb']['db'];
557 $results = $db->Execute($sql);
560 $err = $db->ErrorMsg();
563 if (!$results->EOF
) {
564 $retval = $results->fields
['reason'];
568 // if we generated an error, create an error return response
570 return $this->_handleError($err);
573 // otherwise, we create the right response
574 // with the state name
575 return new xmlrpcresp(new xmlrpcval($retval,"string"));
579 //'FreeB.FBDiagnosis.RelatedToHCFA' => \&FreeB_FBDiagnosis_RelatedToHCFA,
580 //'FreeB.FBDiagnosis.isRelatedToOtherAccident' => \&FreeB_FBDiagnosis_isRelatedToOtherAccident,
581 //'FreeB.FBDiagnosis.DateOfOnset' => \&FreeB_FBDiagnosis_DateOfOnset,
582 //'FreeB.FBDiagnosis.DateOfFirstSymptom' => \&FreeB_FBDiagnosis_DateOfFirstSymptom,
583 //'FreeB.FBDiagnosis.isFirstOccurrence' => \&FreeB_FBDiagnosis_isFirstOccurence,
584 //'FreeB.FBDiagnosis.DateOfFirstOccurrence' => \&FreeB_FBDiagnosis_DateOfFirstOccurence,
585 //'FreeB.FBDiagnosis.isCantWork' => \&FreeB_FBDiagnosis_isCantWork,
586 //'FreeB.FBDiagnosis.DateOfCantWorkStart' => \&FreeB_FBDiagnosis_DateOfCantWorkStart,
587 //'FreeB.FBDiagnosis.DateOfCantWorkEnd' => \&FreeB_FBDiagnosis_DateOfCantWorkEnd,
588 //'FreeB.FBDiagnosis.isRelatedToEmployment' => \&FreeB_FBDiagnosis_isRelatedToEmployment,
589 //'FreeB.FBDiagnosis.isRelatedToAutoAccident' => \&FreeB_FBDiagnosis_isRelatedToAutoAccident,
590 //'FreeB.FBDiagnosis.AutoAccidentState' => \&FreeB_FBDiagnosis_AutoAccidentState,
591 //'FreeB.FBDiagnosis.ICD10Code' => \&FreeB_FBDiagnosis_ICD9Code,
592 //'FreeB.FBDiagnosis.ICD9Code' => \&FreeB_FBDiagnosis_ICD9Code,?>