Wednesday, October 28, 2015

DRGFilt and CGI (Web UI)

With our new DRGFilt control file format it seemed that one could use DRGFilt as a Web page helper app. In other words, we figured it should be easy to call DRGFilt from a CGI script to add DRG assignment to a web page. So we allocated a couple of hours to put that theory to the test and ended up with a fully functional web-based interactive grouper.

We were especially interested in this experiment because we use web-based interactive groupers internally, mostly for debugging specific cases because it is easier for a customer service person to use a web page than to use DRGFilt directly for a single case. We were looking to replace our old CGI-DRG product because we did not want to maintain it in the ICD10 world.

Step 1: we created a simple and lightweight Perl script to provide a basic HTML form and to call DRGFilt which we called "drgui.pl" for "DRG User Interface" and which we eventually made publicly available here.

Step 2: we created a DRGFilt control file group to do CGI, which we cleverly called "cgi":

; this group was added to support drgfilt-as-CGI helper
[cgi]
verbose = 0;
format = csv (^)        ; separator character is in parens
base = 0                ; indices are zero-based
inheaders = 0           ; 1=input column headers, 0=no input column headers
outheaders = 0          ; 1=want column headers, 0=no headers
crlf = 0                ; type of end-of-line: either crlf or lf
blip = 1                ; want something in the log
blipeol = 1             ; 1=newline for progress report, 0=carriage return
batchver = 33
maskdir = /var/www/cgi-bin/drgstuff
log = /tmp/me.out

; input variables: name = index
inid = 0
age =  1
sex = 2
exmp = 3
ds =  4
dx = 5-29
poa = 30-54
surg= 55-79

; these are written out by DRGFilt
rc  = 0
mdc = 1
drg = 2
outver = 3
weight = 4
mean = 5
morp = 6
desc = 7
dflg = 8                ; string of flags for which dx codes were used
sflg = 9                ; string of flags for which pr codes were used
; eof


Step 3: we created some simple plumbing from drgui.pl to DRGFilt (send the input via stdin, read the output via stdout):

my @i = ();
push(@i,0);                     # 0: the record ID
push(@i,$vars{'age'});          # 1: patient age on admission
push(@i,$vars{'sex'});          # 2: patient sex (1=male, 2=female)
push(@i,$vars{'exempt'});       # 3: exempt
push(@i,$vars{'dstat'});        # 4: discharge status (home)
for (my $i = 0; $i < 25; $i++) {# 6-29: ICD DX codes
    my $icd = substr($dx,$i*7,7);
    $icd =~ s/\s+$//;
    push(@i,$icd);
}
for (my $i = 0; $i < 25; $i++) {# 30-54: POA codes
    push(@i,substr($poa,$i,1));
}
for (my $i = 0; $i < 25; $i++) {# 55-79: ICD procedure codes
    my $icd = substr($px,$i*7,7);
    $icd =~ s/\s+$//;
    push(@i,$icd);
}
my $inrec = join('^',@i);

open(PIPE,"/bin/echo \"$inrec\" | $MYDIR/drgfiltv33 -v -l /tmp/me.out $MYDIR/v33.ini cgi|");
my $retval = <PIPE>;
($rc,$mdc,$drg,$ovn,$weight,$mean,$porm,$desc,$dxu,$pru) = split(/\^/,$retval,-1);


Step 4: pick a test case from the CMS data set and try it out:

[       2]-------------------------------------------
   Age: 055   
   Sex: M   
  Disp: 01

  Exem: Z (Exempt-from-HAC indicator)

   DRG: 231    
   MDC: 05    
   GRC: 00

  DX's| Code    |POA indicator
 -----+--------------
  DX01| B5881   |Y
  DX02| I2101   |

Proc's| Code
 -----+---------------------
  SG01| 0210093
  SG02| 02UG3JZ


Step 5: declare success and decide to put this out on the web so that our customers can debug issues with their own installations.

No comments:

Post a Comment