fdb_notes.txt 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347
  1. medSuggest
  2. https://docs.fdbhealth.com/display/MKDOCUS/Navigating+to+a+Routed+Medication+Route+Dosage+Form+and+Medication
  3. Retrieve the MED Medication Name ID (MED_NAME_ID) from the MED Medication Name Table (RMINMID1_MED_NAME) where the MED Medication Name (MED_NAME) equals the given drug.
  4. "SELECT med_name_id, med_name FROM rminmid1_med_name WHERE med_status_cd = '0' AND med_name ILIKE :term ORDER BY med_name",
  5. ['term' => '%' . $term . '%']
  6. SELECT * FROM rminmid1_med_name LIMIT 5;
  7. med_name_id | med_name | med_name_type_cd | med_status_cd
  8. -------------+-------------------------------+------------------+---------------
  9. 1 | sertraline | 2 | 0
  10. 2 | Acetaminophen-Hydrocodone | 1 | 1
  11. 3 | hydrocodone-carbinox-pseudoep | 2 | 3
  12. 4 | Phenylhistine DH | 1 | 3
  13. 5 | denture care products | 2 | 3
  14. routedMeds
  15. https://docs.fdbhealth.com/display/MKDOCUS/Navigating+to+a+Routed+Medication+Route+Dosage+Form+and+Medication
  16. Retrieve the Routed Medication ID (ROUTED_MED_ID) and MED Routed Medication Description (MED_ROUTED_MED_ID_DESC) values from the MED Routed Medication Table (RMIRMID1_ROUTED_MED) where the MED Medication Name (MED_NAME_ID) equals the value retrieved in the previous step and the MED Medication Status Code (MED_STATUS_CD) value equals 0 (active).
  17. "SELECT routed_med_id, med_routed_med_id_desc FROM rmirmid1_routed_med WHERE med_status_cd = '0' AND med_name_id = :medNameID ORDER BY med_routed_med_id_desc",
  18. ['medNameID' => $medNameID]
  19. SELECT * FROM rmirmid1_routed_med WHERE med_name_id = 1;
  20. routed_med_id | med_name_id | med_route_id | med_routed_med_id_desc | med_status_cd
  21. ---------------+-------------+--------------+------------------------+---------------
  22. 1 | 1 | 24 | sertraline oral | 0
  23. routedDosages
  24. https://docs.fdbhealth.com/display/MKDOCUS/Navigating+to+a+Routed+Medication+Route+Dosage+Form+and+Medication
  25. Retrieve the MED Routed Dosage Form Med ID (ROUTED_DOSAGE_FORM_MED_ID) and from the MED Routed Dosage Form Medication Table (RMIDFID1_ROUTED_DOSE_FORM_MED) where the MED Routed Medication ID (ROUTED_MED_ID) equals the value retrieved in step 2 and th
  26. "SELECT routed_dosage_form_med_id, med_routed_df_med_id_desc FROM rmidfid1_routed_dose_form_med WHERE med_status_cd = '0' AND routed_med_id = :routedMedID ORDER BY med_routed_df_med_id_desc",
  27. ['routedMedID' => $routedMedID]
  28. SELECT * FROM rmidfid1_routed_dose_form_med WHERE routed_med_id = 1;
  29. routed_dosage_form_med_id | routed_med_id | med_dosage_form_id | med_routed_df_med_id_desc | med_status_cd
  30. ---------------------------+---------------+--------------------+-----------------------------+---------------
  31. 1 | 1 | 81 | sertraline tablet | 0
  32. 20735 | 1 | 10 | sertraline oral concentrate | 0
  33. meds
  34. https://docs.fdbhealth.com/display/MKDOCUS/Navigating+to+a+Routed+Medication+Route+Dosage+Form+and+Medication
  35. Retrieve the Medication Identifier (MEDID) and MED Medication Description (MED_MEDID_DESC) values from the MED Medication Table (RMIID1_MED) where the MED Routed Dosage Form Med ID (ROUTED_DOSAGE_FORM_MED_ID) equals the value retrieved in the previous step and the MED Medication Status Code (MED_STATUS_CD) value equals 0 (active).
  36. "SELECT medid, med_medid_desc, gcn_seqno FROM rmiid1_med WHERE med_status_cd = '0' AND routed_dosage_form_med_id = :dosageFormMedId ORDER BY med_medid_desc",
  37. ['dosageFormMedId' => $dosageFormMedId]
  38. \d rmiid1_med
  39. Table "public.rmiid1_med"
  40. Column | Type | Collation | Nullable | Default
  41. ---------------------------+-----------------------+-----------+----------+---------
  42. medid | numeric(8,0) | | not null |
  43. routed_dosage_form_med_id | numeric(8,0) | | not null |
  44. med_strength | character varying(15) | | |
  45. med_strength_uom | character varying(15) | | |
  46. med_medid_desc | character varying(70) | | not null |
  47. gcn_seqno | numeric(6,0) | | not null |
  48. med_gcnseqno_assign_cd | character varying(1) | | not null |
  49. med_name_source_cd | character varying(1) | | not null |
  50. med_ref_fed_legend_ind | character varying(1) | | not null |
  51. med_ref_dea_cd | character varying(1) | | not null |
  52. med_ref_multi_source_cd | character varying(1) | | not null |
  53. med_ref_gen_drug_name_cd | character varying(1) | | not null |
  54. med_ref_gen_comp_price_cd | character varying(1) | | not null |
  55. med_ref_gen_spread_cd | character varying(1) | | not null |
  56. med_ref_innov_ind | character varying(1) | | not null |
  57. med_ref_gen_thera_equ_cd | character varying(1) | | not null |
  58. med_ref_desi_ind | character varying(1) | | not null |
  59. med_ref_desi2_ind | character varying(1) | | not null |
  60. med_status_cd | character varying(1) | | not null |
  61. generic_medid | numeric(8,0) | | |
  62. sideEffects
  63. https://docs.fdbhealth.com/display/MKDOCUS/Retrieving+a+List+of+Side+Effects
  64. -- Query the GCN_SEQNO column of the SIDE GCN_SEQNO/Drug Side Effect Code Relation Table (RSIDEGC0_GCNSEQNO_LINK) using the drug’s Clinical Formulation ID (GCN_SEQNO) value to retrieve all of its related SIDE Side Effects Code (SIDE) values.
  65. -- Query the SIDE column of the SIDE Master Table (RSIDEMA3_MSTR) using each SIDE value from the previous step to retrieve the following columns:
  66. -- SIDE Frequency of Occurrence Code (SIDE_FREQ)
  67. -- SIDE Severity Code (SIDE_SEV)
  68. -- FML Disease Identifier (DXID)
  69. -- Follow the process described in the FML module’s Finding DXID Descriptions and Synonyms application to find each DXID value’s Primary Layman Name.
  70. SELECT r1.side, sm.side_freq, sm.side_sev, sm.dxid, dx.dxid_desc56
  71. FROM rsidegc0_gcnseqno_link r1
  72. JOIN rsidema3_mstr sm ON r1.side = sm.side
  73. JOIN rfmldx0_dxid dx ON sm.dxid = dx.dxid
  74. WHERE r1.gcn_seqno = :gcnSeqNo
  75. ORDER BY sm.side_sev DESC, sm.side_freq ASC
  76. ['gcnSeqNo' => $gcnSeqNo]
  77. -- get a drug(routed dosage med) gcn_seqno
  78. SELECT gcn_seqno FROM rmiid1_med WHERE routed_dosage_form_med_id = 20735;
  79. gcn_seqno
  80. -----------
  81. 46230
  82. -- get side effects for the genseq
  83. SELECT * FROM rsidegc0_gcnseqno_link WHERE gcn_seqno = 46230;
  84. gcn_seqno | side
  85. -----------+------
  86. 46230 | 560
  87. 46230 | 2451
  88. -- get side effect details
  89. SELECT * FROM RSIDEMA3_MSTR WHERE side = 560;
  90. side | side_sn | fdbdx | side_freq | side_sev | side_viscd | side_labcd | side_phys | side_hyper | dxid
  91. ------+---------+-----------+-----------+----------+------------+------------+-----------+------------+-------
  92. 560 | 0 | 03.276100 | 2 | 1 | 2 | 1 | 1 | | 736
  93. 560 | 1 | 05.296000 | 2 | 1 | 1 | 0 | 1 | | 950
  94. 560 | 2 | 05.296010 | 2 | 1 | 1 | 0 | 1 | | 951
  95. 560 | 3 | 05.300007 | 2 | 0 | 1 | 0 | 0 | | 14664
  96. 560 | 4 | 05.300906 | 2 | 1 | 1 | 0 | 1 | | 985
  97. 560 | 5 | 05.302700 | 0 | 1 | 1 | 0 | 1 | | 992
  98. 560 | 6 | 05.302701 | 0 | 1 | 1 | 0 | 1 | | 993
  99. 560 | 7 | 05.307900 | 1 | 0 | 1 | 0 | 0 | | 1018
  100. -- side_feq dictionary
  101. 1 = Incidence less frequent
  102. 0 = Incidence more frequent
  103. 2 = Incidence rare or very rare
  104. -- side_sev dictionary
  105. 0 = “less severe” if it is non-threatening (such as constipation)
  106. 1 = “severe” if it may be life-threatening (such as agranulocytosis)
  107. -- get the description for a side effect using dxid
  108. SELECT * FROM rfmldx0_dxid WHERE dxid = 736;
  109. dxid | dxid_desc56 | dxid_desc100 | dxid_status | fdbdx | dxid_disease_duration_cd
  110. ------+--------------+--------------+-------------+-----------+--------------------------
  111. 736 | hyponatremia | hyponatremia | 0 | 03.276100 | 3
  112. geriatricPrecautions
  113. https://docs.fdbhealth.com/display/MKDOCUS/Application%3A+Screening+a+Drug+for+Geriatric+Precautions
  114. -- Select Geriatric Precaution Code (GERI_CODE) from the GERI GCN_SEQNO Link Table (RGERIGC0_GERI_GCNSEQNO_LINK) where the Clinical Formulation ID (GCN_SEQNO) column equals the Clinical Formulation ID (GCN_SEQNO) of the drug to screen.
  115. -- Select GERI precautions information from the Geriatric Precautions Master Table (RGERIMA1_GERI_MSTR) where the GERI_CODE column equals the GERI_CODE value from the previous step.
  116. SELECT r1.geri_code, gm.geri_sl, gm.geri_desc, gm.geri_narrative
  117. FROM rgerigc0_geri_gcnseqno_link r1
  118. JOIN rgerima1_geri_mstr gm ON r1.geri_code = gm.geri_code
  119. WHERE r1.gcn_seqno = :gcnSeqNo
  120. ORDER BY gm.geri_desc
  121. ['gcnSeqNo' => $gcnSeqNo]
  122. -- select geriatricPrecautions based for a given drug formulation code
  123. SELECT * FROM RGERIGC0_GERI_GCNSEQNO_LINK WHERE gcn_seqno = 46230 LIMIT 5 ;
  124. gcn_seqno | geri_code
  125. -----------+-----------
  126. 46230 | 831
  127. -- get the meaning of the geri_code
  128. SELECT geri_code, geri_desc, geri_narrative FROM RGERIMA1_GERI_MSTR WHERE geri_code = 831;
  129. geri_code | geri_desc | geri_narrative
  130. -----------+------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------
  131. 831 | Sertraline | Hepatic-Mild hepatic impairment of aging may predispose the elderly to increased serum levels and increased adverse events. Endocrine-May exacerbate or cause SIADH
  132. or hyponatremia. Monitor sodium level closely when starting or changing dosages in older adults.
  133. indications
  134. https://docs.fdbhealth.com/display/MKDOCUS/Retrieving+a+Drug%27s+List+of+Indications
  135. Indications refers to the use of that drug for treating a particular disease
  136. -- Retrieve the INDM Indications Code (INDCTS) associated to the drug product’s Clinical Formulation ID (GCN_SEQNO) using the INDM GCN_SEQNO/Drug Indications Code Relation Table (RINDMGC0_INDCTS_GCNSEQNO_LINK).
  137. -- For each Clinical Formulation ID (GCN_SEQNO)/INDCTS combination retrieved in step 2, retrieve the following columns from the INDM Master Table (RINDMMA2_INDCTS_MSTR):
  138. -- INDM Sequence Number (INDCTS_SN)
  139. -- INDM Labeled Code (INDCTS_LBL)
  140. -- FML Disease Identifier (DXID)
  141. -- INDM Proxy Indicator (PROXY_IND)
  142. -- Get the description from https://docs.fdbhealth.com/display/MKDOCUS/Finding+DXID+Descriptions+and+Synonyms
  143. -- For DxID 00000595’s Primary Professional Name, find its associated FML 56-character Description column (DXID_DESC56) and FML 100-character Description column (DXID_DESC100) in the FML Disease Identifier (DxID) Table (RFMLDX0_DXID).
  144. SELECT r1.indcts, r2.indcts_sn, r2.indcts_lbl, r2.dxid, r2.proxy_ind, r3.dxid_desc56
  145. FROM rindmgc0_indcts_gcnseqno_link r1
  146. JOIN rindmma2_indcts_mstr r2 ON r1.indcts = r2.indcts
  147. JOIN rfmldx0_dxid r3 ON r2.dxid = r3.dxid
  148. WHERE r1.gcn_seqno = :gcnSeqNo
  149. ORDER BY r3.dxid_desc56
  150. ['gcnSeqNo' => $gcnSeqNo]
  151. -- Select indications for a given gcn_seqno
  152. SELECT * FROM RINDMGC0_INDCTS_GCNSEQNO_LINK WHERE gcn_seqno = 46230;
  153. gcn_seqno | indcts
  154. -----------+--------
  155. 46230 | 201
  156. -- get the details of the indicts
  157. SELECT * FROM RINDMMA2_INDCTS_MSTR WHERE indcts = 201 AND proxy_ind <> 'Y' LIMIT 5;
  158. indcts | indcts_sn | indcts_lbl | fdbdx | dxid | proxy_ind | pred_code
  159. --------+-----------+------------+-----------+-------+-----------+-----------
  160. 201 | 0 | U | 05.296500 | 12862 | N | 3
  161. 201 | 1 | U | 05.298001 | 8464 | N | 3
  162. 201 | 2 | L | 05.300010 | 970 | N | 2
  163. 201 | 3 | L | 05.300230 | 975 | N | 2
  164. 201 | 4 | L | 05.300300 | 976 | N | 3
  165. NB: to remove Non-FDA approved, add where indcts_lbl <> 'U'; //U == unlabeled
  166. -- get the meaning of DXIDs
  167. SELECT * FROM RFMLDX0_DXID WHERE dxid IN (970, 975, 976);
  168. dxid | dxid_desc56 | dxid_desc100 | dxid_status | fdbdx | dxid_disease_duration_cd
  169. ------+-------------------------------+-------------------------------+-------------+-----------+--------------------------
  170. 970 | panic disorder | panic disorder | 0 | 05.300010 | 1
  171. 975 | social phobia | social phobia | 0 | 05.300230 | 2
  172. 976 | obsessive-compulsive disorder | obsessive-compulsive disorder | 0 | 05.300300 | 2
  173. contraindications
  174. https://docs.fdbhealth.com/display/MKDOCUS/Retrieving+a+List+of+Drug+Contraindications
  175. -- Get drug ddxcn from rddcmrm0_routed_med_link
  176. -- Retrieve the FML Disease Identifier (DXID) values associated with DDXCN 50225 from the DDCM Master Table (RDDCMMA1_CONTRA_MSTR).
  177. -- Retrieve the FML 100-Character Description (DXID_DESC100) for each DXID value using the FML Disease Identifier (DxID) Table (RFMLDX0_DXID).
  178. SELECT r1.ddxcn, r2.dxid, r2.ddxcn_sl, r3.dxid_desc56
  179. FROM rddcmrm0_routed_med_link r1
  180. JOIN rddcmma1_contra_mstr r2 ON r1.ddxcn = r2.ddxcn
  181. JOIN rfmldx0_dxid r3 ON r2.dxid = r3.dxid
  182. WHERE r1.routed_med_id = :routedMedID
  183. ORDER BY r2.ddxcn_sl
  184. ['routedMedID' => $routedMedID]
  185. -- get drug disease contraindications for a given routed_med_id
  186. SELECT * FROM RDDCMRM0_ROUTED_MED_LINK WHERE routed_med_id = 1;
  187. routed_med_id | ddxcn
  188. ---------------+-------
  189. 1 | 50005
  190. -- get the details of ddxcn
  191. SELECT * FROM RDDCMDD0_CONTRA_DRUG_DESC WHERE ddxcn = 50005;
  192. ddxcn | ddxcn_drug_desc
  193. -------+-----------------
  194. 50005 | SERTRALINE
  195. -- get dxid associated with the ddxcn (get disease id associated with the contraindications)
  196. SELECT * FROM RDDCMMA1_CONTRA_MSTR WHERE ddxcn = 50005;
  197. ddxcn | ddxcn_sn | fdbdx | ddxcn_sl | ddxcn_ref | dxid
  198. -------+----------+-----------+----------+----------------------------+-------
  199. 50005 | 0 | 03.276100 | 3 | ZOLOFT PI, 12/2016 | 736
  200. 50005 | 1 | 03.253600 | 3 | ZOLOFT PI, 12/2016 | 624
  201. 50005 | 2 | 04.286906 | 3 | ZOLOFT PI, 12/2016 | 867
  202. 50005 | 3 | 05.296700 | 3 | ZOLOFT PI, 12/2016 | 954
  203. 50005 | 4 | 05.300906 | 2 | MEDWATCH, 3/04, PI 5/14 | 985
  204. 50005 | 5 | 09.573900 | 2 | ZOLOFT PI, 12/2016 | 2202
  205. -- get human readable meanings of the dxid
  206. SELECT * FROM RFMLDX0_DXID WHERE dxid IN (736,624,867,954,985,2202);
  207. dxid | dxid_desc56 | dxid_desc100 | dxid_status | fdbdx | dxid_disease_duration_cd
  208. ------+----------------------------+----------------------------+-------------+-----------+--------------------------
  209. 624 | SIADH syndrome | SIADH syndrome | 0 | 03.253600 | 3
  210. 736 | hyponatremia | hyponatremia | 0 | 03.276100 | 3
  211. 867 | increased risk of bleeding | increased risk of bleeding | 0 | 04.286906 | 2
  212. 954 | bipolar disorder | bipolar disorder | 0 | 05.296700 | 2
  213. 985 | suicidal ideation | suicidal ideation | 0 | 05.300906 | 3
  214. 2202 | disease of liver | disease of liver | 0 | 09.573900 | 2
  215. dxSuggest
  216. https://docs.fdbhealth.com/display/MKDOCUS/Finding+DXID+Descriptions+and+Synonyms
  217. -- For DxID 00000595’s Primary Professional Name, find its associated FML 56-character Description column (DXID_DESC56) and FML 100-character Description column (DXID_DESC100) in the FML Disease Identifier (DxID) Table (RFMLDX0_DXID).
  218. -- For DxID 00000595’s Professional Synonyms, find its associated FML 56-character Synonym Description (DXID_SYN_DESC56) and FML 100-character Synonym Description (DXID_SYN_DESC100) in the FML Disease Identifier (DxID) Synonym Table (RFMLSYN0_DXID_SYN). Specify a value of 01 for the FML Name Type Code (DXID_SYN_NMTYP) to signify that you wish to retrieve this DxID’s Professional Synonyms.
  219. -- i.e search where term matches in the main table (rfmldx0_dxid) and in the synonyms table (rfmlsyn0_dxid_syn) on both 56 and 100 character descriptions
  220. SELECT distinct(r1.dxid), r1.dxid_desc56
  221. FROM rfmldx0_dxid r1
  222. JOIN rfmlsyn0_dxid_syn r2 ON r1.dxid = r2.dxid
  223. WHERE (r1.dxid_desc56 ILIKE :term OR r1.dxid_desc100 ILIKE :term OR r2.dxid_syn_desc56 ILIKE :term OR r2.dxid_syn_desc100 ILIKE :term)
  224. ORDER BY r1.dxid_desc56
  225. ['term' => '%' . $term . '%']
  226. -- DX has
  227. - Primary Professional Name: one and only one - RFMLDX0_DXID
  228. RFMLSYN0_DXID_SYN
  229. - Professional Synonym: zero, one, or many - dxid_syn_nmtyp = 01
  230. - Primary Layman Name: zero, one, or many - dxid_syn_nmtyp = 02
  231. - Layman Synonym: zero, one, or many - dxid_syn_nmtyp = 03
  232. - Abbreviation: zero, one, or many - dxid_syn_nmtyp = 04
  233. SELECT * FROM RFMLDX0_DXID WHERE dxid = '595';
  234. dxid | dxid_desc56 | dxid_desc100 | dxid_status | fdbdx | dxid_disease_duration_cd
  235. ------+--------------------------+--------------------------+-------------+-----------+--------------------------
  236. 595 | type 1 diabetes mellitus | type 1 diabetes mellitus | 0 | 03.250010 | 2
  237. -- get synonyms:
  238. SELECT * FROM RFMLSYN0_DXID_SYN WHERE dxid = 595 AND dxid_syn_nmtyp = '01';
  239. dxid_synid | dxid | dxid_syn_nmtyp | dxid_syn_desc56 | dxid_syn_desc100 | dxid_syn_status
  240. ------------+------+----------------+-------------------------------------+-------------------------------------+-----------------
  241. 384 | 595 | 01 | juvenile diabetes | juvenile diabetes | 0
  242. 387 | 595 | 01 | insulin-dependent DM | insulin-dependent DM | 0
  243. 388 | 595 | 01 | insulin-dependent diabetes mellitus | insulin-dependent diabetes mellitus | 0
  244. 389 | 595 | 01 | ketosis-prone diabetes mellitus | ketosis-prone diabetes mellitus | 0
  245. 390 | 595 | 01 | ketosis-prone diabetes | ketosis-prone diabetes | 0
  246. 391 | 595 | 01 | juvenile-onset diabetes | juvenile-onset diabetes | 0
  247. 392 | 595 | 01 | juvenile-onset diabetes mellitus | juvenile-onset diabetes mellitus | 0
  248. 393 | 595 | 01 | juvenile onset DM | juvenile onset DM | 0
  249. 394 | 595 | 01 | type I diabetes mellitus | type I diabetes mellitus | 0
  250. 395 | 595 | 01 | diabetes mellitus type 1 | diabetes mellitus type 1 | 0
  251. 396 | 595 | 01 | ketosis-prone DM | ketosis-prone DM | 0
  252. 58331 | 595 | 01 | insulin dependent diabetes mellitus | insulin dependent diabetes mellitus | 0
  253. 58407 | 595 | 01 | immune mediated diabetes mellitus | immune mediated diabetes mellitus | 0
  254. allergySuggest
  255. https://docs.fdbhealth.com/display/MKDOCUS/Recording+Patient+Allergy+Information
  256. -- Query the DAM Allergen Concept ID Description column (DAM_CONCEPT_ID_DESC) in the RDAMAPM0_ALRGN_PICKLIST_MSTR table or the RDAMCA0_CONCEPT table to find all entries with the description “carbamates."
  257. SELECT r1.dam_concept_id, r1.dam_concept_id_typ, r1.dam_concept_id_desc
  258. FROM rdamca0_concept r1
  259. WHERE (r1.dam_concept_id_desc ILIKE :term)
  260. ORDER BY r1.dam_concept_id_desc
  261. drugDrugInteraction
  262. https://docs.fdbhealth.com/display/MKDOCUS/Screening+for+Active+and+Inactive+Ingredient+Drug-Drug+Interactions
  263. drugCoadministration
  264. https://docs.fdbhealth.com/display/MKDOCUS/Displaying+Coadministration+Text
  265. duplicateTherapy
  266. https://docs.fdbhealth.com/display/MKDOCUS/Detecting+Therapeutic+Class+Duplications
  267. -- Retrieve the Routed Medication ID (ROUTED_MED_ID) in the DPT Routed Medication ID Table(rmirmid1_routed_med), or Routed Generic Identifier (ROUTED_GEN_ID) in the DPT Routed Generic Table, or Clinical Formulation ID (GCN_SEQNO) in the DPT GCN_SEQNO Table for the newly prescribed (prospective) drug and for each drug in the patient profile (profiled drugs).
  268. -- Retrieve the associated DPT Class Identifiers (DPT_CLASS_ID) from the DPT Class Table (RDPTCL0_CLASS_ID) for each prospective drug and each profiled drug.
  269. -- Compare the DPT_CLASS_IDs and retrieve the DPT Class Description (DPT_CLASS_DESC) record from the RDPTCL0_CLASS_ID table when Duplicate Therapy Class matches occur.
  270. -- Compare the number of times that a match of a given class is returned with the DPT Duplication Allowance (DPT_ALLOWANCE) from the RDPTCL0_CLASS_ID table. If the number of matches exceeds the DPT_ALLOWANCE value, a duplicate therapy exists. In most instances, the duplication allowance is zero. Programming for a duplication allowance of one or more should occur only for drugs in the same class that are used concurrently, per accepted medical practice.
  271. =====================================================================================================
  272. Get drugs used to treat a given condition
  273. -- get dxid for the condition eg. 'social phobia'
  274. SELECT * FROM RFMLDX0_DXID WHERE dxid_desc56 ILIKE 'social%';
  275. dxid | dxid_desc56 | dxid_desc100 | dxid_status | fdbdx | dxid_disease_duration_cd
  276. ------+---------------+---------------+-------------+-----------+--------------------------
  277. 975 | social phobia | social phobia | 0 | 05.300230 | 2
  278. -- get indcts for the condition
  279. SELECT DISTINCT(indcts) FROM RINDMMA2_INDCTS_MSTR WHERE dxid = 975 AND proxy_ind <> 'Y' AND indcts_lbl <> 'U';
  280. indcts
  281. --------
  282. 201
  283. 1006
  284. 1457
  285. 1695
  286. -- get clinical formulations (gcn_seqno) for the above indcts
  287. SELECT * FROM RINDMGC0_INDCTS_GCNSEQNO_LINK WHERE indcts IN (201,1006,1457,1695);
  288. gcn_seqno | indcts
  289. -----------+--------
  290. 46222 | 1006
  291. 46223 | 1006
  292. 46224 | 1006
  293. 46225 | 1006
  294. 46226 | 1006
  295. ....
  296. -- get drugs that contain this gcn_seqno
  297. SELECT medid, med_medid_desc, gcn_seqno FROM rmiid1_med WHERE gcn_seqno IN (SELECT gcn_seqno FROM RINDMGC0_INDCTS_GCNSEQNO_LINK WHERE indcts IN (201,1006,1457,1695));
  298. SELECT medid, med_medid_desc, gcn_seqno FROM rmiid1_med WHERE gcn_seqno IN (SELECT gcn_seqno FROM RINDMGC0_INDCTS_GCNSEQNO_LINK WHERE indcts IN (201,1006,1457,1695));
  299. medid | med_medid_desc | gcn_seqno
  300. --------+-------------------------------------------------------+-----------
  301. 157825 | paroxetine ER 37.5 MG tablet,extended release 24 hr | 50138
  302. 159557 | venlafaxine ER 37.5 mg capsule,extended release 24 hr | 46403
  303. 160594 | venlafaxine ER 75 mg capsule,extended release 24 hr | 46404
  304. 162880 | paroxetine 10 mg tablet | 46222
  305. 165384 | Effexor XR 75 mg capsule,extended release | 46404
  306. 166110 | Paxil CR 37.5 MG tablet,extended release | 50138
  307. 182739 | Effexor XR 37.5 mg capsule,extended release | 46403
  308. 183163 | Paxil 20 mg tablet | 46223
  309. 184142 | Paxil 10 mg/5 mL oral suspension | 46226
  310. 187550 | sertraline 100 mg tablet | 46229