<cfcomponent hint="Send Emails to Physicians for Orders Pending Sign-Off">

 <cffunction name="NewOrderEmail" access="public" output="Yes" returnformat="plain" returntype="string">
  <cfargument name="assessmentFormsId" type="string" required="Yes" />
  <cfargument name="docId" type="string" required="Yes" />
  <cfparam default='' name='str'/>
  <cfquery name="getDoc" datasource="#Application.DataSrc#">
   SELECT af.Discharge_Plan,a.Agency_Name
	       ,p.Phys_First, p.Phys_Last, p.Phys_Email
	       ,Pt_First, Pt_Last
   FROM   #Request.prefix_db_agency#.pCMS4857 af,
    #Request.prefix_db_lookup#.pPhysicians p, 
    #Request.prefix_db_lookup#.Agency a
   WHERE  af.Order_ID = '#assessmentFormsId#'
   AND    af.Render_Phys_ID = '#docId#'
   AND    p.Phys_ID = af.Render_Phys_ID
   AND    p.status = '0'
   AND    a.agency_id = p.Loc_ID
  </cfquery>
  <cfif (CGI.SERVER_NAME neq "76.12.35.143" and getDoc.recordcount eq 1)>
   <cfset ReplyTo = "info@MyHomeCareBiz.com" />
   <cfif trim(getDoc.Phys_Email) NEQ ''>
	 <cfmail
		   to = "#getDoc.Phys_Email#"
			 from = "#ReplyTo#" 
			 replyto = "#ReplyTo#"
	     subject = "MyHomeCareBiz.com - New Patient Order Approval..."
			 type = "html">
        <br><br>
       Dr. #getDoc.Phys_First# #getDoc.Phys_Last#,
		    <br><br>
		   A New Patient Order is awaiting your Approval at <a href='https://secure.myhomecarebiz.com/index.cfm'>MyHomeCareBiz.com</a>...
		    <br><br>
		   Please <a href='https://secure.myhomecarebiz.com/index.cfm'>click here</a> to Sign In and then View and Approve your Patient Orders.
		    <br><br>
       <b>ORDER DETAILS...</b>
		    <br><br>
		   <b>Home Health Care Agency Name: </b> #getDoc.Agency_Name#
		    <br><br>
		   <b>Patient Name: </b> #getDoc.Pt_First# #getDoc.Pt_Last#
		    <br><br>
		   <b>Order Info: </b> #getDoc.Discharge_Plan#
		    <br><br><br>
		   <i>
		    This is an automated system notification from <a href='https://secure.myhomecarebiz.com/index.cfm'>MyHomeCareBiz.com</a>. Therefore, there is no Unsubscribe option.
		   </i>
		    <br><br><br><br><br><br>
   </cfmail>
   </cfif>
   <!--- <cfquery name='DocPhys_EmailSent' datasource='#Application.DataSrc#'>
    UPDATE #Request.prefix_db_agency#.Assessment_Forms SET
      Physician_Email_Sent = #CreateODBCDate(Now())#
    WHERE Assessment_Forms_Id = '#assessmentFormsId#'
   </cfquery> --->
  </cfif>
  <cfreturn str />
 </cffunction>

</cfcomponent>
