Advertisement
Guest User

Untitled

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