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"

'### create the main GeneralInvoiceRequestManager interface
Dim generalInvoiceRequestManagerEx As GENERALINVOICEREQUESTMANAGER440Lib.GeneralInvoiceRequestManager
Set generalInvoiceRequestManagerEx = New GeneralInvoiceRequestManager

'### generate the dependend GeneralInvoiceRequest interface (allows to input data)
Dim generalInvoiceRequestEx As GENERALINVOICEREQUESTMANAGER440Lib.GeneralInvoiceRequest
Set generalInvoiceRequestEx = generalInvoiceRequestManagerEx.GeneralInvoiceRequest

'### start the input of data
generalInvoiceRequestEx.Initialize (enGerman)

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

'### set the tiers data  (required)
bStatus = generalInvoiceRequestEx.SetTiers(enTiersGarant, "", 0)

'### set the routing/transport information (needed when generating XML infosets)
bStatus = generalInvoiceRequestEx.SetTransport(strFrom, "", "", strVia, strTo, "")

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

'### set processing instruction regarding printing at the intremediate's side
bStatus = generalInvoiceRequestEx.SetProcessing(enYes, enNo, "")

'### set invoice related data  (required)
bStatus = generalInvoiceRequestEx.SetInvoice("2009_01:001", dTreatmentEnd, 0, "patID_1456")

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

'### create an address interface that is need to add addresses
Dim IAddress As GENERALINVOICEREQUESTMANAGER440Lib.Address
Set IAddress = generalInvoiceRequestEx.CreateAddress

'### define the bank address and the corresponding esr information (required)
IAddress.Initialize
bStatus = IAddress.SetCompany("Bank AG", "Abteilung VESR", "")
bStatus = IAddress.SetPostal("Bankstrasse 11", "Postfach", "4002", "Basel", "BS", "CH")

Dim lPaymentPeriod As Long
lPaymentPeriod = 25
bStatus = generalInvoiceRequestEx.SetEsr(en9to16or27, "010001628", "12345620000188888888888888", "01-162-8", _
                                         IAddress, lPaymentPeriod)

'### define the biller of the invoice (required)
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)

'### define the provider of the medical data (required)
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)

'### define the health insurance (required in case of tiers payant)
IAddress.Initialize
bStatus = IAddress.SetCompany("Krankenkasse AG", "Sektion Basel", "")
bStatus = IAddress.SetPostal("Kassengraben 222", "", "4000", "Basel", "", "")
bStatus = generalInvoiceRequestEx.SetInsurance("2034567890222", IAddress)

'### define the patient (required)
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"), "", "")

'### define a referrer if any (optional)
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)

'### define the employer of the patient (optional)
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 treatment information (required)
Dim strAPID As String
strAPID = "12.3PID"
Dim strACID As String
strACID = "76569.456"
bStatus = generalInvoiceRequestEx.SetTreatment(strAPID,strACID,dTreatmentStart, dTreatmentEnd, _
                                               eCanton, eTreatmentReason)

'### add a diagnosis (optional)
bStatus = generalInvoiceRequestEx.AddDiagnosis(enDiagnosisCantonal, "G1", "")

'### add Tarmed data - the tarmed validator is needed and must be installed
Dim tarmedInputEx As TarmedInput
Set tarmedInputEx = generalInvoiceRequestEx.CreateTarmedInput

tarmedInputEx.ExternalFactor_MT = 1
tarmedInputEx.ExternalFactor_TT = 1

'### define the physician regarding the Tarmed usage 
bStatus = tarmedInputEx.SetPhysician(eMedicalRole, eBillingRole, strEanProvider, _
                                     strEanResponsible)

'### define the patient regarding the Tarmed usage 
bStatus = tarmedInputEx.SetPatient(dBirthdate, eSex)

'### define the treatment regarding the Tarmed usage 
Dim strEanSection As String
strEanSection = "7634567890000"
Dim eSettlement As SettlementType
eSettlement = enSettlementElectronic
bStatus = tarmedInputEx.SetTreatment(eCanton, eLaw, eTreatment, eSettlement, strEanSection)

'### add a Tarmed consultation service triple
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 (auto expansion of TP needs an installed validator)
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)

'### finalize the input
Dim dRoundDifference As Double
bStatus = generalInvoiceRequestEx.Finalize(dRoundDifference)

'### finally produce the XML infoset
Dim lXMLGenerationAttribute As Long
lXMLGenerationAttribute = 0
Dim lValidationError As Long
Dim lTimestamp As Long
Dim generalInvoiceResultEx As GENERALINVOICEREQUESTMANAGER440Lib.GeneralInvoiceResult

Dim strTmpFile As String
Dim strUsedSchema As String
bStatus = generalInvoiceRequestManagerEx.GetXML(lXMLGenerationAttribute, strTmpFile, _
                                                lValidationError, lTimestamp, _ 
                                                strUsedSchema, generalInvoiceResultEx)

'### save the XML infoset
Dim strTargetFile As String
strTargetFile = "GeneralInvoiceRequestExample.xml"
FileCopy strTmpFile, strTargetFile


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

Exit Sub

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

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

End Sub