<cfwindow 
    name="editmed" 
    title="" 	
    height="500"     
    width="800"  
    resizable="false"     
    center="true" 
    closable="false" 
    draggable="true"     
    modal="true"   
    bodystyle="background-color:white;"	
	initshow="true">  
  
   <cfparam name='url.mid' default='' />
  <cfparam name='form.mid' default='' />
  <cfif url.mid eq '' and form.mid neq ''>
    <cfset url.mid = form.mid />
  </cfif>
  
 
  <cfquery datasource="#Application.DataSrc#" name="GetMed">
				SELECT Trade_ID, Name, Classification, Grouping, Trade_Name, Generic_Name
				FROM   #Request.prefix_db_lookup#.Meds_New
				WHERE  Trade_ID = '#URL.MID#'
			</cfquery>
    <cfquery datasource="#Application.DataSrc#" name="GetDose">
				SELECT DISTINCT Trade_ID, Dose, Form
				FROM   #Request.prefix_db_lookup#.Meds_New_Dose
				WHERE  Trade_ID = '#URL.MID#'
				Order by Dose ASC
			</cfquery>

 <cfquery name="GetM" datasource="#Application.DataSrc#">
	SELECT Medication_ID, Notes, Med_Status, DateOrdered, DateDCed, Dose, Route, Freq, Drug_Name, Dose_Units, NewChanged,
	Meds_New.Classification, Meds_New.Grouping, Meds_New.Trade_Name, Meds_New.Generic_Name
	FROM #Request.prefix_db_agency#.PatientMeds
	left outer join #Request.prefix_db_lookup#.Meds_New on PatientMeds.Medication_ID = Meds_New.Trade_id
	WHERE PatientMeds_ID = #Session.CS.PatientMedicationID#
	</cfquery>
	
	<cfquery name="GetP" datasource="#Application.DataSrc#">
	 SELECT Patient_Id, Last_Name_M0040 AS Last_Name, First_Name_M0040 AS First_Name, Middle_Initial_M0040 AS Middle
	 FROM   #Request.prefix_db_agency#.patient 
	 WHERE  Patient_Id = '#session.cs.patientid#'
	 AND    Agency_Id = '#session.AgencyId#'
	</cfquery>

