Hi Ray, I will send the printed pdf files to support. But here is the code:
Code in Global Code:
//======================== variables for Print Physical in PDF============================
stat vExamDate as String
stat vFont as String = " Arial"
stat vFontsize as Int = 17
stat vSignature as String = @XLookup ("Data\Doctor.db", @UserID, "Doctor!UserID", "Signature")
stat vPage as Int
stat vPrintIndicator as String
stat vYExtent as Int
stat vStopReset as Int = 0
stat vDoctor as String
//===================================================================================
Function UDF_FormatDate (vDate as String) as String
var vFormatedDate as String
vFormatedDate = @Mid (vDate, 6,2) + "/" + @Right (vDate, 2) + "/" + @Left (vDate, 4)
Return (vFormatedDate)
End Function
//==========================================================================================================================================================================================================================================================================
SubRoutine CompleteTask ( )
PrintString (vDoctor, 550, @PageExtentY ( ) + 10, 0, vFont, vFontSize, 0)
if @GlobalValue ("SignatureOnPhysicalPrintStringHC") = 1 then
{
PrintImage (vSignature, 550, @PageExtentY ( ) + 2, -1, -1)
//PrintImage ("C:\images\bharat_sig.jpg", 550, @PageExtentY ( ) + 2, -1, -1)
}
If vPage > 1 then
{
//WriteLN ("You were in CompleteTask") //************************************************************************************************************************************************
PrintString (vExamDate, 0, 1060, 0, vFont, vFontsize, 0, PrintString_Align_Right)
PrintString ("Page " + @str (vPage), 0, 1060, 0, vFont, vFontsize, 0, PrintString_Align_Center)
PrintString (First + " " + P_LastName + " - " + RecNumber, 0, 1060, 0, vFont, vFontsize, 0, PrintString_Align_Left )
}
vStopReset = 1
vFontsize = 17 //To Make sure after align Center
FinishPage ( )
//RestoreDefaultPrinter ( )
//Stop //stop is replaced with vStopReset
End Subroutine
SubRoutine PageControlMeasure(vString as String ) //This includes PageControl ( )
//If @PageExtentY ( ) > 850 then //corrected for overflow to work correctly - this can be removed totally as it is controlled in the main programming
//{
If vPage > 1 then // This is in case there is Page 3
{
PrintString (vExamDate, 0, 1060, 0, vFont, vFontsize, 0, PrintString_Align_Right) //put on 03/20/2012
PrintString ("Page " + @str (vPage), 0, 1060, 0, vFont, vFontsize, 0, PrintString_Align_Center)
PrintString (First + " " + P_LastName + " - " + RecNumber, 600, 1060, 0, vFont, vFontsize, 0)
}
FinishPage ( )
NewPage (850, 1100)
vFontsize = 17 //To Make sure after align Center
PageExtentY (0)
vYExtent = 0
//WriteLN ("This will go on 2nd Page " + vString) //*************************************************************************************************************************
PrintString (vString, 0, vYExtent, 0, vFont, vFontSize, 0)
VPrintIndicator = "Printed" //to avoid printing twice
vPage = vPage + 1
//}
End SubRoutine
SubRoutine PageControl( ) //Created just to put at the end otherwise PageControlMeasure ( ) will do
If @PageExtentY ( ) > 1050 then
{
If vPage > 1 then
{
PrintString (vExamDate, 0, 1060, 0, vFont, vFontsize, 0, PrintString_Align_Right) //put on 03/20/2012
PrintString ("Page " + @str (vPage), 0, 1060, 0, vFont, vFontsize, 0, PrintString_Align_Center)
PrintString (First + " " + P_LastName + " - " + RecNumber, 600, 1060, 0, vFont, vFontsize, 0)
}
FinishPage ( )
NewPage (850, 1100)
vFontsize = 17 //To Make sure after align Center
PageExtentY (0)
vPage = vPage + 1
}
End SubRoutine
SubRoutine Printing_Physical (vSelectedDate as String)
var n as Int
var vRSHandle as Int
var vRSScripts1 as Int
var vRSScripts2 as Int
//==========================================for Print Physical==========================
//var vPrinterA as String //= "IBM 4039 LaserPrinter" //Local Printer
//var vPrinterB as String //= "\\Reception\IBMPCL5" //Network Printer
var vStr1 as String
var vStr2 as String
var vStr3 as String
//var n as Int
var vLoop as Int
var vChart as String
var vBP as String
var vHC as String
var vGrowthBlock as String
var vBreastBlock as String
//var vServer as String
//var vStation as String
//var vPhysicalPrintStringPrinterSelect as Int
//var vServerDefault as String
//var vSignatureOnPhysicalPrintString as Int
//var vPrinterList as String
//var vSelectedPrinter as String
//var vList as String
var vMedicine as String
var vInstruction as String
var vWarn as Int
//Functions below is in Global area
//all variables to code below are defined in the begining of code
vRSHandle = @XResultSetSearch(@FN, "Physical", SEARCH_MODE_AND, SEARCH_SYNTAX_QA, "!Chart="+ Chart, "!Date1=" + vSelectedDate)
if(vRSHandle > -1)
{
vDoctor = @XResultSetValue (vRSHandle, "DN")
// ???? vExamDate = UDF_FormatDate (@XResultSetValue (vRSHandle, "Date1"))
vExamDate = @XResultSetValue (vRSHandle, "Date1")
vChart = Chart //Now Chart are there in all forms
vChart = vChart + "-" + @Right (@XResultSetValue (vRSHandle, "Q"), 3)
If @XResultSetValue (vRSHandle, "BP") <> "" then
{
vBP = "BP: " + @XResultSetValue (vRSHandle, "BP")
}
If @XResultSetValue (vRSHandle, "HC") <> "" then
{
vHC = "Head Circum: " + @XResultSetValue (vRSHandle, "HC")
}
VGrowthBlock = Tab (1) + @XResultSetValue (vRSHandle, "W")
If @XResultSetValue (vRSHandle, "H") <> "" then
{
vGrowthBlock = vGrowthBlock + @NL ( ) + Tab (1) + @XResultSetValue (vRSHandle, "H")
}
If @XResultSetValue (vRSHandle, "C") <> "" then
{
vGrowthBlock = vGrowthBlock + @NL ( ) + Tab (1) + @XResultSetValue (vRSHandle, "C")
}
If @XResultSetValue (vRSHandle, "HW") <> "" then
{
vGrowthBlock = vGrowthBlock + @NL ( ) + Tab (1) + @XResultSetValue (vRSHandle, "HW")
}
//Parameters: Value, xpos, ypos, column Width, Font, FontSize, measureOnly, Alignment
NewPage (850, 1100)
PrintPagePaper (28)
PrintPageMargin (30, 35, 40, 40)
vFont = " Arial"
vFontsize = 17
PrintString ("Name: " + First + " " + P_LastName, 0, 0, 0, vFont, vFontSize, 0)
PrintString ("Rec#: " + RecNumber, @PageExtentX ( ) + 30, -1, 0, vFont, vFontSize, 0)
PrintString ("Date: " + UDF_FormatDate (@XResultSetValue (vRSHandle, "Date1")), @PageExtentX ( ) + 30, -1, 0, vFont, vFontSize, 0)
PrintString ("Chart# " + vChart, @PageExtentX ( ) + 30, -1, 0, vFont, vFontSize, 0)
PrintString ("VITAL SIGNS", 0, @PageExtentY ( ) + 10, 0, "BArial", vFontSize, 0)
PrintRGBColor (1, 0, 0)
PrintBox (Box_Type_Flat_Box, 0, @PageExtentY ( ), @PageExtentX( ), 1)
PrintString ("Weight: " + @XResultSetValue (vRSHandle, "WT"), 0, @PageExtentY ( ), 200, vFont, vFontSize, 0)
PrintString ("Height: " + @XResultSetValue (vRSHandle, "HT"), -1, -1, 200, vFont, vFontSize, 0)
PrintString ("Temp: " + @XResultSetValue (vRSHandle, "T"), -1, -1, 200, vFont, vFontSize, 0)
PrintString ("BMI: " + @XResultSetValue (vRSHandle, "BMI"), -1, -1, 150, vFont, vFontSize, 0)
PrintString ("Pulse: " + @XResultSetValue (vRSHandle, "P"), 0, @PageExtentY ( ), 200, vFont, vFontSize, 0)
PrintString ("Resp: " + @XResultSetValue (vRSHandle, "R"), -1, -1, 200, vFont, vFontSize, 0)
If vBP <> "" then
{
PrintString (vBP, -1, -1, 200, vFont, vFontSize, 0)
}
Else
{
PrintString (vHC, -1, -1, 200, vFont, vFontSize, 0)
}
If @XResultSetValue (vRSHandle, "LMP") <> "" then
{
PrintString ("LMP: " + UDF_FormatDate (@XResultSetValue (vRSHandle, "LMP")), 0, @PageExtentY ( ), 200, vFont, vFontSize, 0)
}
IF @XResultSetValue (vRSHandle, "LDP") <> "" then
{
If @XResultSetValue (vRSHandle, "LMP") <> "" then
{
PrintString ("LastDepo: " + UDF_FormatDate (@XResultSetValue (vRSHandle, "LDP")), -1, -1, 200, vFont, vFontSize, 0)
}
Else
{
PrintString ("LastDepo: " + UDF_FormatDate (@XResultSetValue (vRSHandle, "LDP")), 0, @PageExtentY (), 200, vFont, vFontSize, 0)
}
}
If @XResultSetValue (vRSHandle, "FP") <> "" then
{
If @XResultSetValue (vRSHandle, "LMP") <> "" or @XResultSetValue (vRSHandle, "LDP") <> "" then
{
PrintString ("FP: " + @XResultSetValue (vRSHandle, "FP"), -1, -1, 0, vFont, vFontSize, 0)
}
Else
{
PrintString ("FP: " + @XResultSetValue (vRSHandle, "FP"), 0, @PageExtentY ( ), 0, vFont, vFontSize, 0)
}
}
PrintString (vGrowthBlock, 0, @PageExtentY ( ), 0, vFont, vFontSize, 0)
PrintString ("HISTORY OF PRESENT ILLNESS", 0, @PageExtentY ( ) + 5, 0, "BArial", vFontSize, 0)
PrintRGBColor (1, 0, 0)
PrintBox (Box_Type_Flat_Box, 0, @PageExtentY ( ), @PageExtentX( ), 1)
PrintString ("The Patient is " + @XResultSetValue (vRSHandle, "Age") + " old " + @XResultSetValue (vRSHandle, "SEX") + ".", 0, @PageExtentY ( ), 0, vFont, vFontSize, 0)
PrintString (@XResultSetValue (vRSHandle, "HIS1") + " " + @XResultSetValue (vRSHandle, "HIS2") + " " + @XResultSetValue (vRSHandle, "HIS3"), 0, @PageExtentY ( ), 0, vFont, vFontSize, 0)
PrintString ("PHYSICAL EXAMINATION", 0, @PageExtentY ( ) + 5, 0, "BArial", vFontSize, 0)
PrintRGBColor (1, 0, 0)
PrintBox (Box_Type_Flat_Box, 0, @PageExtentY ( ), @PageExtentX( ), 1)
PrintString (@XResultSetValue (vRSHandle, "GRL"), 0, @PageExtentY ( ), 0, vFont, vFontSize, 0)
PrintString (@XResultSetValue (vRSHandle, "HN"), 0, @PageExtentY ( ), 0, vFont, vFontSize, 0)
PrintString (@XResultSetValue (vRSHandle, "Eyes"), 0, @PageExtentY ( ), 0, vFont, vFontSize, 0)
PrintString (@XResultSetValue (vRSHandle, "Ears"), 0, @PageExtentY ( ), 0, vFont, vFontSize, 0)
PrintString (@XResultSetValue (vRSHandle, "Lung"), 0, @PageExtentY ( ), 0, vFont, vFontSize, 0)
PrintString (@XResultSetValue (vRSHandle, "CVS"), 0, @PageExtentY ( ), 0, vFont, vFontSize, 0)
PrintString (@XResultSetValue (vRSHandle, "Breast"), 0, @PageExtentY ( ), 0, vFont, vFontSize, 0)
PrintString (@XResultSetValue (vRSHandle, "ABD"), 0, @PageExtentY ( ), 0, vFont, vFontSize, 0)
PrintString (@XResultSetValue (vRSHandle, "Skin"), 0, @PageExtentY ( ), 0, vFont, vFontSize, 0)
PrintString (@XResultSetValue (vRSHandle, "Joint"), 0, @PageExtentY ( ), 0, vFont, vFontSize, 0)
PrintString (@XResultSetValue (vRSHandle, "Ext"), 0, @PageExtentY ( ), 0, vFont, vFontSize, 0)
PrintString (@XResultSetValue (vRSHandle, "Gtal"), 0, @PageExtentY ( ), 0, vFont, vFontSize, 0)
PrintString (@XResultSetValue (vRSHandle, "CNS"), 0, @PageExtentY ( ), 0, vFont, vFontSize, 0)
PrintString (@XResultSetValue (vRSHandle, "Rtal"), 0, @PageExtentY ( ), 0, vFont, vFontSize, 0)
PrintString (@XResultSetValue (vRSHandle, "LymphN"), 0, @PageExtentY ( ), 0, vFont, vFontSize, 0)
PrintString ("PERTINENT LAB, XRAY AND OTHER DIAGNOSIC WORKUP", 0, @PageExtentY ( ) + 5, 0, "BArial", vFontSize, 0)
PrintRGBColor (1, 0, 0)
PrintBox (Box_Type_Flat_Box, 0, @PageExtentY ( ), @PageExtentX( ), 1)
PrintString (@XResultSetValue (vRSHandle, "AB_Lab"), 0, @PageExtentY ( ), 0, vFont, vFontSize, 0)
IF @XResultSetValue (vRSHandle, "Lab") <> "" or @XResultSetValue (vRSHandle, "Xray1") <> "" then
{
PrintString (@XResultSetValue (vRSHandle, "Lab") + " " + @XResultSetValue (vRSHandle, "Xray1"), 0, @PageExtentY ( ), 0, vFont, vFontSize, 0)
}
If @XResultSetValue (vRSHandle, "HB") <> "" or @XResultSetValue (vRSHandle, "Tine") <> "" or @XResultSetValue (vRSHandle, "Blood_Glucose") <> "" then
{
PrintString (@XResultSetValue (vRSHandle, "HB") + " " + @XResultSetValue (vRSHandle, "Tine") + " " + @XResultSetValue (vRSHandle, "Blood_Glucose"), 0, @PageExtentY ( ), 0, vFont, vFontSize, 0)
}
PrintString (@XResultSetValue (vRSHandle, "UD"), 0, @PageExtentY ( ), 0, vFont, vFontSize, 0)
PrintString (@XResultSetValue (vRSHandle, "Hearing"), 0, @PageExtentY ( ), 0, vFont, vFontSize, 0)
//PrintString (Imm, 0, @PageExtentY ( ), 0, vFont, vFontSize, 0)
PrintString (@XResultSetValue (vRSHandle, "Imm"), 0, @PageExtentY ( ), 0, vFont, 12, 0)
PrintString ("DIAGNOSIS AND ASSESSMENT", 0, @PageExtentY ( ) + 5, 0, "BArial", vFontSize, 0)
PrintRGBColor (1, 0, 0)
PrintBox (Box_Type_Flat_Box, 0, @PageExtentY ( ), @PageExtentX( ), 1)
PrintString (@Left (@XResultSetValue (vRSHandle, "Cond1"), (@Len(@XResultSetValue (vRSHandle, "Cond1")) -7)), 0, @PageExtentY ( ), 0, vFont, vFontSize, 0)
PrintString (@Left (@XResultSetValue (vRSHandle, "Cond2"), (@Len(@XResultSetValue (vRSHandle, "Cond2")) -7)), 0, @PageExtentY ( ), 0, vFont, vFontSize, 0)
PrintString (@Left (@XResultSetValue (vRSHandle, "Cond3"), (@Len(@XResultSetValue (vRSHandle, "Cond3")) -7)), 0, @PageExtentY ( ), 0, vFont, vFontSize, 0)
PrintString ("CHRONIC ONGOING PROBLEMS", 0, @PageExtentY ( ) + 5, 0, "BArial", vFontSize, 0)
PrintRGBColor (1, 0, 0)
PrintBox (Box_Type_Flat_Box, 0, @PageExtentY ( ), @PageExtentX( ), 1)
PrintString (@XResultSetValue (vRSHandle, "Chr_Problems"), 0, @PageExtentY ( ), 0, vFont, vFontSize, 0)
PrintString ("TREATMENT PLAN", 0, @PageExtentY ( ) + 5, 0, "BArial", vFontSize, 0)
PrintRGBColor (1, 0, 0)
PrintBox (Box_Type_Flat_Box, 0, @PageExtentY ( ), @PageExtentX( ), 1)
vRSScripts1 = @XResultSetSearch(@FN, "Physical!Scripts1", SEARCH_MODE_AND, SEARCH_SYNTAX_QA, "!RecNumber="+ RecNumber, "!Date1=" + vSelectedDate)
if(vRSScripts1 > -1)
{
//WriteLN ("You are here in Scripts1 form")
//WriteLN ("Total Records = " + @Str ( @XResultSetTotal (vRSScripts1) ))
For n = 1 to @XResultSetTotal (vRSScripts1)
XResultSetCurrentPosition (vRSScripts1, n)
vMedicine = @XResultSetValue (vRSScripts1, "Medicine")
//WriteLN (vMedicine)
vInstruction = @XResultSetValue (vRSScripts1, "Instruction")
If vMedicine <> "" then
{
vStr3 = vMedicine + " " + vInstruction
//WriteLN ("vStr3 vaule = " + vStr3 )
vYExtent = @PageExtentY ( )
//WriteLn ("Value of vYExtent = " + @Str (vYExtent) )
PrintString (vStr3, 0, @PageExtentY ( ), 0, vFont, vFontSize, 1)
vPrintIndicator = "Not Printed" //Avoid double printing, Reset to printed if printed through pagecontrolMeasure ( )
If vPage = 1 and vYExtent >= 1050 then //Added Later on so Prescriptions do not start printing on 2nd Page too soon
{
PageControlMeasure (vStr3)
}
If vPage = 1 or (vPage = 2 and vPrintIndicator = "Not Printed") then
{
PrintString (vStr3, 0, vYExtent, 0, vFont, vFontSize, 0)
}
}
Next
XResultSetClose (vRSScripts1)
}
vRSScripts2 = @XResultSetSearch(@FN, "Physical!Scripts2", SEARCH_MODE_AND, SEARCH_SYNTAX_QA, "!RecNumber="+ RecNumber, "!Date1=" + vSelectedDate)
if(vRSScripts2 > -1)
{
For n = 1 to @XResultSetTotal (vRSScripts2)
XResultSetCurrentPosition (vRSScripts1, n)
vMedicine = @XResultSetValue (vRSScripts2, "Medicine")
vInstruction = @XResultSetValue (vRSScripts2, "Instruction")
If vMedicine <> "" then
{
vStr3 = vMedicine + " " + vInstruction
vYExtent = @PageExtentY ( )
PrintString (vStr3, 0, @PageExtentY ( ), 0, vFont, vFontSize, 1)
vPrintIndicator = "Not Printed" //Avoid double printing, Reset to printed if printed through pagecontrolMeasure ( )
If vPage = 1 and vYExtent >= 1050 then //Added Later on so Prescriptions do not start printing on 2nd Page too soon
{
PageControlMeasure (vStr3)
}
If vPage = 1 or (vPage = 2 and vPrintIndicator = "Not Printed") then
{
PrintString (vStr3, 0, vYExtent, 0, vFont, vFontSize, 0)
}
}
Next
XResultSetClose (vRSScripts2)
}
vYExtent = @PageExtentY ( )
PrintString (@XResultSetValue (vRSHandle, "AD1") + " " + @XResultSetValue (vRSHandle, "AD2") + " " + @XResultSetValue (vRSHandle, "AD3") + " " + @XResultSetValue (vRSHandle, "ADP"), 0, vYExtent, 0, vFont, vFontSize, 1)
//writeLN ("Step 1 " + @Str (@PageExtentY ( ) )) //*********************************************************************************************************************************************
If @PageExtentY () <= 1100 then
{
PrintString (@XResultSetValue (vRSHandle, "AD1") + " " + @XResultSetValue (vRSHandle, "AD2") + " " + @XResultSetValue (vRSHandle, "AD3") + " " + @XResultSetValue (vRSHandle, "ADP"), 0, vYExtent, 0, vFont, vFontSize, 0)
}
Else
{
PageExtentY (vYExtent)
PrintString (@XResultSetValue (vRSHandle, "AD1") + " " + @XResultSetValue (vRSHandle, "AD2") + " " + @XResultSetValue (vRSHandle, "AD3"), 0, vYExtent, 0, vFont, vFontSize, 1)
//WriteLn (@PageExtentY ( ))
If @PageExtentY () < 1100 and vPage = 1 and vStopReset = 0 then
{
//writeLN ("Step 2 " + @Str (@PageExtentY ( ) )) //*********************************************************************************************************************************************
PrintString (@XResultSetValue (vRSHandle, "AD1") + " " + @XResultSetValue (vRSHandle, "AD2") + " " + @XResultSetValue (vRSHandle, "AD3"), 0, vYExtent, 0, vFont, vFontSize, 0)
PageControlMeasure (@XResultSetValue (vRSHandle, "ADP"))
CompleteTask ( )
}
PageExtentY (vYExtent)
PrintString (@XResultSetValue (vRSHandle, "AD1") + " " + @XResultSetValue (vRSHandle, "AD2"), 0, vYExtent, 0, vFont, vFontSize, 1)
//WriteLN (@PageExtentY ( ) )
If @PageExtentY () < 1100 and vPage = 1 and vStopReset = 0 then
{
//writeLN ("Step 3 " + @Str (@PageExtentY ( ) )) //*********************************************************************************************************************************************
PrintString (@XResultSetValue (vRSHandle, "AD1") + " " + @XResultSetValue (vRSHandle, "AD2"), 0, vYExtent, 0, vFont, vFontSize, 0)
PageControlMeasure (@XResultSetValue (vRSHandle, "AD3") + " " + @XResultSetValue (vRSHandle, "ADP"))
CompleteTask ( )
}
PageExtentY (vYExtent)
PrintString (@XResultSetValue (vRSHandle, "AD1"), 0, vYExtent, 0, vFont, vFontSize, 1)
//WriteLN (@PageExtentY ( ) )
If @PageExtentY () < 1100 and vPage = 1 and vStopReset = 0 then
{
//writeLN ("Step 4 " + @Str (@PageExtentY ( ) )) //*********************************************************************************************************************************************
PrintString (@XResultSetValue (vRSHandle, "AD1"), 0, vYExtent, 0, vFont, vFontSize, 0)
PageControlMeasure (@XResultSetValue (vRSHandle, "AD2") + " " + @XResultSetValue (vRSHandle, "AD3") + " " + @XResultSetValue (vRSHandle, "ADP"))
CompleteTask ( )
}
}
//writeLN ("Step 5 " + @Str (@PageExtentY ( ) )) //*********************************************************************************************************************************************
If vStopReset = 0 and @PageExtentY ( ) <= 1060 then //This works only for Page#, if more pages then CompleteTask subroutine takes over
{
PrintString (@XResultSetValue (vRSHandle, "DN"), 550, @PageExtentY ( ) + 10, 0, vFont, vFontSize, 0)
if @GlobalValue ("SignatureOnPhysicalPrintStringHC") = 1 then
{
//WriteLN ("You are Here")
PrintImage (vSignature, 550, @PageExtentY ( ) + 2, -1, -1)
//PrintImage ("C:\images\bharat_sig.jpg", 550, @PageExtentY ( ) + 2, -1, -1)
}
FinishPage ( )
//RestoreDefaultPrinter ( )
}
Else if vStopReset = 0 and @PageExtentY () > 1060 then
{
PageControlMeasure ("")
CompleteTask ( )
}
xResultSetClose (vRSHandle)
}
End SubRoutine
//============================================
Code in Command Button (Medical Record)
var vPrinter1 as String = "DocuCom PDF Driver"
var vPrinter2 as String = @GlobalValue ("ServerDefaultPrinter")
var vPath1 as String = "C:\PDFiles\"
var vPath3 as String = "C:\Sesame2\Records\"
var vPage1 as Int
var vSuccess as Int
var vRS as Int
var vLoop as Int
var vTotalRecords as Int
var vVisitDate as Date
var vName as String = First + " " + P_LastName
var vFiles as String
var vFilesWithPath as String
var vFinalFile as String
var n as Int
var vString1 as String
var vRSHandle as Int
var vDescription as String
var vFilename as String
var vExtFields as String = ""
var vNoOfRecords as Int
var vLastFile as String
var vFile as String
AlternateDefaultPrinter ("DocuCom PDF Driver")
vSuccess = @Shell ("Del " + vPath1 + "*.pdf" )
vRS = @XResultSetSearch(@FN, "Physical", SEARCH_MODE_AND, SEARCH_SYNTAX_QA, "!Chart=" + Chart) // Since Physical also have Chart element and Chart# never changes
if(vRS > -1)
{
//AlternateDefaultPrinter (vPrinter1)
vTotalRecords = @XResultSetTotal(vRS)
xResultsetSort (vRS, "Date1:1")
for vLoop = 1 to vTotalRecords
XResultSetCurrentPosition(vRS, vLoop)
WriteLN ("Processing Visit " + @Str (vLoop) + " of " + @Str (@XResultSetTotal(vRS)) )
vVisitDate = @XResultSetValue(vRS, "Date1")
vFontsize = 17
vFont = " Arial"
vPage = 1
vStopReset = 0
Printing_Physical (vVisitDate)
next
XResultSetClose(vRS)
}
CLS ( )
CloseSlate ( )
vFile = @LocalListDirectory ("C:\PDFiles\")
vFile = vPath1 + vFile
For n = 1 to 10
If FileExists (vFile) then
{
n = 10
}
Else
{
Loiter (1000)
}
Next
If @CountStringArray (vFiles) > 1 then
{
//vFiles = @SortStringArray (vFiles, 0)
For n = @CountStringArray (vFiles) downto 1
If vFilesWithPath = "" then
{
vFilesWithPath = @Chr (34) + vPath1 + @AccessStringArray (vFiles, n) + @chr (34)
}
Else
{
vFilesWithPath = vFilesWithPath + ";" + @Chr (34) + vPath1 + @AccessStringArray (vFiles, n) + @chr (34)
}
Next
vFilesWithPath = @Replace (vFilesWithPath, ";", " ")
//WriteLN (vFilesWithPath)
vFinalFile = vPath1 + vName + " " + @Month(@Date) + "-" + @DOM (@date) + "-" + @Year (@date) + "-visitnotes" + ".pdf"
//WriteLN (vFinalFile)
vSuccess = @Shell ( "PDFill.exe MERGE " + vFilesWithPath + " " + @chr (34) + vFinalFile + @chr (34) )
}
Else
{
vFilesWithPath = @Chr (34) + vFile + @Chr (34) // since there is a space in the name
//vFileName = vPath1 + vName + " " + @Month(@Date) + "-" + @DOM (@date) + "-" + @Year (@date)+ ".pdf"
//vSuccess = @AsynchShell (@Chr (34) + vPath1 + vFiles + @Chr (34))
}
//*********** Now Working with Documents File
//========= Following Routine Check the Documents file Exists on not and if does not give you choice to delete that record before merging them in pdf files
vRSHandle = @XResultSetSearch(@FN, "Index!Documents", SEARCH_MODE_AND, SEARCH_SYNTAX_QA, "!Chart=" + Chart)
If vRSHandle > -1 then
{
xResultSetSort (vRSHandle, "DateAdded:1")
n = @XResultSetTotal (vRSHandle)
While n >= 1
{
xResultSetCurrentPosition (vRSHandle, n)
vDescription = @xResultSetValue (vRSHandle, "Description" )
//WriteLN (vDescription)
vFileName = @xResultSetValue (vRSHandle, "FileName" ) //Checking it again to make certain that no good record is deleted)
//WriteLN (vFileName)
If Not Fileexists (vFileName)
{
If @AskUser (vDescription + " file does not exist, Do you Want to Delet the Record?", "", "") then
{
xResultSetDeleteRecord (vRSHandle)
}
}
//WriteLN (@str (n))
n = n - 1
}
xResultSetClose (vRSHandle)
}
//******************************Convert RTF and PDF File *****************************************************************************************
vFinalFile = vPath3 + vName + " " + @Month (@date) + "-" + @DOM (@date) + "-" + @Year (@date)+".pdf"
vSuccess = @Shell ( "RUNDLL32 PRINTUI.DLL,PrintUIEntry /y /n " + @Chr (34) + vPrinter1 + @chr (34) )
vRSHandle = @XResultSetSearch(@FN, "Index!Documents", SEARCH_MODE_AND, SEARCH_SYNTAX_QA, "!Chart=" + Chart, "!Print=<>NO")
if(vRSHandle > -1)
{
vNoOfRecords = @XResultSetTotal(vRSHandle)
for vLoop = 1 to vNoOfRecords
XResultSetCurrentPosition(vRSHandle, vLoop)
vFileName = @XResultSetValue(vRSHandle, "FileName")
if @Right (vFileName, 3) = "rtf" then
{
MergeFilePrint(vFileName, "rtf", "", "", vExtFields, "", 0)
For n = 1 to 10
If FileExists ("c:\PDFiles\temporary.pdf") then
{
n = 10
}
Else
{
Loiter (1000)
}
Next
vSuccess = @Shell ("Ren " + vPath1 + "Temporary.pdf" + " " + "Temporary" + @Str (vLoop) + ".pdf" )
If @CountStringArray (vFiles) >= 1 then
{
For n = 1 to @CountStringArray (vFiles)
If vFilesWithPath = "" then
{
vFilesWithPath = vPath1 + @AccessStringArray (vFiles, n)
}
Else
{
vFilesWithPath = vFilesWithPath + ";" + vPath1 + @AccessStringArray (vFiles, n)
}
Next
}
}
Else if @Right (vFileName, 3) = "pdf" then
{
vFilesWithPath = vFilesWithPath + ";" + vFileName
//vSuccess = @Shell ("Copy " + @Chr (34) + vFileName + @Chr (34) + " " + @Chr (34) + vPath1 + "Document" + @str (vLoop) + ".pdf" + @Chr (34) )
}
next
//WriteLn (vFilesWithPath)
XResultSetClose(vRSHandle)
}
vFiles = @LocalListDirectory ("C:\PDFiles\")
vLastFile = @AccessStringArray (vFilesWithPath, @CountStringArray (vFilesWithPath) )
If @CountStringArray (vFilesWithPath) > 1 then
{
vFilesWithPath = @Replace (vFilesWithPath, ";", " ")
vSuccess = @Shell ( "PDFill.exe MERGE " + vFilesWithPath + " " + @chr (34) + vFinalFile + @chr (34) )
}
Else
{
vSuccess = @Shell ("Copy " + vFilesWithPath + " " + @chr (34) + vFinalFile + @chr (34) )
}
For n = 1 to 10
If FileExists (vLastFile)
{
n = 10
}
Else
{
Loiter (1000)
}
Next
vSuccess = @AsynchShell (@Chr (34) + vFinalFile + @Chr (34)) //This is only if you want to open one page
vSuccess = @Shell ( "RUNDLL32 PRINTUI.DLL,PrintUIEntry /y /n " + @Chr (34) + vPrinter2 + @chr (34) )// Default Printer in place again