Thursday, January 30, 2020

Updated VB.NET Sample Code

We recently had to help a customer get our DLL to work in their VB.Net environment because our sample code was so out of date. In order to spare other customers this pain, we post this code example. Note that this code is for version 37 (v37); change the version to match your particular situation.


Option Explicit On
Imports System.Deployment
Imports System.Runtime.InteropServices

Module Module1
    Private Declare Function mhdllver Lib "vbdrgv37.dll" (ByVal Buf As String,
    ByVal BufLen As Int32) As Integer

    Private Declare Function mhdrg1 Lib "vbdrgv37.dll" (ByRef drg As Int32,
    ByVal DRGVersion As String, ByVal MasksPath As String, ByVal DischStat As String,
    ByVal PtAge As String, ByVal PtGender As String, ByVal DXList As String,
    ByVal ProcList As String, ByVal POAPresent As String, ByVal ExemptFlag As String) As Int32

    Private Declare Sub mhinfo Lib "vbdrgv37.dll" (ByVal drg As Int32,
    ByVal DRGVersion As String, ByVal MasksPath As String, ByRef mdc As Int32,
    ByRef weight As Double, ByRef los As Double, ByVal Desc As String, ByVal DescLen As Int32)

    Private Declare Function mhdrgver Lib "vbdrgv37.dll" (ByVal MPath As String,
    ByVal Buf As String, ByVal BufLen As Int32) As Int32

    Private Declare Sub mherrdesc Lib "vbdrgv37.dll" (ByVal errBuffer As String, ByVal errLength As Int32)


    Sub Main()
        AssignDRG()
    End Sub

    Public Function AssignDRG()
        Dim ReturnCode As Integer
        Dim drg As Int32, mdc As Int32
        Dim Desc As String
        Dim descLen As Int32
        Dim weight As Double, los As Double
        Dim masksdir As String

        Dim myver As String, mydstat As String, myage As String, mysex As String, myexempt As String, mypoa As String
        Dim mydxstring As String
        Dim mypxstring As String
        Dim pos As Int32

        ' Hardcoded in this example
        masksdir = "C:\Program Files (x86)\MandH\MASKS\" & ControlChars.NullChar
' Ideally, got from registry. Old VB-for-Access example:
' masksdir = QueryValue("Software\MandH\", "BaseDir") & "\Masks\"

        myver = "v37e" ' version 37, exempt from HAC rules
        mydstat = "1"
        myage = "77"
        mysex = "1"
        mydxstring = "I2119^" ' ^ terminates the string; any of ,|-+ separate fields; ~ is followed by PoA
        mypxstring = "02703ZZ^"
        mypoa = "N" ' no POA because no HAC rules
        myexempt = "X" ' crazy way this works: X = exempt, Z = not exempt
        descLen = 80 ' left over from dumb ASCII terminal days; use whatever you like

        ' these should come back from the DLL call
        drg = 0
        mdc = 0
        weight = 150
        los = 10
        Desc = Space(descLen)

' confirm which DLL we have loaded
        drg = mhdllver(Desc, descLen)
        ' deal with char ASCIIz (null-terminated string)
        pos = InStr(1, Desc, ControlChars.NullChar, CompareMethod.Binary)
        Console.WriteLine("DLL Version: " & Desc.Substring(0, pos))

' Assign the DRG for this age, sex, discharge status, exemption, diagnoses and procedures
        ReturnCode = mhdrg1(drg, myver, masksdir, mydstat, myage, mysex, mydxstring, mypxstring, mypoa, myexempt)
        Console.WriteLine("DLL.mhdrg1 returned RC=" & ReturnCode.ToString)

        If ReturnCode = 0 Then
            Console.WriteLine("DLL.mhdrg1 returned DRG=" & drg.ToString)
            Call mhinfo(drg, myver, masksdir, mdc, weight, los, Desc, descLen)
            Console.WriteLine("DLL.mhinfo returned ver=" & myver & " " _
                              & "MDC=" & mdc.ToString & " " _
                              & "Weight=" & weight.ToString & " " _
                              & "LOS=" & los.ToString & " ")
            Console.WriteLine("Desc=[" & Desc & "]")
        Else
            Call mherrdesc(Desc, descLen)
            Console.WriteLine("Error: " & Desc)
        End If

