Advertisement
Guest User

Untitled

a guest
Jul 27th, 2017
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 51.08 KB | None | 0 0
  1. drop program agc_floyd_common_fields go
  2. create program agc_floyd_common_fields
  3.  
  4.  
  5. prompt
  6. "Output to File/Printer/MINE" = "MINE" ;* Enter or select the printer or file name to send this report to.
  7.  
  8. with OUTDEV
  9.  
  10. declare all_canceled_cd = f8 with public, noconstant(0.0)
  11. set stat = uar_get_meaning_by_codeset(12025,"CANCELED",1,all_canceled_cd)
  12.  
  13. ; visit list
  14. record vl (
  15. 1 list[*]
  16. 2 encntrid = n8
  17. 2 personid = n8
  18. 2 first_name = vc
  19. 2 last_name = vc
  20. 2 middle_name = vc
  21. 2 birth_date = vc
  22. 2 gender = vc
  23. 2 ethnicity = vc
  24. 2 language = vc
  25. 2 martial_status = vc
  26. 2 decease_date = vc
  27. 2 deceased_reason = vc
  28. 2 race = vc
  29. 2 religion = vc
  30. 2 vip = vc
  31. ;-person
  32. 2 patient_identifiers[*]
  33. 3 idtype = vc
  34. 3 source = vc
  35. 3 idvalue = vc
  36. 2 addresses[*]
  37. 3 type = vc
  38. 3 street1 = vc
  39. 3 street2 = vc
  40. 3 city = vc
  41. 3 state = vc
  42. 3 country = vc
  43. 3 postalcode = vc
  44. 2 phones[*]
  45. 3 type = vc
  46. 3 phonenbr = vc
  47. 2 allergies[*]
  48. 3 substance_nom_id = n8
  49. 3 substance = vc
  50. 3 onset_date = vc
  51. 3 allergy_id = n8
  52. 3 reaction = vc
  53. 3 reaction_nom_id = n8
  54. 3 substance_type = vc
  55. 3 severity = vc
  56. 3 cancel_date = vc
  57. 3 cancel_reason = vc
  58. 3 reaction_status = vc
  59. 3 source_identifier = vc
  60. 3 source_coding = vc
  61. 3 reviewed_date = vc
  62. 3 reviewed_by = vc
  63. 3 last_update_by = vc
  64. 3 last_updated = vc
  65. ;-allergy
  66. 2 payers[*]
  67. 3 effective_date = vc
  68. 3 payer = vc
  69. 3 financial_class = vc
  70. 3 group_name = vc
  71. 3 group_nbr = vc
  72. 3 plan_type = vc
  73. 3 policy_nbr = vc
  74. 3 service_coverage = vc
  75. 3 last_update_by = vc
  76. 3 last_updated = vc
  77. ;-payer
  78. 2 actors[*]
  79. 3 id = vc
  80. 3 role = vc
  81. 3 xml = vc
  82. 3 userid = n8
  83. 2 immunizations[*]
  84. 3 vaccine = vc
  85. 3 admin_date = vc
  86. 3 admin_dosage = vc
  87. 3 admin_dosage_unit = vc
  88. 3 note = vc
  89. 3 location = vc
  90. 3 route = vc
  91. 3 site = vc
  92. 3 strength = vc
  93. 3 strength_units = vc
  94. 3 type = vc
  95. 3 lot_number = vc
  96. 3 manufacturer = vc
  97. 3 last_update_by = vc
  98. 3 last_updated = vc
  99. ;-immunization
  100. 2 problems[*]
  101. 3 problem_nom_id = n8
  102. 3 problem = vc
  103. 3 problem_date = vc
  104. 3 annotation = vc
  105. 3 cancel_reason = vc
  106. 3 certainty = vc
  107. 3 classification = vc
  108. 3 pregnancy_indicator = vc
  109. 3 confirmation_status = vc
  110. 3 progress = vc
  111. 3 family_aware = vc
  112. 3 persistence = vc
  113. 3 prognosis = vc
  114. 3 ranking = vc
  115. 3 severity = vc
  116. 3 source_identifier = vc
  117. 3 source_coding = vc
  118. 3 last_update_by = vc
  119. 3 last_updated = vc
  120. ;-problem
  121. 2 diagnoses[*]
  122. 3 diagnosis_nom_id = n8
  123. 3 diagnosis = vc
  124. 3 diagnosis_date = vc
  125. 3 certainty = vc
  126. 3 classification = vc
  127. 3 clinical_priority = vc
  128. 3 service = vc
  129. 3 confirmation_status = vc
  130. 3 annotated_display = vc
  131. 3 category = vc
  132. 3 class = vc
  133. 3 priority = vc
  134. 3 type = vc
  135. 3 admission_diagnosis = vc
  136. 3 ranking = vc
  137. 3 severity = vc
  138. 3 source_identifier = vc
  139. 3 source_coding = vc
  140. 3 last_update_by = vc
  141. 3 last_updated = vc
  142. ;-diagnosis
  143. 2 procedures[*]
  144. 3 procedure_nom_id = n8
  145. 3 procedure = vc
  146. 3 procedure_date = vc
  147. 3 anesthesia = vc
  148. 3 service = vc
  149. 3 note = vc
  150. 3 location = vc
  151. 3 duration_minutes = vc
  152. 3 ranking = vc
  153. 3 source_identifier = vc
  154. 3 source_coding = vc
  155. 3 last_update_by = vc
  156. 3 last_updated = vc
  157. ;-procedure
  158. 2 visits[*]
  159. 3 arrival_date = vc
  160. ;-visit
  161. 2 medications[*]
  162. 3 medication = vc
  163. 3 instructions = vc
  164. 3 start_date = vc
  165. 3 order_item = vc
  166. 3 order_id = vc
  167. 3 clinical_display = vc
  168. 3 discontinue_indicator = vc
  169. 3 discontinue_type = vc
  170. 3 med_order_type = vc
  171. 3 ordered_as = vc
  172. 3 status = vc
  173. 3 order_date = vc
  174. 3 stop_date = vc
  175. 3 stop_type = vc
  176. ;-medication
  177. 3 order_item = vc
  178. 3 order_id = vc
  179. 3 clinical_display = vc
  180. 3 discontinue_indicator = vc
  181. 3 discontinue_type = vc
  182. 3 med_order_type = vc
  183. 3 ordered_as = vc
  184. 3 status = vc
  185. 3 order_date = vc
  186. 3 stop_date = vc
  187. 3 stop_type = vc
  188. ;-medicationdetail
  189. 2 orders[*]
  190. 3 order_name = vc
  191. 3 instructions = vc
  192. 3 start_date = vc
  193. 2 results[*]
  194. 3 test_name = vc
  195. 3 result_date = vc
  196. 3 result_value = vc
  197.  
  198. )
  199.  
  200. set stat = alterlist(vl->list, 1)
  201. set vl->list[1].encntrid = 5044789
  202.  
  203. set x=0
  204. while (x < size(vl->list,5))
  205. call getActors(x, vl->list[x].encntrid)
  206. call getDemographics(x, vl->list[x].encntrid)
  207. call getAllergies(x, vl->list[x].encntrid)
  208. call getInsurance(x, vl->list[x].encntrid)
  209. call getImmunizations(x, vl->list[x].encntrid)
  210. call getProblems(x, vl->list[x].encntrid)
  211. call getDiagnoses(x, vl->list[x].encntrid)
  212. call getVisits(x, vl->list[x].encntrid)
  213. call getProcedures(x, vl->list[x].encntrid)
  214. call getMedications(x, vl->list[x].encntrid)
  215. call getOrders(x, vl->list[x].encntrid)
  216. call getResults(x, vl->list[x].encntrid)
  217.  
  218. set x = x +1
  219. endwhile;
  220.  
  221.  
  222. record tmp (
  223. 1 var = vc
  224. 1 actorid = vc
  225. )
  226.  
  227. /** create actors **/
  228.  
  229.  
  230.  
  231. /** get the actor id **/
  232. subroutine getActorId(index, actorRole)
  233. set tmp->actorid = "???"
  234. set x = 0
  235. while (x < size(vl->list[index].actors,5))
  236. if (vl->list[index].actors[x+1].role = actorRole)
  237. set tmp->actorid = vl->list[index].actors[x+1].id
  238. endif
  239. set x = x+1
  240. endwhile
  241. end;
  242.  
  243. /** actors **/
  244. subroutine getActors(index, encntrid)
  245. ; patient actor
  246. set newsize = size(vl->list[index].actors,5)+1
  247. set stat = alterlist(vl->list[index].actors, newsize)
  248. set vl->list[index].actors[newsize].id = build("ACT",format(newsize,"0000;P0"))
  249. set vl->list[index].actors[newsize].role = "PATIENT"
  250. set vl->list[index].actors[newsize].xml = ""
  251.  
  252. select into "nl:"
  253. from encntr_prsnl_reltn epr, prsnl p, code_value cv
  254. where epr.encntr_id = encntrid
  255. and epr.active_ind = 1
  256. and epr.end_effective_dt_tm > cnvtdatetime(curdate, curtime3)
  257. and epr.beg_effective_dt_tm < cnvtdatetime(curdate, curtime3)
  258. and epr.prsnl_person_id = p.person_id
  259. and epr.encntr_prsnl_r_cd = cv.code_value
  260. and cv.display_key like "*PHYSICIAN*"
  261. head report
  262. cnt = size(vl->list[index].actors,5)
  263. detail
  264. cnt = cnt+1
  265. stat = alterlist(vl->list[index].actors, cnt)
  266. vl->list[index].actors[cnt].id = build("ACT",format(cnt,"0000;P0"))
  267. vl->list[index].actors[cnt].role = build(uar_get_code_display(epr.encntr_prsnl_r_cd))
  268. vl->list[index].actors[cnt].xml = build("<CurrentName><Given>", p.name_first, "</Given><Family>", p.name_last,
  269. "</Family><Middle>",
  270. "</Middle></CurrentName><Role>", uar_get_code_display(epr.encntr_prsnl_r_cd), "</Role>")
  271. with check, nocounter
  272.  
  273. end; getActors
  274.  
  275. ; demographics
  276. subroutine getDemographics(index, encntrid)
  277. select into "nl:"
  278. from person p, encounter e
  279. where e.encntr_id = encntrid
  280. and e.person_id = p.person_id
  281. detail
  282. vl->list[index].first_name = build(p.name_first)
  283. vl->list[index].last_name = build(p.name_last)
  284. vl->list[index].middle_name = build(p.name_middle)
  285. vl->list[index].gender = build(uar_get_code_display(p.sex_cd))
  286. vl->list[index].birth_date = format(p.birth_dt_tm, "yyyy-MM-dd;;d")
  287. vl->list[index].ethnicity = build(uar_get_code_display(p.ethnic_grp_cd))
  288. vl->list[index].language = build(uar_get_code_display(p.language_cd))
  289. vl->list[index].martial_status = build(uar_get_code_display(p.marital_type_cd))
  290. vl->list[index].decease_date = format(p.deceased_dt_tm, "yyyy-MM-dd HH:mm;;d")
  291. vl->list[index].deceased_reason = build(uar_get_code_display(p.deceased_cd))
  292. vl->list[index].race = build(uar_get_code_display(p.race_cd))
  293. vl->list[index].religion = build(uar_get_code_display(p.religion_cd))
  294. vl->list[index].vip = build(uar_get_code_display(p.vip_cd))
  295. ;!person
  296. with check, nocounter
  297.  
  298. ; identifiers
  299. select into "nl:"
  300. from encounter e, person_alias pa
  301. where e.encntr_id = encntrid
  302. and e.person_id = pa.person_id
  303. and pa.active_ind = 1
  304. and pa.end_effective_dt_tm > cnvtdatetime(curdate, curtime3)
  305. head report
  306. cnt = 0
  307. detail
  308. cnt = size(vl->list[index].patient_identifiers, 5)+1
  309. stat = alterlist(vl->list[index].patient_identifiers, cnt)
  310. vl->list[index].patient_identifiers[cnt].idvalue = pa.alias
  311. vl->list[index].patient_identifiers[cnt].idtype = build(uar_get_code_display(pa.person_alias_type_cd))
  312. vl->list[index].patient_identifiers[cnt].source = build(uar_get_code_display(pa.alias_pool_cd))
  313.  
  314. with check, nocounter
  315.  
  316. ; address
  317. select into "nl:"
  318. from encounter e, address a
  319. where e.encntr_id = encntrid
  320. and e.person_id = a.parent_entity_id
  321. and "PERSON" = a.parent_entity_name
  322. and a.active_ind = 1
  323. and a.end_effective_dt_tm > cnvtdatetime(curdate, curtime3)
  324. head report
  325. cnt = 0
  326. detail
  327. cnt = size(vl->list[index].addresses, 5)+1
  328. stat = alterlist(vl->list[index].addresses, cnt)
  329. vl->list[index].addresses[cnt].street1 = a.street_addr
  330. vl->list[index].addresses[cnt].street2 = a.street_addr2
  331. if (a.city_cd > 0)
  332. vl->list[index].addresses[cnt].city = build(uar_get_code_display(a.city_cd))
  333. else
  334. vl->list[index].addresses[cnt].city = a.city
  335. endif
  336. if (a.country_cd > 0)
  337. vl->list[index].addresses[cnt].country = build(uar_get_code_display(a.country_cd))
  338. else
  339. vl->list[index].addresses[cnt].country = a.country
  340. endif
  341. vl->list[index].addresses[cnt].postalcode = a.zipcode
  342. vl->list[index].addresses[cnt].type = build(uar_get_code_display(a.address_type_cd))
  343. with check, nocounter
  344.  
  345. ; telephone
  346. select into "nl:"
  347. from encounter e, phone p
  348. where e.encntr_id = encntrid
  349. and e.person_id = p.parent_entity_id
  350. and "PERSON" = p.parent_entity_name
  351. and p.active_ind = 1
  352. and p.end_effective_dt_tm > cnvtdatetime(curdate, curtime3)
  353. head report
  354. cnt = 0
  355. detail
  356. cnt = size(vl->list[index].phones, 5)+1
  357. stat = alterlist(vl->list[index].phones, cnt)
  358. vl->list[index].phones[cnt].phonenbr = p.phone_num
  359. vl->list[index].phones[cnt].type = build(uar_get_code_display(p.phone_type_cd))
  360. with check, nocounter
  361.  
  362.  
  363. end; getDemographics
  364.  
  365.  
  366. ; Allergies
  367. subroutine getAllergies(index, encntrid)
  368.  
  369. select into "nl:"
  370. a.onset_dt_tm,
  371. a.substance_ftdesc
  372. from
  373. encounter e,
  374. allergy a
  375. where e.encntr_id = encntrid
  376. and e.person_id = a.person_id
  377. and a.active_ind = 1
  378. and a.reaction_status_cd != all_canceled_cd
  379. and a.end_effective_dt_tm > cnvtdatetime(curdate, curtime3)
  380. head report
  381. cnt = 0
  382. detail
  383. cnt = cnt+1
  384. stat = alterlist(vl->list[index].allergies, cnt)
  385. vl->list[index].allergies[cnt].onset_date = format(a.onset_dt_tm, "yyyy-MM-dd HH:mm;;d")
  386. vl->list[index].allergies[cnt].substance = a.substance_ftdesc
  387. vl->list[index].allergies[cnt].substance_nom_id = a.substance_nom_id
  388. vl->list[index].allergies[cnt].allergy_id = a.allergy_id
  389. vl->list[index].allergies[cnt].substance_type = build(uar_get_code_display(a.substance_type_cd))
  390. vl->list[index].allergies[cnt].severity = build(uar_get_code_display(a.severity_cd))
  391. vl->list[index].allergies[cnt].cancel_date = format(a.cancel_dt_tm, "yyyy-MM-dd HH:mm;;d")
  392. vl->list[index].allergies[cnt].cancel_reason = build(uar_get_code_display(a.cancel_reason_cd))
  393. vl->list[index].allergies[cnt].reaction_status = build(uar_get_code_display(a.reaction_status_cd))
  394. vl->list[index].allergies[cnt].source_identifier = build(a.rec_src_identifer)
  395. vl->list[index].allergies[cnt].source_coding = build(uar_get_code_display(a.rec_src_vocab_cd))
  396. vl->list[index].allergies[cnt].reviewed_date = format(a.reviewed_dt_tm, "yyyy-MM-dd HH:mm;;d")
  397. vl->list[index].allergies[cnt].reviewed_by = build(a.reviewed_prsnl_id)
  398. vl->list[index].allergies[cnt].last_update_by = build(a.updt_id)
  399. vl->list[index].allergies[cnt].last_updated = format(a.updt_dt_tm, "yyyy-MM-dd HH:mm;;d")
  400. ;!allergy
  401.  
  402. with check, nocounter
  403.  
  404. ; coded substance
  405. select into "nl:"
  406. n.source_string
  407. from (dummyt d with seq = value(size(vl->list[index]->allergies,5))),
  408. nomenclature n
  409. plan d
  410. join n where vl->list[index]->allergies[d.seq].substance_nom_id = n.nomenclature_id
  411. detail
  412. if (vl->list[index].allergies[d.seq].substance_nom_id > 0)
  413. vl->list[index].allergies[d.seq].substance = n.source_string
  414. vl->list[index].allergies[d.seq].source_coding = uar_get_code_display(n.concept_source_cd)
  415. vl->list[index].allergies[d.seq].source_identifier = n.concept_identifier
  416. endif
  417. with check, noccounter
  418.  
  419. ; reaction
  420. select into "nl:"
  421. from (dummyt d with seq = value(size(vl->list[index]->allergies,5))),
  422. reaction r
  423. plan d
  424. join r where vl->list[index]->allergies[d.seq].allergy_id = r.allergy_id
  425. detail
  426. vl->list[index].allergies[d.seq].reaction = r.reaction_ftdesc
  427. vl->list[index].allergies[d.seq].reaction_nom_id = r.reaction_nom_id
  428. with check, noccounter
  429.  
  430. ; coded reaction
  431. select into "nl:"
  432. n.source_string
  433. from (dummyt d with seq = value(size(vl->list[index]->allergies,5))),
  434. nomenclature n
  435. plan d
  436. join n where vl->list[index]->allergies[d.seq].reaction_nom_id = n.nomenclature_id
  437. detail
  438. if (vl->list[index].allergies[d.seq].reaction_nom_id > 0)
  439. vl->list[index].allergies[d.seq].reaction = n.source_string
  440. endif
  441. with check, noccounter
  442.  
  443.  
  444. end; getAllergies
  445.  
  446. ; Insurance
  447. subroutine getInsurance(index, encntrid)
  448.  
  449. select into "nl:"
  450. from
  451. encntr_plan_reltn epr,
  452. health_plan hp,
  453. org_plan_reltn opr,
  454. organization o
  455. where epr.encntr_id = encntrid
  456. and epr.active_ind = 1
  457. and epr.end_effective_dt_tm > cnvtdatetime(curdate, curtime3)
  458. and epr.beg_effective_dt_tm < cnvtdatetime(curdate, curtime3)
  459. and epr.health_plan_id = hp.health_plan_id
  460. and hp.active_ind = 1
  461. and hp.health_plan_id = opr.health_plan_id
  462. and opr.active_ind = 1
  463. and opr.beg_effective_dt_tm < cnvtdatetime(curdate, curtime3)
  464. and opr.end_effective_dt_tm > cnvtdatetime(curdate, curtime3)
  465. and opr.organization_id = o.organization_id
  466. order by o.organization_id
  467. head report
  468. cnt = 0
  469. detail
  470. cnt = cnt+1
  471. stat = alterlist(vl->list[index].payers, cnt)
  472. vl->list[index].payers[cnt].effective_date = format(epr.beg_effective_dt_tm, "yyyy-MM-dd HH:mm;;d")
  473. vl->list[index].payers[cnt].payer = build(o.org_name)
  474. vl->list[index].payers[cnt].financial_class = build(uar_get_code_display(hp.financial_class_cd))
  475. vl->list[index].payers[cnt].group_name = build(hp.group_name)
  476. vl->list[index].payers[cnt].group_nbr = build(hp.group_nbr)
  477. vl->list[index].payers[cnt].plan_type = build(uar_get_code_display(hp.plan_type_cd))
  478. vl->list[index].payers[cnt].policy_nbr = build(hp.policy_nbr)
  479. vl->list[index].payers[cnt].service_coverage = build(uar_get_code_display(hp.service_type_cd))
  480. vl->list[index].payers[cnt].last_update_by = build(hp.updt_id)
  481. vl->list[index].payers[cnt].last_updated = format(hp.updt_dt_tm, "yyyy-MM-dd HH:mm;;d")
  482. ;!payer
  483.  
  484. with check, nocounter
  485.  
  486. end; getInsurance
  487.  
  488.  
  489. ; Immunizations
  490. subroutine getImmunizations(index, encntrid)
  491.  
  492. select into "nl:"
  493. from
  494. code_value cv,
  495. clinical_event ce,
  496. ce_med_result cmr
  497. where cv.code_set = 72
  498. and cv.display_key like "*VACCINE*"
  499. and cv.code_value = ce.event_cd
  500. and ce.person_id = (select e.person_id from encounter e where e.encntr_id = encntrid)
  501. and ce.valid_from_dt_tm < cnvtdatetime(curdate, curtime3)
  502. and ce.valid_until_dt_tm > cnvtdatetime(curdate, curtime3)
  503. and ce.event_id = cmr.event_id
  504. and cmr.valid_from_dt_tm < cnvtdatetime(curdate, curtime3)
  505. and cmr.valid_until_dt_tm > cnvtdatetime(curdate, curtime3)
  506. order by cnvtdatetime(cmr.admin_start_dt_tm)
  507. head report
  508. cnt = 0
  509. detail
  510. cnt = cnt+1
  511. stat = alterlist(vl->list[index].immunizations, cnt)
  512. vl->list[index].immunizations[cnt].vaccine = build(uar_get_code_display(ce.event_cd))
  513. vl->list[index].immunizations[cnt].admin_date = format(cmr.admin_start_dt_tm, "yyyy-mm-dd HH:mm;;d")
  514. vl->list[index].immunizations[cnt].admin_dosage = build(cmr.admin_dosage)
  515. vl->list[index].immunizations[cnt].admin_dosage_unit = build(uar_get_code_display(cmr.dosage_unit_cd))
  516. vl->list[index].immunizations[cnt].note = build(cmr.admin_note)
  517. vl->list[index].immunizations[cnt].location = build(uar_get_code_display(cmr.admin_pt_loc_cd))
  518. vl->list[index].immunizations[cnt].route = build(uar_get_code_display(cmr.admin_route_cd))
  519. vl->list[index].immunizations[cnt].site = build(uar_get_code_display(cmr.admin_site_cd))
  520. vl->list[index].immunizations[cnt].strength = build(cmr.admin_strength)
  521. vl->list[index].immunizations[cnt].strength_units = build(uar_get_code_display(cmr.admin_strength_unit_cd))
  522. vl->list[index].immunizations[cnt].type = build(uar_get_code_display(cmr.immunization_type_cd))
  523. vl->list[index].immunizations[cnt].lot_number = build(cmr.substance_lot_number)
  524. vl->list[index].immunizations[cnt].manufacturer = build(uar_get_code_display(cmr.substance_manufacturer_cd))
  525. vl->list[index].immunizations[cnt].last_update_by = build(cmr.updt_id)
  526. vl->list[index].immunizations[cnt].last_updated = format(cmr.updt_dt_tm, "yyyy-MM-dd HH:mm;;d")
  527. ;!immunization
  528.  
  529. with check, nocounter
  530.  
  531. end; getImmunizations
  532.  
  533. ; Problems
  534. subroutine getProblems(index, encntrid)
  535.  
  536. select into "nl:"
  537. p.nomenclature_id,
  538. p.problem_ftdesc
  539. from
  540. encounter e,
  541. problem p
  542. where e.encntr_id = encntrid
  543. and e.person_id = p.person_id
  544. and p.active_ind = 1
  545. and p.end_effective_dt_tm > cnvtdatetime(curdate, curtime3)
  546. head report
  547. cnt = 0
  548. detail
  549. cnt = cnt+1
  550. stat = alterlist(vl->list[index].problems, cnt)
  551. vl->list[index].problems[cnt].problem_date = format(p.onset_dt_tm, "yyyy-MM-dd HH:mm;;d")
  552. vl->list[index].problems[cnt].problem = p.problem_ftdesc
  553. vl->list[index].problems[cnt].problem_nom_id = p.nomenclature_id
  554. vl->list[index].problems[cnt].annotation = build(p.annotated_display)
  555. vl->list[index].problems[cnt].cancel_reason = build(uar_get_code_display(p.cancel_reason_cd))
  556. vl->list[index].problems[cnt].certainty = build(uar_get_code_display(p.certainty_cd))
  557. vl->list[index].problems[cnt].classification = build(uar_get_code_display(p.classification_cd))
  558. vl->list[index].problems[cnt].pregnancy_indicator = build(p.cond_type_flag)
  559. vl->list[index].problems[cnt].confirmation_status = build(uar_get_code_display(p.confirmation_status_cd))
  560. vl->list[index].problems[cnt].progress = build(uar_get_code_display(p.course_cd))
  561. vl->list[index].problems[cnt].family_aware = build(uar_get_code_display(p.family_aware_cd))
  562. vl->list[index].problems[cnt].persistence = build(uar_get_code_display(p.persistence_cd))
  563. vl->list[index].problems[cnt].prognosis = build(uar_get_code_display(p.prognosis_cd))
  564. vl->list[index].problems[cnt].ranking = build(uar_get_code_display(p.ranking_cd))
  565. vl->list[index].problems[cnt].severity = build(uar_get_code_display(p.severity_cd))
  566. vl->list[index].problems[cnt].last_update_by = build(p.updt_id)
  567. vl->list[index].problems[cnt].last_updated = format(p.updt_dt_tm, "yyyy-MM-dd HH:mm;;d")
  568. ;!problem
  569.  
  570. with check, nocounter
  571.  
  572. ; coded problem
  573. select into "nl:"
  574. n.source_string
  575. from (dummyt d with seq = value(size(vl->list[index]->problems,5))),
  576. nomenclature n
  577. plan d
  578. join n where vl->list[index]->problems[d.seq].problem_nom_id = n.nomenclature_id
  579. detail
  580. if (vl->list[index].problems[d.seq].problem_nom_id > 0)
  581. vl->list[index].problems[d.seq].problem = n.source_string
  582. vl->list[index].problems[d.seq].source_coding = uar_get_code_display(n.concept_source_cd)
  583. vl->list[index].problems[d.seq].source_identifier = n.concept_identifier
  584. endif
  585. with check, noccounter
  586.  
  587.  
  588. end; getProblems
  589.  
  590.  
  591. ; Diagnoses
  592. subroutine getDiagnoses(index, encntrid)
  593.  
  594. select into "nl:"
  595. d.nomenclature_id,
  596. d.diag_ftdesc
  597. from
  598. encounter e,
  599. diagnosis d
  600. where e.encntr_id = encntrid
  601. and e.person_id = d.person_id
  602. and d.active_ind = 1
  603. and d.end_effective_dt_tm > cnvtdatetime(curdate, curtime3)
  604. head report
  605. cnt = 0
  606. detail
  607. cnt = cnt+1
  608. stat = alterlist(vl->list[index].diagnoses, cnt)
  609. vl->list[index].diagnoses[cnt].diagnosis_date = format(d.diag_dt_tm, "yyyy-MM-dd HH:mm;;d")
  610. vl->list[index].diagnoses[cnt].diagnosis = d.diag_ftdesc
  611. vl->list[index].diagnoses[cnt].diagnosis_nom_id = d.nomenclature_id
  612. vl->list[index].diagnoses[cnt].certainty = build(uar_get_code_display(d.certainty_cd))
  613. vl->list[index].diagnoses[cnt].classification = build(uar_get_code_display(d.classification_cd))
  614. vl->list[index].diagnoses[cnt].clinical_priority = build(d.clinical_diag_priority)
  615. vl->list[index].diagnoses[cnt].service = build(uar_get_code_display(d.clinical_service_cd))
  616. vl->list[index].diagnoses[cnt].confirmation_status = build(uar_get_code_display(d.confirmation_status_cd))
  617. vl->list[index].diagnoses[cnt].annotated_display = build(d.diagnosis_display)
  618. vl->list[index].diagnoses[cnt].category = build(uar_get_code_display(d.diagnostic_category_cd))
  619. vl->list[index].diagnoses[cnt].class = build(uar_get_code_display(d.diag_class_cd))
  620. vl->list[index].diagnoses[cnt].priority = build(d.diag_priority)
  621. vl->list[index].diagnoses[cnt].type = build(uar_get_code_display(d.diag_type_cd))
  622. vl->list[index].diagnoses[cnt].admission_diagnosis = build(uar_get_code_display(d.present_on_admit_cd))
  623. vl->list[index].diagnoses[cnt].ranking = build(uar_get_code_display(d.ranking_cd))
  624. vl->list[index].diagnoses[cnt].severity = build(uar_get_code_display(d.severity_cd))
  625. vl->list[index].diagnoses[cnt].last_update_by = build(d.updt_id)
  626. vl->list[index].diagnoses[cnt].last_updated = format(d.updt_dt_tm, "yyyy-MM-dd HH:mm;;d")
  627. ;!diagnosis
  628.  
  629. with check, nocounter
  630.  
  631. ; coded diagnosis
  632. select into "nl:"
  633. n.source_string
  634. from (dummyt d with seq = value(size(vl->list[index]->diagnoses,5))),
  635. nomenclature n
  636. plan d
  637. join n where vl->list[index]->diagnoses[d.seq].diagnosis_nom_id = n.nomenclature_id
  638. detail
  639. if (vl->list[index].diagnoses[d.seq].diagnosis_nom_id > 0)
  640. vl->list[index].diagnoses[d.seq].diagnosis = n.source_string
  641. vl->list[index].diagnoses[d.seq].source_coding = uar_get_code_display(n.concept_source_cd)
  642. vl->list[index].diagnoses[d.seq].source_identifier = n.concept_identifier
  643. endif
  644. with check, noccounter
  645.  
  646.  
  647. end; getDiagnoses
  648.  
  649.  
  650.  
  651.  
  652.  
  653. ; Visits
  654. subroutine getVisits(index, encntrid)
  655.  
  656. select into "nl:"
  657. from
  658. encounter e
  659. where e.encntr_id = encntrid
  660. and e.active_ind = 1
  661. and e.end_effective_dt_tm > cnvtdatetime(curdate, curtime3)
  662. head report
  663. cnt = 0
  664. detail
  665. cnt = cnt+1
  666. stat = alterlist(vl->list[index].visits, cnt)
  667. vl->list[index].visits[cnt].arrival_date = format(e.reg_dt_tm, "yyyy-MM-dd HH:mm;;d")
  668. ;!visit
  669.  
  670. with check, nocounter
  671. end; getVisits
  672.  
  673.  
  674. ; Procedures
  675. subroutine getProcedures(index, encntrid)
  676.  
  677. select into "nl:"
  678. p.nomenclature_id,
  679. p.proc_ftdesc
  680. from
  681. procedure p
  682. where p.encntr_id = encntrid
  683. and p.active_ind = 1
  684. and p.end_effective_dt_tm > cnvtdatetime(curdate, curtime3)
  685. head report
  686. cnt = 0
  687. detail
  688. cnt = cnt+1
  689. stat = alterlist(vl->list[index].procedures, cnt)
  690. vl->list[index].procedures[cnt].procedure_date = format(p.proc_dt_tm, "yyyy-MM-dd HH:mm;;d")
  691. vl->list[index].procedures[cnt].procedure = p.proc_ftdesc
  692. vl->list[index].procedures[cnt].procedure_nom_id = p.nomenclature_id
  693. vl->list[index].procedures[cnt].anesthesia = build(uar_get_code_display(p.anesthesia_cd))
  694. vl->list[index].procedures[cnt].service = build(uar_get_code_display(p.clinical_service_cd))
  695. vl->list[index].procedures[cnt].note = build(p.procedure_note)
  696. vl->list[index].procedures[cnt].location = build(uar_get_code_display(p.proc_loc_cd))
  697. vl->list[index].procedures[cnt].duration_minutes = build(p.proc_minutes)
  698. vl->list[index].procedures[cnt].ranking = build(uar_get_code_display(p.ranking_cd))
  699. vl->list[index].procedures[cnt].last_update_by = build(p.updt_id)
  700. vl->list[index].procedures[cnt].last_updated = format(p.updt_dt_tm, "yyyy-MM-dd HH:mm;;d")
  701. ;!procedure
  702.  
  703. with check, nocounter
  704.  
  705. ; coded procedure
  706. select into "nl:"
  707. n.source_string
  708. from (dummyt d with seq = value(size(vl->list[index]->procedures,5))),
  709. nomenclature n
  710. plan d
  711. join n where vl->list[index]->procedures[d.seq].procedure_nom_id = n.nomenclature_id
  712. detail
  713. if (vl->list[index].procedures[d.seq].procedure_nom_id > 0)
  714. vl->list[index].procedures[d.seq].procedure = n.source_string
  715. vl->list[index].procedures[d.seq].source_coding = uar_get_code_display(n.concept_source_cd)
  716. vl->list[index].procedures[d.seq].source_identifier = n.concept_identifier
  717. endif
  718. with check, noccounter
  719.  
  720.  
  721. end; getProcedures
  722.  
  723.  
  724. ; Home meds
  725. subroutine getMedications(index, encntrid)
  726.  
  727. select into "nl:"
  728. from
  729. encounter e,
  730. orders o,
  731. order_details od
  732. where e.encntr_id = encntrid
  733. and e.person_id = o.person_id
  734. and o.active_ind = 1
  735. and o.orig_ord_as_flag in (1,2)
  736. and o.order_id = od.order_id
  737.  
  738. order by o.current_start_dt_tm, o.order_id
  739.  
  740. head report
  741. cnt = 0
  742.  
  743. head o.order_id
  744. cnt = cnt+1
  745. stat = alterlist(vl->list[index].medications, cnt)
  746. vl->list[index].medications[cnt].start_date = format(o.current_start_dt_tm, "yyyy-MM-dd HH:mm;;d")
  747. vl->list[index].medications[cnt].medication = build(uar_get_code_display(o.catalog_cd))
  748. vl->list[index].medications[cnt].instructions = o.simplified_display_line
  749. vl->list[index].medications[cnt].order_item = build(uar_get_code_display(o.catalog_cd))
  750. vl->list[index].medications[cnt].order_id = build(o.order_id)
  751. vl->list[index].medications[cnt].clinical_display = build(o.clinical_display_line)
  752. vl->list[index].medications[cnt].discontinue_indicator = build(o.discontinue_ind)
  753. vl->list[index].medications[cnt].discontinue_type = build(uar_get_code_display(o.discontinue_type_cd))
  754. vl->list[index].medications[cnt].med_order_type = build(uar_get_code_display(o.med_order_type_cd))
  755. vl->list[index].medications[cnt].ordered_as = build(o.ordered_as_mnemonic)
  756. vl->list[index].medications[cnt].status = build(uar_get_code_display(o.order_status_cd))
  757. vl->list[index].medications[cnt].order_date = format(o.orig_order_dt_tm, "yyyy-MM-dd HH:mm;;d")
  758. vl->list[index].medications[cnt].stop_date = format(o.projected_stop_dt_tm, "yyyy-MM-dd HH:mm;;d")
  759. vl->list[index].medications[cnt].stop_type = build(uar_get_code_display(o.stop_type_cd))
  760. ;!medication
  761.  
  762. detail
  763. if (od.oe_field_meaning = "VOLUMEDOSE")
  764. vl->list[index].medications[cnt].volume_dose = build(od.oe_field_display_value)
  765. endif
  766. if (od.oe_field_meaning = "VOLUMEDOSEUNIT")
  767. vl->list[index].medications[cnt].volume_dose_unit = build(od.oe_field_display_value)
  768. endif
  769. if (od.oe_field_meaning = "RXROUTE")
  770. vl->list[index].medications[cnt].route = build(od.oe_field_display_value)
  771. endif
  772. if (od.oe_field_meaning = "FREQ")
  773. vl->list[index].medications[cnt].frequency = build(od.oe_field_display_value)
  774. endif
  775. if (od.oe_field_meaning = "SCH/PRN")
  776. vl->list[index].medications[cnt].prn_yes_no = build(od.oe_field_display_value)
  777. endif
  778. if (od.oe_field_meaning = "DISPENSEQTY")
  779. vl->list[index].medications[cnt].dispense_quantity = build(od.oe_field_display_value)
  780. endif
  781. if (od.oe_field_meaning = "DISPENSEQTYUNIT")
  782. vl->list[index].medications[cnt].dispense_quantity_unit = build(od.oe_field_display_value)
  783. endif
  784. if (od.oe_field_meaning = "REQSTARTDTTM")
  785. vl->list[index].medications[cnt].requested_start_date = build(od.oe_field_display_value)
  786. endif
  787. ;!detailmedication
  788.  
  789.  
  790.  
  791. with check, nocounter
  792.  
  793.  
  794.  
  795. end; getMedications
  796.  
  797. ; Orders
  798. subroutine getOrders(index, encntrid)
  799.  
  800. select into "nl:"
  801. from
  802. encounter e,
  803. orders o,
  804. order_details od
  805. where e.encntr_id = encntrid
  806. and e.person_id = o.person_id
  807. and o.active_ind = 1
  808. and not o.orig_ord_as_flag in (1,2)
  809. and o.order_id = od.order_id
  810.  
  811. order by o.current_start_dt_tm, o.order_id
  812.  
  813. head report
  814. cnt = 0
  815.  
  816. head o.order_id
  817. cnt = cnt+1
  818. stat = alterlist(vl->list[index].orders, cnt)
  819. vl->list[index].orders[cnt].start_date = format(o.current_start_dt_tm, "yyyy-MM-dd HH:mm;;d")
  820. vl->list[index].orders[cnt].order_name = build(uar_get_code_display(o.catalog_cd))
  821. vl->list[index].orders[cnt].instructions = o.simplified_display_line
  822. ;!order
  823.  
  824. detail
  825. ;!detailorder
  826.  
  827.  
  828.  
  829. with check, nocounter
  830.  
  831.  
  832.  
  833. end; getOrders
  834.  
  835.  
  836.  
  837. ; Results
  838. subroutine getResults(index, encntrid)
  839.  
  840. select into "nl:"
  841. from
  842. encounter e,
  843. clinical_event ce
  844.  
  845. where e.encntr_id = encntrid
  846. and e.person_id = ce.person_id
  847. and ce.active_ind = 1
  848.  
  849. order by ce.clinical_event_id
  850.  
  851. head report
  852. cnt = 0
  853.  
  854. detail
  855. cnt = cnt+1
  856. stat = alterlist(vl->list[index].results, cnt)
  857. vl->list[index].orders[cnt].test_name = ce.event_tag
  858. vl->list[index].orders[cnt].result_date = format(ce.insert_dt, "yyyy-MM-dd HH:mm;;d")
  859. vl->list[index].orders[cnt].result_value = ce.result_val
  860. ;!result
  861.  
  862.  
  863.  
  864. with check, nocounter
  865.  
  866.  
  867.  
  868. end; getOrders
  869.  
  870.  
  871.  
  872.  
  873. select into $OUTDEV
  874.  
  875. head report
  876.  
  877. x=0
  878. id=0
  879.  
  880. detail
  881.  
  882. while (id < size(vl->list,5))
  883.  
  884. col 0 ^<?xml version="1.0"?><?xml-stylesheet type="text/xsl"?>^
  885. row+1
  886. col 0 ^<ContinuityOfCareRecord>^
  887. row+1
  888. tmp->var = build(^<CCRDocumentObjectID>^, ^00000000000000^, ^</CCRDocumentObjectID>^)
  889. col 0 tmp->var
  890. row+1
  891. col 0 "<Version>V1.0</Version>"
  892. row+1
  893. tmp->var = concat("<DateTime><ExactDateTime>", format(cnvtdatetime(curdate, curtime3), "yyyy-MM-dd;;d"), "T"
  894. , format(cnvtdatetime(curdate, curtime3), "HH:mm:ss;;d") , "</ExactDateTime></DateTime>")
  895. col 0 tmp->var
  896. row+1
  897. call getActorId(id, "PATIENT")
  898. tmp->var = build("<Patient><ActorID>", tmp->actorid,"</ActorID></Patient>")
  899. col 0 tmp->var
  900. row+1
  901. tmp->var = build("<Event>Discharge</Event>")
  902. col 0 tmp->var
  903. row+1
  904.  
  905. ; allergies
  906. col 0 "<Allergies>"
  907. row +1
  908. x = 1
  909. while (x <= size(vl->list[id].allergies, 5))
  910. tmp->var = build("<Allergy><CCRDataObjectID>ALL", format(x, "0000;p0"),
  911. "</CCRDataObjectID><Onset>", vl->list[id].allergies[x].onset_date, "</Onset><Substance>",
  912. vl->list[id].allergies[x].substance,
  913. "</Substance><Reaction>", vl->list[id].allergies[x].reaction ,"</Reaction>")
  914. col 0 tmp->var
  915. row+1
  916. tmp->var = build("<SubstanceType>",vl->list[id].allergies[x].substance_type,"</SubstanceType>")
  917. col 01 tmp->var
  918. row+1
  919. tmp->var = build("<Severity>",vl->list[id].allergies[x].severity,"</Severity>")
  920. col 01 tmp->var
  921. row+1
  922. tmp->var = build("<CancelDate>",vl->list[id].allergies[x].cancel_date,"</CancelDate>")
  923. col 01 tmp->var
  924. row+1
  925. tmp->var = build("<CancelReason>",vl->list[id].allergies[x].cancel_reason,"</CancelReason>")
  926. col 01 tmp->var
  927. row+1
  928. tmp->var = build("<ReactionStatus>",vl->list[id].allergies[x].reaction_status,"</ReactionStatus>")
  929. col 01 tmp->var
  930. row+1
  931. tmp->var = build("<SourceIdentifier>",vl->list[id].allergies[x].source_identifier,"</SourceIdentifier>")
  932. col 01 tmp->var
  933. row+1
  934. tmp->var = build("<SourceCoding>",vl->list[id].allergies[x].source_coding,"</SourceCoding>")
  935. col 01 tmp->var
  936. row+1
  937. tmp->var = build("<ReviewedDate>",vl->list[id].allergies[x].reviewed_date,"</ReviewedDate>")
  938. col 01 tmp->var
  939. row+1
  940. tmp->var = build("<ReviewedBy>",vl->list[id].allergies[x].reviewed_by,"</ReviewedBy>")
  941. col 01 tmp->var
  942. row+1
  943. tmp->var = build("<LastUpdateBy>",vl->list[id].allergies[x].last_update_by,"</LastUpdateBy>")
  944. col 01 tmp->var
  945. row+1
  946. tmp->var = build("<LastUpdated>",vl->list[id].allergies[x].last_updated,"</LastUpdated>")
  947. col 01 tmp->var
  948. row+1
  949. ;allergy
  950. tmp->var = "</Allergy>"
  951. col 01 tmp->var
  952. row+1
  953. x = x+1
  954. endwhile
  955. col 0 "</Allergies>"
  956. row+1
  957.  
  958. ; immunizations
  959. col 0 "<Immunizations>"
  960. row +1
  961. x = 1
  962. while (x <= size(vl->list[id].immunizations, 5))
  963. tmp->var = build("<Immunization><CCRDataObjectID>IMM", format(x, "0000;p0"),
  964. "</CCRDataObjectID><Administered>", vl->list[id].immunizations[x].admin_date, "</Administered><Vaccine>",
  965. vl->list[id].immunizations[x].vaccine,
  966. "</Vaccine>")
  967. col 0 tmp->var
  968. row+1
  969. tmp->var = build("<AdminDosage>",vl->list[id].immunizations[x].admin_dosage,"</AdminDosage>")
  970. col 01 tmp->var
  971. row+1
  972. tmp->var = build("<AdminDosageUnit>",vl->list[id].immunizations[x].admin_dosage_unit,"</AdminDosageUnit>")
  973. col 01 tmp->var
  974. row+1
  975. tmp->var = build("<Note>",vl->list[id].immunizations[x].note,"</Note>")
  976. col 01 tmp->var
  977. row+1
  978. tmp->var = build("<Location>",vl->list[id].immunizations[x].location,"</Location>")
  979. col 01 tmp->var
  980. row+1
  981. tmp->var = build("<Route>",vl->list[id].immunizations[x].route,"</Route>")
  982. col 01 tmp->var
  983. row+1
  984. tmp->var = build("<Site>",vl->list[id].immunizations[x].site,"</Site>")
  985. col 01 tmp->var
  986. row+1
  987. tmp->var = build("<Strength>",vl->list[id].immunizations[x].strength,"</Strength>")
  988. col 01 tmp->var
  989. row+1
  990. tmp->var = build("<StrengthUnits>",vl->list[id].immunizations[x].strength_units,"</StrengthUnits>")
  991. col 01 tmp->var
  992. row+1
  993. tmp->var = build("<Type>",vl->list[id].immunizations[x].type,"</Type>")
  994. col 01 tmp->var
  995. row+1
  996. tmp->var = build("<LotNumber>",vl->list[id].immunizations[x].lot_number,"</LotNumber>")
  997. col 01 tmp->var
  998. row+1
  999. tmp->var = build("<Manufacturer>",vl->list[id].immunizations[x].manufacturer,"</Manufacturer>")
  1000. col 01 tmp->var
  1001. row+1
  1002. tmp->var = build("<LastUpdateBy>",vl->list[id].immunizations[x].last_update_by,"</LastUpdateBy>")
  1003. col 01 tmp->var
  1004. row+1
  1005. tmp->var = build("<LastUpdated>",vl->list[id].immunizations[x].last_updated,"</LastUpdated>")
  1006. col 01 tmp->var
  1007. row+1
  1008. ;immunization
  1009. tmp->var = "</Immunization>"
  1010. col 01 tmp->var
  1011. row+1
  1012. x = x+1
  1013. endwhile
  1014. col 0 "</Immunizations>"
  1015. row+1
  1016.  
  1017. ; problems
  1018. col 0 "<Problems>"
  1019. row +1
  1020. x = 1
  1021. while (x <= size(vl->list[id].problems, 5))
  1022. tmp->var = build("<Problem><CCRDataObjectID>PROB", format(x, "0000;p0"),
  1023. "</CCRDataObjectID><Onset>", vl->list[id].problems[x].problem_date, "</Onset><Name>",
  1024. vl->list[id].problems[x].problem,
  1025. "</Name>")
  1026. col 0 tmp->var
  1027. row+1
  1028. tmp->var = build("<Annotation>",vl->list[id].problems[x].annotation,"</Annotation>")
  1029. col 01 tmp->var
  1030. row+1
  1031. tmp->var = build("<CancelReason>",vl->list[id].problems[x].cancel_reason,"</CancelReason>")
  1032. col 01 tmp->var
  1033. row+1
  1034. tmp->var = build("<Certainty>",vl->list[id].problems[x].certainty,"</Certainty>")
  1035. col 01 tmp->var
  1036. row+1
  1037. tmp->var = build("<Classification>",vl->list[id].problems[x].classification,"</Classification>")
  1038. col 01 tmp->var
  1039. row+1
  1040. tmp->var = build("<PregnancyIndicator>",vl->list[id].problems[x].pregnancy_indicator,"</PregnancyIndicator>")
  1041. col 01 tmp->var
  1042. row+1
  1043. tmp->var = build("<ConfirmationStatus>",vl->list[id].problems[x].confirmation_status,"</ConfirmationStatus>")
  1044. col 01 tmp->var
  1045. row+1
  1046. tmp->var = build("<Progress>",vl->list[id].problems[x].progress,"</Progress>")
  1047. col 01 tmp->var
  1048. row+1
  1049. tmp->var = build("<FamilyAware>",vl->list[id].problems[x].family_aware,"</FamilyAware>")
  1050. col 01 tmp->var
  1051. row+1
  1052. tmp->var = build("<Persistence>",vl->list[id].problems[x].persistence,"</Persistence>")
  1053. col 01 tmp->var
  1054. row+1
  1055. tmp->var = build("<Prognosis>",vl->list[id].problems[x].prognosis,"</Prognosis>")
  1056. col 01 tmp->var
  1057. row+1
  1058. tmp->var = build("<Ranking>",vl->list[id].problems[x].ranking,"</Ranking>")
  1059. col 01 tmp->var
  1060. row+1
  1061. tmp->var = build("<Severity>",vl->list[id].problems[x].severity,"</Severity>")
  1062. col 01 tmp->var
  1063. row+1
  1064. tmp->var = build("<SourceIdentifier>",vl->list[id].problems[x].source_identifier,"</SourceIdentifier>")
  1065. col 01 tmp->var
  1066. row+1
  1067. tmp->var = build("<SourceCoding>",vl->list[id].problems[x].source_coding,"</SourceCoding>")
  1068. col 01 tmp->var
  1069. row+1
  1070. tmp->var = build("<LastUpdateBy>",vl->list[id].problems[x].last_update_by,"</LastUpdateBy>")
  1071. col 01 tmp->var
  1072. row+1
  1073. tmp->var = build("<LastUpdated>",vl->list[id].problems[x].last_updated,"</LastUpdated>")
  1074. col 01 tmp->var
  1075. row+1
  1076. ;problem
  1077. tmp->var = "</Problem>"
  1078. col 01 tmp->var
  1079. row+1
  1080. x = x+1
  1081. endwhile
  1082. col 0 "</Problems>"
  1083. row+1
  1084.  
  1085.  
  1086. ; diagnoses
  1087. col 0 "<Diagnoses>"
  1088. row +1
  1089. x = 1
  1090. while (x <= size(vl->list[id].diagnoses, 5))
  1091. tmp->var = build("<Diagnosis><CCRDataObjectID>DIAG", format(x, "0000;p0"),
  1092. "</CCRDataObjectID><Onset>", vl->list[id].diagnoses[x].diagnosis_date, "</Onset><Name>",
  1093. vl->list[id].diagnoses[x].diagnosis,
  1094. "</Name>")
  1095. col 0 tmp->var
  1096. row+1
  1097. tmp->var = build("<Certainty>",vl->list[id].diagnoses[x].certainty,"</Certainty>")
  1098. col 01 tmp->var
  1099. row+1
  1100. tmp->var = build("<Classification>",vl->list[id].diagnoses[x].classification,"</Classification>")
  1101. col 01 tmp->var
  1102. row+1
  1103. tmp->var = build("<ClinicalPriority>",vl->list[id].diagnoses[x].clinical_priority,"</ClinicalPriority>")
  1104. col 01 tmp->var
  1105. row+1
  1106. tmp->var = build("<Service>",vl->list[id].diagnoses[x].service,"</Service>")
  1107. col 01 tmp->var
  1108. row+1
  1109. tmp->var = build("<ConfirmationStatus>",vl->list[id].diagnoses[x].confirmation_status,"</ConfirmationStatus>")
  1110. col 01 tmp->var
  1111. row+1
  1112. tmp->var = build("<AnnotatedDisplay>",vl->list[id].diagnoses[x].annotated_display,"</AnnotatedDisplay>")
  1113. col 01 tmp->var
  1114. row+1
  1115. tmp->var = build("<Category>",vl->list[id].diagnoses[x].category,"</Category>")
  1116. col 01 tmp->var
  1117. row+1
  1118. tmp->var = build("<Class>",vl->list[id].diagnoses[x].class,"</Class>")
  1119. col 01 tmp->var
  1120. row+1
  1121. tmp->var = build("<Priority>",vl->list[id].diagnoses[x].priority,"</Priority>")
  1122. col 01 tmp->var
  1123. row+1
  1124. tmp->var = build("<Type>",vl->list[id].diagnoses[x].type,"</Type>")
  1125. col 01 tmp->var
  1126. row+1
  1127. tmp->var = build("<AdmissionDiagnosis>",vl->list[id].diagnoses[x].admission_diagnosis,"</AdmissionDiagnosis>")
  1128. col 01 tmp->var
  1129. row+1
  1130. tmp->var = build("<Ranking>",vl->list[id].diagnoses[x].ranking,"</Ranking>")
  1131. col 01 tmp->var
  1132. row+1
  1133. tmp->var = build("<Severity>",vl->list[id].diagnoses[x].severity,"</Severity>")
  1134. col 01 tmp->var
  1135. row+1
  1136. tmp->var = build("<SourceIdentifier>",vl->list[id].diagnoses[x].source_identifier,"</SourceIdentifier>")
  1137. col 01 tmp->var
  1138. row+1
  1139. tmp->var = build("<SourceCoding>",vl->list[id].diagnoses[x].source_coding,"</SourceCoding>")
  1140. col 01 tmp->var
  1141. row+1
  1142. tmp->var = build("<LastUpdateBy>",vl->list[id].diagnoses[x].last_update_by,"</LastUpdateBy>")
  1143. col 01 tmp->var
  1144. row+1
  1145. tmp->var = build("<LastUpdated>",vl->list[id].diagnoses[x].last_updated,"</LastUpdated>")
  1146. col 01 tmp->var
  1147. row+1
  1148. ;diagnosis
  1149. tmp->var = "</Diagnosis>"
  1150. col 01 tmp->var
  1151. row+1
  1152. x = x+1
  1153. endwhile
  1154. col 0 "</Diagnoses>"
  1155. row+1
  1156.  
  1157.  
  1158.  
  1159. ; visits
  1160. col 0 "<Visits>"
  1161. row +1
  1162. x = 1
  1163. while (x <= size(vl->list[id].visits, 5))
  1164. tmp->var = build("<Visit><CCRDataObjectID>VIS", format(x, "0000;p0"),
  1165. "</CCRDataObjectID><Arrival>", vl->list[id].visits[x].arrival_date, "</Arrival>")
  1166. col 0 tmp->var
  1167. row+1
  1168. ;visit
  1169. tmp->var = "</Visit>"
  1170. col 01 tmp->var
  1171. row+1
  1172. x = x+1
  1173. endwhile
  1174. col 0 "</Visits>"
  1175. row+1
  1176.  
  1177.  
  1178. ; procedures
  1179. col 0 "<Procedures>"
  1180. row +1
  1181. x = 1
  1182. while (x <= size(vl->list[id].procedures, 5))
  1183. tmp->var = build("<Procedure><CCRDataObjectID>PROC", format(x, "0000;p0"),
  1184. "</CCRDataObjectID><Date>", vl->list[id].procedures[x].procedure_date, "</Date><Name>",
  1185. vl->list[id].procedures[x].procedure,
  1186. "</Name>")
  1187. col 0 tmp->var
  1188. row+1
  1189. tmp->var = build("<Anesthesia>",vl->list[id].procedures[x].anesthesia,"</Anesthesia>")
  1190. col 01 tmp->var
  1191. row+1
  1192. tmp->var = build("<Service>",vl->list[id].procedures[x].service,"</Service>")
  1193. col 01 tmp->var
  1194. row+1
  1195. tmp->var = build("<Note>",vl->list[id].procedures[x].note,"</Note>")
  1196. col 01 tmp->var
  1197. row+1
  1198. tmp->var = build("<Location>",vl->list[id].procedures[x].location,"</Location>")
  1199. col 01 tmp->var
  1200. row+1
  1201. tmp->var = build("<DurationMinutes>",vl->list[id].procedures[x].duration_minutes,"</DurationMinutes>")
  1202. col 01 tmp->var
  1203. row+1
  1204. tmp->var = build("<Ranking>",vl->list[id].procedures[x].ranking,"</Ranking>")
  1205. col 01 tmp->var
  1206. row+1
  1207. tmp->var = build("<SourceIdentifier>",vl->list[id].procedures[x].source_identifier,"</SourceIdentifier>")
  1208. col 01 tmp->var
  1209. row+1
  1210. tmp->var = build("<SourceCoding>",vl->list[id].procedures[x].source_coding,"</SourceCoding>")
  1211. col 01 tmp->var
  1212. row+1
  1213. tmp->var = build("<LastUpdateBy>",vl->list[id].procedures[x].last_update_by,"</LastUpdateBy>")
  1214. col 01 tmp->var
  1215. row+1
  1216. tmp->var = build("<LastUpdated>",vl->list[id].procedures[x].last_updated,"</LastUpdated>")
  1217. col 01 tmp->var
  1218. row+1
  1219. ;procedure
  1220. tmp->var = "</Procedure>"
  1221. col 01 tmp->var
  1222. row+1
  1223. x = x+1
  1224. endwhile
  1225. col 0 "</Procedures>"
  1226. row+1
  1227.  
  1228. ; medications
  1229. col 0 "<Medications>"
  1230. row +1
  1231. x = 1
  1232. while (x <= size(vl->list[id].medications, 5))
  1233. tmp->var = build("<Medication><CCRDataObjectID>MED", format(x, "0000;p0"),
  1234. "</CCRDataObjectID><Start>", vl->list[id].medications[x].start_date, "</Start><Name>",
  1235. vl->list[id].medications[x].medication,
  1236. "</Name><Instructions>", vl->list[id].medications[x].instructions, "</Instructions>")
  1237. col 0 tmp->var
  1238. row+1
  1239. tmp->var = build("<OrderItem>",vl->list[id].medications[x].order_item,"</OrderItem>")
  1240. col 01 tmp->var
  1241. row+1
  1242. tmp->var = build("<OrderId>",vl->list[id].medications[x].order_id,"</OrderId>")
  1243. col 01 tmp->var
  1244. row+1
  1245. tmp->var = build("<ClinicalDisplay>",vl->list[id].medications[x].clinical_display,"</ClinicalDisplay>")
  1246. col 01 tmp->var
  1247. row+1
  1248. tmp->var = build("<DiscontinueIndicator>",vl->list[id].medications[x].discontinue_indicator,"</DiscontinueIndicator>")
  1249. col 01 tmp->var
  1250. row+1
  1251. tmp->var = build("<DiscontinueType>",vl->list[id].medications[x].discontinue_type,"</DiscontinueType>")
  1252. col 01 tmp->var
  1253. row+1
  1254. tmp->var = build("<MedOrderType>",vl->list[id].medications[x].med_order_type,"</MedOrderType>")
  1255. col 01 tmp->var
  1256. row+1
  1257. tmp->var = build("<OrderedAs>",vl->list[id].medications[x].ordered_as,"</OrderedAs>")
  1258. col 01 tmp->var
  1259. row+1
  1260. tmp->var = build("<Status>",vl->list[id].medications[x].status,"</Status>")
  1261. col 01 tmp->var
  1262. row+1
  1263. tmp->var = build("<OrderDate>",vl->list[id].medications[x].order_date,"</OrderDate>")
  1264. col 01 tmp->var
  1265. row+1
  1266. tmp->var = build("<StopDate>",vl->list[id].medications[x].stop_date,"</StopDate>")
  1267. col 01 tmp->var
  1268. row+1
  1269. tmp->var = build("<StopType>",vl->list[id].medications[x].stop_type,"</StopType>")
  1270. col 01 tmp->var
  1271. row+1
  1272. ;medication
  1273. tmp->var = build("<VolumeDose>",vl->list[id].medications[x].volume_dose,"</VolumeDose>")
  1274. col 01 tmp->var
  1275. row+1
  1276. tmp->var = build("<VolumeDoseUnit>",vl->list[id].medications[x].volume_dose_unit,"</VolumeDoseUnit>")
  1277. col 01 tmp->var
  1278. row+1
  1279. tmp->var = build("<Route>",vl->list[id].medications[x].route,"</Route>")
  1280. col 01 tmp->var
  1281. row+1
  1282. tmp->var = build("<Frequency>",vl->list[id].medications[x].frequency,"</Frequency>")
  1283. col 01 tmp->var
  1284. row+1
  1285. tmp->var = build("<PrnYesNo>",vl->list[id].medications[x].prn_yes_no,"</PrnYesNo>")
  1286. col 01 tmp->var
  1287. row+1
  1288. tmp->var = build("<DispenseQuantity>",vl->list[id].medications[x].dispense_quantity,"</DispenseQuantity>")
  1289. col 01 tmp->var
  1290. row+1
  1291. tmp->var = build("<DispenseQuantityUnit>",vl->list[id].medications[x].dispense_quantity_unit,"</DispenseQuantityUnit>")
  1292. col 01 tmp->var
  1293. row+1
  1294. tmp->var = build("<RequestedStartDate>",vl->list[id].medications[x].requested_start_date,"</RequestedStartDate>")
  1295. col 01 tmp->var
  1296. row+1
  1297. ;detailmedication
  1298. tmp->var = "</Medication>"
  1299. col 01 tmp->var
  1300. row+1
  1301. x = x+1
  1302. endwhile
  1303. col 0 "</Medications>"
  1304. row+1
  1305.  
  1306. ; orders
  1307. col 0 "<Orders>"
  1308. row +1
  1309. x = 1
  1310. while (x <= size(vl->list[id].orders, 5))
  1311. tmp->var = build("<Order><CCRDataObjectID>ORD", format(x, "0000;p0"),
  1312. "</CCRDataObjectID><Start>", vl->list[id].orders[x].start_date, "</Start><Name>",
  1313. vl->list[id].orders[x].order_name,
  1314. "</Name><Instructions>", vl->list[id].orders[x].instructions, "</Instructions>")
  1315. col 0 tmp->var
  1316. row+1
  1317. ;order
  1318. ;detailorder
  1319. tmp->var = "</Order>"
  1320. col 01 tmp->var
  1321. row+1
  1322. x = x+1
  1323. endwhile
  1324. col 0 "</Orders>"
  1325. row+1
  1326.  
  1327.  
  1328.  
  1329. ; results
  1330. col 0 "<Results>"
  1331. row +1
  1332. x = 1
  1333. while (x <= size(vl->list[id].results, 5))
  1334. tmp->var = build("<Result><CCRDataObjectID>RES", format(x, "00000;p0"),
  1335. "</CCRDataObjectID><Date>", vl->list[id].results[x].result_date, "</Date><TestName>",
  1336. vl->list[id].results[x].result_name,
  1337. "</TestName><Value>", vl->list[id].results[x].result_value, "</Value>")
  1338. col 0 tmp->var
  1339. row+1
  1340. ;result
  1341. tmp->var = "</Result>"
  1342. col 01 tmp->var
  1343. row+1
  1344. x = x+1
  1345. endwhile
  1346. col 0 "</Results>"
  1347. row+1
  1348.  
  1349.  
  1350. ; payers
  1351. col 0 "<Payers>"
  1352. row +1
  1353. x = 1
  1354. while (x <= size(vl->list[id].payers, 5))
  1355. tmp->var = build("<Payer><CCRDataObjectID>PAY", format(x, "0000;p0"),
  1356. "</CCRDataObjectID><Effective>",
  1357. vl->list[id].payers[x].effective_date, "</Effective><Name>",
  1358. vl->list[id].payers[x].payer, "</Name>")
  1359. col 0 tmp->var
  1360. row+1
  1361. tmp->var = build("<FinancialClass>",vl->list[id].payers[x].financial_class,"</FinancialClass>")
  1362. col 01 tmp->var
  1363. row+1
  1364. tmp->var = build("<GroupName>",vl->list[id].payers[x].group_name,"</GroupName>")
  1365. col 01 tmp->var
  1366. row+1
  1367. tmp->var = build("<GroupNbr>",vl->list[id].payers[x].group_nbr,"</GroupNbr>")
  1368. col 01 tmp->var
  1369. row+1
  1370. tmp->var = build("<PlanType>",vl->list[id].payers[x].plan_type,"</PlanType>")
  1371. col 01 tmp->var
  1372. row+1
  1373. tmp->var = build("<PolicyNbr>",vl->list[id].payers[x].policy_nbr,"</PolicyNbr>")
  1374. col 01 tmp->var
  1375. row+1
  1376. tmp->var = build("<ServiceCoverage>",vl->list[id].payers[x].service_coverage,"</ServiceCoverage>")
  1377. col 01 tmp->var
  1378. row+1
  1379. tmp->var = build("<LastUpdateBy>",vl->list[id].payers[x].last_update_by,"</LastUpdateBy>")
  1380. col 01 tmp->var
  1381. row+1
  1382. tmp->var = build("<LastUpdated>",vl->list[id].payers[x].last_updated,"</LastUpdated>")
  1383. col 01 tmp->var
  1384. row+1
  1385. ;payer
  1386. tmp->var = "</Payer>"
  1387. col 01 tmp->var
  1388. row+1
  1389. x = x+1
  1390. endwhile
  1391.  
  1392. col 0 "</Payers>"
  1393. row+1
  1394.  
  1395. ; actors
  1396. col 0 "<Actors>"
  1397. row +1
  1398. x = 1
  1399. while (x <= size(vl->list[id].actors,5))
  1400. if (vl->list[id].actors[x].role = "PATIENT")
  1401. tmp->var = build("<Patient><ActorObjectID>", vl->list[id].actors[x].id, "</ActorObjectID>")
  1402. col 0 tmp->var
  1403. row+1
  1404. else
  1405. tmp->var = build("<Actor><ActorObjectID>", vl->list[id].actors[x].id, "</ActorObjectID>")
  1406. col 0 tmp->var
  1407. row+1
  1408. endif
  1409.  
  1410. if (vl->list[id].actors[x].role = "PATIENT")
  1411. tmp->var = build("<Person><CurrentName><Given>", vl->list[id].first_name, "</Given><Family>", vl->list[id].last_name,
  1412. "</Family><Middle>",vl->list[id].middle_name,"</Middle></CurrentName><DateOfBirth><ExactDateTime>",
  1413. vl->list[id].birth_date,
  1414. "</ExactDateTime></DateOfBirth><Gender>", vl->list[id].gender, "</Gender>")
  1415. col 01 tmp->var
  1416. row+1
  1417. tmp->var = build("<Ethnicity>",vl->list[id].ethnicity,"</Ethnicity>")
  1418. col 01 tmp->var
  1419. row+1
  1420. tmp->var = build("<Language>",vl->list[id].language,"</Language>")
  1421. col 01 tmp->var
  1422. row+1
  1423. tmp->var = build("<MartialStatus>",vl->list[id].martial_status,"</MartialStatus>")
  1424. col 01 tmp->var
  1425. row+1
  1426. tmp->var = build("<DeceaseDate>",vl->list[id].decease_date,"</DeceaseDate>")
  1427. col 01 tmp->var
  1428. row+1
  1429. tmp->var = build("<DeceasedReason>",vl->list[id].deceased_reason,"</DeceasedReason>")
  1430. col 01 tmp->var
  1431. row+1
  1432. tmp->var = build("<Race>",vl->list[id].race,"</Race>")
  1433. col 01 tmp->var
  1434. row+1
  1435. tmp->var = build("<Religion>",vl->list[id].religion,"</Religion>")
  1436. col 01 tmp->var
  1437. row+1
  1438. tmp->var = build("<Vip>",vl->list[id].vip,"</Vip>")
  1439. col 01 tmp->var
  1440. row+1
  1441. ;person
  1442. tmp->var = "</Person>"
  1443. col 01 tmp->var
  1444. row+1
  1445. x1 = 1
  1446. while (x1 <= size(vl->list[id].patient_identifiers, 5))
  1447. tmp->var = build("<IDs><Type>", vl->list[id].patient_identifiers[x1].idtype, "</Type><ID>",
  1448. vl->list[id].patient_identifiers[x1].idvalue, "</ID><Source>", vl->list[id].patient_identifiers[x1].source,
  1449. "</Source></IDs>")
  1450. col 01 tmp->var
  1451. row+1
  1452. x1 = x1 + 1
  1453. endwhile; patient identifiers
  1454. x1 = 1
  1455. while (x1 <= size(vl->list[id].addresses, 5))
  1456. tmp->var = build("<Address><Type>", vl->list[id].addresses[x1].type, "</Type><Line1>",
  1457. vl->list[id].addresses[x1].street1, "</Line1><Line2>", vl->list[id].addresses[x1].street2,
  1458. "</Line2><City>", vl->list[id].addresses[x1].city,
  1459. "</City><State>", vl->list[id].addresses[x1].state,
  1460. "</State><Country>", vl->list[id].addresses[x1].country,
  1461. "</Country><PostalCode>", vl->list[id].addresses[x1].postalcode,
  1462. "</PostalCode></Address>")
  1463. col 01 tmp->var
  1464. row+1
  1465. x1 = x1 + 1
  1466. endwhile; addresses
  1467. x1 = 1
  1468. while (x1 <= size(vl->list[id].phones, 5))
  1469. tmp->var = build("<Telephone><Type>", vl->list[id].phones[x1].type, "</Type><Number>",
  1470. vl->list[id].phones[x1].phonenbr, "</Number></Telephone>")
  1471. col 01 tmp->var
  1472. row+1
  1473. x1 = x1 + 1
  1474. endwhile; phones
  1475.  
  1476. elseif (vl->list[id].actors[x].role = "ATTENDING")
  1477. ;tmp->var = build("<Person><Name><CurrentName><Given>")
  1478. ;col 01 tmp->var
  1479. row+1
  1480. elseif (vl->list[id].actors[x].role = "PCP")
  1481. ;tmp->var = build("<Person><Name><CurrentName><Given>")
  1482. ;col 01 tmp->var
  1483. row+1
  1484. else
  1485. col 01 vl->list[id].actors[x].xml
  1486. row+1
  1487. endif
  1488.  
  1489. if (vl->list[id].actors[x].role = "PATIENT")
  1490. col 0 "</Patient>"
  1491. row+1
  1492. else
  1493. col 0 "</Actor>"
  1494. row+1
  1495. endif
  1496.  
  1497. x = x+1
  1498. endwhile
  1499. col 0 "</Actors>"
  1500. row+1
  1501.  
  1502.  
  1503. col 0 "</ContinuityOfCareRecord>"
  1504. row+1
  1505.  
  1506. id = id +1
  1507. endwhile; loop visits
  1508.  
  1509.  
  1510. with check, format, maxcol=400, maxrow=0
  1511.  
  1512.  
  1513. ; convert xml markup
  1514. subroutine getXmlDisplay(s)
  1515. set getXmlDisplay = build(s)
  1516. end; getXmlDisplay
  1517.  
  1518.  
  1519.  
  1520.  
  1521. end
  1522. go
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement