here is the ENTIRE VB code of my program and an output file. the information is me and i agree to have it shared.
Lets try to optimize what i have sofar and comment on what I could do better
Attachment 96197 (rename to .htm)
Lets try to optimize what i have sofar and comment on what I could do better
Code:
Private Type Info 'general patient info
label As String * 12
Name As String * 30
gender As String * 1
addr As String * 30
Location As String * 30
Birth As String * 8
phone As String * 12
work As String * 12
Clear As String * 28
Ephone As String * 12
Ework As String * 12
Ename As String * 38
SS As String * 11
c As String * 18
id As Integer
Email As String * 30
End Type
Private Type Info2 ' physician information and repeat of patient info including insurance
ignore As String * 34
assist As String * 15
phys As String * 15
unk As String * 1728
adate As String * 8
pdate As String * 7
plan As String * 100
prob As String * 80
primaryi As String * 308
tdate As String * 8
pcode As String * 13
pname As String * 30
gender As String * 1
addr As String * 60
bdate As String * 8
phone As String * 12
work As String * 12
fill As String * 90
soc As String * 11
fill2 As String * 32
ins As String * 120
data As String * 123
End Type
Private Type Info3 'lab tests performed
a As String * 62
n1 As String * 18
b As String * 69
n2 As String * 11
c As String * 62
n3 As String * 34
d As String * 70
n4 As String * 10
e As String * 62
n5 As String * 18
f As String * 96
g As String * 80
h As String * 80
i As String * 96
j As String * 80
k As String * 80
l As String * 80
End Type
'Private Type info4 'pharmacy information
'End Type
Private Sub Command1_Click()
Dim LineOfText As String
FileCopy "c:\med\headhtm.txt", "c:\test\patient.htm"
Open "c:\med\tophtm2.txt" For Input As #1
Open "c:\test\patient.htm" For Append As #2
Do While Not EOF(1)
Line Input #1, LineOfText
Print #2, LineOfText
Loop
Close #1
Close #2
Dim udtInfo As Info 'Dimension a variable of type Info
Dim Labc As Info2
Dim CATL As String
Dim TP As String
Dim PP As Integer
Dim PP2 As String
On Error GoTo errorHandler
Me.MousePointer = vbHourglass
Open "A:\Patient.txt" For Random As #1 Len = 286
Open "A:\labstuff.txt" For Random As #3 Len = 2817
Label1.Caption = "Gathering Data"
Get #1, , udtInfo
Get #3, , Labc
Close #1
Open "C:\Test\Patient.htm" For Append As #2
Close #3
TP = "MEDICAL CONSIDERATIONS, PROGRESS NOTES, AND ACTION PLAN": PP = 1: PP2 = "#"
Print #2, "<table width=100%><td nowrap><i>";
Print #2, "<td width=100%><hr></table>"
Print #2,
Print #2, "<table width=100%><td><big>"; TP; "<td align=right><i>Page "; USING; PP; PP2
Print #2, "</table>"
With udtInfo
sPatientDoB = .Birth
dateDOb = DateSerial(Mid$(sPatientDoB, 7, 2), Mid$(sPatientDoB, 1, 2), Mid$(sPatientDoB, 4, 2))
age = DateDiff("yyyy", dateDOb, Date$)
gen = .gender
If gen = "M" Then gender = "Male"
If gen = "F" Then gender = "Female"
Print #2, "<table width=100% align=center>"
Print #2, "<td>"; .Name; "<br>"; .addr; "<br>"; .Location; "<br>Patient ID:"; .id
Print #2, "<td>Born: "; .Birth; "<br>"; gender; " Age: "; age; "<br>"; "Home: "; .phone; "<br>Work: "; .work; "<br>"
End With
With Labc
Timee = Mid(.ignore, 1, 5)
Print #2, "<td>Date of Visit: "; .tdate; "<br>"; "Time seen by MA: "; Timee; "<br>"
Print #2, "Date Printed:"; Date$; "<br>Time Printed:"; Left$(Time$, 5)
Print #2, "</table>"
Print #2, "<br> <pre><table width=100%><td nowrap><small><i>During this visit, we considered, among other items, the following:<td width=100%><hr></table></b><table width=100%><td nowrap><small><i>GENERAL INFORMATION<td width=100%><hr></table></b>"
End With
Close #2
Dim Lab As Info2 'Dimension a variable of type Info
Open "A:\labstuff.txt" For Random As #1 Len = 2817
Get #1, , Lab
Close #1
Open "C:\Test\Patient.htm" For Append As #2
With Lab
Print #2, "<td nowrap>"
Print #2, "<td>"; ; "<br>"; ; "<br>";
Print #2, "<td>Primary Physician: "; .phys; "<br>Assistant: "; .assist; "<br>Last assigned ICD9: "; .primaryi
Print #2, "<td>Visit Plan: "; .plan; "<br>Insurance: "; .ins; "<br>Primary Diagnosis: "; .prob
Print #2, "<td>Next Appointment: "; .adate
Print #2, "</table> <br>"
End With
Close #2
Dim tests As Info3 'Dimension a variable of type Info
Open "A:\acutes.txt" For Random As #1 Len = 1024
Get #1, , tests
Close #1
Open "C:\Test\Patient.htm" For Append As #2
With tests
Print #2, "<table width=100% align=center>"
Print #2, "<td></i><br>"; .a; "<br>"; .b; "<br>"; .c; "<br>"; .d; "<br>"; .e; "<br>"; .f; "<br>"; .g; "<br>"; .h; "<br>"; .i; "<br>"; .j; "<br>"; .k; "<br>"; .l; "</table>"
End With
Close #2
Open "a:\vsigns.txt" For Input As #1
Open "c:\test\patient.htm" For Append As #2
Print #2, "<table width=100% align=center>"
Print #2, "<td>"; ; "<br>"; ; "<br>"
Do While Not EOF(1)
Line Input #1, LineOfText
Print #2, ""
Print #2, Mid$(LineOfText, 11); "<br>"
Loop
Print #2, "</table>"
Close #1
Close #2
Dim Records As Integer
Dim x As Integer
Dim InputHandle As Integer
Dim OutputHandle As Integer
Dim FileData As String
FileData = Space$(256)
Open "a:\ltmed.txt" For Binary As #1
Open "C:\Test\Patient.htm" For Append As #2
Records = LOF(1) / 256
For x = 0 To Records - 1
Get #1, , FileData
Print #2, FileData
Next
Close #1
Close #2
Open "a:\phys.txt" For Input As #1
Open "c:\test\patient.htm" For Append As #2
Print #2, "<table width=100% align=center>"
Print #2, "<td>"; ; "<br>"; ; "<br>"
Do While Not EOF(1)
Line Input #1, LineOfText
Print #2,
Print #2, Mid$(LineOfText, 11); "<br>"
Loop
Print #2, "</table>"
Close #1
Close #2
Open "a:\vxdata.txt" For Input As #1
Open "c:\test\patient.htm" For Append As #2
Print #2, "<table width=100% align=center>"
Print #2, "<td>"; ; "<br>"; ; "<br>"
Do While Not EOF(1)
Line Input #1, LineOfText
Print #2,
Print #2, LineOfText; "<br>"
Loop
Print #2, "</table>"
Close #1
Close #2
Label1.Caption = "Data Ready you may eject the Disk"
Me.MousePointer = vbNormal
Exit Sub
errorHandler:
Label1.Caption = "NO DISK"
Me.MousePointer = vbArrowQuestion
If MsgBox("Please Insert Disk", vbRetryCancel, "No Disk") = vbRetry Then
Resume
End If
End Sub