Advertisement
Guest User

Untitled

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