The ATL COM module generalInvoiceRequest is capable of
generating electronic and printed invoices & reminders
generating electronic and printed invoices & reminders
Code snippets for using the generalInvoiceRequestManager
Private Sub GeneralInvoiceRequestExampleButton_Click()
On Error GoTo Err_Trap
Dim bStatus As Boolean
'### init variables
Dim strFrom As String
strFrom = "2001001302112"
Dim strVia As String
strVia = "2001000012345"
Dim strTo As String
strTo = "2034567890000"
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("2017-01-31")
Dim dTreatmentStart As Date
dTreatmentStart = DateValue("2017-01-01")
Dim strPatientInsID As String
strPatientInsID = "123.45.678-012"
Dim eTreatmentReason As TreatmentReasonType
eTreatmentReason = enDisease
Dim eTreatmentType As TreatmentType
eTreatmentType = enAmbulatory
Dim eMedicalRole As MedicalRoleType
eMedicalRole = enMedicalRoleSelfEmployed
Dim eBillingRole As BillingRoleType
eBillingRole = enBillingRoleBoth
Dim strEanProvider As String
strEanProvider = "2034567890111"
Dim strEanResponsible As String
strEanResponsible = "2034567890333"
'### create the main GeneralInvoiceRequestManager interface
Dim generalInvoiceRequestManagerEx As GENERALINVOICEREQUESTMANAGER450Lib.GeneralInvoiceRequestManager
Set generalInvoiceRequestManagerEx = New GeneralInvoiceRequestManager
'### generate the dependend GeneralInvoiceRequest interface (allows to input data)
Dim generalInvoiceRequestEx As GENERALINVOICEREQUESTMANAGER450Lib.GeneralInvoiceRequest
Set generalInvoiceRequestEx = generalInvoiceRequestManagerEx.GeneralInvoiceRequest
'### start the input of data
generalInvoiceRequestEx.Initialize(enGerman)
'### generate some routing/transport as well as some identifying data (required for XML only)
bStatus = generalInvoiceRequestEx.SetTransport(strFrom, "", "", strVia, strTo, "")
bStatus = generalInvoiceRequestEx.SetPackage("GeneralInvoiceRequestExample", 10001, 4, "sumex1")
'### set processing instruction regarding printing at the intermediate's side (required for XML only)
bStatus = generalInvoiceRequestEx.SetProcessing(enNo, enNo, "")
'###############################################################################
'### start with the invoice relevant data, followed by the various address data
'###############################################################################
'### set data triple of the invoice (required)
bStatus = generalInvoiceRequestEx.SetRequest(eRole, ePlace, "", enNo, enNo, "some optional remark")
'### set the tiers mode (TG or TP) (required)
bStatus = generalInvoiceRequestEx.SetTiers(enTiersGarant, "", 0.0)
'### set invoice related data (required)
bStatus = generalInvoiceRequestEx.SetInvoice("InvoiceID20170612", dTreatmentEnd, 0)
'### set the applicable law (required)
bStatus = generalInvoiceRequestEx.SetLaw(enKVG, 0, "", strPatientInsID)
'### create an address interface that is need to add all the following addresses
'### do not forget to initialize the IAddress interface befor using it
Dim addressEx As GENERALINVOICEREQUESTMANAGER450Lib.Address
Set addressEx = generalInvoiceRequestEx.CreateAddress
'### define the bank address and the corresponding esr information (required)
'### creditorAddress is not set and thus the biller address is used automatically
addressEx.Initialize()
bStatus = addressEx.SetCompany("Bank AG", "Abteilung VESR", "")
bStatus = addressEx.SetPostal("Bankstrasse 11", "", "4002", "Basel", "", "")
Dim lPaymentPeriod As Long
lPaymentPeriod = 25
bStatus = generalInvoiceRequestEx.SetEsr(en9to16or27, "010001628", "12345620000188888888888888", _
"01-162-8", addressEx,Nothing, lPaymentPeriod)
'### define the biller of the invoice (required)
'### note that phone, fax and online data are optional
addressEx.Initialize
bStatus = addressEx.SetCompany("Biller AG", "Abteilung Inkasso", "")
bStatus = addressEx.SetPostal("Billerweg 128", "", "4414", "Frenkendorf", "", "")
bStatus = addressEx.AddPhone("956 99 00", "061", "", "")
bStatus = addressEx.SetFax("956 99 10", "061", "+41", "")
bStatus = addressEx.SetOnline("info@biller.ch", "")
bStatus = generalInvoiceRequestEx.SetBiller("2011234567890", "H-1211-11", "", "", addressEx)
'### define the provider of the medical data (required)
'### note that only the required parts are defined here
addressEx.Initialize
bStatus = addressEx.SetPerson("Aerztin", "Patricia", "Frau", "Dr. med.", "")
bStatus = addressEx.SetPostal("Arztgasse 17b5", "", "4000", "Basel", "", "")
bStatus = generalInvoiceRequestEx.SetProvider(strEanProvider,"P-1234-56","", _
"FMH Allgemeinmedizin", addressEx)
'### define the health insurance (required in case of tiers payant only)
addressEx.Initialize
bStatus = addressEx.SetCompany("Krankenkasse AG", "Sektion Basel", "")
bStatus = addressEx.SetPostal("Kassengraben 222", "", "4000", "Basel", "", "")
bStatus = generalInvoiceRequestEx.SetInsurance("2034567890222", addressEx)
'### define the patient (required)
'### note that more data are needed here (sex, birthdate,ssn). data from the insurance
'### card can be supplied as well
addressEx.Initialize
bStatus = addressEx.SetPerson("Muster", "Peter", "Herr", "", "c/o Mieter Karl")
bStatus = addressEx.SetPostal("Musterstrasse 5", "", "7304", "Maienfeld", "", "")
bStatus = generalInvoiceRequestEx.SetPatient(eSex, dBirthdate, "756.1234.5678.90", addressEx)
bStatus = generalInvoiceRequestEx.SetCard("12345678901234567890", DateValue("2016-12-31"), _
DateValue("2016-12-31"), "", "")
'### define a referrer if any (optional)
addressEx.Initialize
bStatus = addressEx.SetPerson("Ueberweiser", "Herbert", "Herr", "Dr. med.", "")
bStatus = addressEx.SetPostal("Referrerstrasse 11", "", "5000", "Aarau", "", "")
bStatus = generalInvoiceRequestEx.SetReferrer("2034567890333", "R-2345-67", "", "", addressEx)
'### define the employer of the patient (optional)
addressEx.Initialize
bStatus = addressEx.SetCompany("Arbeitgeber AG", "R&D", "")
bStatus = addressEx.SetPostal("Arbeitsplatz 3-5", "", "4410", "Liestal", "BL", "")
bStatus = generalInvoiceRequestEx.SetEmployer("7600123456789", "CHE-108.791.452", addressEx)
'###############################################################################
'### define some treatment data for an ambulatory case and supply a drug service
'### and a Tarmed consultation
'###############################################################################
'### set treatment information (required)
bStatus = generalInvoiceRequestEx.SetTreatment("","",dTreatmentStart, dTreatmentEnd, eCanton, _
eTreatmentType, eTreatmentReason,0)
'### add a diagnosis (optional)
bStatus = generalInvoiceRequestEx.AddDiagnosis(enDiagnosisCantonal, "G1", "Einfacher Infekt")
'### add a drug service (auto expansion of TP needs an installed validator)
Dim lID as Long
bStatus = generalInvoiceRequestEx.AddService("402", "7680573380018", "", _
1, 1, _
dTreatmentStart, 0, _
strEanProvider, strEanResponsible, _
"Co Amoxi Mepha, Disp Tabl 625 mg, 10 Stk", 27.20, _
1, 1, 27.20, 0, _
enObligationAutomatic, "", _
"", enYes, 0, _
lID)
'###############################################################################
'### add ServiceExInput data - the tarmed validator is required here and must be
'### installed. Furthermore to input services via the AddServiceEx method, the
'### auxiliary interface ServiceExInput must be used
'###############################################################################
Dim serviceInputEx As ServiceExInput
Set serviceInputEx = generalInvoiceRequestEx.CreateServiceExInput("001")
'### define the various data for the tarmed validation later on - cf tarmedValidator usage
serviceInputEx.ExternalFactor_MT = 1
serviceInputEx.ExternalFactor_TT = 1
bStatus = serviceInputEx.SetPhysician(eMedicalRole,eBillingRole,strEanProvider,strEanResponsible)
bStatus = serviceInputEx.SetPatient(dBirthdate, eSex)
Dim strEanSection As String
strEanSection = "7634567890000"
Dim eSettlement As SettlementType
eSettlement = enSettlementElectronic
bStatus = serviceInputEx.SetTreatment(eCanton, eLaw, eTreatmentType, eSettlement, strEanSection)
'### add a Tarmed consultation service triple. Note that TP and service text are auto expaned
'### by the validator based on the remaining input data
Dim lSession As Long
lSession = 1
Dim lStatus As Long
bStatus = generalInvoiceRequestEx.AddServiceEx(serviceInputEx, "001", "00.0010", "", _
1, lSession, _
dTreatmentStart, dTreatmentStart, _
enSideNone, "", _
0, 0.92, 1, 0, _
0, 0.92, 1, 0, _
0, 0, _
enObligationAutomatic, "", _
0, "", enNo, 0, _
lID)
bStatus = generalInvoiceRequestEx.AddServiceEx(serviceInputEx, "001", "00.0020", "00.0010", _
1, lSession, _
dTreatmentStart, 0,_
enSideNone, "", _
0, 0.92, 1, 0, _
0, 0.92, 1, 0, _
0, 0, _
enObligationAutomatic, "", _
0, "", enNo, 0, _
lID)
bStatus = generalInvoiceRequestEx.AddServiceEx(serviceInputEx, "001", "00.0030", "00.0010", _
1, lSession, _
dTreatmentStart, 0, _
enSideNone, "", _
0, 0.92, 1, 0, _
0, 0.92, 1, 0, _
0, 0, _
enObligationAutomatic, "", _
0, "", enNo, 0, _
lID)
'### finalize the input
Dim dRoundDifference As Double
bStatus = generalInvoiceRequestEx.Finalize(dRoundDifference)
'### preview the invoice out as defined by the data
Dim lTimestamp As Interger
Dim generalInvoiceResultEx As GENERALINVOICEREQUESTMANAGER450Lib.GeneralInvoiceResult
bStatus = generalInvoiceRequestManagerEx.Print("",0,enYes,enYes,enNo, _
"",lTimestamp,generalInvoiceResultEx)
Set generalInvoiceResultEx = Nothing
'### finally produce the XML infoset
'### note that the interface generalInvoiceResultEx is returned by the method
'### if the call was successful - it must not be created!
Dim lGenerationAttribute As Long
lGenerationAttribute = 0
Dim lValidationError As Long
Dim strXMLFile As String
Dim strUsedXSDSchema As String
bStatus = generalInvoiceRequestManagerEx.GetXML(lGenerationAttribute, strXMLFile, lValidationError, _
lTimestamp, strUsedXSDSchema, generalInvoiceResultEx)
'### copy the XML infoset away
Dim strTargetFile As String
strTargetFile = "C:\\GeneralInvoiceRequestExample.xml"
FileCopy strXMLFile, strTargetFile
'### relase all resources
Set serviceInputEx = Nothing
Set addressEx = 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)
'### release all resources
Set serviceInputEx = Nothing
Set addressEx = Nothing
Set generalInvoiceResultEx = Nothing
Set generalInvoiceRequestEx = Nothing
Set generalInvoiceRequestManagerEx = Nothing
End Sub
private void generalInvoiceRequestExampleButton_Click()
{
ServiceExInput serviceInputEx;
GENERALINVOICEREQUESTMANAGER450Lib.Address addressEx;
GENERALINVOICEREQUESTMANAGER450Lib.GeneralInvoiceRequest generalInvoiceRequestEx;
GENERALINVOICEREQUESTMANAGER450Lib.GeneralInvoiceRequestManager generalInvoiceRequestManagerEx;
GENERALINVOICEREQUESTMANAGER450Lib.GeneralInvoiceResult generalInvoiceResultEx;
try
{
bool bStatus;
// ### init variables
string strFrom = "2001001302112";
string strVia = "2001000012345";
string strTo = "2034567890000";
DateTime dBirthdate = DateTime.ParseExact("1964-02-28", "yyyy-MM-dd",
System.Globalization.CultureInfo.InvariantCulture);
SexType eSex = SexType.enMale;
CantonType eCanton = CantonType.enBS;
LawType eLaw = LawType.enKVG;
TreatmentType eTreatType = TreatmentType.enAmbulatory;
RoleType eRole = RoleType.enRolePhysician;
PlaceType ePlace = PlaceType.enPlacePractice;
string eTitle = "";
DateTime dTreatmentEnd = DateTime.ParseExact("2017-01-31", "yyyy-MM-dd",
System.Globalization.CultureInfo.InvariantCulture);
DateTime dTreatmentStart = DateTime.ParseExact("2017-01-01", "yyyy-MM-dd",
System.Globalization.CultureInfo.InvariantCulture);
string strPatientInsID = "123.45.678-012";
TreatmentReasonType eTreatmentReason = TreatmentReasonType.enDisease;
TreatmentType eTreatmentType = TreatmentType.enAmbulatory;
MedicalRoleType eMedicalRole = MedicalRoleType.enMedicalRoleSelfEmployed;
BillingRoleType eBillingRole = BillingRoleType.enBillingRoleBoth;
string strEanProvider = "2034567890111";
string strEanResponsible = "2034567890333";
// ### create the main GeneralInvoiceRequestManager interface
generalInvoiceRequestManagerEx = new GeneralInvoiceRequestManager();
// ### generate the dependend GeneralInvoiceRequest interface (allows to input data)
generalInvoiceRequestEx = generalInvoiceRequestManagerEx.GeneralInvoiceRequest;
// ### start the input of data
generalInvoiceRequestEx.Initialize(LanguageType.enGerman);
// ### generate some routing/transport as well as some identifying data (required for XML only)
bStatus = generalInvoiceRequestEx.SetTransport(strFrom, "", "", strVia, strTo, "");
bStatus = generalInvoiceRequestEx.SetPackage("GeneralInvoiceRequestExample", 10001, 4, "sumex1");
// ### set processing instruction regarding printing at the intermediate's side (required for XML only)
bStatus = generalInvoiceRequestEx.SetProcessing(YesNoType.enYes, YesNoType.enNo, "");
// ###############################################################################
// ### start with the invoice relevant data, followed by the various address data
// ###############################################################################
// ### set data triple of the invoice (required)
bStatus = generalInvoiceRequestEx.SetRequest(eRole, ePlace, "", YesNoType.enNo, YesNoType.enNo,
"some optional remark");
// ### set the tiers mode (TG or TP) (required)
bStatus = generalInvoiceRequestEx.SetTiers(TiersModeType.enTiersGarant, "", 0);
// ### set invoice related data (required)
bStatus = generalInvoiceRequestEx.SetInvoice("InvoiceID20170612", dTreatmentEnd, 0);
// ### set the applicable law (required)
bStatus = generalInvoiceRequestEx.SetLaw(LawType.enKVG, DateTime.MinValue, "", strPatientInsID);
// ### create an address interface that is need to add all the following addresses
// ### do not forget to initialize the IAddress interface befor using it
addressEx = generalInvoiceRequestEx.CreateAddress;
// ### define the bank address and the corresponding esr information (required)
// ### creditorAddress is not set and thus the biller address is used automatically
addressEx.Initialize();
bStatus = addressEx.SetCompany("Bank AG", "Abteilung VESR", "");
bStatus = addressEx.SetPostal("Bankstrasse 11", "", "4002", "Basel", "", "");
int lPaymentPeriod = 25;
bStatus = generalInvoiceRequestEx.SetEsr(EsrType.en9to16or27, "010001628", "12345620000188888888888888",
"01-162-8", addressEx, null, lPaymentPeriod);
// ### define the biller of the invoice (required)
// ### note that phone, fax and online data are optional
addressEx.Initialize();
bStatus = addressEx.SetCompany("Biller AG", "Abteilung Inkasso", "");
bStatus = addressEx.SetPostal("Billerweg 128", "", "4414", "Frenkendorf", "", "");
bStatus = addressEx.AddPhone("956 99 00", "061", "", "");
bStatus = addressEx.SetFax("956 99 10", "061", "+41", "");
bStatus = addressEx.SetOnline("info@biller.ch", "");
bStatus = generalInvoiceRequestEx.SetBiller("2011234567890", "H-1211-11", "", "", addressEx);
// ### define the provider of the medical data (required)
// ### note that only the required parts are defined here
addressEx.Initialize();
bStatus = addressEx.SetPerson("Aerztin", "Patricia", "Frau", "Dr. med.", "");
bStatus = addressEx.SetPostal("Arztgasse 17b5", "", "4000", "Basel", "", "");
bStatus = generalInvoiceRequestEx.SetProvider(strEanProvider, "P-1234-56", "42042",
"FMH Innere Medizin", addressEx);
// ### define the health insurance (required in case of tiers payant only)
addressEx.Initialize();
bStatus = addressEx.SetCompany("Krankenkasse AG", "Sektion Basel", "");
bStatus = addressEx.SetPostal("Kassengraben 222", "", "4000", "Basel", "", "");
bStatus = generalInvoiceRequestEx.SetInsurance("2034567890222", addressEx);
// ### define the patient (required)
// ### note that more data are needed here (sex, birthdate,ssn) as well as insurance card data
addressEx.Initialize();
bStatus = addressEx.SetPerson("Muster", "Peter", "Herr", "", "c/o Mieter Karl");
bStatus = addressEx.SetPostal("Musterstrasse 5", "", "7304", "Maienfeld", "", "");
bStatus = generalInvoiceRequestEx.SetPatient(eSex, dBirthdate, "756.1234.5678.90", addressEx);
bStatus = generalInvoiceRequestEx.SetCard("12345678901234567890", DateTime.ParseExact("2016-12-31",
"yyyy-MM-dd",
System.Globalization.CultureInfo.InvariantCulture),
DateTime.ParseExact("2016-12-31", "yyyy-MM-dd",
System.Globalization.CultureInfo.InvariantCulture),
"", "");
// ### define a referrer if any (optional)
addressEx.Initialize();
bStatus = addressEx.SetPerson("Ueberweiser", "Herbert", "Herr", "Dr. med.", "");
bStatus = addressEx.SetPostal("Referrerstrasse 11", "", "5000", "Aarau", "", "");
bStatus = generalInvoiceRequestEx.SetReferrer("2034567890333", "R-2345-67", "", "", addressEx);
// ### define the employer of the patient (optional)
addressEx.Initialize();
bStatus = addressEx.SetCompany("Arbeitgeber AG", "R&D", "");
bStatus = addressEx.SetPostal("Arbeitsplatz 3-5", "", "4410", "Liestal", "BL", "");
bStatus = generalInvoiceRequestEx.SetEmployer("7600123456789", "CHE-108.791.452", addressEx);
// ###############################################################################
// ### define some treatment data for an ambulatory case and supply a drug service
// ### and a Tarmed consultation
// ###############################################################################
// ### set treatment information (required)
bStatus = generalInvoiceRequestEx.SetTreatment("", "", dTreatmentStart, dTreatmentEnd,
eCanton, eTreatmentType, eTreatmentReason,
DateTime.MinValue);
// ### add a diagnosis (optional)
bStatus = generalInvoiceRequestEx.AddDiagnosis(DiagnosisType.enDiagnosisCantonal, "G1", "");
int lID;
// ### add a drug service (auto expansion of TP needs an installed validator)
bStatus = generalInvoiceRequestEx.AddService("402", "7680573380018", "",
1, 1,
dTreatmentStart, DateTime.MinValue,
strEanProvider, strEanResponsible,
"Co Amoxi Mepha, Disp Tabl 625 mg, 10 Stk", 27.20,
1, 1, 0, 0,
ObligationType.enObligationAutomatic, "",
"", YesNoType.enNo, 0,
out lID);
// ###############################################################################
// ### add ServiceExInput data - the tarmed validator is required here and must be
// ### installed. Furthermore to input services via the AddServiceEx method, the
// ### auxiliary interface ServiceExInput must be used
// ###############################################################################
serviceInputEx = generalInvoiceRequestEx.get_CreateServiceExInput("001");
// ### define the various data for the tarmed validation later on - cf tarmedValidator usage
serviceInputEx.ExternalFactor_MT = 1;
serviceInputEx.ExternalFactor_TT = 1;
bStatus = serviceInputEx.SetPhysician(eMedicalRole,eBillingRole,strEanProvider,strEanResponsible);
bStatus = serviceInputEx.SetPatient(dBirthdate, eSex);
string strEanSection = "7634567890000";
SettlementType eSettlement = SettlementType.enSettlementElectronic;
bStatus = serviceInputEx.SetTreatment(eCanton, eLaw, eTreatmentType, eSettlement,strEanSection);
// ### add a Tarmed consultation service triple. Note that TP and service text are auto expaned
// ### by the validator based on the remaining input data
int lSession = 1;
int lStatus;
bStatus = generalInvoiceRequestEx.AddServiceEx(serviceInputEx, "001", "00.0010", "",
1, lSession,
dTreatmentStart, DateTime.MinValue,
SideType.enSideNone, "",
0, 0.92, 1, 0,
0, 0.92, 1, 0,
0, 0,
ObligationType.enObligationAutomatic, "",
0, "", YesNoType.enNo, 0,
out lID);
bStatus = generalInvoiceRequestEx.AddServiceEx(serviceInputEx, "001", "00.0020", "00.0010",
1, lSession,
dTreatmentStart, DateTime.MinValue,
SideType.enSideNone, "",
0, 0.92, 1, 0,
0, 0.92, 1, 0,
0, 0,
ObligationType.enObligationAutomatic, "",
0, "", YesNoType.enNo, 0,
out lID);
bStatus = generalInvoiceRequestEx.AddServiceEx(serviceInputEx, "001", "00.0030", "00.0010",
1, lSession,
dTreatmentStart, DateTime.MinValue,
SideType.enSideNone, "",
0, 0.92, 1, 0,
0, 0.92, 1, 0,
0, 0,
ObligationType.enObligationAutomatic, "",
0, "", YesNoType.enNo, 0,
out lID);
// ### finalize the input
double dRoundDifference;
bStatus = generalInvoiceRequestEx.Finalize(out dRoundDifference);
// ### finally produce the XML infoset
// ### note that the interface generalInvoiceResultEx is returned by the method
// ### if the call was successful - it must not be created!
int lGenerationAttribute = 0;
int lValidationError;
int lTimestamp = 0;
string strXMLFile;
string strUsedXSDSchema;
bStatus = generalInvoiceRequestManagerEx.GetXML(lGenerationAttribute, out strXMLFile,
out lValidationError, ref lTimestamp,
out strUsedXSDSchema, out generalInvoiceResultEx);
// ### copy the XML infoset away
string strTargetFile = "GeneralInvoiceRequestExample.xml";
System.IO.File.Copy(strXMLFile, strTargetFile);
}
catch (Exception ex)
{
MessageBox.Show("Opps! Error " + ex.ToString(), "OK");
}
finally
{
// ### relase all resources
serviceInputEx = null;
addressEx = null;
generalInvoiceResultEx = null;
generalInvoiceRequestEx = null;
generalInvoiceRequestManagerEx = null;
}
}