Tuesday, 27 May 2014

MYSQL Stored Procedure for EDI 837 P 5010 Version

Here is a sample Stored Procedure which is used to generate Loop 2010BB. For complete List, please email me at vbsenthilinnet@gmail.com

DELIMITER $$


DROP PROCEDURE IF EXISTS `Loop2010BB`$$

CREATE DEFINER=`root`@`localhost` PROCEDURE `Loop2010BB`(pclaimNo INT, patientInsID LONG)
BEGIN
DECLARE varReturnValue VARCHAR(5000);
DECLARE fieldSep VARCHAR(10);
DECLARE varname VARCHAR(100);
DECLARE varaddress1 VARCHAR(100);
DECLARE varaddress2 VARCHAR(100);
DECLARE varcity VARCHAR(30);
DECLARE varstate VARCHAR(10);
DECLARE varzip VARCHAR(20);
DECLARE varpayerID VARCHAR(50);
DECLARE varLastBilledInfo VARCHAR(500);
DECLARE varInsCode VARCHAR(50);

SET fieldSep= '*';
SET varReturnValue = '';

SELECT
IFNULL(ins.Code,''), IFNULL(ins.name,''),IFNULL(ins.address1,''),IFNULL(ins.address2,''),
IFNULL(ins.city,''),IFNULL(ins.state,''),IFNULL(ins.zip,''),IFNULL(ins.payerID,'')
INTO
varInsCode, varname,varaddress1,varaddress2,varcity,varstate,varzip,varpayerID
FROM
patientinsurance patins, insurance ins
WHERE
patins.ID = patientInsID
AND
patins.insuranceID = ins.ID;

SET varLastBilledInfo = CONCAT(':',varInsCode,':',varname,':',varpayerID);


SET varReturnValue = CONCAT(varReturnValue,'NM1',fieldSep);
/*
Page No : 131
Loop No : 2010BB
Loop Name : PAYER NAME
Segment Name : NM1 Individual or Organizational Name
Data Element : NM101 - Entity Identifier Code
*/
SET varReturnValue = CONCAT(varReturnValue,'PR',fieldSep);
/*
Page No : 131
Loop No : 2010BB
Loop Name : PAYER NAME
Segment Name : NM1 Individual or Organizational Name
Data Element : NM102 - Entity Type Qualifier
*/
SET varReturnValue = CONCAT(varReturnValue,'2',fieldSep);

SET varReturnValue = CONCAT(varReturnValue,varname,fieldSep);

/*
Page No : 131
Loop No : 2010BB
Loop Name : PAYER NAME
Segment Name : NM1 Individual or Organizational Name
Data Element : NM104,NM105,NM106,NM107
NOT USED
*/

SET varReturnValue = CONCAT(varReturnValue,fieldSep);
SET varReturnValue = CONCAT(varReturnValue,fieldSep);
SET varReturnValue = CONCAT(varReturnValue,fieldSep);
SET varReturnValue = CONCAT(varReturnValue,fieldSep);

/*
Page No : 131
Loop No : 2010BB
Loop Name : PAYER NAME
Segment Name : NM1 Individual or Organizational Name
Data Element : NM108,NM109
*/

SET varReturnValue = CONCAT(varReturnValue,'PI',fieldSep);
SET varReturnValue = CONCAT(varReturnValue,varpayerID,'~');

IF varAddress1 <> '' THEN
#2010BB Payer Address
SET varReturnValue = CONCAT(varReturnValue,'N3',fieldSep);
#N301 Address Line 1
SET varReturnValue = CONCAT(varReturnValue,varAddress1);
#N302 Address Line 2
IF IFNULL(varAddress2,'') <> '' THEN
SET varReturnValue = CONCAT(varReturnValue,fieldSep,varAddress2,'~');
ELSE
SET varReturnValue = CONCAT(varReturnValue,'~');
END IF;
END IF;

IF varCity <> '' THEN
#2010BB Payer City/State/Zip code
SET varReturnValue = CONCAT(varReturnValue,'N4',fieldSep);

#N401 City Name
SET varReturnValue = CONCAT(varReturnValue,varCity,fieldSep);
#N402 State
SET varReturnValue = CONCAT(varReturnValue,varState,fieldSep);
#N402 Zip
SET varReturnValue = CONCAT(varReturnValue,varzip,'~');
END IF;

