Skip to content

Commit

Permalink
Provision to send email with attachment of the patient document from …
Browse files Browse the repository at this point in the history
…patient documents page
  • Loading branch information
rreddy70 authored and bradymiller committed Nov 17, 2014
1 parent d36db00 commit 227218d
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 4 deletions.
50 changes: 47 additions & 3 deletions controllers/C_Document.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,24 @@ function note_action_process($patient_id) {
$n = new Note();
$n->set_owner($_SESSION['authUserID']);
parent::populate_object($n);
$n->persist();

if ($_POST['identifier'] == "no"){
$n->persist();
}elseif ($_POST['identifier'] == "yes"){

$d = new Document($_POST['foreign_id']);
$att = $d->get_url();
$att_mtype = $d->get_mimetype();
$att_mtypearr = explode('/',$att_mtype);
$body_notes = attr($_POST['note']);
$att = trim(str_replace("file:https://","",$att));
$att_parts = pathinfo($att);
if($att_parts['extension'] == ""){
$att = $att.".".$att_mtypearr[1];
}
$pdetails = getPatientData($patient_id);
$pname = $pdetails['fname']." ".$pdetails['lname'];
$this->document_send($_POST['provide_email'],$body_notes,$att,$pname);
}
$this->_state = false;
$_POST['process'] = "";
return $this->view_action($patient_id,$n->get_foreign_id());
Expand Down Expand Up @@ -1025,7 +1041,35 @@ function document_upload_download_log($patientid,$content){
fwrite($LOG,$content);
fclose($LOG);
}


function document_send($email,$body,$attfile,$pname) {
if (empty($email)) {
$this->assign("process_result","Email could not be sent, the address supplied: '$email' was empty or invalid.");
return;
}

require_once($GLOBALS['fileroot'] . "/library/classes/postmaster.php" );
$desc = "Please check the attached patient document.\n Content:".attr($body);
$mail = new MyMailer();
$from_name = $GLOBALS["practice_return_email_path"];
$from = $GLOBALS["practice_return_email_path"];
$mail->AddReplyTo($from,$from_name);
$mail->SetFrom($from,$from );
$to = $email ; $to_name =$email;
$mail->AddAddress($to, $to_name);
$subject = "Patient documents";
$mail->Subject = $subject;
$mail->Body = $desc;
$mail->AddAttachment($attfile);
if ($mail->Send()) {
$retstatus = "email_sent";
} else {
$email_status = $mail->ErrorInfo;
//echo "EMAIL ERROR: ".$email_status;
$retstatus = "email_fail";
}
}

//place to hold optional code
//$first_node = array_keys($t->tree);
//$first_node = $first_node[0];
Expand Down
14 changes: 13 additions & 1 deletion templates/documents/general_view.html
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,19 @@
<b>{xl t='Notes'}</b>&nbsp;
</div>
<div style="float:none">
<a href="javascript:;" onclick="document.forms['notes'].submit();">(<span>{xl t='add'}</span>)</a>
<a href="javascript:;" onclick="document.notes.identifier.value='no';document.forms['notes'].submit();">(<span>{xl t='add'}</span>)</a>
&nbsp;&nbsp;&nbsp;<b>{xl t='Email'}</b>&nbsp;
<input type="text" size="25" name="provide_email" id="provide_email" />
<input type="hidden" name="identifier" id="identifier" />
<a href="javascript:;" onclick="javascript:document.notes.identifier.value='yes';document.forms['notes'].submit();">
(<span>{xl t='Send'}</span>)
</a>
</div>
<div>

</div>
<div style="float:none">

</div>
<div>
<textarea cols="53" rows="8" wrap="virtual" name="note" style="width:100%"></textarea><br>
Expand Down

0 comments on commit 227218d

Please sign in to comment.