' Should produce this output:
' DLL Version: mhdrgv37.dll v2.10 (c) 2015 M+H Consulting, LLC: v37
' DLL.mhdrg1 returned RC=0
' DLL.mhdrg1 returned DRG=251
' DLL.mhinfo returned ver=v37e MDC=5 Weight=1.683 LOS=2.2
' Desc=[PERC CARDIOVASC PROC W/O CORONARY ARTERY STENT W/O MCC                          ]

        Return ReturnCode
    End Function

End Module

Wednesday, October 2, 2019

V37 Release

Earlier today, we released versions of our products which support v37 of the US federal grouping algorithm, which version went into service on October 1st, 2019.

What's new with this year's release?

  • Our 64 Bit Linux PHP, Perl and C objects are now created on a new platform, a cloud server.
  • Our 32 Bit Linux products are one step closer to being retired: we are running out of platforms on which to build them. Please leave a comment if you are still using 32 bit executables.
  • On a Windows 7 computer, our VB DLL is triggering warnings from Norton when we install it on a computer which runs Norton. These warnings can be safely ignored.
  • We are planning on putting previous versions of our DRG Manual on-line for reference, attached to entries in this blog.

Tuesday, October 1, 2019

V37 Manual

The link to our v37 technical documentation is here: [link]

Friday, August 2, 2019

Which Executables Work With Which Masks Files?

QUESTION:
Which Executables Work With Which Masks Files?

ANSWER:
Our code base is effectively split into the original branch which supports ICD9cm codes and the new branch which supports ICD10 codes.

The original branch has version numbers which begin with f (for "federal") while the new branch has version numbers which start with v. The original branch starts with f2 and ends with f32. The new branch starts with v33 and is currently up to v36.

In order to assign a DRG, you need both the logic (which we encode in the software) and the attributes or "masks" (which we encode in masks files).

The original branch is backwardly compatible: f32 has all the logic for some early version (f6, I believe) up and including f32. (The versions are internally designated with letters, so each executable can only support 26 versions. We have an executable and masks which support f2-f5 but that combination is a special order item).

The new branch is not backwardly compatible: v33 only supports v33, v34 only supports v34, etc. So v36 cannot use v34 masks because it does not have v34 logic in it.

We have a project on the books to combine all the logic into a backwardly compatible super-set, but currently this project is inactive.

Thursday, December 20, 2018

Discharge Disposition

Discharge disposition has, alas, been coded by at least two different standards: UB82 and UHDDS. We try to support both but it has been years since we say UHDDS codes so we are not sure how much longer we will support them.

Here is the mapping we usually use:

    "0 - Unknown"
    "1 - Home"
    "2 - Other Hosp"
    "3 - SNF"
    "4 - ICF"
    "5 - Other Inst"
    "6 - Home Care"
    "7 - AMA"
    "20- Expired"

As bit-bashers, we are happy with this rather simple listing. If you want to know more, check out these links:

https://www.cms.gov/Medicare/Medicare-Contracting/ContractorLearningResources/downloads/JA0801.pdf

https://www.resdac.org/cms-data/variables/patient-discharge-status-code

Sunday, September 30, 2018

V36 Validation

Looks like 460 cases fail, with 57 underlying DRGs. That should not be too bad.

Update Sun Sep 30 7:11pm Eastern: we are close, but not close enough to pull the trigger tonight. We are expecting to finish validation and do the release by the end of business tomorrow.

Update Mon Oct 1 7:04pm Eastern: we are down to two DRG definitions which have issues; we ran into issues interpreting the specs for some of the pseudo-code, requiring us to slog through the IBM 360 assembler version. But we are now very confident that we will finish validation early tomorrow and do the release tomorrow afternoon.

Update Tue Oct 2 11:22am Eastern: the official test data set passes through our DRG engine without any issues, so QA is done and we are starting the release process.

Update Wed Oct 3 2:11pm Eastern: our usual 32 bit Linux environment is out of action and we have to move to the backup environment which is taking some time. It is not clear how many more 32 bit Linux releases we will do.

Update Wed Oct 3 8:34pm Eastern: our back up 32 bit Linux environment has been configured and our development system ported to it and now we have 32 bit Linux executables again.

Saturday, September 29, 2018

V36 Masks & Weights

The V36 masks and weights file has been built and validated. The logic module is still under construction. This year's differences from last year are pretty massive. Validation is going to be epic this year.