UPDATE claimheader SET tmpLastBilledInfo = CONCAT(IFNULL(tmpLastBilledInfo,'') ,varLastBilledInfo)
WHERE claimNo = pclaimNo;

UPDATE claimdetail SET tmpLastBilledInfo = CONCAT(IFNULL(tmpLastBilledInfo,'') ,varLastBilledInfo)
WHERE claimNo = pclaimNo AND claimTranModeInsID = patientInsID;

SELECT varReturnValue;

END$$

DELIMITER ;

SQL Server Stored Procedure for EDI 837 P 5010 Version

Here is a sample Stored Procedure which is used to generate Loop 2010BB. For complete List, please email me at vbsenthilinnet@gmail.com

 

set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
GO



/********************************************************************************
Page No : 130
Purpose : PAYER NAME
********************************************************************************/

ALTER PROCEDURE [dbo].[ProcHCEDI_Loop2010BB]
@plngClaimNo Bigint = NULL,
@pstrSegDelim VARCHAR(1) = Null,
@plngInsPlanRowID Bigint = NULL

AS
DECLARE
@strValidText VARCHAR(8000),
@strInValidText VARCHAR(8000),
@StrInsName VARCHAR(100),
@strAddress1 VARCHAR(100),
@strAddress2 VARCHAR(100),
@strCity VARCHAR(50),
@strState VARCHAR(50),
@strZip VARCHAR(50),
@strPayerID VARCHAR(50),
@strNHPI VARCHAR(80)



BEGIN

SET @strValidText = ''
SET @strInvalidText = ''
SELECT @pstrSegDelim = IsNull(@pstrSegDelim,'*')

SET @strValidText = 'NM1' + @pstrSegDelim


/*
Page No : 131
Loop No : 2010BB
Loop Name : PAYER NAME
Segment Name : NM1 Individual or Organizational Name
Data Element : NM101 - Entity Identifier Code
*/

SET @strValidText = @strValidText + 'PR' + @pstrSegDelim


/*
Page No : 131
Loop No : 2010BB
Loop Name : PAYER NAME
Segment Name : NM1 Individual or Organizational Name
Data Element : NM102 - Entity Type Qualifier
*/

SET @strValidText = @strValidText + '2' + @pstrSegDelim


SELECT
@StrInsName = LTRIM(RTRIM(ISNULL(InsuranceName,''))),
@strAddress1 = LTRIM(RTRIM(ISNULL(Address1,''))),
@strAddress2 = LTRIM(RTRIM(ISNULL(Address2,''))),
@strCity = LTRIM(RTRIM(ISNULL(City,''))),
@strState = LTRIM(RTRIM(ISNULL(State,''))),
@strZip = LTRIM(RTRIM(ISNULL(Zip,''))),
@strPayerID = LTRIM(RTRIM(ISNULL(PayerID,'')))
FROM
ViewHCInsurance
WHERE
Code = (SELECT InsCode From ViewHCPatientPolicy Where InsPlanRowID =@plngInsPlanRowID)



SELECT @strNHPI = LTRIM(RTRIM(ISNULL(NHPI,'')))

FROM
ViewHCInsurancePlan
WHERE
PlanRowID = (SELECT PlanRowID From ViewHCPatientPolicy Where InsPlanRowID =@plngInsPlanRowID)



IF @StrInsName= ''
SET @strInValidText = @strInValidText + 'E2010BB_NM103' + @pstrSegDelim
ELSE IF LEN(@StrInsName) > 35
SET @strInValidText = @strInValidText + 'E2010BB_NM103_01' + @pstrSegDelim
ELSE
SET @StrValidText = @strValidText + @StrInsName + @pstrSegDelim


/*
Page No : 131
Loop No : 2010BB
Loop Name : PAYER NAME
Segment Name : NM1 Individual or Organizational Name
Data Element : NM104,NM105,NM106,NM107
NOT USED
*/

SET @StrValidText = @strValidText + @pstrSegDelim + @pstrSegDelim + @pstrSegDelim + @pstrSegDelim

/*
Page No : 131
Loop No : 2010BB
Loop Name : PAYER NAME
Segment Name : NM1 Individual or Organizational Name
Data Element : NM108,NM109
*/


IF @strPayerID = '' AND @strNHPI = ''
SET @strInValidText = @strInValidText + 'E2010BB_NM109' + @pstrSegDelim
ELSE
BEGIN
IF @strNHPI <> ''
SET @StrValidText = @strValidText + 'XV' + @pstrSegDelim + @strNHPI
ELSE IF @strPayerID <> ''
SET @StrValidText = @strValidText + 'PI' + @pstrSegDelim + @strPayerID
END


SELECT @strValidText as EDIinfo, @strInvalidText as ErrInfo,1 as RowNum,'2010BB - Payer Name' +space(200) AS LoopNo,'NM1' as SegmentName, '130' as PageNo into #temp
--**************************************************************************************************

/*
Page No : 134
Loop No : 2010BB
Loop Name : PAYER NAME
Segment Name : N3 Address Information
*/


SET @strValidText = ''
SET @strInvalidText =''

/*
Page No : 134
Loop No : 2010BB
Loop Name : PAYER NAME
Segment Name : N3 Address Information
Data Element : N301 - ALIAS: Payer Address 1
*/

SET @strValidText = 'N3' + @pstrSegDelim

IF @strAddress1 =''
SET @strInValidText = @strInValidText + 'E2010BB_N301' + @pstrSegDelim
ELSE
SET @StrValidText = @strValidText + @strAddress1


/*
Page No : 134
Loop No : 2010BB
Loop Name : PAYER NAME
Segment Name : N3 Address Information
Data Element : N302 - ALIAS: Payer Address 2
*/

IF @strAddress2 <> ''
SET @StrValidText = @strValidText + @pstrSegDelim + @strAddress2
Insert into #temp SELECT @strValidText as EDIinfo, @strInvalidText ,2,'2010BB - Payer Name Address','N3', '134'
--**************************************************************************************************


/*
Page No : 135
Loop No : 2010BB
Loop Name : PAYER NAME
Segment Name : N4 Geographic Location PAYER CITY/STATE/ZIP CODE
*/

SET @strValidText = ''
SET @strInvalidText =''

SET @StrValidText = 'N4' + @pstrSegDelim


-- Page No 135
IF @strCity = ''
SET @strInValidText = @strInValidText + 'E2010BB_N401' + @pstrSegDelim
ELSE
SET @StrValidText = @strValidText + @strCity + @pstrSegDelim

-- Page No 135
IF @strState = ''
SET @strInValidText = @strInValidText + 'E2010BB_N402' + @pstrSegDelim
ELSE
SET @StrValidText = @strValidText + @strState + @pstrSegDelim

if @strZip <> ''
SET @strZip = REPLACE(@strZip,'-','')

-- Page No 135
IF @strZip = ''
SET @strInValidText = @strInValidText + 'E2010BB_N403' + @pstrSegDelim
ELSE
SET @StrValidText = @strValidText + @strZip

Insert into #temp SELECT @strValidText as EDIinfo, @strInvalidText ,3,'2010BB - Payer City/State/ZipCode','N4', '135'
--**************************************************************************************************


SELECT EDIinfo, ErrInfo,LoopNo,SegmentName,PageNo FROM #temp order by RowNum

IF @@ERROR = 0
RETURN 0
ELSE
RETURN 1

END



EDI 835 Health Care Claim Payment/Advice

Looking for best Practice Management software ? Please email at vbsenthilinnet@gmail.com


If you are new to Medical Billing, then please read this article
first.
If you are new to EDI, then  read the following articles

1. What is an EDI ?
2. EDI Transactions 

3. Understanding EDI Structure
4. EDI Instruction


EDI 835 Health Care Claim Payment/Advice

The 835 is used primarily by Healthcare insurance plans to make payments to healthcare providers, to provide Explanations of Benefits (EOBs), or both. When a healthcare service provider submits an 837 Health Care Claim, the insurance plan uses the 835 to detail the payment to that claim, including:

  • What charges were paid, reduced or denied
  • Whether there was a deductible, co-insurance, co-pay, etc.
  • Any bundling or splitting of claims or line items
  • How the payment was made, such as through a clearinghouse

A particular 835 document may not necessarily match up one-for-one with a specific 837. In fact, it is not uncommon for multiple 835 transactions to be used in response to a single 837, or for one 835 to address multiple 837 submissions. As a result, the 835 is important to healthcare providers, to track what payments were received for services they provided and billed. And also one EDI 835 File, may contain multiple Checks i.e Multiple EOBs

Before going into detail, Let us understand how insurance Payer make the Payment. Please understand and have good understanding on the following topics.

1. What is Copay, Co Insurance and Deductible in  Insurance Payment Posting ?
2. EOB – Explanation of Benefits

 

I have developed a small Parsing tool in VB.NET/VB.6/Java . This tool will take the EDI File and convert into PDF File as shown here.



 

Looking for best Practice Management software ? Please email at vbsenthilinnet@gmail.com 

Questions or feedback are always welcome. You can email me at vbsenthilinnet@gmail.com

Monday, 26 May 2014

ZK MVVM List box with Dynamic Template

Requirement.

In a screen, want to show the list of records with three different layout. Say for example, for layout1, we want to display three columns, for layouy2, we want to display four columns and so on.

 

Here is the code.

 

<?page title="new page title" contentType="text/html;charset=UTF-8"?>
<zk>
<window id="listboxdynamic" border="none"
apply="org.zkoss.bind.BindComposer"
viewModel="@id('vm') @init('com.product.webapp.examples.ListBoxDynamicVM')">
<custom-attributes listenKeys="willlistenforKeys" />
<separator />
<button label="Template 1" onClick="@command('onTemplate',type='simple')"></button>
<space></space>
<button label="Template 2" onClick="@command('onTemplate',type='simple2')"></button>
<space></space>
<button label="Template 3" onClick="@command('onTemplate',type='simple3')"></button>
<space></space>
<separator></separator>
<div children="@load('1') @template(vm.templatetype)">
<template name="simple">
<listbox id="" mold="paging"
model="@load(vm.persons)">
<listhead sizable="true">
<listheader label="First Name" />
<listheader label="Last Name" />
</listhead>
<template name="model" var="p1">
<listitem>
<listcell label="@load(p1.firstName)" />
<listcell label="@load(p1.lastName)" />
</listitem>
</template>
</listbox>
</template>
<template name="simple2">
<listbox id="" mold="paging"
model="@load(vm.persons)">
<listhead sizable="true">
<listheader label="First Name" />
<listheader label="Last Name" />
<listheader label="Address1" />
</listhead>
<template name="model" var="p1">
<listitem>
<listcell label="@load(p1.firstName)" />
<listcell label="@load(p1.lastName)" />
<listcell label="@load(p1.address1)" />
</listitem>
</template>
</listbox>
</template>

<template name="simple3">3333</template>
</div>
</window>
</zk>

 


View Model


package com.product.webapp.examples;

import java.util.ArrayList;
import java.util.List;

import org.zkoss.bind.annotation.AfterCompose;
import org.zkoss.bind.annotation.BindingParam;
import org.zkoss.bind.annotation.Command;
import org.zkoss.bind.annotation.ContextParam;
import org.zkoss.bind.annotation.ContextType;
import org.zkoss.bind.annotation.NotifyChange;
import org.zkoss.zk.ui.Component;
import org.zkoss.zk.ui.select.Selectors;
import org.zkoss.zul.Messagebox;

public class ListBoxDynamicVM {

private String templatetype;
private List<Person> persons;

public List<Person> getPersons() {
return persons;
}

public void setPersons(List<Person> persons) {
this.persons = persons;
}

public String getTemplatetype() {
return templatetype;
}

public void setTemplatetype(String templatetype) {
this.templatetype = templatetype;
}

@AfterCompose
public void initSetup(@ContextParam(ContextType.VIEW) Component view) {
Selectors.wireComponents(view, this, false);

System.out.println("starting creating list");
persons = new ArrayList<Person>();
for (int i = 0; i < 10; i++) {
persons.add(new Person("firstname_" + i, "lastname_" + i,
"address_" + i, "city_" + i));
}

this.templatetype = "simple";
}

@NotifyChange("templatetype")
@Command
public void onTemplate(@BindingParam("type") String type) {

this.templatetype = type;
Messagebox.show(" " + templatetype);
}

public static class Person {
private String firstName;
private String lastName;
private String address1;
private String city;

public Person(String firstName, String lastName, String address1,
String city) {
this.firstName = firstName;
this.lastName = lastName;
this.address1 = address1;
this.city = city;

}

public String getFirstName() {
System.out.println(" " + this.firstName);
return firstName;
}

public void setFirstName(String firstName) {
this.firstName = firstName;
}

public String getLastName() {
return lastName;
}

public void setLastName(String lastName) {
this.lastName = lastName;
}

public String getAddress1() {
return address1;
}

public void setAddress1(String address1) {
this.address1 = address1;
}

public String getCity() {
return city;
}

public void setCity(String city) {
this.city = city;
}

}
}

