Ir al contenido



Foto

Ayuda con XML con ListView, urgente! auxilio :(

#xml #ListView #Delphi7

Mejor respuesta MarCaribe , 02 julio 2019 - 05:24

Hola, pude solucionar esto..

si alguien tiene una mejor solucion y algo mas optima se la agradezco:


delphi
  1. procedure TForm1.btn1Click(Sender: TObject);
  2. var
  3. ANodo, nodo: IXMLNode;
  4. xmlDocum: TXMLDocument;
  5. i,j: Integer;
  6. aux: Boolean;
  7. begin
  8. lv1.Clear;
  9. xmlDocum:= TXMLDocument.Create(Self);
  10. xmlDocum.XML.Text:= XMLStringToWideString(ConvertirCaracteresNoValidos(
  11. StringReplace(mmo1.Lines.Text, '"utf-8"', '"iso-8859-1"',
  12. [rfReplaceAll, rfIgnoreCase])));
  13. xmlDocum.DOMVendor:= OpenXMLFactory;
  14. xmlDocum.Active:= True;
  15. //validar si hay mas registros component2 y meter en un ciclo para que lea todos los estudios
  16. ANodo:= xmlDocum.DocumentElement.ChildNodes.FindNode('hl7:controlActProcess').ChildNodes.FindNode('hl7:subject').
  17. ChildNodes.FindNode('hl7:observationRequest').ChildNodes.FindNode('hl7:component2');//.ChildNodes.FindNode('hl7:observationRequest');
  18. nodo:=ANodo;
  19. //j:=0;
  20. repeat
  21. //with nodo.ChildNodes.FindNode('hl7:component2') do
  22. //j:=j+1;
  23. lv1.Items.Add.Caption:= VarToStr(nodo.ChildNodes['hl7:observationRequest'].ChildNodes['hl7:numExam'].Text);
  24. lv1.Items.Add.Caption:= VarToStr(nodo.ChildNodes['hl7:observationRequest'].ChildNodes['hl7:text'].Text);
  25. //SubItems.Add(VarToStr(nodo.ChildNodes['hl7:id'].Text));
  26. lv1.Items.Add.Caption:= VarToStr(nodo.ChildNodes['hl7:observationRequest'].ChildNodes['hl7:id'].GetAttributeNS('root',''));
  27. lv1.Items.Add.Caption:= VarToStr(nodo.ChildNodes['hl7:observationRequest'].ChildNodes['hl7:id'].GetAttributeNS('extension',''));
  28.  
  29. lv1.Items.Add.Caption:= VarToStr(nodo.ChildNodes['hl7:observationRequest'].ChildNodes['hl7:code'].GetAttributeNS('code',''));
  30. lv1.Items.Add.Caption:= VarToStr(nodo.ChildNodes['hl7:observationRequest'].ChildNodes['hl7:code'].GetAttributeNS('codeSystemName',''));
  31. lv1.Items.Add.Caption:= VarToStr(nodo.ChildNodes['hl7:observationRequest'].ChildNodes['hl7:code'].GetAttributeNS('displayName',''));
  32.  
  33. lv1.Items.Add.Caption:= VarToStr(nodo.ChildNodes['hl7:observationRequest'].ChildNodes['hl7:statusCode'].GetAttributeNS('code',''));
  34.  
  35. lv1.Items.Add.Caption:= VarToStr(nodo.ChildNodes['hl7:observationRequest'].ChildNodes['hl7:priorityCode'].GetAttributeNS('code',''));
  36. lv1.Items.Add.Caption:= VarToStr(nodo.ChildNodes['hl7:observationRequest'].ChildNodes['hl7:priorityCode'].GetAttributeNS('codeSystem',''));
  37. lv1.Items.Add.Caption:= VarToStr(nodo.ChildNodes['hl7:observationRequest'].ChildNodes['hl7:priorityCode'].GetAttributeNS('codeSystemName',''));
  38. lv1.Items.Add.Caption:= VarToStr(nodo.ChildNodes['hl7:observationRequest'].ChildNodes['hl7:priorityCode'].GetAttributeNS('displayName',''));
  39.  
  40. lv1.Items.Add.Caption:= VarToStr(nodo.ChildNodes['hl7:observationRequest'].ChildNodes['hl7:interpretationCode'].GetAttributeNS('nullFlavor',''));
  41. //SubItems.Add(VarToStr(nodo.ChildNodes['hl7:id'].GetAttributeNS('extension','')));
  42. //SubItems.Add(VarToStr(nodo.ChildNodes['hl7:text'].Text)); }
  43.  
  44. nodo:= nodo.NextSibling;
  45. until nodo= nil;
  46. //lv1.Items.Add.Caption:= VarToStr(j) + ' registros';
  47.  
  48. end;

Ir al mensaje completo


  • Por favor identifícate para responder
6 respuestas en este tema

#1 MarCaribe

MarCaribe

    Member

  • Miembros
  • PipPip
  • 34 mensajes

Escrito 29 junio 2019 - 03:48

Hola a todos,

 

Compañeros, solicito su ayuda para resolver y hacer funcionar un código que me lea los datos de un XML y los pase a un TListView en delphi 7, el tema es el siguiente...

 

me pasaron una trama XML para tratar unos datos, el equipo medico me envia de 5 a 10 registros, dependiendo lo que me envien, me manda varias tramas xml para ser tratadas, antes de tratar todas las tramas juntas busque de alguna manera poder leer una trama de xml de manera individual y no he podido con el problemilla.

 

OBSERVACIÓN, el formato de xml es nuevo para mi, no lo habia conocido antes y se me hace complejo tratarlo, por lo que voy a dejar un archivo para que puedan ver como es el formato del mismo.

 

Les adjunto lo que llevo hecho del código para tal objetivo, acepto todas las correcciones, ayudas y mejores soluciones posibles a la mía.

Estoy desesperada porque no me sale..., 

 

el programa se rompe en esta linea del codigo: 

"startItemNode:= xmlDocum.DocumentElement.ChildNodes.FindNode('hl7:POOR_IN200901UV').ChildNodes.First;;"   - linea 19

"Caption:= ANodo.ChildNodes['hl7:templateId'].Text;"   - linea 24

 

Adjunto archivo y codigo 


delphi
  1. procedure TForm1.btnDatosXMlClick(Sender: TObject);
  2. var
  3. xmlDocum: TXMLDocument;
  4. startItemNode: IXMLNode;
  5. ANodo, ANodoReceiver, ANodoSender, ANodocontrolActProcess: IXMLNode;
  6. subNodoDataCenter, subNodoSubject, subNodoExamenes: IXMLNode;
  7. begin
  8. lvDatosGenerales.Clear;
  9. lvDatosPactesAndExam.Clear;
  10. xmlDocum:= TXMLDocument.Create(Self);
  11. try
  12. xmlDocum.XML.Text:= XMLStringToWideString(ConvertirCaracteresNoValidos(
  13. StringReplace(mmo1.Lines.Text, '"utf-8"', '"iso-8859-1"',
  14. [rfReplaceAll, rfIgnoreCase])));
  15. xmlDocum.DOMVendor:= OpenXMLFactory;
  16.  
  17. xmlDocum.Active:= True;
  18. //nodos en datos generales
  19. //startItemNode:= xmlDocum.DocumentElement.ChildNodes.FindNode('hl7:POOR_IN200901UV').ChildNodes.First;
  20. ANodo:= startItemNode;
  21. repeat
  22. with lvDatosGenerales.Items.Add do
  23. begin
  24. Caption:= ANodo.ChildNodes['hl7:templateId'].Text;
  25. SubItems.Add(ANodo.ChildNodes['extension'].Text);
  26. SubItems.Add(ANodo.ChildNodes['assigningAuthorityName'].Text);
  27. ANodo.ChildNodes['hl7:id'].Text;
  28. SubItems.Add(ANodo.ChildNodes['root'].Text);
  29. SubItems.Add(ANodo.ChildNodes['extension'].Text);
  30. SubItems.Add(ANodo.ChildNodes['displayable'].Text);
  31. ANodo.ChildNodes['hl7:creationTime'].Text;
  32. SubItems.Add(ANodo.ChildNodes['value'].Text);
  33. ANodo.ChildNodes['hl7:versionCode'].Text;
  34. SubItems.Add(ANodo.ChildNodes['code'].Text);
  35. ANodo.ChildNodes['hl7:interactionId'].Text;
  36. SubItems.Add(ANodo.ChildNodes['root'].Text);
  37. SubItems.Add(ANodo.ChildNodes['extension'].Text);
  38. ANodo.ChildNodes['hl7:processingCode'].Text;
  39. SubItems.Add(ANodo.ChildNodes['code'].Text);
  40. ANodo.ChildNodes['hl7:processingModeCode'].Text;
  41. SubItems.Add(ANodo.ChildNodes['code'].Text);
  42. ANodo.ChildNodes['hl7:acceptAckCode'].Text;
  43. SubItems.Add(ANodo.ChildNodes['code'].Text);
  44. ANodo.ChildNodes['hl7:receiver'].Text;
  45. SubItems.Add(ANodo.ChildNodes['typeCode'].Text);
  46. ANodo.ChildNodes['hl7:receiver'].ChildNodes['hl7:device'].Text;
  47. SubItems.Add(ANodo.ChildNodes['classCode'].Text);
  48. SubItems.Add(ANodo.ChildNodes['determinerCode'].Text);
  49. //continuamos extrayendo el xml
  50. //nodo -> receiver <-
  51. ANodo:= xmlDocum.DocumentElement.ChildNodes.FindNode('hl7:receiver').ChildNodes.FindNode('hl7:device');
  52. ANodoReceiver:=ANodo;
  53. repeat
  54. with lvDatosGenerales.Items.Add do
  55. begin
  56. Caption:= ANodoReceiver.ChildNodes['hl7:id'].Text;
  57. SubItems.Add(ANodoReceiver.ChildNodes['root'].Text);
  58. SubItems.Add(ANodoReceiver.ChildNodes['extension'].Text);
  59. ANodoReceiver.ChildNodes['hl7:softwareName'].Text;
  60. SubItems.Add(ANodoReceiver.ChildNodes['displayName'].Text);
  61. end;
  62. until ANodoReceiver = nil;
  63.  
  64. ANodo.ChildNodes['hl7:sender'].Text;
  65. SubItems.Add(ANodo.ChildNodes['typeCode'].Text);
  66. ANodo.ChildNodes['hl7:sender'].ChildNodes['hl7:device'].Text;
  67. SubItems.Add(ANodo.ChildNodes['classCode'].Text);
  68. SubItems.Add(ANodo.ChildNodes['determinerCode'].Text);
  69.  
  70. //continuamos extrayendo el xml
  71. //nodo -> sender <-
  72. ANodo:= xmlDocum.DocumentElement.ChildNodes.FindNode('hl7:sender').ChildNodes.FindNode('hl7:device');
  73. ANodoSender:=ANodo;
  74. repeat
  75. with lvDatosGenerales.Items.Add do
  76. begin
  77. Caption:= ANodoSender.ChildNodes['hl7:id'].Text;
  78. SubItems.Add(ANodoSender.ChildNodes['root'].Text);
  79. SubItems.Add(ANodoSender.ChildNodes['extension'].Text);
  80. ANodoSender.ChildNodes['hl7:softwareName'].Text;
  81. SubItems.Add(ANodoSender.ChildNodes['displayName'].Text);
  82. end;
  83. until ANodoSender = nil;
  84.  
  85. ANodo.ChildNodes['hl7:controlActProcess'].Text;
  86. SubItems.Add(ANodo.ChildNodes['classCode'].Text);
  87. SubItems.Add(ANodo.ChildNodes['moodCode'].Text);
  88.  
  89. //continuamos extrayendo el xml
  90. //nodo -> controlActProcess <-
  91. ANodo:= xmlDocum.DocumentElement.ChildNodes.FindNode('hl7:controlActProcess');
  92. ANodocontrolActProcess:=ANodo;
  93. repeat
  94. with lvDatosGenerales.Items.Add do
  95. begin
  96. Caption:= ANodocontrolActProcess.ChildNodes['hl7:code'].Text;
  97. SubItems.Add(ANodocontrolActProcess.ChildNodes['code'].Text);
  98. SubItems.Add(ANodocontrolActProcess.ChildNodes['codeSystem'].Text);
  99. SubItems.Add(ANodocontrolActProcess.ChildNodes['codeSystemName'].Text);
  100. SubItems.Add(ANodocontrolActProcess.ChildNodes['displayName'].Text);
  101. ANodocontrolActProcess.ChildNodes['hl7:languageCode'].Text;
  102. SubItems.Add(ANodocontrolActProcess.ChildNodes['code'].Text);
  103. SubItems.Add(ANodocontrolActProcess.ChildNodes['codeSystem'].Text);
  104. SubItems.Add(ANodocontrolActProcess.ChildNodes['codeSystemName'].Text);
  105. SubItems.Add(ANodocontrolActProcess.ChildNodes['displayName'].Text);
  106. ANodocontrolActProcess.ChildNodes['hl7:dataEnterer'].Text;
  107. SubItems.Add(ANodocontrolActProcess.ChildNodes['contextControlCode'].Text);
  108. SubItems.Add(ANodocontrolActProcess.ChildNodes['typeCode'].Text);
  109.  
  110. //continuamos extrayendo el xml
  111. //nodo -> controlActProcess - dataEnterer <-
  112. ANodo:= xmlDocum.DocumentElement.ChildNodes.FindNode('hl7:controlActProcess').ChildNodes.FindNode('hl7:dataEntererdataEnterer');
  113. subNodoDataCenter:=ANodo;
  114. repeat
  115. with lvDatosPactesAndExam.Items.Add do
  116. begin
  117. Caption:= subNodoDataCenter.ChildNodes['hl7:assignedPerson'].Text;
  118. SubItems.Add(subNodoDataCenter.ChildNodes['hl7:id'].Text);
  119. SubItems.Add(subNodoDataCenter.ChildNodes['hl7:assignedPerson'].Text);
  120. SubItems.Add(subNodoDataCenter.ChildNodes['hl7:assignedPerson'].ChildNodes['hl7:name'].Text);
  121. SubItems.Add(subNodoDataCenter.ChildNodes['hl7:assignedPerson'].ChildNodes['hl7:name'].ChildNodes['hl7:given'].Text);
  122. SubItems.Add(subNodoDataCenter.ChildNodes['hl7:assignedPerson'].ChildNodes['hl7:name'].ChildNodes['hl7:family'].Text);
  123. end;
  124. until subNodoDataCenter = nil;
  125.  
  126. ANodocontrolActProcess.ChildNodes['hl7:subject'].Text;
  127. SubItems.Add(ANodocontrolActProcess.ChildNodes['typeCode'].Text);
  128. SubItems.Add(ANodocontrolActProcess.ChildNodes['contextConductionInd'].Text);
  129. ANodocontrolActProcess.ChildNodes['hl7:subject'].ChildNodes['hl7:observationRequest'].Text;
  130. SubItems.Add(subNodoSubject.ChildNodes['classCode'].Text);
  131. SubItems.Add(subNodoSubject.ChildNodes['moodCode'].Text);
  132. SubItems.Add(subNodoSubject.ChildNodes['negationInd'].Text);
  133.  
  134. //continuamos extrayendo el xml
  135. //nodo -> controlActProcess - subject <-
  136. ANodo:= xmlDocum.DocumentElement.ChildNodes.FindNode('hl7:controlActProcess').ChildNodes.FindNode('hl7:subject').ChildNodes.FindNode('hl7:observationRequest');
  137. subNodoSubject:=ANodo;
  138. repeat
  139. with lvDatosPactesAndExam.Items.Add do
  140. begin
  141. Caption:= subNodoSubject.ChildNodes['hl7:id'].Text;
  142. SubItems.Add(subNodoSubject.ChildNodes['root'].Text);
  143. SubItems.Add(subNodoSubject.ChildNodes['extension'].Text);
  144. subNodoSubject.ChildNodes['hl7:code'].Text;
  145. SubItems.Add(subNodoSubject.ChildNodes['code'].Text);
  146. SubItems.Add(subNodoSubject.ChildNodes['codeSystem'].Text);
  147. SubItems.Add(subNodoSubject.ChildNodes['codeSystemName'].Text);
  148. SubItems.Add(subNodoSubject.ChildNodes['displayName'].Text);
  149. subNodoSubject.ChildNodes['hl7:text'].Text;
  150. subNodoSubject.ChildNodes['hl7:statusCode'].Text;
  151. SubItems.Add(subNodoSubject.ChildNodes['code'].Text);
  152. subNodoSubject.ChildNodes['hl7:device'].Text;
  153. SubItems.Add(subNodoSubject.ChildNodes['typeCode'].Text);
  154. SubItems.Add(subNodoSubject.ChildNodes['contextControlCode'].Text);
  155. subNodoSubject.ChildNodes['hl7:device'].ChildNodes['hl7:assignedDevice'].Text;
  156. SubItems.Add(subNodoSubject.ChildNodes['classCode'].Text);
  157. subNodoSubject.ChildNodes['hl7:device'].ChildNodes['hl7:assignedDevice'].ChildNodes['hl7:id'].Text;
  158. SubItems.Add(subNodoSubject.ChildNodes['root'].Text);
  159. SubItems.Add(subNodoSubject.ChildNodes['extension'].Text);
  160. subNodoSubject.ChildNodes['hl7:device'].ChildNodes['hl7:assignedDevice'].ChildNodes['hl7:assignedDevice'].Text;
  161. SubItems.Add(subNodoSubject.ChildNodes['classCode'].Text);
  162. SubItems.Add(subNodoSubject.ChildNodes['determinerCode'].Text);
  163. subNodoSubject.ChildNodes['hl7:device'].ChildNodes['hl7:assignedDevice'].ChildNodes['hl7:assignedDevice'].ChildNodes['hl7:manufacturerModelName'].Text;
  164. SubItems.Add(subNodoSubject.ChildNodes['code'].Text);
  165. SubItems.Add(subNodoSubject.ChildNodes['displayName'].Text);
  166. subNodoSubject.ChildNodes['hl7:recordTarget'].Text;
  167. SubItems.Add(subNodoSubject.ChildNodes['typeCode'].Text);
  168. SubItems.Add(subNodoSubject.ChildNodes['contextControlCode'].Text);
  169. subNodoSubject.ChildNodes['hl7:recordTarget'].ChildNodes['hl7:patient'].Text;
  170. SubItems.Add(subNodoSubject.ChildNodes['classCode'].Text);
  171. subNodoSubject.ChildNodes['hl7:recordTarget'].ChildNodes['hl7:patient'].ChildNodes['hl7:id'].Text;
  172. SubItems.Add(subNodoSubject.ChildNodes['root'].Text);
  173. SubItems.Add(subNodoSubject.ChildNodes['extension'].Text);
  174. subNodoSubject.ChildNodes['hl7:recordTarget'].ChildNodes['hl7:patient'].ChildNodes['hl7:patientPerson'].Text;
  175. SubItems.Add(subNodoSubject.ChildNodes['classCode'].Text);
  176. SubItems.Add(subNodoSubject.ChildNodes['determinerCode'].Text);
  177. subNodoSubject.ChildNodes['hl7:recordTarget'].ChildNodes['hl7:patient'].ChildNodes['hl7:patientPerson'].ChildNodes['hl7:id'].Text;
  178. subNodoSubject.ChildNodes['hl7:recordTarget'].ChildNodes['hl7:patient'].ChildNodes['hl7:patientPerson'].ChildNodes['hl7:name'].Text;
  179. SubItems.Add(subNodoSubject.ChildNodes['hl7:given'].Text);
  180. SubItems.Add(subNodoSubject.ChildNodes['hl7:family'].Text);
  181. subNodoSubject.ChildNodes['hl7:recordTarget'].ChildNodes['hl7:patient'].ChildNodes['hl7:patientPerson'].ChildNodes['hl7:administrativeGenderCode'].Text;
  182. subNodoSubject.ChildNodes['hl7:recordTarget'].ChildNodes['hl7:patient'].ChildNodes['hl7:patientPerson'].ChildNodes['hl7:birthTime'].Text;
  183. subNodoSubject.ChildNodes['hl7:recordTarget'].ChildNodes['hl7:patient'].ChildNodes['hl7:patientPerson'].ChildNodes['hl7:direction'].Text;
  184. subNodoSubject.ChildNodes['hl7:recordTarget'].ChildNodes['hl7:patient'].ChildNodes['hl7:patientPerson'].ChildNodes['hl7:phone'].Text;
  185. subNodoSubject.ChildNodes['hl7:recordTarget'].ChildNodes['hl7:patient'].ChildNodes['hl7:patientPerson'].ChildNodes['hl7:celphone'].Text;
  186. subNodoSubject.ChildNodes['hl7:recordTarget'].ChildNodes['hl7:patient'].ChildNodes['hl7:patientPerson'].ChildNodes['hl7:city'].Text;
  187. subNodoSubject.ChildNodes['hl7:recordTarget'].ChildNodes['hl7:patient'].ChildNodes['hl7:patientPerson'].ChildNodes['hl7:zone'].Text;
  188. subNodoSubject.ChildNodes['hl7:recordTarget'].ChildNodes['hl7:patient'].ChildNodes['hl7:patientPerson'].ChildNodes['hl7:pregnant'].Text;
  189. subNodoSubject.ChildNodes['hl7:recordTarget'].ChildNodes['hl7:patient'].ChildNodes['hl7:patientPerson'].ChildNodes['hl7:client'].Text;
  190. subNodoSubject.ChildNodes['hl7:recordTarget'].ChildNodes['hl7:patient'].ChildNodes['hl7:patientPerson'].ChildNodes['hl7:clientName'].Text;
  191. subNodoSubject.ChildNodes['hl7:recordTarget'].ChildNodes['hl7:patient'].ChildNodes['hl7:patientPerson'].ChildNodes['hl7:clientNit'].Text;
  192. subNodoSubject.ChildNodes['hl7:recordTarget'].ChildNodes['hl7:patient'].ChildNodes['hl7:patientPerson'].ChildNodes['hl7:doctor'].Text;
  193. subNodoSubject.ChildNodes['hl7:recordTarget'].ChildNodes['hl7:patient'].ChildNodes['hl7:patientPerson'].ChildNodes['hl7:doctorName'].Text;
  194. subNodoSubject.ChildNodes['hl7:recordTarget'].ChildNodes['hl7:patient'].ChildNodes['hl7:patientPerson'].ChildNodes['hl7:doctorNit'].Text;
  195. subNodoSubject.ChildNodes['hl7:recordTarget'].ChildNodes['hl7:patient'].ChildNodes['hl7:patientPerson'].ChildNodes['hl7:email'].Text;
  196. subNodoSubject.ChildNodes['hl7:recordTarget'].ChildNodes['hl7:patient'].ChildNodes['hl7:patientPerson'].ChildNodes['hl7:bed'].Text;
  197. subNodoSubject.ChildNodes['hl7:recordTarget'].ChildNodes['hl7:patient'].ChildNodes['hl7:patientPerson'].ChildNodes['hl7:diagnosis'].Text;
  198. subNodoSubject.ChildNodes['hl7:recordTarget'].ChildNodes['hl7:patient'].ChildNodes['hl7:patientPerson'].ChildNodes['hl7:wight'].Text;
  199. subNodoSubject.ChildNodes['hl7:recordTarget'].ChildNodes['hl7:patient'].ChildNodes['hl7:patientPerson'].ChildNodes['hl7:size'].Text;
  200. subNodoSubject.ChildNodes['hl7:recordTarget'].ChildNodes['hl7:patient'].ChildNodes['hl7:patientPerson'].ChildNodes['hl7:affiliateType'].Text;
  201. subNodoSubject.ChildNodes['hl7:recordTarget'].ChildNodes['hl7:patient'].ChildNodes['hl7:patientPerson'].ChildNodes['hl7:userType'].Text;
  202. subNodoSubject.ChildNodes['hl7:recordTarget'].ChildNodes['hl7:patient'].ChildNodes['hl7:patientPerson'].ChildNodes['hl7:copayment'].Text;
  203. subNodoSubject.ChildNodes['hl7:recordTarget'].ChildNodes['hl7:patient'].ChildNodes['hl7:patientPerson'].ChildNodes['hl7:costCenter'].Text;
  204. subNodoSubject.ChildNodes['hl7:recordTarget'].ChildNodes['hl7:patient'].ChildNodes['hl7:patientPerson'].ChildNodes['hl7:costCenterName'].Text;
  205. subNodoSubject.ChildNodes['hl7:recordTarget'].ChildNodes['hl7:patient'].ChildNodes['hl7:patientPerson'].ChildNodes['hl7:renalControl'].Text;
  206. subNodoSubject.ChildNodes['hl7:author'].Text;
  207. SubItems.Add(subNodoSubject.ChildNodes['typeCode'].Text);
  208. SubItems.Add(subNodoSubject.ChildNodes['contextControlCode'].Text);
  209. subNodoSubject.ChildNodes['hl7:author'].ChildNodes['hl7:assignedEntity'].Text;
  210. SubItems.Add(subNodoSubject.ChildNodes['classCode'].Text);
  211. subNodoSubject.ChildNodes['hl7:author'].ChildNodes['hl7:assignedEntity'].ChildNodes['hl7:id'].Text;
  212. SubItems.Add(subNodoSubject.ChildNodes['root'].Text);
  213. SubItems.Add(subNodoSubject.ChildNodes['extension'].Text);
  214. subNodoSubject.ChildNodes['hl7:author'].ChildNodes['hl7:assignedEntity'].ChildNodes['hl7:telecom'].Text;
  215. SubItems.Add(subNodoSubject.ChildNodes['value'].Text);
  216. subNodoSubject.ChildNodes['hl7:author'].ChildNodes['hl7:assignedEntity'].ChildNodes['hl7:assignedPerson'].Text;
  217. SubItems.Add(subNodoSubject.ChildNodes['classCode'].Text);
  218. SubItems.Add(subNodoSubject.ChildNodes['determinerCode'].Text);
  219. subNodoSubject.ChildNodes['hl7:author'].ChildNodes['hl7:assignedEntity'].ChildNodes['hl7:assignedPerson'].ChildNodes['hl7:name'].Text;
  220. SubItems.Add(subNodoSubject.ChildNodes['hl7:given'].Text);
  221. SubItems.Add(subNodoSubject.ChildNodes['hl7:family'].Text);
  222. subNodoSubject.ChildNodes['hl7:author'].ChildNodes['hl7:assignedEntity'].ChildNodes['hl7:assignedPerson'].ChildNodes['hl7:asLocatedEntity'].Text;
  223. SubItems.Add(subNodoSubject.ChildNodes['classCode'].Text);
  224. subNodoSubject.ChildNodes['hl7:author'].ChildNodes['hl7:assignedEntity'].ChildNodes['hl7:assignedPerson'].ChildNodes['hl7:asLocatedEntity'].ChildNodes['location'].Text;
  225. SubItems.Add(subNodoSubject.ChildNodes['classCode'].Text);
  226. SubItems.Add(subNodoSubject.ChildNodes['determinerCode'].Text);
  227. subNodoSubject.ChildNodes['hl7:author'].ChildNodes['hl7:assignedEntity'].ChildNodes['hl7:assignedPerson'].ChildNodes['hl7:asLocatedEntity'].ChildNodes['location'].ChildNodes['hl7:name'].Text;
  228. subNodoSubject.ChildNodes['hl7:author'].ChildNodes['hl7:assignedEntity'].ChildNodes['hl7:representedOrganization'].Text;
  229. SubItems.Add(subNodoSubject.ChildNodes['classCode'].Text);
  230. SubItems.Add(subNodoSubject.ChildNodes['determinerCode'].Text);
  231. subNodoSubject.ChildNodes['hl7:author'].ChildNodes['hl7:assignedEntity'].ChildNodes['hl7:representedOrganization'].ChildNodes['hl7:id'].Text;
  232. SubItems.Add(subNodoSubject.ChildNodes['root'].Text);
  233. SubItems.Add(subNodoSubject.ChildNodes['extension'].Text);
  234. SubItems.Add(subNodoSubject.ChildNodes['assigningAuthorityName'].Text);
  235. subNodoSubject.ChildNodes['hl7:author'].ChildNodes['hl7:assignedEntity'].ChildNodes['hl7:representedOrganization'].ChildNodes['hl7:name'].Text;
  236. subNodoSubject.ChildNodes['hl7:component2'].Text;
  237. SubItems.Add(subNodoSubject.ChildNodes['typeCode'].Text);
  238. SubItems.Add(subNodoSubject.ChildNodes['contextControlCode'].Text);
  239. SubItems.Add(subNodoSubject.ChildNodes['contextConductionInd'].Text);
  240. end;
  241. until subNodoSubject = nil;
  242.  
  243. //continuamos extrayendo el xml
  244. //nodo -> controlActProcess - subject - component2 (son los examenes) <-
  245. ANodo:= xmlDocum.DocumentElement.ChildNodes.FindNode('hl7:controlActProcess').ChildNodes.FindNode('hl7:subject').ChildNodes.FindNode('hl7:observationRequest').ChildNodes.FindNode('hl7:component2');
  246. subNodoExamenes:=ANodo;
  247. repeat
  248. with lvExamenes.Items.Add do
  249. begin
  250. Caption:= subNodoExamenes.ChildNodes['hl7:sequenceNumber'].Text;
  251. SubItems.Add(subNodoExamenes['value'].Text);
  252. subNodoExamenes.ChildNodes['hl7:observationRequest'].Text;
  253. SubItems.Add(subNodoExamenes.ChildNodes['classCode'].Text);
  254. SubItems.Add(subNodoExamenes.ChildNodes['moodCode'].Text);
  255. SubItems.Add(subNodoExamenes.ChildNodes['negationInd'].Text);
  256. subNodoExamenes.ChildNodes['hl7:observationRequest'].ChildNodes['hl7:id'].Text;
  257. SubItems.Add(subNodoExamenes['root'].Text);
  258. SubItems.Add(subNodoExamenes['extension'].Text);
  259. subNodoExamenes.ChildNodes['hl7:observationRequest'].ChildNodes['hl7:code'].Text;
  260. SubItems.Add(subNodoExamenes['code'].Text);
  261. SubItems.Add(subNodoExamenes['codeSystemName'].Text);
  262. SubItems.Add(subNodoExamenes['displayName'].Text);
  263. subNodoExamenes.ChildNodes['hl7:observationRequest'].ChildNodes['hl7:numExam'].Text;
  264. subNodoExamenes.ChildNodes['hl7:observationRequest'].ChildNodes['hl7:text'].Text;
  265. subNodoExamenes.ChildNodes['hl7:observationRequest'].ChildNodes['hl7:statusCode'].Text;
  266. SubItems.Add(subNodoExamenes['code'].Text);
  267. subNodoExamenes.ChildNodes['hl7:observationRequest'].ChildNodes['hl7:priorityCode'].Text;
  268. SubItems.Add(subNodoExamenes['code'].Text);
  269. SubItems.Add(subNodoExamenes['codeSystem'].Text);
  270. SubItems.Add(subNodoExamenes['codeSystemName'].Text);
  271. SubItems.Add(subNodoExamenes['displayName'].Text);
  272. subNodoExamenes.ChildNodes['hl7:observationRequest'].ChildNodes['hl7:interpretationCode'].Text;
  273. SubItems.Add(subNodoExamenes['nullFlavor'].Text);
  274. end;
  275. until subNodoExamenes = nil;
  276. end;
  277. until ANodocontrolActProcess = nil;
  278. end;
  279. ANodo:= ANodo.NextSibling;
  280. until ANodo= nil;
  281. finally
  282. xmlDocum.Active:= False;
  283. xmlDocum.Free;
  284. end;
  285. end;


  • 0

#2 MarCaribe

MarCaribe

    Member

  • Miembros
  • PipPip
  • 34 mensajes

Escrito 29 junio 2019 - 03:55

iba adjuntar en un archivo de texto la trama xml, que tambien es larguisima, pero no tengo permisos, asi que la subo por aqui, espero no les incomode tantas lineas de codigo...

 

Agradezco infinitamente vuestra ayuda...

 

trama XML:


xml
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <hl7:POOR_IN200901UV
  3. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:hl7-org:v3 http://www.hl7.org/v3ballot/html/processable/multicacheschemas/POOR_IN200901UV.xsd"
  4. xmlns:hl7="urn:hl7-org:v3" TSVersion="XML_1.0">
  5. <hl7:templateId extension="POOR_RM201270CO01" assigningAuthorityName="HL7CO"/>
  6. <hl7:id root="UNK" extension="POOR_IN200901UV-768895" displayable="true"/>
  7. <hl7:creationTime value="20190606112815"/>
  8. <hl7:versionCode code="V3-2009N"/>
  9. <hl7:interactionId root="2.16.840.1.113883.1.6" extension="POOR_IN200901UV"/>
  10. <hl7:processingCode code="P"/>
  11. <hl7:processingModeCode code="T"/>
  12. <hl7:acceptAckCode code="AL"/>
  13. <hl7:receiver typeCode="RCV">
  14. <hl7:device classCode="DEV" determinerCode="INSTANCE">
  15. <hl7:id root="UNK" extension="00000000-0000-0000-0000-000000000000"/>
  16. <hl7:softwareName displayName=""/>
  17. </hl7:device>
  18. </hl7:receiver>
  19. <hl7:sender typeCode="SND">
  20. <hl7:device classCode="DEV" determinerCode="INSTANCE">
  21. <hl7:id root="UNK" extension="SIOS"/>
  22. <hl7:softwareName displayName="Sistema de Informacion para Operaciones en Salud"/>
  23. </hl7:device>
  24. </hl7:sender>
  25. <hl7:controlActProcess classCode="CACT" moodCode="EVN">
  26. <hl7:code code="POOR_TE200901UV" codeSystem="2.16.840.1.113883.1.18" codeSystemName="TriggerEventID" displayName="Composite Order Activate"/>
  27. <hl7:languageCode code="es-co" codeSystem="2.16.840.1.113883.1.11.11526" codeSystemName="HumanLanguage" displayName="Espanol Colombia"/>
  28. <hl7:dataEnterer contextControlCode="AP" typeCode="ENT">
  29. <hl7:assignedPerson classCode="ASSIGNED">
  30. <hl7:id root="CC" extension="1123994304"/>
  31. <hl7:assignedPerson classCode="PSN" determinerCode="INSTANCE">
  32. <hl7:name>
  33. <hl7:given>JANET</hl7:given>
  34. <hl7:given></hl7:given>
  35. <hl7:family>FONTALVO</hl7:family>
  36. <hl7:family>SOLANO</hl7:family>
  37. </hl7:name>
  38. </hl7:assignedPerson>
  39. </hl7:assignedPerson>
  40. </hl7:dataEnterer>
  41. <hl7:subject typeCode="SUBJ" contextConductionInd="true">
  42. <hl7:observationRequest classCode="OBS" moodCode="RQO" negationInd="false">
  43. <hl7:id root="UNK" extension="768895"/>
  44. <hl7:code code="26436-6" codeSystem="2.16.840.1.113883.6.1" codeSystemName="LOINC" displayName="Pruebas diagnosticas de laboratorio"/>
  45. <hl7:text></hl7:text>
  46. <hl7:statusCode code="active"/>
  47. <hl7:device typeCode="DEV" contextControlCode="ON">
  48. <hl7:assignedDevice classCode="ASSIGNED">
  49. <hl7:id root="" extension=""/>
  50. <hl7:assignedDevice classCode="DEV" determinerCode="INSTANCE">
  51. <hl7:manufacturerModelName code="" displayName=""/>
  52. </hl7:assignedDevice>
  53. </hl7:assignedDevice>
  54. </hl7:device>
  55. <hl7:recordTarget typeCode="RCT" contextControlCode="OP">
  56. <hl7:patient classCode="PAT">
  57. <hl7:id root="UNK" extension="VEN29787695"/>
  58. <hl7:patientPerson classCode="PSN" determinerCode="INSTANCE">
  59. <hl7:id root="AS" extension="VEN29787695"/>
  60. <hl7:name>
  61. <hl7:given>YOSUKAY</hl7:given>
  62. <hl7:given>DE LOS ANGELES</hl7:given>
  63. <hl7:family>GALUE</hl7:family>
  64. <hl7:family>GONZALEZ</hl7:family>
  65. </hl7:name>
  66. <hl7:administrativeGenderCode code="F" codeSystem="2.16.840.1.113883.5.1" codeSystemName="AdministrativeGender" displayName="FEMENINO"/>
  67. <hl7:birthTime value="20030424"/>
  68. <hl7:direction>NO SABE </hl7:direction>
  69. <hl7:phone>0000000000</hl7:phone>
  70. <hl7:celphone>0000000000</hl7:celphone>
  71. <hl7:city>44430</hl7:city>
  72. <hl7:zone>U</hl7:zone>
  73. <hl7:pregnant>No</hl7:pregnant>
  74. <hl7:client>99</hl7:client>
  75. <hl7:clientName>GOBERNACIÓN DEL DEPARTAMENTO DE LA GUAJIRA</hl7:clientName>
  76. <hl7:clientNit>892115015</hl7:clientNit>
  77. <hl7:doctor>1126122969</hl7:doctor>
  78. <hl7:doctorName>ELVIS ANTONIO BASABE LOPEZ</hl7:doctorName>
  79. <hl7:doctorNit>1126122969</hl7:doctorNit>
  80. <hl7:email>No Registra</hl7:email>
  81. <hl7:bed></hl7:bed>
  82. <hl7:diagnosis></hl7:diagnosis>
  83. <hl7:wight></hl7:wight>
  84. <hl7:size></hl7:size>
  85. <hl7:affiliateType>BENEFICIARIO</hl7:affiliateType>
  86. <hl7:userType>BENEFICIARIO</hl7:userType>
  87. <hl7:copayment>0 + 0.00</hl7:copayment>
  88. <hl7:costCenter>07</hl7:costCenter>
  89. <hl7:costCenterName>Urgencias Ginecologia</hl7:costCenterName>
  90. <hl7:renalControl></hl7:renalControl>
  91. </hl7:patientPerson>
  92. </hl7:patient>
  93. </hl7:recordTarget>
  94. <hl7:author typeCode="AUT" contextControlCode="OP">
  95. <hl7:assignedEntity classCode="ASSIGNED">
  96. <hl7:id root="CC" extension="1126122969"/>
  97. <hl7:telecom value=""/>
  98. <hl7:assignedPerson classCode="PSN" determinerCode="INSTANCE">
  99. <hl7:name>
  100. <hl7:given>ELVIS</hl7:given>
  101. <hl7:given>ANTONIO</hl7:given>
  102. <hl7:family>BASABE</hl7:family>
  103. <hl7:family>LOPEZ</hl7:family>
  104. </hl7:name>
  105. <hl7:asLocatedEntity classCode="LOCE">
  106. <hl7:location classCode="PLC" determinerCode="INSTANCE">
  107. <hl7:name>Urgencias</hl7:name>
  108. </hl7:location>
  109. </hl7:asLocatedEntity>
  110. </hl7:assignedPerson>
  111. <hl7:representedOrganization classCode="ORG" determinerCode="INSTANCE">
  112. <hl7:id root="codHabilitacionPrestadorSalud" extension="444300027701" assigningAuthorityName="MinProteccionSocial"/>
  113. <hl7:name>ESE HOSPITAL SAN JOSE DE MAICAO</hl7:name>
  114. </hl7:representedOrganization>
  115. </hl7:assignedEntity>
  116. </hl7:author>
  117. <hl7:component2 typeCode="COMP" contextControlCode="AP" contextConductionInd="true">
  118. <hl7:sequenceNumber value="1"/>
  119. <hl7:observationRequest classCode="OBS" moodCode="RQO" negationInd="false">
  120. <hl7:id root="UNK" extension="ORDEN-1774391"/>
  121. <hl7:code code="902210" codeSystemName="CUPS" displayName="HEMOGRAMA IV"/>
  122. <hl7:numExam>1</hl7:numExam>
  123. <hl7:text></hl7:text>
  124. <hl7:statusCode code="active"/>
  125. <hl7:priorityCode code="R" codeSystem="2.16.840.1.113883.5.7" codeSystemName="ActPriority" displayName="Rutina"/>
  126. <hl7:interpretationCode nullFlavor="UNK"/>
  127. </hl7:observationRequest>
  128. </hl7:component2>
  129. <hl7:component2 typeCode="COMP" contextControlCode="AP" contextConductionInd="true">
  130. <hl7:sequenceNumber value="2"/>
  131. <hl7:observationRequest classCode="OBS" moodCode="RQO" negationInd="false">
  132. <hl7:id root="UNK" extension="ORDEN-1774392"/>
  133. <hl7:code code="902045" codeSystemName="CUPS" displayName="TIEMPO DE PROTROMBINA [PT]"/>
  134. <hl7:numExam>2</hl7:numExam>
  135. <hl7:text></hl7:text>
  136. <hl7:statusCode code="active"/>
  137. <hl7:priorityCode code="R" codeSystem="2.16.840.1.113883.5.7" codeSystemName="ActPriority" displayName="Rutina"/>
  138. <hl7:interpretationCode nullFlavor="UNK"/>
  139. </hl7:observationRequest>
  140. </hl7:component2>
  141. <hl7:component2 typeCode="COMP" contextControlCode="AP" contextConductionInd="true">
  142. <hl7:sequenceNumber value="3"/>
  143. <hl7:observationRequest classCode="OBS" moodCode="RQO" negationInd="false">
  144. <hl7:id root="UNK" extension="ORDEN-1774393"/>
  145. <hl7:code code="902049" codeSystemName="CUPS" displayName="TIEMPO DE TROMBOPLASTINA PARCIAL [PTT]"/>
  146. <hl7:numExam>3</hl7:numExam>
  147. <hl7:text></hl7:text>
  148. <hl7:statusCode code="active"/>
  149. <hl7:priorityCode code="R" codeSystem="2.16.840.1.113883.5.7" codeSystemName="ActPriority" displayName="Rutina"/>
  150. <hl7:interpretationCode nullFlavor="UNK"/>
  151. </hl7:observationRequest>
  152. </hl7:component2>
  153. <hl7:component2 typeCode="COMP" contextControlCode="AP" contextConductionInd="true">
  154. <hl7:sequenceNumber value="4"/>
  155. <hl7:observationRequest classCode="OBS" moodCode="RQO" negationInd="false">
  156. <hl7:id root="UNK" extension="ORDEN-1774394"/>
  157. <hl7:code code="906249" codeSystemName="CUPS" displayName="VIH 1 Y 2, ANTICUERPOS"/>
  158. <hl7:numExam>4</hl7:numExam>
  159. <hl7:text></hl7:text>
  160. <hl7:statusCode code="active"/>
  161. <hl7:priorityCode code="R" codeSystem="2.16.840.1.113883.5.7" codeSystemName="ActPriority" displayName="Rutina"/>
  162. <hl7:interpretationCode nullFlavor="UNK"/>
  163. </hl7:observationRequest>
  164. </hl7:component2>
  165. </hl7:observationRequest>
  166. </hl7:subject>
  167. </hl7:controlActProcess>
  168. </hl7:POOR_IN200901UV>


  • 0

#3 MarCaribe

MarCaribe

    Member

  • Miembros
  • PipPip
  • 34 mensajes

Escrito 02 julio 2019 - 07:53

Hola amigos, ya pude solucionar el tema.


  • 0

#4 egostar

egostar

    missing my father, I love my mother.

  • Administrador
  • 13.953 mensajes
  • LocationMéxico

Escrito 02 julio 2019 - 11:17

Que bien, (y)

 

¿Podrías decirnos como se solucionó?

 

Saludos


  • 0

#5 MarCaribe

MarCaribe

    Member

  • Miembros
  • PipPip
  • 34 mensajes

Escrito 02 julio 2019 - 02:36

Hola egostar, 

 

Aun no lo termino como yo quisiera, solo estoy tratando de desglozar el contenido del xml....

 

aqui dejo el codigo usado, lo acorte por temas de espacios... es muy largoooo ajaja, aunque no lo he optimizado


delphi
  1. {El siguiente código se realizo para visualizar de manera mas facil un xml en un componente ValueEditor y List view...
  2.   lo cual es una prueba, este codigo puede optimizarce mas, pero me demoro mas jajajaj :) }
  3. procedure TForm1.btnDatosXMlClick(Sender: TObject);
  4. var
  5. xmlDocum: TXMLDocument;
  6. startItemNode: IXMLNode;
  7. ANodo, ANodoReceiver, ANodoSender, ANodocontrolActProcess: IXMLNode;
  8. //subNodoDataCenter, subNodoSubject, subNodoExamenes: IXMLNode;
  9. begin
  10. vle1.Strings.Clear;
  11. xmlDocum:= TXMLDocument.Create(Self);
  12. try
  13. xmlDocum.XML.Text:= XMLStringToWideString(ConvertirCaracteresNoValidos(
  14. StringReplace(mmo1.Lines.Text, '"utf-8"', '"iso-8859-1"',
  15. [rfReplaceAll, rfIgnoreCase])));
  16. xmlDocum.DOMVendor:= OpenXMLFactory;
  17. xmlDocum.Active:= True;
  18. //añadimos atributos al value listor templateId
  19. startItemNode:= xmlDocum.DocumentElement.ChildNodes.FindNode('hl7:templateId');
  20. vle1.Strings.Add('<< hl7:templateId >>'+'='+'');
  21. vle1.Strings.Add('extension'+'='+startItemNode.GetAttributeNS('extension',''));
  22. vle1.Strings.Add('assigningAuthorityName'+'='+startItemNode.GetAttributeNS('assigningAuthorityName',''));
  23. //ANodo.ChildNodes templateId
  24. startItemNode:= startItemNode.NextSibling;
  25. .
  26. .
  27. .
  28. .
  29. .
  30. .
  31. .
  32. .
  33. .
  34. ANodo:= xmlDocum.DocumentElement.ChildNodes.FindNode('hl7:controlActProcess').ChildNodes.FindNode('hl7:subject').
  35. ChildNodes.FindNode('hl7:observationRequest').ChildNodes.FindNode('hl7:component2').ChildNodes.FindNode('hl7:observationRequest').
  36. ChildNodes.FindNode('hl7:interpretationCode');
  37. vle2.Strings.Add('<< hl7:controlActProcess / hl7:subject / hl7:observationRequest / hl7:component2 / hl7:observationRequest / hl7:interpretationCode >>'+'='+'');
  38. vle2.Strings.Add('nullFlavor'+'='+VarToStr(ANodo.GetAttributeNS('nullFlavor','')));
  39. ANodo:= ANodo.NextSibling;
  40. until ANodo=nil;
  41. finally
  42. xmlDocum.Active:= False;
  43. xmlDocum.Free;
  44. end;
  45. end;
  46.  
  47. procedure TForm1.btn1Click(Sender: TObject);
  48. var
  49. ANodo: IXMLNode;
  50. xmlDocum: TXMLDocument;
  51. i,j: Integer;
  52. aux: Boolean;
  53. begin
  54. vle2.Strings.Clear;
  55. xmlDocum:= TXMLDocument.Create(Self);
  56. xmlDocum.XML.Text:= XMLStringToWideString(ConvertirCaracteresNoValidos(
  57. StringReplace(mmo1.Lines.Text, '"utf-8"', '"iso-8859-1"',
  58. [rfReplaceAll, rfIgnoreCase])));
  59. xmlDocum.DOMVendor:= OpenXMLFactory;
  60. xmlDocum.Active:= True;
  61. //validar si hay mas registros component2 y meter en un ciclo para que lea todos los estudios
  62. ANodo:= xmlDocum.DocumentElement.ChildNodes.FindNode('hl7:controlActProcess').ChildNodes.FindNode('hl7:subject').
  63. ChildNodes.FindNode('hl7:observationRequest').ChildNodes.FindNode('hl7:component2');
  64. if ANodo.HasChildNodes then begin
  65. i:=0;
  66. vle2.Strings.Add('Si hay registro');
  67. j:= ANodo.Collection.ChildNodes.Count;
  68. //if then
  69. for j:=0 to j-1 do begin
  70. i:=i+1;
  71. end;
  72. vle2.Strings.Add('Hay '+ IntToStr(i) +' registros de examenes');
  73. end else
  74. vle2.Strings.Add('No hay registro');
  75.  
  76.  
  77. //subject-observationRequest - component2
  78. {ANodo:= xmlDocum.DocumentElement.ChildNodes.FindNode('hl7:controlActProcess').ChildNodes.FindNode('hl7:subject').
  79.   ChildNodes.FindNode('hl7:observationRequest').ChildNodes.FindNode('hl7:component2'); }
  80. end;


  • 0

#6 MarCaribe

MarCaribe

    Member

  • Miembros
  • PipPip
  • 34 mensajes

Escrito 02 julio 2019 - 02:43

Hay algo que me esta molestando y es lo siguiente...

 

En este pedazo de codigo, no logro como hacer que me recorra varios nodos que se llaman igual pero tienen diferente información


delphi
  1. procedure TForm1.btn1Click(Sender: TObject);
  2. var
  3. ANodo: IXMLNode;
  4. xmlDocum: TXMLDocument;
  5. i,j: Integer;
  6. aux: Boolean;
  7. begin
  8. vle2.Strings.Clear;
  9. xmlDocum:= TXMLDocument.Create(Self);
  10. xmlDocum.XML.Text:= XMLStringToWideString(ConvertirCaracteresNoValidos(
  11. StringReplace(mmo1.Lines.Text, '"utf-8"', '"iso-8859-1"',
  12. [rfReplaceAll, rfIgnoreCase])));
  13. xmlDocum.DOMVendor:= OpenXMLFactory;
  14. xmlDocum.Active:= True;
  15. //validar si hay mas registros component2 y meter en un ciclo para que lea todos los estudios
  16. ANodo:= xmlDocum.DocumentElement.ChildNodes.FindNode('hl7:controlActProcess').ChildNodes.FindNode('hl7:subject').
  17. ChildNodes.FindNode('hl7:observationRequest').ChildNodes.FindNode('hl7:component2');
  18. if ANodo.HasChildNodes then begin
  19. i:=0;
  20. vle2.Strings.Add('Si hay registro');
  21. j:= ANodo.Collection.ChildNodes.Count;
  22. //if then
  23. for j:=0 to j-1 do begin
  24. i:=i+1;
  25. end;
  26. vle2.Strings.Add('Hay '+ IntToStr(i) +' registros de examenes');
  27. end else
  28. vle2.Strings.Add('No hay registro');
  29.  
  30.  
  31. //subject-observationRequest - component2
  32. {ANodo:= xmlDocum.DocumentElement.ChildNodes.FindNode('hl7:controlActProcess').ChildNodes.FindNode('hl7:subject').
  33.   ChildNodes.FindNode('hl7:observationRequest').ChildNodes.FindNode('hl7:component2'); }
  34. end;

En la linea 17... Alguien que me ayude porfavor.....  estoy realmente estresada, pues algo me late que es mas facil de lo que pienso...

 

La parte que quiero recorrer del xml es la del nodo (<hl7:component2 typeCode="COMP" contextControlCode="AP" contextConductionInd="true">)

 

aqui les dejo la porcion del xml que no he podido  concretar


xml
  1. <hl7:subject typeCode="SUBJ" contextConductionInd="true">
  2. <hl7:observationRequest classCode="OBS" moodCode="RQO" negationInd="false">
  3. <hl7:id root="UNK" extension="768895"/>
  4. <hl7:code code="26436-6" codeSystem="2.16.840.1.113883.6.1" codeSystemName="LOINC" displayName="Pruebas diagnosticas de laboratorio"/>
  5. <hl7:text></hl7:text>
  6. <hl7:statusCode code="active"/>
  7. ...
  8. ...
  9. ...
  10. ...
  11. <hl7:component2 typeCode="COMP" contextControlCode="AP" contextConductionInd="true">
  12. <hl7:sequenceNumber value="1"/>
  13. <hl7:observationRequest classCode="OBS" moodCode="RQO" negationInd="false">
  14. <hl7:id root="UNK" extension="ORDEN-1774391"/>
  15. <hl7:code code="902210" codeSystemName="CUPS" displayName="HEMOGRAMA IV"/>
  16. <hl7:numExam>1</hl7:numExam>
  17. <hl7:text></hl7:text>
  18. <hl7:statusCode code="active"/>
  19. <hl7:priorityCode code="R" codeSystem="2.16.840.1.113883.5.7" codeSystemName="ActPriority" displayName="Rutina"/>
  20. <hl7:interpretationCode nullFlavor="UNK"/>
  21. </hl7:observationRequest>
  22. </hl7:component2>
  23. <hl7:component2 typeCode="COMP" contextControlCode="AP" contextConductionInd="true">
  24. <hl7:sequenceNumber value="2"/>
  25. <hl7:observationRequest classCode="OBS" moodCode="RQO" negationInd="false">
  26. <hl7:id root="UNK" extension="ORDEN-1774392"/>
  27. <hl7:code code="902045" codeSystemName="CUPS" displayName="TIEMPO DE PROTROMBINA [PT]"/>
  28. <hl7:numExam>2</hl7:numExam>
  29. <hl7:text></hl7:text>
  30. <hl7:statusCode code="active"/>
  31. <hl7:priorityCode code="R" codeSystem="2.16.840.1.113883.5.7" codeSystemName="ActPriority" displayName="Rutina"/>
  32. <hl7:interpretationCode nullFlavor="UNK"/>
  33. </hl7:observationRequest>
  34. </hl7:component2>
  35. <hl7:component2 typeCode="COMP" contextControlCode="AP" contextConductionInd="true">
  36. <hl7:sequenceNumber value="3"/>
  37. <hl7:observationRequest classCode="OBS" moodCode="RQO" negationInd="false">
  38. <hl7:id root="UNK" extension="ORDEN-1774393"/>
  39. <hl7:code code="902049" codeSystemName="CUPS" displayName="TIEMPO DE TROMBOPLASTINA PARCIAL [PTT]"/>
  40. <hl7:numExam>3</hl7:numExam>
  41. <hl7:text></hl7:text>
  42. <hl7:statusCode code="active"/>
  43. <hl7:priorityCode code="R" codeSystem="2.16.840.1.113883.5.7" codeSystemName="ActPriority" displayName="Rutina"/>
  44. <hl7:interpretationCode nullFlavor="UNK"/>
  45. </hl7:observationRequest>
  46. </hl7:component2>
  47. <hl7:component2 typeCode="COMP" contextControlCode="AP" contextConductionInd="true">
  48. <hl7:sequenceNumber value="4"/>
  49. <hl7:observationRequest classCode="OBS" moodCode="RQO" negationInd="false">
  50. <hl7:id root="UNK" extension="ORDEN-1774394"/>
  51. <hl7:code code="906249" codeSystemName="CUPS" displayName="VIH 1 Y 2, ANTICUERPOS"/>
  52. <hl7:numExam>4</hl7:numExam>
  53. <hl7:text></hl7:text>
  54. <hl7:statusCode code="active"/>
  55. <hl7:priorityCode code="R" codeSystem="2.16.840.1.113883.5.7" codeSystemName="ActPriority" displayName="Rutina"/>
  56. <hl7:interpretationCode nullFlavor="UNK"/>
  57. </hl7:observationRequest>
  58. </hl7:component2>
  59. </hl7:observationRequest>
  60. </hl7:subject> 

Por poner un ejemplo.


  • 0

#7 MarCaribe

MarCaribe

    Member

  • Miembros
  • PipPip
  • 34 mensajes

Escrito 02 julio 2019 - 05:24   Mejor respuesta

Hola, pude solucionar esto..

si alguien tiene una mejor solucion y algo mas optima se la agradezco:


delphi
  1. procedure TForm1.btn1Click(Sender: TObject);
  2. var
  3. ANodo, nodo: IXMLNode;
  4. xmlDocum: TXMLDocument;
  5. i,j: Integer;
  6. aux: Boolean;
  7. begin
  8. lv1.Clear;
  9. xmlDocum:= TXMLDocument.Create(Self);
  10. xmlDocum.XML.Text:= XMLStringToWideString(ConvertirCaracteresNoValidos(
  11. StringReplace(mmo1.Lines.Text, '"utf-8"', '"iso-8859-1"',
  12. [rfReplaceAll, rfIgnoreCase])));
  13. xmlDocum.DOMVendor:= OpenXMLFactory;
  14. xmlDocum.Active:= True;
  15. //validar si hay mas registros component2 y meter en un ciclo para que lea todos los estudios
  16. ANodo:= xmlDocum.DocumentElement.ChildNodes.FindNode('hl7:controlActProcess').ChildNodes.FindNode('hl7:subject').
  17. ChildNodes.FindNode('hl7:observationRequest').ChildNodes.FindNode('hl7:component2');//.ChildNodes.FindNode('hl7:observationRequest');
  18. nodo:=ANodo;
  19. //j:=0;
  20. repeat
  21. //with nodo.ChildNodes.FindNode('hl7:component2') do
  22. //j:=j+1;
  23. lv1.Items.Add.Caption:= VarToStr(nodo.ChildNodes['hl7:observationRequest'].ChildNodes['hl7:numExam'].Text);
  24. lv1.Items.Add.Caption:= VarToStr(nodo.ChildNodes['hl7:observationRequest'].ChildNodes['hl7:text'].Text);
  25. //SubItems.Add(VarToStr(nodo.ChildNodes['hl7:id'].Text));
  26. lv1.Items.Add.Caption:= VarToStr(nodo.ChildNodes['hl7:observationRequest'].ChildNodes['hl7:id'].GetAttributeNS('root',''));
  27. lv1.Items.Add.Caption:= VarToStr(nodo.ChildNodes['hl7:observationRequest'].ChildNodes['hl7:id'].GetAttributeNS('extension',''));
  28.  
  29. lv1.Items.Add.Caption:= VarToStr(nodo.ChildNodes['hl7:observationRequest'].ChildNodes['hl7:code'].GetAttributeNS('code',''));
  30. lv1.Items.Add.Caption:= VarToStr(nodo.ChildNodes['hl7:observationRequest'].ChildNodes['hl7:code'].GetAttributeNS('codeSystemName',''));
  31. lv1.Items.Add.Caption:= VarToStr(nodo.ChildNodes['hl7:observationRequest'].ChildNodes['hl7:code'].GetAttributeNS('displayName',''));
  32.  
  33. lv1.Items.Add.Caption:= VarToStr(nodo.ChildNodes['hl7:observationRequest'].ChildNodes['hl7:statusCode'].GetAttributeNS('code',''));
  34.  
  35. lv1.Items.Add.Caption:= VarToStr(nodo.ChildNodes['hl7:observationRequest'].ChildNodes['hl7:priorityCode'].GetAttributeNS('code',''));
  36. lv1.Items.Add.Caption:= VarToStr(nodo.ChildNodes['hl7:observationRequest'].ChildNodes['hl7:priorityCode'].GetAttributeNS('codeSystem',''));
  37. lv1.Items.Add.Caption:= VarToStr(nodo.ChildNodes['hl7:observationRequest'].ChildNodes['hl7:priorityCode'].GetAttributeNS('codeSystemName',''));
  38. lv1.Items.Add.Caption:= VarToStr(nodo.ChildNodes['hl7:observationRequest'].ChildNodes['hl7:priorityCode'].GetAttributeNS('displayName',''));
  39.  
  40. lv1.Items.Add.Caption:= VarToStr(nodo.ChildNodes['hl7:observationRequest'].ChildNodes['hl7:interpretationCode'].GetAttributeNS('nullFlavor',''));
  41. //SubItems.Add(VarToStr(nodo.ChildNodes['hl7:id'].GetAttributeNS('extension','')));
  42. //SubItems.Add(VarToStr(nodo.ChildNodes['hl7:text'].Text)); }
  43.  
  44. nodo:= nodo.NextSibling;
  45. until nodo= nil;
  46. //lv1.Items.Add.Caption:= VarToStr(j) + ' registros';
  47.  
  48. end;


  • 1





Etiquetado también con una o más de estas palabras: #xml, #ListView, #Delphi7