I'm working on a form that I would like for the users to be able to choose 2 diagnoses (sometimes for procedures they do need to have that functionality available. And have them be able to use an action button (runprocess) to enter the order with the double dx in place. I've seen it work previously, but for some reason I cannot get it to work on the form that I am trying to build now. This is the MEL code that I am using to identify the fields etc.
{fn break_dx(field,item){
local odx = ""
local opar = match(field," (")
local fsz = size(field)
if item == "desc" and opar <> 0 then
odx = sub(field,1,opar)
else if item == "desc" and opar == 0 then
odx = field
else if item == "code" AND opar <> "" then
odx = sub(field,opar + 2,fsz - opar - 2)
else ""
endif
endif
endif
odx}}
{fn torder_dx(type){
local dxarg = ""
local d1 = break_dx(DOCUMENT.DIAGNOSIS1,type)
local d2 = break_dx(DOCUMENT.DIAGNOSIS,type)
if size(d1) > 0 then
dxarg = d1
endif
if size(d2) > 0 then
dxarg = dxarg + "|" + d2
endif
dxarg}}
The DOCUMENT.DIAGNOSIS1 and the DOCUMENT DIAGNOSIS document variables are dropdown fields. Then for adding the order, the example for a left sided, single level cervical facet injection would be as follows:
MEL_ADD_ORDER("S", "*Injections", "Facet cerv/thor single lvl", "LT",torder_dx("code"),torder_dx("desc"), "", "", "", "", "")
But unfortunately, it doesn't add the order at all.
This code for adding the order does add a single dx code - and this one does work correctly, but I do need it to be able to add at least 2. MEL_ADD_ORDER("S", "*Injections", "Facet cerv/thor single lvl", "LT", break_dx(DOCUMENT.DIAGNOSIS1,"code"), break_dx(DOCUMENT.DIAGNOSIS1,"desc"), "", "", "", "", "")
Any thoughts, suggestions, advice would be most appreciated.
A note of caution on your approach and a recommendation on improving your code:
The caution:
Always consider the data input you are working with. It may be possible that you are working with a diagnosis description containing an open parenthesis which would, if present, completely blow up your function.
The recommendation:
Using the string from the select field (selected diagnoses), parse the prob_after list and look for a match by rebuilding the string using the prob_after elements. If a match is found, then build your delimited description and code strings, otherwise continue the loop. In this manner, you will ensure you have an exact match, which is more important today as it relates to the similarities in ICD-10 coding than ever before. You would need two loops (or functions), 1 to loop through the selected items, the other to parse/compare each item with the prob_after list.
Hope this helps. 🙂