VB code snippet for using the generalFormRequestManager


Private Sub Launch_Click()


On Error GoTo Err_Trap

Dim bStatus As Boolean

Dim formRequestManagerEx As GENERALFORMREQUESTMANAGER430Lib.GeneralFormRequestManager
Set formRequestManagerEx = New GENERALFORMREQUESTMANAGER430Lib.GeneralFormRequestManager

Dim formRequestEx As GENERALFORMREQUESTMANAGER430Lib.GeneralFormRequest
Dim formResultEx As GENERALFORMREQUESTMANAGER430Lib.GeneralFormResult

'### set module language to german
formRequestManagerEx.ModuleLanguage = enGerman

'### load an example form
bStatus = formRequestManagerEx.LoadPDF("medforms.30.40.300.5050", formRequestEx, formResultEx)


'### set addresses
Dim IAddress As GENERALFORMREQUESTMANAGER430Lib.Address
Set IAddress = formRequestEx.CreateAddress
Dim eAddressRole As AddressRoleType
Dim strAddressName As String
Dim lIndex As Long
Dim lMaxOccurs As Long
Dim eIsDefined As GENERALFORMREQUESTMANAGER430Lib.YesNoType

Dim bHasAddress, bFirst As Boolean
bHasAddress = True
bFirst = True


While bHasAddress
    If bFirst Then
            bStatus = formRequestEx.GetFirstAddressRole(eAddressRole, strAddressName, lIndex, _
                                                        lMaxOccurs, eIsDefined)
            bFirst = False
    Else
            bStatus = formRequestEx.GetNextAddressRole(eAddressRole, strAddressName, lIndex, _
                                                       lMaxOccurs, eIsDefined)
    End If
    If bStatus Then
        '### set the producer
        If eAddressRole = enAddressRoleProducer Then
            IAddress.Initialize
            bStatus = IAddress.SetCompany("Gruppenpraxis XY", "", "")
            bStatus = IAddress.SetPostal("Arztgasse 17b5", "", "4000", "Basel", "BS", "")
            bStatus = formRequestEx.AddAddress(strAddressName, "2000000110000", "", "", "speciality", IAddress)
        End If
        '### set the consumer
        If eAddressRole = enAddressRoleConsumer Then
            IAddress.Initialize
            bStatus = IAddress.SetCompany("Krankenkasse AG", "Sektion Basel", "")
            bStatus = IAddress.SetPostal("Kassengraben 222", "", "4000", "Basel", "", "")
            bStatus = formRequestEx.AddAddress(strAddressName, "2034567890222", "", "", "", IAddress)
        End If
        '### set the provider
        If eAddressRole = enAddressRoleProvider Then
            IAddress.Initialize
            bStatus = IAddress.SetPerson("Aerztin", "Patricia", "Frau", "Dr. med.", "")
            bStatus = IAddress.SetPostal("Arztgasse 17b5", "", "4000", "Basel", "BS", "")
            bStatus = formRequestEx.AddAddress(strAddressName, "2000000000000", "", "", "speciality", IAddress)
        End If
        '### set the patient
        If eAddressRole = enAddressRolePatient Then
            IAddress.Initialize
            bStatus = IAddress.SetPerson("Muster", "Peter", "Herr", "", "c/o Mieter Karl")
            bStatus = IAddress.SetPostal("Musterstrasse 5", "", "7304", "Maienfeld", "", "")
            bStatus = formRequestEx.SetPatient(strAddressName, enMale, DateValue("1940-6-25"), "", IAddress)
        End If
    Else
        bHasAddress = False
    End If
Wend




'### add a diagnosis
Dim eStructRole As GENERALFORMREQUESTMANAGER430Lib.StructRoleType
Dim strStructName As String
Dim bHasStruct As Boolean
Dim strConstrained As String

bHasStruct = True
bFirst = True

While bHasStruct
    If bFirst Then
        bStatus = formRequestEx.GetFirstStructRole(eStructRole, strStructName, lIndex, lMaxOccurs, _
                                                   eIsDefined, strConstrained)
        bFirst = False
        
    Else
        bStatus = formRequestEx.GetNextStructRole(eStructRole, strStructName, lIndex, lMaxOccurs, _
                                                  eIsDefined, strConstrained)
    End If
    If bStatus Then
        If eStructRole = enStructRoleDiagnosis Then
            bStatus = formRequestEx.AddDiagnosis(strStructName, enDiagnosisFreeText, "n/a", "unknown virus")
            bHasStruct = False
        End If
    Else
        bHasStruct = False
    End If
Wend


'### set transport
bStatus = formRequestEx.SetTransport("2000000110000", "", "", "", "2034567890222", "")

'### set request
bStatus = formRequestEx.SetRequest(enRolePhysician, enPlacePractice, "", enNo, enNo)


'### set form
Dim dRequestFormDate As Date
dRequestFormDate = DateValue("2011-09-20")
Dim strRequestFormID As String
strRequestFormID = "internal-id"
Dim lRequestTimestamp As Long
lRequestTimetamp = 11111111

bStatus = formRequestEx.SetForm(strRequestFormID, dRequestFormDate, lRequestTimestamp)

'###
Dim lTotalVars As Long
Dim lUndefVars As Long
Dim strPDFFile As String

'### produce an xml
Dim lXMLGenerationAttributes As Long
lXMLGenerationAttributes = 0
Dim strOutputXml As String
Dim lValidationError As Long
Dim lTimestamp As Long


bStatus = formRequestManagerEx.GetXML(lXMLGenerationAttributes, enYes, strOutputXml, lValidationError, _
                                      lTimestamp)
If bStatus Then
Dim strTargetFile As String
    strTargetFile = "d:\TestXML.xml"
    FileCopy strOutputXml, strTargetFile
End If

Exit Sub

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

'### relase resources

End Sub