2013-10-21 45 views
0

ColdFusion的新手。需要查看正在發送的ColdFusion查詢參數並返回數據

我有一個適用於除一個供應商以外的所有供應商的腳本。該腳本傳遞了一些參數,並接收指定供應商的索賠清單,但前面提到的供應商除外。

我想調試一個函數,這樣我就可以確保我爲這個供應商傳遞了正確的參數,並且還看到了爲同一供應商返回的響應。

什麼是調試我的腳本的最佳方式? 這些都是不錯的選擇嗎?

<cfdump var="#VARIABLES#"> 
<cfdump var="#getPageContext().getBuiltInScopes()#"/> 

我敢肯定,你們都有一個情況,你必須證明它是一個數據庫問題,而不是腳本問題。

這裏的功能

<!--- function getAllRenewalRequestsChrisTest for testing ---> 
<cffunction name="getAllRenewalRequestsChrisTest" access="public" returnType="Query" hint=""> 
    <cfargument name="Domain" type="String" required="true" hint="Domain for Database Identification."> 
    <cfargument name="Org_ID" type="Numeric" required="true" hint="Org_Id - Primary Key"> 
    <cfargument name="UserKey" type="Numeric" required="true" hint="UserPK - Primary Key"> 

    <cfset var Local = StructNew()> 

    <cftry> 
     <cfset Local.ERXInfo = CreateObject("component","cfc.org.Org").getEprescribeStatus("#Arguments.Domain#","#Arguments.Org_ID#")> 
     <cfset Local.credentials = StructNew()> 
     <cfset Local.credentials.PartnerName = "#Local.ERXInfo.eRxPartnerName#"> 
     <cfset Local.credentials.Name = "#Local.ERXInfo.eRxName#"> 
     <cfset Local.credentials.Password = "#Local.ERXInfo.eRxPassword#"> 

     <cfset Local.accountRequest = StructNew()> 
     <cfset Local.accountRequest.AccountId = "#getEMRDataDSN(Arguments.Domain)#-#Arguments.Org_ID#"> 
     <cfset Local.accountRequest.SiteId = "#Local.ERXInfo.eRxSiteId#"> 

     <cfset Local.wsargs = StructNew()> 
     <cfset Local.wsargs.timeout = 5> 
     <cfset Local.objWebService = CreateObject("webservice","#getErxServer(Arguments.Domain)#v7/WebServices/Update1.asmx?WSDL", Local.wsargs)> 

     <cfset Local.objSearchResponse = Local.objWebService.GetAllRenewalRequestsV2 (Local.credentials, Local.accountRequest, "","")> 

     <cfset Local.qTemp = QueryNew("DoctorFullName,DrugInfo,ExternalPrescriptionId,ExternalDoctorId,NumberOfRefills,PatientDOB,PatientName,FirstName,LastName,MiddleName,PatientGender,ReceivedTimestamp,RenewalRequestGuid,Quantity,Sig,RenewalRequestMed,EcastPharmacyId,EcastPharmacyName,EcastPharmacyInfo,EcastPharmacyInfoToolTip")> 

     <cfset Local.renewalRequests = Local.objSearchResponse.getRenewalSummaryArray().getRenewalSummaryV2()> 

     <cfset Local.objPharmacy = CreateObject("component","cfc.pharmacy")> 

     <cfloop from="1" to="#ArrayLen(Local.renewalRequests)#" index="Local.indexB"> 
      <cfset QueryAddRow(Local.qTemp)> 
      <cfset QuerySetCell(Local.qTemp, "DoctorFullName", "#Local.renewalRequests[Local.indexB].getDoctorFullName()#")> 
      <cfset QuerySetCell(Local.qTemp, "DrugInfo", "#Local.renewalRequests[Local.indexB].getDrugInfo()#")> 
      <cfset QuerySetCell(Local.qTemp, "ExternalPrescriptionId", "#Local.renewalRequests[Local.indexB].getExternalPrescriptionId()#")> 
      <cfif Trim(Local.renewalRequests[Local.indexB].getExternalDoctorId()) EQ ""> 
       <cfset QuerySetCell(Local.qTemp, "ExternalDoctorId", "0")> 
      <cfelse> 
       <cfset QuerySetCell(Local.qTemp, "ExternalDoctorId", "#Trim(Local.renewalRequests[Local.indexB].getExternalDoctorId())#")> 
      </cfif> 

      <cfset QuerySetCell(Local.qTemp, "NumberOfRefills", "#Local.renewalRequests[Local.indexB].getNumberOfRefills()#")> 

      <cfif Len(trim(Local.renewalRequests[Local.indexB].getPatientDOB())) EQ 8> 
       <cfset QuerySetCell(Local.qTemp, "PatientDOB", "#DateFormat(CreateDate(Left(trim(Local.renewalRequests[Local.indexB].getPatientDOB()), 4), Mid(trim(Local.renewalRequests[Local.indexB].getPatientDOB()), 5, 2), Mid(trim(Local.renewalRequests[Local.indexB].getPatientDOB()), 7, 2)),'mm/dd/yyyy')#")> 
      <cfelse> 
       <cfset QuerySetCell(Local.qTemp, "PatientDOB", "#Trim(Local.renewalRequests[Local.indexB].getPatientDOB())#")> 
      </cfif> 

      <cfset QuerySetCell(Local.qTemp, "PatientName", "#Local.renewalRequests[Local.indexB].getPatientLastName()#, #Local.renewalRequests[Local.indexB].getPatientFirstName()# #Local.renewalRequests[Local.indexB].getPatientMiddleName()#")> 
      <cfset QuerySetCell(Local.qTemp, "FirstName", "#Local.renewalRequests[Local.indexB].getPatientFirstName()#")> 
      <cfset QuerySetCell(Local.qTemp, "LastName", "#Local.renewalRequests[Local.indexB].getPatientLastName()#")> 
      <cfset QuerySetCell(Local.qTemp, "MiddleName", "#Local.renewalRequests[Local.indexB].getPatientMiddleName()#")> 
      <cfset QuerySetCell(Local.qTemp, "PatientGender", "#UCase(Local.renewalRequests[Local.indexB].getPatientGender())#")> 

      <cfset Local.tempPharmacyInfo = Local.objPharmacy.getPharmacyInfoByNCPDID(Arguments.Domain,Arguments.Org_ID,Local.renewalRequests[Local.indexB].getNcpdpID(),0)> 
      <cfif Local.tempPharmacyInfo.recordcount GT 0><!--- non hidden pharmacy already exists---> 
       <cfset Local.currentPharmacyInfo = Local.objPharmacy.getPharmacyInfoById(Arguments.Domain,Local.tempPharmacyInfo.Pharmacy_Id)> 
       <cfif Trim(Local.currentPharmacyInfo.PharmacyDisplayName) NEQ ""> 
        <cfset QuerySetCell(Local.qTemp, "EcastPharmacyName", "#Trim(Local.currentPharmacyInfo.PharmacyDisplayName)#")> 
       <cfelse> 
        <cfset QuerySetCell(Local.qTemp, "EcastPharmacyName", "#Trim(Local.currentPharmacyInfo.Pharmacy_Name)#")> 
       </cfif> 
       <cfset QuerySetCell(Local.qTemp, "EcastPharmacyId", "#Local.currentPharmacyInfo.Pharmacy_Id#")> 
      <cfelse> 
       <cfset Local.tempPharmacyInfo = Local.objPharmacy.getPharmacyInfoByNCPDID(Arguments.Domain,Arguments.Org_ID,Local.renewalRequests[Local.indexB].getNcpdpID(),1)> 
       <cfif Local.tempPharmacyInfo.recordcount GT 0><!--- hidden pharmacy already exists---> 
        <cfset Local.currentPharmacyInfo = Local.objPharmacy.getPharmacyInfoById(Arguments.Domain,Local.tempPharmacyInfo.Pharmacy_Id)> 
        <cfset QuerySetCell(Local.qTemp, "EcastPharmacyId", "#Local.currentPharmacyInfo.Pharmacy_Id#")> 
        <cfif Trim(Local.currentPharmacyInfo.PharmacyDisplayName) NEQ ""> 
        <cfset QuerySetCell(Local.qTemp, "EcastPharmacyName", "#Trim(Local.currentPharmacyInfo.PharmacyDisplayName)#")> 
        <cfelse> 
        <cfset QuerySetCell(Local.qTemp, "EcastPharmacyName", "#Trim(Local.currentPharmacyInfo.Pharmacy_Name)#")> 
        </cfif> 
       <cfelse> <!--- add pharmacy to org ---> 
        <cfset Local.tempPharmacyInfo = getPharmacyByNCPDID(Arguments.Domain,Arguments.Org_Id,Local.renewalRequests[Local.indexB].getNcpdpID())> 
        <cfset Local.newPharmacyId = Local.objPharmacy.setPharmacy(Arguments.domain,Arguments.Org_ID,Arguments.UserKey,Local.tempPharmacyInfo.NAME,Local.tempPharmacyInfo.NAME,Local.tempPharmacyInfo.PHONE,Local.tempPharmacyInfo.FAX,Local.tempPharmacyInfo.ADDRESS,Local.tempPharmacyInfo.CITY,Local.tempPharmacyInfo.ZIP,Local.tempPharmacyInfo.STATE,-1,Local.tempPharmacyInfo.NCPDID,Local.tempPharmacyInfo.PHARMACYTYPE,1)> 
        <cfset Local.currentPharmacyInfo = Local.objPharmacy.getPharmacyInfoById(Arguments.Domain,Local.newPharmacyId)> 
        <cfset QuerySetCell(Local.qTemp, "EcastPharmacyId", "#Local.newPharmacyId#")> 
        <cfif Trim(Local.currentPharmacyInfo.PharmacyDisplayName) NEQ ""> 
        <cfset QuerySetCell(Local.qTemp, "EcastPharmacyName", "#Trim(Local.currentPharmacyInfo.PharmacyDisplayName)#")> 
        <cfelse> 
        <cfset QuerySetCell(Local.qTemp, "EcastPharmacyName", "#Trim(Local.currentPharmacyInfo.Pharmacy_Name)#")> 
        </cfif> 
       </cfif> 
      </cfif> 
      <cfif Trim(Local.currentPharmacyInfo.PharmacyDisplayName) NEQ ""> 
       <cfset QuerySetCell(Local.qTemp, "EcastPharmacyInfoToolTip", "#Trim("Name: #Local.currentPharmacyInfo.PharmacyDisplayName#$SPLIT$Address: #Local.currentPharmacyInfo.Pharmacy_Address# #Local.currentPharmacyInfo.Pharmacy_City# #Local.currentPharmacyInfo.Pharmacy_State# #Local.currentPharmacyInfo.Pharmacy_Zip#$SPLIT$Phone: #Local.currentPharmacyInfo.Pharmacy_Phone#$SPLIT$Fax: #Local.currentPharmacyInfo.Pharmacy_Fax#")#")> 
       <cfset QuerySetCell(Local.qTemp, "EcastPharmacyInfo", "#Trim("#Local.currentPharmacyInfo.PharmacyDisplayName#$SPLIT$#Local.currentPharmacyInfo.Pharmacy_Address#$SPLIT$#Local.currentPharmacyInfo.Pharmacy_City#, #Local.currentPharmacyInfo.Pharmacy_State# #Local.currentPharmacyInfo.Pharmacy_Zip#$SPLIT$#Local.currentPharmacyInfo.Pharmacy_Phone# (phone)$SPLIT$#Local.currentPharmacyInfo.Pharmacy_Fax# (fax)")#")> 
      <cfelse> 
       <cfset QuerySetCell(Local.qTemp, "EcastPharmacyInfoToolTip", "#Trim("Name: #Local.currentPharmacyInfo.Pharmacy_Name#$SPLIT$Address: #Local.currentPharmacyInfo.Pharmacy_Address# #Local.currentPharmacyInfo.Pharmacy_City# #Local.currentPharmacyInfo.Pharmacy_State# #Local.currentPharmacyInfo.Pharmacy_Zip#$SPLIT$Phone: #Local.currentPharmacyInfo.Pharmacy_Phone#$SPLIT$Fax: #Local.currentPharmacyInfo.Pharmacy_Fax#")#")> 
       <cfset QuerySetCell(Local.qTemp, "EcastPharmacyInfo", "#Trim("#Local.currentPharmacyInfo.Pharmacy_Name#$SPLIT$#Local.currentPharmacyInfo.Pharmacy_Address#$SPLIT$#Local.currentPharmacyInfo.Pharmacy_City#, #Local.currentPharmacyInfo.Pharmacy_State# #Local.currentPharmacyInfo.Pharmacy_Zip#$SPLIT$#Local.currentPharmacyInfo.Pharmacy_Phone# (phone)$SPLIT$#Local.currentPharmacyInfo.Pharmacy_Fax# (fax)")#")> 
      </cfif> 
      <cfset QuerySetCell(Local.qTemp, "ReceivedTimestamp", "#Local.renewalRequests[Local.indexB].getReceivedTimestamp()#")> 
      <cfset QuerySetCell(Local.qTemp, "RenewalRequestGuid", "#Local.renewalRequests[Local.indexB].getRenewalRequestGuid()#")> 
      <cfset QuerySetCell(Local.qTemp, "Quantity", "#Local.renewalRequests[Local.indexB].getQuantity()#")> 
      <cfset QuerySetCell(Local.qTemp, "Sig", "#Local.renewalRequests[Local.indexB].getSig()#")> 

      <cfif Trim(Local.renewalRequests[Local.indexB].getQuantity()) NEQ "" AND Trim(Local.renewalRequests[Local.indexB].getSig()) NEQ ""> 
       <cfset QuerySetCell(Local.qTemp, "RenewalRequestMed", "#Local.renewalRequests[Local.indexB].getDrugInfo()# (#Trim(Local.renewalRequests[Local.indexB].getQuantity())#, #Trim(Local.renewalRequests[Local.indexB].getSig())#)")> 
      <cfelse> 
       <cfif Trim(Local.renewalRequests[Local.indexB].getQuantity()) NEQ ""> 
        <cfset QuerySetCell(Local.qTemp, "RenewalRequestMed", "#Local.renewalRequests[Local.indexB].getDrugInfo()# (#Trim(Local.renewalRequests[Local.indexB].getQuantity())#)")> 
       <cfelse> 
        <cfset QuerySetCell(Local.qTemp, "RenewalRequestMed", "#Local.renewalRequests[Local.indexB].getDrugInfo()# (#Trim(Local.renewalRequests[Local.indexB].getSig())#)")> 
       </cfif> 
      </cfif> 
     </cfloop> 

     <cfcatch type="Any"> 
      <cfset Local.qTemp = QueryNew("DoctorFullName,DrugInfo,ExternalPrescriptionId,ExternalDoctorId,NumberOfRefills,PatientDOB,PatientName,FirstName,LastName,MiddleName,PatientGender,ReceivedTimestamp,RenewalRequestGuid,Quantity,Sig,RenewalRequestMed,EcastPharmacyId,EcastPharmacyName,EcastPharmacyInfo,EcastPharmacyInfoToolTip")> 
     </cfcatch> 
    </cftry> 
    <cfreturn Local.qTemp> 
    <cfdump var="getAllRenewalRequestsChrisTest"> 
</cffunction> 
+5

''這會給你執行的查詢,並從那裏你可以決定,如果它是一個數據庫的問題。如果你轉儲變量作用域,查詢也應該顯示出來。或者你也可以打開你的CF管理員的調試來查看執行的查詢。 –

回答

1

上正在窗體或URL範圍傳遞你的參數?或者你的意思是你有幾個參數被傳遞到查詢中?

這聽起來像你想要做的就是在參數被使用之前(或者在它們被傳入之後)轉儲這些參數,以便查看它們對於問題供應商的含義。

例如,如果您的參數在表單範圍中傳遞,您可以將表單範圍的第一件事轉儲到應執行查詢的腳本中。

<!--- params passed in via form scope ---> 
<cfdump var="#form#" output="browser" /> 

<!--- do query ---> 
<cfquery name="myVendorData" datasource="..."> 
    ... SQL which uses the suspect parameters goes here... 
</cfquery> 

這有幫助嗎?

代碼示例會幫助我更好地回答問題。

+0

馬特的評論暗示了一種更簡單,更有效的方法。 –

+0

這裏的功能 –