Dear Code Master
Blessed day to you all, and i believe the question meet you all in good health. i have a challange with my code and i really need your assistance.
The issue is that i develop an application that generate patient level records in XML format. some of the facilities that use the application have patient greater than 10,000.
Now i want to read the data below from it
ID
FacID
FacName
DOB
Sex
Age
ArtStartDate
ArtVisit
Nxt_App_Date
Drug_Reg
VL_Result
VL_Date
TestCode
i wrote the code below to see if i can read through each XML file and to get the above fields but i keep geting multiples record i thin the loops are the cause.
- Dim Enrol_idm As String = ""
-
- Dim xMLDirectory As String = Server.MapPath(String.Format("~/{0}/", "NDRExport"))
- If Not Directory.Exists(xMLDirectory) Then
-
- fillClient.Show("Create NDRExport Folder before using this utility")
- End If
-
-
-
-
- Dim xMLName() As String = Directory.GetFiles(xMLDirectory, "*.xml")
-
- Dim ID As String = ""
- Dim FacID As String = ""
- Dim FacName As String = ""
- Dim DOB As String = ""
- Dim Sex As String = ""
- Dim Age As String = ""
- Dim AgeA As Integer
- Dim AgeP As Integer
- Dim ArtStartDate As String = ""
- Dim ArtVisit As String = ""
- Dim Nxt_App_Date As String = ""
- Dim Drug_Reg As String = ""
- Dim VL_Result As String = ""
- Dim VL_Date As String = ""
- Dim TestCode As String = ""
-
- FC.Create_RADET_Table()
-
- For Each _xml As String In xMLName
- Using reader As XmlReader = XmlReader.Create(_xml)
- While reader.Read()
- Select Case reader.NodeType
- Case XmlNodeType.Element
- Select Case reader.Name
- Case "PatientIdentifier"
- ID = reader.ReadElementContentAsString()
- If ID = "" Then
- Exit While
- End If
-
- FacName = "Barau Dikko Specialist Hospital"
-
-
- FacID = "aQTk0pRk6eY"
- Case "PatientDateOfBirth"
- DOB = reader.ReadElementContentAsString()
- Case "PatientSexCode"
- Sex = reader.ReadElementContentAsString()
- Case = "PatientAge"
- Age = reader.ReadElementContentAsString()
- If Convert.ToInt16(Age) >= 14 Then
- AgeA = Convert.ToInt32(Age)
- Else
- AgeP = Convert.ToInt32(Age)
- End If
- Case = "ARTStartDate"
- ArtStartDate = reader.ReadElementContentAsString()
- Case = "VisitDate"
- ArtVisit = reader.ReadElementContentAsString()
- Case = "NextAppointmentDate"
- Nxt_App_Date = reader.ReadElementContentAsString()
- Case = "CodeDescTxt"
- Drug_Reg = reader.ReadElementContentAsString()
- Case = "ResultedTestDate"
- VL_Date = reader.ReadElementContentAsString()
- Case = "Code"
- TestCode = reader.ReadElementContentAsString()
- Case = "Value1"
- VL_Result = reader.ReadElementContentAsString()
-
- End Select
-
- If ID <> "" And DOB <> "" And Sex <> "" And Age <> "" Then
- If TestCode = "80" Then
- FC.Process_Insert(ID, FacID, FacName, Sex, DOB, AgeA, AgeP, ArtStartDate, ArtVisit, Nxt_App_Date, Drug_Reg, "", "", VL_Result, VL_Date)
- Else
- FC.Process_Insert1(ID, FacID, FacName, Sex, DOB, AgeA, AgeP, ArtStartDate, ArtVisit, Nxt_App_Date, Drug_Reg, "", "")
- End If
- End If
- End Select
- End While
- End Using
- Next
This is one of the Patient Xml file i try to read
please help me to modify my code above to read this xml.
Thank you all