VB code snippet for using the generalInvoiceRequestManager


Private Sub GeneralInvoiceRequestExampleButton_Click()

On Error GoTo Err_Trap

Dim bStatus As Boolean

'### init variables
Dim strFrom As String
strFrom = "7601001302112"
Dim strVia As String
strVia = "7601000012345"
Dim strTo As String
strTo = "7634567890000"
Dim dBirthdate As Date
dBirthdate = DateValue("1964-2-28")
Dim eSex As SexType
eSex = enMale
Dim eCanton As CantonType
eCanton = enBS
Dim eLaw As LawType
eLaw = enKVG
Dim eTreatType As TreatmentType
eTreatType = enAmbulatory
Dim eRole As RoleType
eRole = enRolePhysician
Dim ePlace As PlaceType
ePlace = enPlacePractice
Dim eTitle As String
eTitle = ""
Dim dTreatmentEnd As Date
dTreatmentEnd = DateValue("2010-08-31")
Dim dTreatmentStart As Date
dTreatmentStart = DateValue("2010-08-01")
Dim strCaseID As String
strCaseID = "123456-6789"
Dim strPatientInsID As String
strPatientInsID = "123.45.678-012"
Dim strContractNumber As String
strContractNumber = "AZ-3.456"
Dim eTreatmentReason As TreatmentReasonType
eTreatmentReason = enDisease
Dim eMedicalRole As MedicalRoleType
eMedicalRole = enMedicalRoleSelfEmployed
Dim eBillingRole As BillingRoleType
eBillingRole = enBillingRoleBoth
Dim strEanProvider As String
strEanProvider = "7634567890111"
Dim strEanResponsible As String
strEanResponsible = "7634567890333"

'### GeneralInvoiceRequestManager interface
Dim generalInvoiceRequestManagerEx As GENERALINVOICEREQUESTMANAGER430Lib.GeneralInvoiceRequestManager
Set generalInvoiceRequestManagerEx = New GeneralInvoiceRequestManager

'### GeneralInvoiceRequest interface
Dim generalInvoiceRequestEx As GENERALINVOICEREQUESTMANAGER430Lib.GeneralInvoiceRequest
Set generalInvoiceRequestEx = generalInvoiceRequestManagerEx.GeneralInvoiceRequest

generalInvoiceRequestEx.Initialize (enGerman)

'### Set request
bStatus = generalInvoiceRequestEx.SetRequest(eRole, ePlace, strTitle, enNo, enNo, "some remark")

'### Set tiers
bStatus = generalInvoiceRequestEx.SetTiers(enTiersGarant, "", 0)

'### Set transport
bStatus = generalInvoiceRequestEx.SetTransport(strFrom, "", "", strVia, strTo, "")

'### Set package
bStatus = generalInvoiceRequestEx.SetPackage("GeneralInvoiceRequestExample", 10001, 4, "sumex1")

'### Set invoice
bStatus = generalInvoiceRequestEx.SetInvoice("2009_01:001", dTreatmentEnd, 0, "patID_1456")

Dim IAddress As GENERALINVOICEREQUESTMANAGER430Lib.Address
Set IAddress = generalInvoiceRequestEx.CreateAddress
'### esr
Dim lPaymentPeriod As Long
lPaymentPeriod = 25
IAddress.Initialize
bStatus = IAddress.SetCompany("Bank AG", "Abteilung VESR", "")
bStatus = IAddress.SetPostal("Bankstrasse 11", "Postfach", "4002", "Basel", "BS", "CH")
bStatus = generalInvoiceRequestEx.SetEsr(en9to16or27, "010001628", "12345620000188888888888888",  _
                                         "01-162-8", IAddress, lPaymentPeriod)

'### biller
IAddress.Initialize
bStatus = IAddress.SetCompany("Biller AG", "Abteilung Inkasso", "")
bStatus = IAddress.SetPostal("Billerweg 128", "", "4414", "Frenkendorf", "", "")
bStatus = IAddress.AddPhone("956 99 00", "061", "", "")
bStatus = IAddress.SetFax("956 99 10", "061", "+41", "")
bStatus = IAddress.SetOnline("info@biller.ch", "")
bStatus = generalInvoiceRequestEx.SetBiller("2011234567890", "H-1211-11", "334455", "", IAddress)

'### set provider
IAddress.Initialize
bStatus = IAddress.SetPerson("Aerztin", "Patricia", "Frau", "Dr. med.", "")
bStatus = IAddress.SetPostal("Arztgasse 17b5", "", "4000", "Basel", "BS", "")
bStatus = generalInvoiceRequestEx.SetProvider(strEanProvider, "P-1234-56", "42042",  _
                                              "FMH Innere Medizin", IAddress)


'### health insurance
IAddress.Initialize
bStatus = IAddress.SetCompany("Krankenkasse AG", "Sektion Basel", "")
bStatus = IAddress.SetPostal("Kassengraben 222", "", "4000", "Basel", "", "")
bStatus = generalInvoiceRequestEx.SetInsurance("2034567890222", IAddress)

'### patient
IAddress.Initialize
bStatus = IAddress.SetPerson("Muster", "Peter", "Herr", "", "c/o Mieter Karl")
bStatus = IAddress.SetPostal("Musterstrasse 5", "", "7304", "Maienfeld", "", "")
bStatus = generalInvoiceRequestEx.SetPatient(eSex, dBirthdate, "756.1234.5678.90", IAddress)
bStatus = generalInvoiceRequestEx.SetCard("12345678901234567890", DateValue("2009-12-31"),  _
                                          DateValue("2011-12-31"), "", "")
