- modules/fotolab updated imagej to current version & some cod fixes to make it work
[care2x.git] / Care2007 / modules / medocs / show_medocs.php
blobe7acab45dc373d6ba06bf29bd59e20b5049c8495
1 <?php
2 error_reporting(E_COMPILE_ERROR|E_ERROR|E_CORE_ERROR);
3 require('./roots.php');
4 require($root_path.'include/inc_environment_global.php');
5 /**
6 * CARE2X Integrated Hospital Information System Deployment 2.2 - 2006-07-10
7 * GNU General Public License
8 * Copyright 2002,2003,2004,2005,2006 Elpidio Latorilla
9 * elpidio@care2x.org,
11 * See the file "copy_notice.txt" for the licence notice
13 $thisfile=basename(__FILE__);
15 if(!isset($type_nr)||!$type_nr) $type_nr=1; //* 1 = history physical notes
17 require_once($root_path.'include/care_api_classes/class_notes.php');
18 $obj=new Notes;
19 $types=$obj->getAllTypesSort('name');
20 $this_type=$obj->getType($type_nr);
22 //$db->debug=1;
24 if(!isset($mode)){
25 $mode='show';
26 } elseif(($mode=='create'||$mode=='update')
27 &&!empty($HTTP_POST_VARS['text_diagnosis'])
28 &&!empty($HTTP_POST_VARS['text_therapy'])) {
29 # Prepare the posted data for saving in databank
30 include_once($root_path.'include/inc_date_format_functions.php');
31 # If date is empty,default to today
32 if(empty($HTTP_POST_VARS['date'])){
33 $HTTP_POST_VARS['date']=date('Y-m-d');
34 }else{
35 $HTTP_POST_VARS['date']=@formatDate2STD($HTTP_POST_VARS['date'],$date_format);
38 # Prune the aux_notes data to max 255
39 $HTTP_POST_VARS['aux_notes']=substr($HTTP_POST_VARS['aux_notes'],0,255);
41 # Prepare history
42 $HTTP_POST_VARS['history']='Entry: '.date('Y-m-d H:i:s').' '.$HTTP_SESSION_VARS['sess_user_name'];
43 $HTTP_POST_VARS['time']=date('H:i:s');
44 $HTTP_POST_VARS['type_nr']=12; // 12 = text_diagnosis
45 $HTTP_POST_VARS['notes']=$HTTP_POST_VARS['text_diagnosis'];
46 # Prevent redirection
47 $redirect=false;
48 include('./include/save_admission_data.inc.php');
49 $insid=$db->Insert_ID();
50 $HTTP_POST_VARS['ref_notes_nr']=$obj->LastInsertPK('nr',$insid);
51 $HTTP_POST_VARS['notes']=$HTTP_POST_VARS['text_therapy'];
52 $HTTP_POST_VARS['type_nr']=13; // 13 = text_therapy
53 $HTTP_POST_VARS['short_notes']='';
54 $HTTP_POST_VARS['aux_notes']='';
55 $redirect=true;
56 include('./include/save_admission_data.inc.php');
59 require('./include/init_show.php');
61 $page_title=$LDMedocs;
63 # Load the entire encounter data
64 require_once($root_path.'include/care_api_classes/class_encounter.php');
65 $enc_obj=new Encounter($encounter_nr);
66 $enc_obj->loadEncounterData();
67 # Get encounter class
68 $enc_class=$enc_obj->EncounterClass();
69 /*if($enc_class==2) $HTTP_SESSION_VARS['sess_full_en']=$GLOBAL_CONFIG['patient_outpatient_nr_adder']+$encounter_nr;
70 else $HTTP_SESSION_VARS['sess_full_en']=$GLOBAL_CONFIG['patient_inpatient_nr_adder']+$encounter_nr;
72 $HTTP_SESSION_VARS['sess_full_en']=$encounter_nr;
74 if(empty($encounter_nr)&&!empty($HTTP_SESSION_VARS['sess_en'])){
75 $encounter_nr=$HTTP_SESSION_VARS['sess_en'];
76 }elseif($encounter_nr) {
77 $HTTP_SESSION_VARS['sess_en']=$encounter_nr;
80 if($mode=='show')
82 $sql="SELECT e.encounter_nr,e.is_discharged,nd.nr, nd.notes AS diagnosis,nd.short_notes, nd.date,nd.personell_nr,nd.personell_name, nt.notes AS therapy
83 FROM care_encounter AS e,
84 care_encounter_notes AS nd
85 LEFT JOIN care_encounter_notes AS nt ON nt.ref_notes_nr=nd.nr
86 WHERE e.encounter_nr=".$encounter_nr."
87 AND e.encounter_nr=nd.encounter_nr
88 AND nd.type_nr=12
89 ORDER BY nd.create_time DESC";
91 /* 12 = text_diagnosis type of notes
92 * 13 = text_therapy type of notes
94 if($result=$db->Execute($sql)){
95 if($rows=$result->RecordCount()){
96 # Resync the encounter_nr
97 if($HTTP_SESSION_VARS['sess_en']!=$encounter_nr) $HTTP_SESSION_VARS['sess_en']=$encounter_nr;
98 if($rows==1){
99 $row=$result->FetchRow();
100 if($row['is_discharged']) $edit=0;
102 header("location:".$thisfile.URL_REDIRECT_APPEND."&target=$target&mode=details&nolist=1&pid=$pid&encounter_nr=&encounter_nr&nr=".$row['nr']."&edit=$edit&is_discharged=".$row['is_discharged']);
103 exit;
106 }else{
107 echo "$LDDbNoRead<p>$sql";
109 }elseif(($mode=='details')&&!empty($nr)){
110 $sql="SELECT nd.notes AS diagnosis,
111 nd.short_notes,
112 nd.aux_notes,
113 nd.date,
114 nd.personell_nr,
115 nd.personell_name,
116 nt.notes AS therapy
117 FROM care_encounter_notes AS nd LEFT JOIN care_encounter_notes AS nt ON nd.nr=nt.ref_notes_nr
118 WHERE nd.nr=$nr";
120 if($result=$db->Execute($sql)){
121 if($rows=$result->RecordCount()) $row=$result->FetchRow();
122 }else{
123 echo $sql;
127 $subtitle=$LDMedocs;
129 $buffer=str_replace('~tag~',$title.' '.$name_last,$LDNoRecordFor);
130 $norecordyet=str_replace('~obj~',strtolower($subtitle),$buffer);
131 $HTTP_SESSION_VARS['sess_file_return']=$thisfile;
133 # Set break file
134 require('include/inc_breakfile.php');
136 if($mode=='show') $glob_obj->getConfig('medocs_%');
137 /* Load GUI page */
138 require('./gui_bridge/default/gui_show_medocs.php');