Monday, 19 May 2014

MySQL query reference

To list all the databases;

show databases;



String to Date

SELECT dob, STR_TO_DATE(dob, "%d-%M-%y") FROM patdemofloridalab 

 


Query which contains future date.

SELECT * FROM patient WHERE dob >= CURDATE()

 


Example for Date_Sub

UPDATE patient SET dob = DATE_SUB(dob,INTERVAL 100 YEAR) WHERE dob >= CURDATE()

This will convert 01/01/2045 to 01/01/1945


Update mysql table with data from another table

UPDATE table1 t1, table2 t2
SET t1.field_to_change = t2.field_with_data
WHERE t1.field1 = t2.field2;


Add new column with default value

ALTER TABLE insurance ADD primaryedi INTEGER DEFAULT 1;

ALTER TABLE appsettings ADD claimstatusnew BIGINT NULL;


Drop Foreign Key constraint and Column

ALTER TABLE patientreceipt DROP FOREIGN KEY FK_patientreceipt_practiceID;
ALTER TABLE patientreceipt DROP   practiceID;


Update from another select

UPDATE tmpreport AS a
JOIN
(SELECT
    this_.accountCode AS accountcode,
        SUM(this_.billedAmount) AS amount
    FROM
        viewreporttranheader this_
    WHERE
        this_.DOSYear=2014 AND this_.DOSMonth = 3
    GROUP BY
        this_.accountCode) b
ON
  a.datacode = b.accountcode
SET billedAmt1 = b.amount

Wednesday, 14 May 2014

271–5010 Health Care Eligibility Benefit Response - Subscriber Demographic Information and Subscriber Date –Loop 2100C

        

Subscriber Demographic Information.

Loop Seg ID Segment Name Format Length Ref# Req Value
2100C DMG Demographic Information ID 3 S DMG
Element Separator AN 1 *
DMG01 Date Time Period format Qualifier ID 2 1250 S D8 = Date format
Element Separator AN 1 *
DMG02 Date Time Period AN 8 1251 S <CCYYMMDD - Recipient Date of Birth>
Segment Terminator ~


Sample
DMG*D8*19571112

image_thumb6



Loop Seg ID Segment Name Format Length Ref# Req Value
2100C DTP Subscriber Date ID 3 R DTP
Element Separator AN 1 *
DTP01 Date Time Qualifier ID 2 374 R See values below
Element Separator AN 1 *
DTP02 Date Time Period Format Qualifier ID 2/3 1250 R D8 or RD8
Segment Terminator ~


DTP 01 – Date Time Qualifier
 
Code Definition
096 Discharge
102 Issue
152 Effective Date of Change
291 Plan
307 Eligibility
340 Consolidated Omnibus Budget Reconciliation Act (COBRA) Begin
341 Consolidated Omnibus Budget Reconciliation Act (COBRA) End
342 Premium Paid to Date Begin
343 Premium Paid to Date End
346 Plan Begin
347 Plan End
356 Eligibility Begin
357 Eligibility End
382 Enrolment
435 Admission
442 Date of Death
458 Certification
472 Service
539 Policy Effective
540 Policy Expiration
636 Date of Last Update
771 Status

DTP 02 – Date Time Period Qualifier

Code Definition
D8 Date Expressed in Format CCYYMMDD
RD8 Range of Dates Expressed in Format CCYYMMDD-CCYYMMDD


Sample

DTP*356*D8*20110101
DTP*346*D8*20140101
DTP*347*D8*20141231

image



        
Questions or feedback are always welcome. You can email me at vbsenthilinnet@gmail.com. 

271–5010 Health Care Eligibility Benefit Response – Loop 2100C Subscriber Name

 
        

image

Use this segment to identify an entity by name and/or identification number. Use this NM1 loop to identify the insured or subscriber

 
Loop Seg ID Segment Name Format Length Ref# Req Value
2100C NM1 Subscriber Name ID 3 R NM1
Element Separator AN 1 *
NM101 Entity Identifier Code ID 2/3 98 R IL
Element Separator AN 1 *
NM102 Entity Type qualifier ID 1/1 1065 R 1
Element Separator AN 1 *
NM103 Name Last or Organization Name AN 1/60 1035 R Insured Person Last Name
Element Separator AN 1 *
NM104 Name First AN 1/35 1036 S Insured Person First Name
Element Separator AN 1 *
NM105 Name Middle AN 1/25 1037 S Insured Person Middle Name
Element Separator AN 1 *
NM106 Name Prefix AN 1/10 1038 Not used
Element Separator AN 1 *
NM107 Name Suffix AN 1/10 1039 S Insured Person Suffix
Element Separator AN 1 *
NM108 Identification code Qualifier ID 1/2 66 R MI
Element Separator AN 1 *
NM109 Identification code AN 2/80 67 R Insured Policy No
Segment Terminator ~
               
 
 
NM102 - Entity Type Qualifier
Code qualifying the type of entity
Code Definition
1 Person
2 Non-Person Entity
 
Sample
NM1*IL*1*MULLIN*DANIEL****MI*XJBH12345678~

Segment Structure
image_thumb1


SUBSCRIBER Additional identification

Loop Seg ID Segment Name Format Length Ref# Req Value
2100C REF Reference Identification ID 3 R REF
Element Separator AN 1 *
REF01 Reference Identification qualifier ID 2/3 128 R See below for valid values
Element Separator AN 1 *
REF02 Reference Identification AN 1/50 127 R Identification value
    Element Separator AN 1 *
  REF03 Description AN 1/80 352 S Free form description as optional

REF01- Reference Identification Type Qualifier
 
Code Definition
18 Plan Number
1L Group Policy Number
1W Member Identification Number
3H Case Number
49 Family Unit Number
6P Group Number
CE Class of Contract
CT Contract Number
EA Medical Record  Identification Number
EJ Patient Account Number
F6 Health Insurance Claim (HIC) Number
GH Identification Card Serial Number
HJ Identify Card Number
IF Issue Number
IG Insurance Policy Number
N6 Plan Network Identification Number
NQ Medicaid Recipient Identification Number
Q4 Prior Identifier Number
SY Social Security Number
Y4 Agency Claim Number
   

Sample
REF*6P*1111119*XXXXXXX XXXXXXXXXX XXXXXXXXX, INC.
REF*EJ*660415~

image



2100C Subscriber Address
 
Loop Seg ID Segment Name Format Length Ref# Req Value
2100C N3 Subscriber Address AN 2 R N3
Element Separator AN 1 *
N301 Address Line 1 AN 1/55 166 R Insured Person Address Line 1
Element Separator AN 1 *
N302 Address Line 2 AN 1/55 166 S Insured Person Address Line 2 if exists
Segment Terminator ~

 
2100C Subscriber City/State/Zip code
Loop Seg ID Segment Name Format Length Ref# Req Value
2100C N4 Subscriber City / State / Zip Code AN 2 R N4
Element Separator AN 1 *
N401 City Name AN 2/30 19 R Insured Person City Name
Element Separator AN 1 *
N402 State or Province Code ID 2/2 156 R Insured Person State Code
Element Separator AN 1 *
N403 Postal Code ID 3/15 116 R Insured Person Zip Code
Segment Terminator ~



2100C Subscriber Demographic Information.
Loop Seg ID Segment Name Format Length Ref# Req Value
2100C DMG Subscriber Demographic ID 3 R DMG
Element Separator AN 1 *
DMG01 Date time Period Format Qualifier ID 2/3 1250 R D8
Element Separator AN 1 *
DMG02 Date time Period AN 1/35 1251 R Insured Date of birth in the Format CCYYMMDD
Element Separator AN 1 *
DMG03 Gender Code ID 1 1068 R Print M for Male
Print F for Female
Print U for unknown
Segment Terminator

Sample

N3*254 Holly ST
N4*HYDE PARK*NY*011111117
DMG*D8*19521212*M


image

image

image

 
        
Questions or feedback are always welcome. You can email me at vbsenthilinnet@gmail.com.