'### guarantor, same as patient
bStatus = generalInvoiceRequestEx.SetGuarantor(IAddress)

'### referrer
IAddress.Initialize
bStatus = IAddress.SetPerson("Ueberweiser", "Herbert", "Herr", "Dr. med.", "")
bStatus = IAddress.SetPostal("Referrerstrasse 11", "", "5000", "Aarau", "AG", "")
bStatus = generalInvoiceRequestEx.SetReferrer("2034567890333", "R-2345-67", "",  _
                                              "FMH Inner Medizin", IAddress)

'### employer
IAddress.Initialize
bStatus = IAddress.SetCompany("Arbeitgeber AG", "R&D", "")
bStatus = IAddress.SetPostal("Arbeitsplatz 3-5", "", "4410", "Liestal", "BL", "")
bStatus = generalInvoiceRequestEx.SetEmployer("7600123456789", "123-456.78", IAddress)

'### set applicable law
bStatus = generalInvoiceRequestEx.SetLaw(enKVG, dTreatmentEnd, strCaseID, strPatientInsID,  _
                                         strContractNumber)

'### set processing
bStatus = generalInvoiceRequestEx.SetProcessing(enYes, enNo, "69")

'### set treatment
bStatus = generalInvoiceRequestEx.SetTreatment(dTreatmentStart, dTreatmentEnd, eCanton,  _
                                               eTreatmentReason)
'bStatus = generalInvoiceRequestEx.AddDiagnosis(enDiagnosisByContract, "A1", "A1 Text")
'bStatus = generalInvoiceRequestEx.AddDiagnosis(enDiagnosisByContract, "B2", "")

'### Tarmed data
Dim tarmedInputEx As TarmedInput
Set tarmedInputEx = generalInvoiceRequestEx.CreateTarmedInput

tarmedInputEx.ExternalFactor_MT = 1
tarmedInputEx.ExternalFactor_TT = 1

'### physician
bStatus = tarmedInputEx.SetPhysician(eMedicalRole, eBillingRole, strEanProvider, strEanResponsible)
'### patient
bStatus = tarmedInputEx.SetPatient(dBirthdate, eSex)
'### treatment
Dim strEanSection As String
strEanSection = "7634567890000"
Dim eSettlement As SettlementType
eSettlement = enSettlementElectronic
bStatus = tarmedInputEx.SetTreatment(eCanton, eLaw, eTreatment, eSettlement, strEanSection)

'### add consultation
Dim lID As Long
Dim lSession As Long
lSession = 1
Dim lStatus As Long
bStatus = generalInvoiceRequestEx.AddTarmedService(tarmedInputEx, _
                                "001", _
                                "00.0010", _
                                "", _
                                1, _
                                lSession, _
                                dTreatmentStart, _
                                enSideNone, _
                                enNo, _
                                0.92, _
                                0.92, _
                                6, _
                                enObligationAutomatic, _
                                "", _
                                "", _
                                0, _
                                lID)

bStatus = generalInvoiceRequestEx.AddTarmedService(tarmedInputEx, "001", _
                                "00.0020", _
                                "00.0010", _
                                1, _
                                lSession, _
                                dTreatmentStart, _
                                enSideNone, _
                                enNo, _
                                0.92, _
                                0.92, _
                                6, _
                                enObligationAutomatic, _
                                "", _
                                "", _
                                0, _
                                lID)

bStatus = generalInvoiceRequestEx.AddTarmedService(tarmedInputEx, "001", _
                                "00.0030", _
                                "00.0010", _
                                1, _
                                lSession, _
                                dTreatmentStart, _
                                enSideNone, _
                                enNo, _
                                0.92, _
                                0.92, _
                                6, _
                                enObligationAutomatic, _
                                "", _
                                "", _
                                0, _
                                lID)

'### Add a drug service
bStatus = generalInvoiceRequestEx.AddService("402", _
                                "7680381331011", _
                                "", _
                                1#, _
                                1, _
                                dTreatmentStart, _
                                strEanProvider, _
                                strEanResponsible, _
                                "Aspegic Forte 20 Sach. 1000 mg", _
                                0#, _
                                0#, _
                                1#, _
                                0#, _
                                0, _
                                enObligationAutomatic, _
                                "", _
                                "", _
                                enNo, _
                                1, _
                                lID)

Dim dRoundDifference As Double
dRoundDiference = 1#
bStatus = generalInvoiceRequestEx.Finalize(dRoundDifference)

Dim lXMLGenerationAttribute As Long
lXMLGenerationAttribute = 0
Dim lValidationError As Long
Dim lTimestamp As Long
Dim generalInvoiceResultEx As GENERALINVOICEREQUESTMANAGER430Lib.GeneralInvoiceResult

Dim strTmpFile As String
Dim strUsedSchema As String
bStatus = generalInvoiceRequestManagerEx.GetXML(lXMLGenerationAttribute, strTmpFile, lValidationError,  _
                                                lTimestamp, strUsedSchema, generalInvoiceResultEx)
Dim strTargetFile As String
strTargetFile = "GeneralInvoiceRequestExample.xml"
FileCopy strTmpFile, strTargetFile


'### relase resources
Set tarmedInputEx = Nothing
Set IAddress = Nothing
Set generalInvoiceResultEx = Nothing
Set generalInvoiceRequestEx = Nothing
Set generalInvoiceRequestManagerEx = Nothing

Exit Sub

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

'### relase resources
Set tarmedInputEx = Nothing
Set IAddress = Nothing
Set generalInvoiceResultEx = Nothing
Set generalInvoiceRequestEx = Nothing
Set generalInvoiceRequestManagerEx = Nothing

End Sub