<table  align="center" width="98%" cellpadding="0" cellspacing="0">
    <tr>
      <td style="height:5px"></td>
    </tr>
    <tr>
      <td align="left" style="font-family:Arial; font-size:14px;font-weight:bold;color:ff6b00;padding-left:10px"><cfoutput>
          <cfif  isDefined("url.Action") and url.Action is "Add">
            #GetP.First_Name# #GetP.Last_Name# - New Medication
            <cfelse>
            #GetP.First_Name# #GetP.Last_Name# - Update Medication
          </cfif>
        </cfoutput></td>
      <td align="right" style="padding-right:2px"><cfoutput><img src="../../images/vizard_close.png" onClick="window.location='/patientadmin_new/index.cfm?page=patient&cat=PatientSummary'" style="cursor:pointer" name="imgclose" id="imgclose" /></cfoutput></td>
    </tr>
    <tr>
      <td style="height:5px"></td>
    </tr>
    <tr>
      <td colspan="2" style=" background-image:url(../../images/vizard_title_bg.gif); height:13px;" ></td>
    </tr>
    <tr>
      <td style="height:5px"></td>
    </tr>
  </table>
  
 <cfoutput>
        <cfquery datasource="#Application.DataSrc#" name="GetDoses">
				SELECT DISTINCT Trade_ID, Dose, Form
				FROM   #Request.prefix_db_lookup#.Meds_New_Dose
				WHERE  Trade_ID = '#GetM.Medication_Id#'
				Order by Dose ASC
			</cfquery>
        
        <form name="contact" action="index.cfm?page=patient&cat=medorder_action&Action=Update" method="post" onSubmit="return checkMedForm(this,2);">
          <input type=hidden name="page" value="#url.page#">
          <input type=hidden name="cat" value="medlist">
          <input type="hidden" name="ID" value="#session.cs.patientid#">
          <input type="hidden" name="MID" value="#Session.CS.MedicationID#">
          <input type="hidden" name="MPID" value="#Session.CS.PatientMedicationID#">
		  <table>
          <tr>
            <td class="form-label">Medication</td>
            <td><textarea name="Medication" rows="2" cols="45"><cfoutput>#GetM.Drug_Name#</cfoutput></textarea></td>
          </tr>
          <tr>
          <tr>
            <td class="form-label">Dose</td>
            <td><cfset gotDose = false />
              <cfloop query="GetDoses">
                <cfif GetM.Dose eq GetDoses.Dose or Replace(GetM.Dose, ' ', '', 'ALL') eq Replace(GetDoses.Dose, ' ', '', 'ALL')>
                  <cfset gotDose = true />
                </cfif>
              </cfloop>
              <input type="Radio" name="Dose" value="0" <cfif gotDose eq false or GetM.Dose eq '0' or GetM.Dose eq ''>checked</cfif>>
              <em>I'll enter my own dose under Dose Units</em><br>
              <cfloop query="GetDoses">
                <input type="Radio" name="Dose" value="#GetDoses.Dose#" <cfif GetM.Dose eq GetDoses.Dose or Replace(GetM.Dose, ' ', '', 'ALL') eq Replace(GetDoses.Dose, ' ', '', 'ALL')>checked </cfif> <cfset gotDose = true />>
                #GetDoses.Dose# (#GetDoses.form#)<br>
              </cfloop></td>
          </tr>
          <tr>
            <td class="form-label">Dose Units</td>
            <td><input type="text" name="Dose_Units" size="20" value="#GetM.Dose_Units#"></td>
          </tr>
          <tr>
            <td class="form-label">Route</td>
            <td><select name="Route">
                <option <cfif GetM.Route IS "">selected</cfif>> - </option>
                <option <cfif GetM.Route IS "by mouth">selected</cfif>>by mouth</option>
                <option <cfif GetM.Route IS "PO">selected</cfif>>PO</option>
                <option <cfif GetM.Route IS "inhalant">selected</cfif>>inhalant</option>
                <option <cfif GetM.Route IS "I">selected</cfif>>I</option>
                <option <cfif GetM.Route IS "intramuscular">selected</cfif>>intramuscular</option>
                <option <cfif GetM.Route IS "IM">selected</cfif>>IM</option>
                <option <cfif GetM.Route IS "right eye">selected</cfif>>right eye</option>
                <option <cfif GetM.Route IS "OD">selected</cfif>>OD</option>
                <option <cfif GetM.Route IS "left eye">selected</cfif>>left eye</option>
                <option <cfif GetM.Route IS "OS">selected</cfif>>OS</option>
                <option <cfif GetM.Route IS "both eyes">selected</cfif>>both eyes</option>
                <option <cfif GetM.Route IS "OM">selected</cfif>>OM</option>
                <option <cfif GetM.Route IS "drops">selected</cfif>>drops</option>
                <option <cfif GetM.Route IS "Gt">selected</cfif>>Gt</option>
                <option <cfif GetM.Route IS "J-tube">selected</cfif>>J-tube</option>
                <option <cfif GetM.Route IS "nasal cannula">selected</cfif>>nasal cannula</option>
                <option <cfif GetM.Route IS "NC">selected</cfif>>NC</option>
                <option <cfif GetM.Route IS "rectal">selected</cfif>>rectal</option>
                <option <cfif GetM.Route IS "PR">selected</cfif>>PR</option>
                <option <cfif GetM.Route IS "subcutaneous">selected</cfif>>subcutaneous</option>
                <option <cfif GetM.Route IS "SC">selected</cfif>>SC</option>
                <option <cfif GetM.Route IS "sublingual">selected</cfif>>sublingual</option>
                <option <cfif GetM.Route IS "SL">selected</cfif>>SL</option>
                <option <cfif GetM.Route IS "topical">selected</cfif>>topical</option>
                <option <cfif GetM.Route IS "T">selected</cfif>>T</option>
                <option <cfif GetM.Route IS "transdermal">selected</cfif>>transdermal</option>
                <option <cfif GetM.Route IS "TD">selected</cfif>>TD</option>
                <option <cfif GetM.Route IS "intravenous">selected</cfif>>intravenous</option>
                <option <cfif GetM.Route IS "IV">selected</cfif>>IV</option>
                <option <cfif GetM.Route IS "vaginal">selected</cfif>>vaginal</option>
                <option <cfif GetM.Route IS "V">selected</cfif>>V</option>
              </select></td>
          </tr>
          <tr>
            <td class="form-label">Frequency</td>
            <td><select name="Freq">
                <option <cfif GetM.Freq IS "">selected</cfif>> - </option>
                <option <cfif GetM.Freq IS "before meal">selected</cfif>>before meal</option>
                <option <cfif GetM.Freq IS "after meal">selected</cfif>>after meal</option>
                <option <cfif GetM.Freq IS "in the morning">selected</cfif>>in the morning</option>
                <option <cfif GetM.Freq IS "at bedtime">selected</cfif>>at bedtime</option>
                <option <cfif GetM.Freq IS "once a day">selected</cfif>>once a day</option>
                <option <cfif GetM.Freq IS "twice a day">selected</cfif>>twice a day</option>
                <option <cfif GetM.Freq IS "three times a day">selected</cfif>>three times a day</option>
                <option <cfif GetM.Freq IS "four times a day">selected</cfif>>four times a day</option>
                <option <cfif GetM.Freq IS "every other day">selected</cfif>>every other day</option>
                <option <cfif GetM.Freq IS "every hour">selected</cfif>>every hour</option>
                <option <cfif GetM.Freq IS "every 2 hours">selected</cfif>>every 2 hours</option>
                <option <cfif GetM.Freq IS "every 3 hours">selected</cfif>>every 3 hours</option>
                <option <cfif GetM.Freq IS "every 4 hours">selected</cfif>>every 4 hours</option>
                <option <cfif GetM.Freq IS "every 8 hours">selected</cfif>>every 8 hours</option>
                <option <cfif GetM.Freq IS "every 12 hours">selected</cfif>>every 12 hours</option>
                <option <cfif GetM.Freq IS "every 4-6 hours">selected</cfif>>every 4-6 hours</option>
                <option <cfif GetM.Freq IS "once a week">selected</cfif>>once a week</option>
                <option <cfif GetM.Freq IS "every other week">selected</cfif>>every other week</option>
                <option <cfif GetM.Freq IS "immediately">selected</cfif>>immediately</option>
                <option <cfif GetM.Freq IS "as necessary">selected</cfif>>as necessary</option>
              </select></td>
          </tr>
          <tr>
            <td class="form-label">Ongoing, New or Changed?</td>
            <td><cfoutput><!-- jdb getm.NewChanged: #getm.NewChanged# // --></cfoutput> Ongoing
              <input type="Radio" name="NewChanged" value="" <cfif getm.NewChanged eq '' or (getm.NewChanged neq 'N' and getm.NewChanged neq 'C')>checked='checked'</cfif>>
               
              New
              <input type="Radio" name="NewChanged" value="N" <cfif getm.NewChanged eq 'N'>checked</cfif>>
               
              Changed
              <input type="Radio" name="NewChanged" value="C" <cfif getm.NewChanged eq 'C'>checked</cfif>>
          </tr>
          <tr>
            <td class="form-label">Notes</td>
            <td><textarea name="Notes" rows="2" cols="45"><cfoutput>#GetM.Notes#</cfoutput></textarea></td>
          </tr>
          <tr>
            <td class="form-label">Status</td>
            <td> Active
              <input type="Radio" name="med_status" value="active" <cfif getm.med_status is 'active' or getm.med_status is ''>checked</cfif>>
                
              Inactive
              <input type="Radio" name="med_status" value="inactive" <cfif getm.med_status neq 'active' and getm.med_status neq ''>checked</cfif>>
                
              Delete
              <input type="Radio" name="med_status" value="delete"></td>
          </tr>
          <tr>
            <td class="form-label-req">Ordered</td>
            <td><cf_popdatetime formname="contact" fieldvalue="#DateFormat(GetM.DateOrdered,'mm/dd/yyyy')#" fieldname="dateordered" time="no" euro="no" scriptpath="#NavRoot#/Scripts/popDateTime/"></td>
          </tr>
          <tr>
            <td style="height:5px"></td>
          </tr>
          <tr>
            <td class="form-label">Discontinued</td>
            <td><cf_popdatetime formname="contact" fieldvalue="#DateFormat(GetM.DateDCed,'mm/dd/yyyy')#" fieldname="DateDCed" time="no" euro="no" scriptpath="#NavRoot#/Scripts/popDateTime/"></td>
          </tr>
          <tr>
            <td colspan="2" height="1"  class="solidline" ></td>
          </tr>
          <tr>
            <td></td>
           <td>
			  <input type="submit" name="Submit" value="Update Medication">

              <input type="button" name="Cancel" value="Cancel" onClick="history.back();"></td>
          </tr>
		  </table>
        </form>
		
		<!---<form name="contact" action="index.cfm?page=patient&cat=medorder_action&Action=Update" method="post" onsubmit="return checkMedForm(this,2);">
          <input type=hidden name="page" value="#url.page#">
          <input type=hidden name="cat" value="medlist">
          <input type="hidden" name="ID" value="#session.cs.patientid#">
          <input type="hidden" name="MID" value="#Session.CS.MedicationID#">
          <input type="hidden" name="MPID" value="#Session.CS.PatientMedicationID#">
		  <table>
          <tr>
            <td class="form-label">Medication</td>
            <td><input type="text" name="Medication" value="#GetM.Drug_Name#" size="30"></td>
          </tr>
          <tr>
          <tr>
            <td class="form-label">Dose</td>
            <td><cfset gotDose = false />
              <cfloop query="GetDoses">
                <cfif GetM.Dose eq GetDoses.Dose or Replace(GetM.Dose, ' ', '', 'ALL') eq Replace(GetDoses.Dose, ' ', '', 'ALL')>
                  <cfset gotDose = true />
                </cfif>
              </cfloop>
              <input type="Radio" name="Dose" value="0" <cfif gotDose eq false or GetM.Dose eq '0' or GetM.Dose eq ''>checked</cfif>>
              <em>I'll enter my own dose under Dose Units</em><br>
              <cfloop query="GetDoses">
                <input type="Radio" name="Dose" value="#GetDoses.Dose#" <cfif GetM.Dose eq GetDoses.Dose or Replace(GetM.Dose, ' ', '', 'ALL') eq Replace(GetDoses.Dose, ' ', '', 'ALL')>checked </cfif> <cfset gotDose = true />>
                #GetDoses.Dose# (#GetDoses.form#)<br>
              </cfloop></td>
          </tr>
          <tr>
            <td class="form-label">Dose Units</td>
            <td><input type="text" name="Dose_Units" size="20" value="#GetM.Dose_Units#"></td>
          </tr>
          <tr>
            <td class="form-label">Route</td>
            <td><select name="Route">
                <option <cfif GetM.Route IS "">selected</cfif>> - </option>
                <option <cfif GetM.Route IS "by mouth">selected</cfif>>by mouth</option>
                <option <cfif GetM.Route IS "PO">selected</cfif>>PO</option>
                <option <cfif GetM.Route IS "inhalant">selected</cfif>>inhalant</option>
                <option <cfif GetM.Route IS "I">selected</cfif>>I</option>
                <option <cfif GetM.Route IS "intramuscular">selected</cfif>>intramuscular</option>
                <option <cfif GetM.Route IS "IM">selected</cfif>>IM</option>
                <option <cfif GetM.Route IS "right eye">selected</cfif>>right eye</option>
                <option <cfif GetM.Route IS "OD">selected</cfif>>OD</option>
                <option <cfif GetM.Route IS "left eye">selected</cfif>>left eye</option>
                <option <cfif GetM.Route IS "OS">selected</cfif>>OS</option>
                <option <cfif GetM.Route IS "both eyes">selected</cfif>>both eyes</option>
                <option <cfif GetM.Route IS "OM">selected</cfif>>OM</option>
                <option <cfif GetM.Route IS "drops">selected</cfif>>drops</option>
                <option <cfif GetM.Route IS "Gt">selected</cfif>>Gt</option>
                <option <cfif GetM.Route IS "nasal cannula">selected</cfif>>nasal cannula</option>
                <option <cfif GetM.Route IS "NC">selected</cfif>>NC</option>
                <option <cfif GetM.Route IS "rectal">selected</cfif>>rectal</option>
                <option <cfif GetM.Route IS "PR">selected</cfif>>PR</option>
                <option <cfif GetM.Route IS "subcutaneous">selected</cfif>>subcutaneous</option>
                <option <cfif GetM.Route IS "SC">selected</cfif>>SC</option>
                <option <cfif GetM.Route IS "sublingual">selected</cfif>>sublingual</option>
                <option <cfif GetM.Route IS "SL">selected</cfif>>SL</option>
                <option <cfif GetM.Route IS "topical">selected</cfif>>topical</option>
                <option <cfif GetM.Route IS "T">selected</cfif>>T</option>
                <option <cfif GetM.Route IS "transdermal">selected</cfif>>transdermal</option>
                <option <cfif GetM.Route IS "TD">selected</cfif>>TD</option>
                <option <cfif GetM.Route IS "intravenous">selected</cfif>>intravenous</option>
                <option <cfif GetM.Route IS "IV">selected</cfif>>IV</option>
                <option <cfif GetM.Route IS "vaginal">selected</cfif>>vaginal</option>
                <option <cfif GetM.Route IS "V">selected</cfif>>V</option>
              </select></td>
          </tr>
          <tr>
            <td class="form-label">Frequency</td>
            <td><select name="Freq">
                <option <cfif GetM.Freq IS "">selected</cfif>> - </option>
                <option <cfif GetM.Freq IS "before meal">selected</cfif>>before meal</option>
                <option <cfif GetM.Freq IS "after meal">selected</cfif>>after meal</option>
                <option <cfif GetM.Freq IS "in the morning">selected</cfif>>in the morning</option>
                <option <cfif GetM.Freq IS "at bedtime">selected</cfif>>at bedtime</option>
                <option <cfif GetM.Freq IS "once a day">selected</cfif>>once a day</option>
                <option <cfif GetM.Freq IS "twice a day">selected</cfif>>twice a day</option>
                <option <cfif GetM.Freq IS "three times a day">selected</cfif>>three times a day</option>
                <option <cfif GetM.Freq IS "four times a day">selected</cfif>>four times a day</option>
                <option <cfif GetM.Freq IS "every other day">selected</cfif>>every other day</option>
                <option <cfif GetM.Freq IS "every hour">selected</cfif>>every hour</option>
                <option <cfif GetM.Freq IS "every 2 hours">selected</cfif>>every 2 hours</option>
                <option <cfif GetM.Freq IS "every 3 hours">selected</cfif>>every 3 hours</option>
                <option <cfif GetM.Freq IS "every 4 hours">selected</cfif>>every 4 hours</option>
                <option <cfif GetM.Freq IS "every 8 hours">selected</cfif>>every 8 hours</option>
                <option <cfif GetM.Freq IS "every 12 hours">selected</cfif>>every 12 hours</option>
                <option <cfif GetM.Freq IS "every 4-6 hours">selected</cfif>>every 4-6 hours</option>
                <option <cfif GetM.Freq IS "once a week">selected</cfif>>once a week</option>
                <option <cfif GetM.Freq IS "every other week">selected</cfif>>every other week</option>
                <option <cfif GetM.Freq IS "immediately">selected</cfif>>immediately</option>
                <option <cfif GetM.Freq IS "as necessary">selected</cfif>>as necessary</option>
              </select></td>
          </tr>
          <tr>
            <td class="form-label">Ongoing, New or Changed?</td>
            <td><cfoutput><!-- jdb getm.NewChanged: #getm.NewChanged# // --></cfoutput> Ongoing
              <input type="Radio" name="NewChanged" value="" <cfif getm.NewChanged eq '' or (getm.NewChanged neq 'N' and getm.NewChanged neq 'C')>checked='checked'</cfif>>
               
              New
              <input type="Radio" name="NewChanged" value="N" <cfif getm.NewChanged eq 'N'>checked</cfif>>
               
              Changed
              <input type="Radio" name="NewChanged" value="C" <cfif getm.NewChanged eq 'C'>checked</cfif>>
          </tr>
          <tr>
            <td class="form-label">Notes</td>
            <td><textarea name="Notes" rows="2" cols="45"><cfoutput>#GetM.Notes#</cfoutput></textarea></td>
          </tr>
          <tr>
            <td class="form-label">Status</td>
            <td> Active
              <input type="Radio" name="med_status" value="active" <cfif getm.med_status is 'active' or getm.med_status is ''>checked</cfif>>
                
              Inactive
              <input type="Radio" name="med_status" value="inactive" <cfif getm.med_status neq 'active' and getm.med_status neq ''>checked</cfif>>
                
              Delete
              <input type="Radio" name="med_status" value="delete"></td>
          </tr>
          <tr>
            <td class="form-label-req">Ordered</td>
            <td><cf_popdatetime formname="contact" fieldvalue="#DateFormat(GetM.DateOrdered,'mm/dd/yyyy')#" fieldname="dateordered" time="no" euro="no" scriptpath="#NavRoot#/Scripts/popDateTime/"></td>
          </tr>
          <tr>
            <td style="height:5px"></td>
          </tr>
          <tr>
            <td class="form-label">Discontinued</td>
            <td><cf_popdatetime formname="contact" fieldvalue="#DateFormat(GetM.DateDCed,'mm/dd/yyyy')#" fieldname="DateDCed" time="no" euro="no" scriptpath="#NavRoot#/Scripts/popDateTime/"></td>
          </tr>
          <tr>
            <td colspan="2" height="1"  class="solidline" ></td>
          </tr>
          <tr>
            <td></td>
			 <td><input type="submit" name="Submit" value="Update Medication">
              <input type="button" name="Cancel" value="Cancel" onClick="history.back();"></td>
           <!--- <td><cfif URL.MID EQ '' or URL.MID EQ 0> 
              <input type="submit" name="Submit" value="Add Medication"> 
			  <cfelse>
			  <input type="submit" name="Submit" value="Update Medication">
			  </cfif>
              <input type="button" name="Cancel" value="Cancel" onclick="history.back();"></td>--->
          </tr>
		  </table>
        </form>--->
      </cfoutput>
 </cfwindow>
		  
