Visual Basic code snippet for using the miscValidator200 COM module


Private Sub miscValidator200Test_Click()
    On Error GoTo Err_Trap

    Dim bStatus As Boolean

    ' ### IMiscValidatorInterface
    ' obtain the misc validator main interface
    ' ### 
    Dim IMiscValidator As MISCVALIDATOR200Lib.MiscValidator
    Set IMiscValidator = New MiscValidator


    ' open the database first and set the language
    ' ### 
    bStatus = IMiscValidator.Open(enGerman)
    If bStatus Then
        ' Restrict the role of the provider to be a physiotherapist working under KVG
        ' ### 
        lRoleRestrict = MISCVALIDATOR200Lib.enRolePhysiotherapist
        lPlaceRestrict = MISCVALIDATOR200Lib.enPlacePractice
        lLawRestrict = MISCVALIDATOR200Lib.enKVG
        Dim strEAN As String
        strEAN = ""
        bStatus = IMiscValidator.SetTariffFilter(lRoleRestrict, lPlaceRestrict, lLawRestrict, strEAN)
 
        Dim bstrTariffType As String
        Dim bstrTariffName As String
        Dim bstrVersion As String
        Dim dValidFrom As Date
        Dim dValidTo As Date

        'Loop over all tariffs that match the criteria
        bFoundTariffs = IMiscValidator.GetFirstTariff(bstrTariffType, bstrTariffName,  _
                                                      bstrVersion, dValidFrom, dValidTo)
        If bFoundTariffs Then
            While IMiscValidator.GetNextTariff(bstrTariffType, bstrTariffName, bstrVersion, _
                                               dValidFrom, dValidTo)
               ' ### 
               ' do something in here
               ' ### 
            Wend
        End If

        '### IChapter interface
        ' Chapters group a specific tariff in to a hierarchical order
        ' e.g. for Physio
        '   311:5
        '   311:5.1
        '   311:5.2
        ' ### 
        Dim IChapter As MISCVALIDATOR200Lib.Chapter

        ' Get the chapter interface from the main interface
        ' ### 
        Set IChapter = IMiscValidator.CreateChapter
        Dim dDate As Date
        Dim bstrCode As String
        bstrTariffType = "311"       ' use the physiotherapy tariff
        bstrCode = ""                ' this will return all chapters
        dDate = DateValue(Now)

        bStatus = IChapter.SearchName(bstrTariffType, dDate, bstrCode)
        If bStatus Then
            Dim bContinue As Boolean
            bContinue = IChapter.MoveFirst
            While bContinue
                bstrCode = IChapter.Code
                bstrParentCode = IChapter.ParentCode
                bstrName = IChapter.Name
                bstrInterpretation = IChapter.Interpretation
 
                ' ### 
                ' do something
                ' ### 

                bContinue = IChapter.MoveNext
            Wend
        End If

        ' ### ISearch interface
        ' search vor tariffe positions/codes
        ' ### 
        Dim ISearch As MISCVALIDATOR200Lib.Search
        Set ISearch = IMiscValidator.CreateSearch

        ' search within the physiotherapy tariff 311
        ' for all codes starting with 73
        ' ### 
        bResult = ISearch.SearchCode("311", dDate, "73*")
        If bResult Then
            Dim bHasResult As Boolean
            bHasMoreCodes = ISearch.MoveFirst
            While bHasMoreCodes
                bstrCode = ISearch.Code
                bstrChapterCode = ISearch.ChapterCode
                bstrName = ISearch.Name
                bstrTariffType = ISearch.TariffType

                ' servicesProperties defines available properties by an 
                ' ORed long value of ServicePropertyType enumerators
                ' the meaning if the bits is defined in the ServicePropertyType enum
                ' ### 
                lServiceProperties = ISearch.ServiceProperties
                'check if the TP property is available
                If (enServicePropertyHasTP & lServiceProperties) > 0 Then
                    Dim bstrPropName As String
                    bstrPropName = "TP" 'also works with the full name enServicePropertyHasTP
                    Dim bstrPropValue As String
                    bResult = ISearch.GetPropertyValue(bstrPropName, bstrPropValue)
                    If bResult Then

                        ' ### 
                        ' do someting TP value
                        ' ### 

                    End If
                End If
                bHasMoreCodes = ISearch.MoveNext
            Wend
        End If

        ' ### IValidate ###
        ' Input and validate services
        ' ### 
        Dim IValidate As MISCVALIDATOR200Lib.Validate
        Set IValidate = IMiscValidator.CreateValidate

        ' Initialize the module for the physiotherapist example
        ' ### 
        bStatus = IValidate.Initialize("311", enRolePhysiotherapist, enPlacePractice)
        If bStatus Then
            bstrTariffType = "311"      ' physio tariffe number
            bstrCode = "7301"           ' code 7301 = Sitzungspauschale
            bstrRefCode = ""            ' parent code is empty due to enServicePropertyIsNeedsRefCode bit
            dQuantity = 1               ' the quantity
            dTP = 0                     ' the tax points: if given as 0 then the TP is auto expaned 
                                        ' if dTP>0 then it is checked against the internal TP. An error  
                                        ' is raised if dTP > dTpinternal
            dTPV = 1                    ' tax point value of the service. 
                                        ' Please note that the TPV must be supplied as input 
            dExternalFactor = 1         ' defines a discount or an upscaling
            lSessionNumber = 1          ' session number
            Dim dServiceDate As Date
            dServiceDate = DateValue(Now)
            Dim lHook As Long
            lHook = 1234                ' a hook, e.g. software specific recordID 
                                        ' to identifiy a potentially errorneous position

            ' Input the service and validate the current services against the previous records supplied
            ' ### 
            bStatus = IValidate.AddService(bstrTariffType, bstrCode, bstrRefCode, dQuantity, dTP, dTPV,  _
                                           dExternalFactor, lSessionNumber, dServiceDate, enNo, lHook)
 
            If Not bStatus Then
                MsgBox "Failed to add Service " & bstrCode
            End If

            ' calculate the total amount for a specific service
            ' ### 
            Dim dTotalAmount As Double
            dTotalAmount = 0
            bResult = IValidate.Finalize(bstrTariffType, dTotalAmount)
            If Not bStatus Then
                MsgBox "something dammed wrong here "
            End If

        End If
    End If

    Exit Sub

Err_Trap:
    MsgBox "Error: " & Err.Description, vbCritical, _
           "Opps! Error" & Str$(Err.Number)

End Sub