fPatientsFilter.frm

 VERSION 5.00
Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX"
Begin VB.Form fPatientsFilter
   BorderStyle     =   4  'Fixed ToolWindow
   Caption         =   "Pacienti"
   ClientHeight    =   6540
   ClientLeft      =   45
   ClientTop       =   285
   ClientWidth     =   7095
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   6540
   ScaleWidth      =   7095
   ShowInTaskbar   =   0   'False
   StartUpPosition =   1  'CenterOwner
   Begin VB.Frame Frame1
      Height          =   6465
      Left            =   3000
      TabIndex        =   1
      Top             =   0
      Width           =   4065
      Begin VB.ComboBox cboAgeEqual
         Enabled         =   0   'False
         Height          =   315
         Left            =   1875
         TabIndex        =   9
         Text            =   "Combo1"
         Top             =   1200
         Width           =   690
      End
      Begin VB.ComboBox cboAgeBetween
         Enabled         =   0   'False
         Height          =   315
         Index           =   1
         Left            =   3000
         TabIndex        =   8
         Text            =   "Combo1"
         Top             =   1650
         Width           =   690
      End
      Begin VB.ComboBox cboAgeBetween
         Enabled         =   0   'False
         Height          =   315
         Index           =   0
         Left            =   1875
         TabIndex        =   6
         Text            =   "Combo1"
         Top             =   1650
         Width           =   690
      End
      Begin VB.CheckBox chkAge
         Caption         =   "intre"
         Enabled         =   0   'False
         Height          =   240
         Index           =   1
         Left            =   600
         TabIndex        =   5
         Top             =   1725
         Width           =   1215
      End
      Begin VB.CheckBox chkAge
         Caption         =   "de"
         Enabled         =   0   'False
         Height          =   240
         Index           =   0
         Left            =   600
         TabIndex        =   4
         Top             =   1275
         Width           =   1215
      End
      Begin VB.OptionButton optFilter
         Caption         =   "Pacientii cu varsta (ani):"
         Height          =   240
         Index           =   1
         Left            =   75
         TabIndex        =   3
         Top             =   825
         Width           =   3315
      End
      Begin VB.OptionButton optFilter
         Caption         =   "Toti Pacientii"
         Height          =   240
         Index           =   0
         Left            =   75
         TabIndex        =   2
         Top             =   450
         Value           =   -1  'True
         Width           =   3315
      End
      Begin MSComctlLib.ImageList ImageList1
         Left            =   -225
         Top             =   6150
         _ExtentX        =   1005
         _ExtentY        =   1005
         BackColor       =   -2147483643
         ImageWidth      =   16
         ImageHeight     =   16
         MaskColor       =   12632256
         _Version        =   393216
         BeginProperty Images {2C247F25-8591-11D1-B16A-00C0F0283628}
            NumListImages   =   4
            BeginProperty ListImage1 {2C247F27-8591-11D1-B16A-00C0F0283628}
               Picture         =   "fPatientsFilter.frx":0000
               Key             =   "close"
            EndProperty
            BeginProperty ListImage2 {2C247F27-8591-11D1-B16A-00C0F0283628}
               Picture         =   "fPatientsFilter.frx":0452
               Key             =   "women"
            EndProperty
            BeginProperty ListImage3 {2C247F27-8591-11D1-B16A-00C0F0283628}
               Picture         =   "fPatientsFilter.frx":08A4
               Key             =   "men"
            EndProperty
            BeginProperty ListImage4 {2C247F27-8591-11D1-B16A-00C0F0283628}
               Picture         =   "fPatientsFilter.frx":0CF6
               Key             =   "open"
            EndProperty
         EndProperty
      End
      Begin VB.Label lblAnd
         Caption         =   "si"
         Height          =   240
         Left            =   2625
         TabIndex        =   7
         Top             =   1725
         Width           =   315
      End
   End
   Begin MSComctlLib.TreeView tvwPatients
      Height          =   6390
      Left            =   0
      TabIndex        =   0
      Top             =   75
      Width           =   2940
      _ExtentX        =   5186
      _ExtentY        =   11271
      _Version        =   393217
      HideSelection   =   0   'False
      Indentation     =   706
      Style           =   7
      HotTracking     =   -1  'True
      SingleSel       =   -1  'True
      ImageList       =   "ImageList1"
      Appearance      =   1
   End
End
Attribute VB_Name = "fPatientsFilter"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private m_SelectedModule As String

Private Sub chkAge_Click(Index As Integer)
   
    Select Case Index
    Case 0 'with age equal
        chkAge(1).Value = vbUnchecked
        If chkAge(0).Value = vbUnchecked Then
            cboAgeEqual.Enabled = False
        Else
            cboAgeEqual.Enabled = True
        End If
        cboAgeBetween(0).Enabled = False
        cboAgeBetween(1).Enabled = False
    Case 1 'with age between
        chkAge(0).Value = vbUnchecked
        If chkAge(1).Value = vbUnchecked Then
            cboAgeBetween(0).Enabled = False
            cboAgeBetween(1).Enabled = False
        Else
            cboAgeBetween(0).Enabled = True
            cboAgeBetween(1).Enabled = True
        End If
        cboAgeEqual.Enabled = False
    End Select
   
   
End Sub

Private Sub Form_Activate()
   
    Call ColapseAllNodes
   
End Sub

Private Sub Form_Load()
       
    Call InitializeTree
    Call SetControlsCaption(Me)
   
End Sub

Private Sub InitializeTree()
   
    Dim NodX As Node
    Dim intLetter As Integer
   
    For intLetter = 65 To 90
        Set NodX = tvwPatients.Nodes.Add(, , Chr(intLetter), Chr(intLetter), "close")
        NodX.ExpandedImage = "open"
        NodX.Tag = "Initial_Last_Name"
    Next
   
End Sub



Private Sub optFilter_Click(Index As Integer)
       
    Dim i As Integer
   
    For i = 1 To tvwPatients.Nodes.Count
        ' Colapse all nodes.
        tvwPatients.Nodes(i).Expanded = False
    Next i
   
    Select Case Index
    Case 0 'all patients
        chkAge(0).Enabled = False
        chkAge(1).Enabled = False
        chkAge(0).Value = vbUnchecked
        chkAge(1).Value = vbUnchecked

    Case 1 ' with age equal or between
        chkAge(0).Enabled = True
        chkAge(1).Enabled = True
    End Select
   
End Sub

Private Sub ColapseAllNodes()
    Dim i As Integer
   
    For i = 1 To tvwPatients.Nodes.Count
        ' Colapse all nodes.
        tvwPatients.Nodes(i).Expanded = False
    Next i
   
End Sub

Private Sub tvwPatients_BeforeLabelEdit(Cancel As Integer)
    'user do not edit a node
    Cancel = True
   
End Sub



Private Sub tvwPatients_DblClick()
   
    If tvwPatients.SelectedItem.Tag = "Initial_Last_Name" Then Exit Sub
    strCNP_PatientsFilter = Left$(tvwPatients.SelectedItem.Key, Len(tvwPatients.SelectedItem.Key) - 1)
    'we know the CNP for selected patient
    Screen.MousePointer = vbHourglass
    Select Case SelectedModule
    Case "fPatientsDetails"
        'check first for duplicate
        If CheckDuplicate("fPatientsDetails", strCNP_PatientsFilter) Then
            Screen.MousePointer = vbNormal
            strMessage = oMessage.GetMessage(Get_Module_ID(Me.Name), "tvwPatients_DblClick", oLanguage.Language_Index)
            MsgBox strMessage, vbInformation, "MedCare"
            Exit Sub
        Else
            Set fPatientsDetails = New fPatientsDetails
            fPatientsDetails.CNP = strCNP_PatientsFilter
            strCNP_PatientsFilter = ""
            Screen.MousePointer = vbNormal
            fPatientsDetails.Show
        End If
    Case "fConsultationsPatientHistory"
        'check first for duplicate ; have to get Form Name from DB !!
        If CheckDuplicate("fConsultationsPatientHistory", strCNP_PatientsFilter) Then
            Screen.MousePointer = vbNormal
            strMessage = oMessage.GetMessage(Get_Module_ID(Me.Name), "tvwPatients_DblClick", oLanguage.Language_Index)
            MsgBox strMessage, vbInformation, "MedCare"
            Exit Sub
        Else
            Set fConsultationsPatientHistory = New fConsultationsPatientHistory
            fConsultationsPatientHistory.CNP = strCNP_PatientsFilter
            strCNP_PatientsFilter = ""
            Screen.MousePointer = vbNormal
            fConsultationsPatientHistory.Show
        End If
    Case Else
   
    End Select
End Sub

Private Sub tvwPatients_KeyPress(KeyAscii As Integer)
   
    Call tvwPatients_DblClick
   
End Sub

Private Sub tvwPatients_NodeClick(ByVal Node As MSComctlLib.Node)

    Dim strNodeKey As String, strNodeTag As String
    Dim rsPatients As New ADODB.Recordset
    Dim NodX As Node
   
    strNodeTag = Node.Tag
    If strNodeTag <> "Initial_Last_Name" Then Exit Sub
    If optFilter(0).Value Then
        'loads patients with given initial
        If Not Get_Patients_With_Initial(Node.Key, rsPatients) Then
            Node.Expanded = False
            Exit Sub
        End If
        If Node.Children > 0 Then 'if the node has children delete them first
            Dim i As Integer
            Set NodX = tvwPatients.SelectedItem.Child.LastSibling
            Debug.Print NodX.Text
            i = tvwPatients.SelectedItem.Child.LastSibling.Index
            'from last child to first one
            While i <> tvwPatients.SelectedItem.Child.FirstSibling.Index
                j = i
                Set NodX = tvwPatients.SelectedItem.Child.Previous
                i = tvwPatients.Nodes(i).Previous.Index
                tvwPatients.Nodes().Remove j
            Wend
            'remove first child
            Set NodX = tvwPatients.SelectedItem.Child.FirstSibling
            i = tvwPatients.SelectedItem.Child.FirstSibling.Index
            tvwPatients.Nodes().Remove i
        End If
        Do While Not rsPatients.EOF
            Set NodX = tvwPatients.Nodes.Add(Node.Key, tvwChild, rsPatients!CNP & "P", Trim(rsPatients!FirstName) & " " & Trim(rsPatients!LastName), "women")
            rsPatients.MoveNext
        Loop
        Node.EnsureVisible
        rsPatients.Close
        Set rsPatients = Nothing
    ElseIf optFilter(1).Value Then  'with age equal or between
   
    End If
End Sub





Public Property Get SelectedModule() As String
    SelectedModule = m_SelectedModule
End Property

Public Property Let SelectedModule(ByVal vNewValue As String)
    m_SelectedModule = vNewValue
End Property

Project Homepage: