Imports patientrx.fclsRegisterPatient
Imports System.Security.Cryptography.X509Certificates
Imports System.Net.Security
Imports System.Security.Policy.Zone
Imports System.Net

Public Class fclsRegisterPatient

Public Function MyCertValidationCb(ByVal sender As Object, ByVal certificate As X509Certificate, ByVal chain As X509Chain, ByVal sslPolicyErrors As SslPolicyErrors) As Boolean
If sslPolicyErrors = System.Net.Security.SslPolicyErrors.RemoteCertificateChainErrors Then
'WindowsEventLogger.LogMessageWarning((cName & ": Remote Certificate Chain Error") + Constants.vbNewLine + c_url)
Return True
ElseIf sslPolicyErrors = sslPolicyErrors.RemoteCertificateNameMismatch Then
Dim z As System.Security.Policy.Zone = Nothing
z = System.Security.Policy.Zone.CreateFromUrl(DirectCast(sender, HttpWebRequest).RequestUri.ToString())
If (z.SecurityZone = System.Security.SecurityZone.Intranet Or z.SecurityZone = System.Security.SecurityZone.MyComputer) Then
Return True
Else
'WindowsEventLogger.LogMessageWarning((cName & ": Remote Certificate Name Mismatch") + Constants.vbNewLine + c_url)
Return False
End If
ElseIf sslPolicyErrors = sslPolicyErrors.RemoteCertificateNotAvailable Then
'WindowsEventLogger.LogMessageWarning((cName & ": Remote Certificate not available") + Constants.vbNewLine + c_url)
Return False
ElseIf sslPolicyErrors = sslPolicyErrors.None Then
Return True
End If
End Function

Private Sub fclsRegisterPatient_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

ServicePointManager.ServerCertificateValidationCallback = New RemoteCertificateValidationCallback(AddressOf MyCertValidationCb)

 

' Dim WS As New com.h2hdigitalrx.www.DigitalRxIntegrator

' Dim ws As New com.h2hdigitalrx.wwwOld.DigitalRxIntegrator (the old web reference -renamed to old-BT-05/22/09)
Dim ws As New drx.DigitalRxIntegrator

Dim PatientInfo As String

Dim response As String

' We need a text file to store Patient ID
Dim FILE_NAME As String = "C:\om8\work\DRXPTID.txt"

Dim strPatientID As String

Dim strFirstPositionString As String
Dim strSecondPositionString As String
Dim strIsolateBBXPatientID As String

' Dim patient As String

' WS.registerPatient(patient)

PatientInfo = "<patientRegistration><hostSystemId>DR_JOE_1</hostSystemId><registerPatient><patientInfo><hostSystemPatientId>MICH00000011</hostSystemPatientId><namePrefix/><firstName>BOB</firstName><lastName>THOMAS</lastName><nameSuffix> </nameSuffix><birthDate>1966-10-01</birthDate><sex>M</sex><patientAddress><hostSystemAddressId>318</hostSystemAddressId><addressLine1>123 TEST STREET</addressLine1><city>CLINTON TWP.</city><stateCode>MI</stateCode><zipCode>48038</zipCode><country>US</country><addressType>OFFICE</addressType><primaryFlag>1</primaryFlag></patientAddress><patientContact><contactType>HP</contactType><contactTypeInput>(941)555-1212</contactTypeInput></patientContact></patientInfo><hostSystemPhysicianId>C0DTY</hostSystemPhysicianId></registerPatient></patientRegistration>"
' PatientInfo = Command()

' String function to isolate <hostSystemPatientId>

 

strFirstPositionString = PatientInfo.IndexOf("<hostSystemPatientId>")

 

strIsolateBBXPatientID = PatientInfo.Remove(0, strFirstPositionString + 21)

' MsgBox(strIsolateBBXPatientID)

strSecondPositionString = strIsolateBBXPatientID.IndexOf("</hostSystemPatientId>")

strIsolateBBXPatientID = strIsolateBBXPatientID.Remove(strSecondPositionString)

'MsgBox(strIsolateBBXPatientID)

ws.Url = "https://partners.h2hdigitalrx.com/service/DigitalRxP2PIntegrator" ' Old Web Server Address BT-01/26/09
'ws.Url = "https://partners.h2hdigitalrx.com/service/DigitalRxP2PIntegrator" ' Old Web Server Address BT-01/26/09 TESTING

'ws.Url = "https://www.h2hdigitalrx.com/service/DigitalRxP2PIntegrator" ' For Production

 

ws.registerPatient(PatientInfo)

 

' MessageBox.Show(WS.registerPatient("DR_JOE_1"))

 

response = ws.registerPatient(PatientInfo)

' Write the text file

'MsgBox(response)

If System.IO.File.Exists(FILE_NAME) = True Then
Dim objWriter As New System.IO.StreamWriter(FILE_NAME)

' Remove "SUCCESS" from the Patient ID

strPatientID = response.Remove(0, 8)

' MsgBox(strPatientID)

objWriter.Write(strIsolateBBXPatientID & "," & strPatientID)
objWriter.Close()
' MsgBox("Text written to file")
Else
' MsgBox("File Does Not Exist")
End If

' MsgBox(response) 'Comment out, so program executes without operator interaction - BT-01/21/09

Me.Dispose()

 

 

 

 

 

 

 

 

End Sub
End Class