ABME5NM1 ; IHS/ASDST/DMJ - 837 NM1 Segment
;;2.6;IHS Third Party Billing System;**6,8,9,10,11,20**;NOV 12, 2009;Build 317
;Submitter Name
;IHS/SD/SDR 2.6*20 - HEAT270943 - Made change to default NM109 to the origanization/facility NPI if the provider doesn't have an NPI
;
EP(X,Y) ;EP - START HERE
;x=entity identifier
;y=file ien (optional)
S ABMEIC=X
S ABMNIEN=$G(Y)
K ABMREC("NM1"),ABMR("NM1")
S ABME("RTYPE")="NM1"
D LOOP
K ABME,ABMEIC
Q
;
LOOP ;LOOP HERE
F I=10:10:120 D
.D @I
.I $D(^ABMEXLM("AA",+$G(ABMP("INS")),+$G(ABMP("EXP")),ABME("RTYPE"),I)) D @(^(I))
.I $G(ABMREC("NM1"))'="" S ABMREC("NM1")=ABMREC("NM1")_"*"
.S ABMREC("NM1")=$G(ABMREC("NM1"))_ABMR("NM1",I)
I '$D(^ABMEXLM("AA",+$G(ABMP("INS")),+$G(ABMP("EXP")),ABME("RTYPE"),I)) D 837^ABMUTL8
Q
;
10 ;segment
S ABMR("NM1",10)="NM1"
Q
;
20 ;NM101 - Entity Identifier Code
S ABMR("NM1",20)=ABMEIC
Q
;
30 ;NM102 - Entity Type Qualifier
S ABMR("NM1",30)=1
S:"40^41^85^87^PR^77^PW^45"[ABMEIC ABMR("NM1",30)=2
Q
;
40 ;NM103 - Name Last or Organization Name
;
S ABMR("NM1",40)=""
;
; Receiver
I ABMEIC=40 D
.;S ABMR("NM1",40)=$P($G(^AUTNINS(ABMP("INS"),2)),"^",13) ;abm*2.6*8
.;start new code abm*2.6*6 HEAT28891
.I $D(^ABMRECVR("C",ABMP("INS"))) D
..S ABMCHIEN=$O(^ABMRECVR("C",ABMP("INS"),0))
..S ABMR("NM1",40)=$P($G(^ABMRECVR(ABMCHIEN,1,ABMP("INS"),0)),U,3)
..K ABMCHIEN
.;end new code HEAT28891
.S:ABMR("NM1",40)="" ABMR("NM1",40)=$P($G(^AUTNINS(ABMP("INS"),2)),"^",13) ;abm*2.6*8
.S:ABMR("NM1",40)="" ABMR("NM1",40)=$P($G(^AUTNINS(ABMP("INS"),0)),U)
;
; Submitter ^ Billing Provider
I "41^85"[ABMEIC D
.S ABMR("NM1",40)=$P($G(^DIC(4,DUZ(2),0)),U)
;
; Patient
I ABMEIC="QC" D
.S ABMR("NM1",40)=$$LNM^ABMUTLN(2,ABMP("PDFN"))
;
; Provider
I "71^72^ZZ^82^QB^DK^DN^DQ^P3"[ABMEIC D
.I +ABM("PRV")'=0 D
..S ABMR("NM1",40)=$$LNM^ABMUTLN(200,ABM("PRV"))
.E S ABMR("NM1",40)=$P(ABM("PRV"),",")
;
; Payer
I ABMEIC="PR" D
.S ABMR("NM1",40)=$P($G(^ABMNINS(DUZ(2),ABMNIEN,1,ABMP("VTYP"),1)),"^",2)
.S:ABMR("NM1",40)="" ABMR("NM1",40)=$P($G(^AUTNINS(ABMNIEN,2)),"^",13)
.S:ABMR("NM1",40)="" ABMR("NM1",40)=$P(^AUTNINS(ABMNIEN,0),U)
;
; Insured or Subscriber
I ABMEIC="IL" D
.S ABMR("NM1",40)=$$LNM^ABMUTLN(ABMSFILE,ABMSIEN)
;
; Facility
I ABMEIC="77" D
.S ABMR("NM1",40)=$P($G(^DIC(4,ABMP("LDFN"),0)),U)
;S:$G(ABMP("ITYPE"))'="D" ABMR("NM1",40)=$TR(ABMR("NM1",40),"-"," ") ;abm*2.6*11 HEAT104117
;
; Ambulance Drop Off Location
I ABMEIC="45" D
.S ABMR("NM1",40)=$$GET1^DIQ("9002274.4",ABMP("BDFN"),".127")
Q
;
50 ;NM104 - Name First
S ABMR("NM1",50)=""
;
; Patient
I ABMEIC="QC" D
.S ABMR("NM1",50)=$$FNM^ABMUTLN(2,ABMP("PDFN"))
;
; Provider
I "71^72^ZZ^82^QB^DK^DN^DQ^P3"[ABMEIC D
.I +ABM("PRV")'=0 D
..S ABMR("NM1",50)=$$FNM^ABMUTLN(200,ABM("PRV"))
.E S ABMR("NM1",50)=$P(ABM("PRV"),",",2)
;
; Insured or Subscriber
I ABMEIC="IL" D
.S ABMR("NM1",50)=$$FNM^ABMUTLN(ABMSFILE,ABMSIEN)
Q
;
60 ;NM105 - Name Middle
S ABMR("NM1",60)=""
;
; Patient
I ABMEIC="QC" D
.S ABMR("NM1",60)=$$MI^ABMUTLN(2,ABMP("PDFN"))
;
; Insured or Subscriber
I ABMEIC="IL" D
.S ABMR("NM1",60)=$$MI^ABMUTLN(ABMSFILE,ABMSIEN)
;
; Provider
I "71^72^ZZ^82^QB^DK^DN^DQ^P3"[ABMEIC D
.S ABMR("NM1",50)=$$MI^ABMUTLN(200,ABM("PRV"))
;
Q
;
70 ;NM106 - Name Prefix (Not Used)
S ABMR("NM1",70)=""
Q
;
80 ;NM107 - Name Suffix
S ABMR("NM1",80)=""
;
; Patient
I ABMEIC="QC" D
.S ABMR("NM1",80)=$$SFX^ABMUTLN(2,ABMP("PDFN"))
;
; Insured or Subscriber
I ABMEIC="IL" D
.S ABMR("NM1",80)=$$SFX^ABMUTLN(ABMSFILE,ABMSIEN)
;
; Provider
I "71^72^ZZ^82^QB^DK^DN^DQ^P3"[ABMEIC D
.S ABMR("NM1",50)=$$SFX^ABMUTLN(200,ABM("PRV"))
;
Q
;
90 ;NM108 - Identification Code Qualifier
S ABMNPIU=$$NPIUSAGE^ABMUTLF(ABMP("LDFN"),ABMP("INS"))
S ABMR("NM1",90)=""
I "40^41"[ABMEIC S ABMR("NM1",90)=46
I ABMEIC=85 S ABMR("NM1",90)="XX"
I "71^72^77^ZZ^82^DN^QB^DQ^DK"[ABMEIC S ABMR("NM1",90)="XX"
I ABMEIC="PR" S ABMR("NM1",90)="PI"
I ABMEIC="IL" S ABMR("NM1",90)="MI"
Q
;
100 ;NM109 - Identification Code
S ABMR("NM1",100)=""
I ABMEIC=40 D
.;S ABMR("NM1",100)=$$RCID^ABMUTLP(ABMP("INS")) ;abm*2.6*8
.;start new code abm*2.6*8 HEAT45044
.I $D(^ABMRECVR("C",ABMP("INS"))) D
..S ABMCHIEN=$O(^ABMRECVR("C",ABMP("INS"),0))
..S:ABMCHIEN ABMR("NM1",100)=$P($G(^ABMRECVR(ABMCHIEN,1,ABMP("INS"),0)),U,2)
.;I ABMR("NM1",100)="" S ABMR("NM1",100)=$P($G(^ABMNINS(DUZ(2),ABMP("INS"),1,ABMP("VTYP"),0)),U,19) ;abm*2.6*10 HEAT68447
.I ABMR("NM1",100)="" S ABMR("NM1",100)=$P($G(^ABMNINS(ABMP("LDFN"),ABMP("INS"),1,ABMP("VTYP"),0)),U,19) ;abm*2.6*10 HEAT68447
.I ABMR("NM1",100)="" S ABMR("NM1",100)=$$RCID^ABMUTLP(ABMP("INS"))
.;end new code HEAT45044
;
I ABMEIC=41 D
.S ABMR("NM1",100)=$P($G(^ABMNINS(DUZ(2),ABMP("INS"),1,ABMP("VTYP"),0)),U,19)
.I ABMR("NM1",100)="" S ABMR("NM1",100)=$P($G(^ABMNINS(DUZ(2),ABMP("INS"),0)),U,2)
;
I ABMEIC=85 D
.I ABMNPIU="N"!(ABMNPIU="B") D Q
..S ABMLNPI=$S($P($G(^ABMNINS(ABMP("LDFN"),ABMP("INS"),1,ABMP("VTYP"),1)),U,8)'="":$P(^ABMNINS(ABMP("LDFN"),ABMP("INS"),1,ABMP("VTYP"),1),U,8),$P($G(^ABMDPARM(ABMP("LDFN"),1,2)),U,12)'="":$P(^ABMDPARM(ABMP("LDFN"),1,2),U,12),1:ABMP("LDFN"))
..S ABMR("NM1",100)=$S($P($$NPI^XUSNPI("Organization_ID",ABMLNPI),U)>0:$P($$NPI^XUSNPI("Organization_ID",ABMLNPI),U),1:"")
.S ABMR("NM1",100)=$P($G(^AUTTLOC(DUZ(2),0)),"^",18)
;
;attending/operating/other provider
I "71^72^ZZ^82^DN^QB^DQ^DK^P3"[ABMEIC D
.I ABMEIC="DN" S ABMR("NM1",100)=$S($D(^VA(200,ABMIEN)):$P($$NPI^XUSNPI("Individual_ID",+ABMIEN),U),1:$P($G(ABMP("PRV","F",ABMIEN)),U,3)) Q ;abm*2.6*9 HEAT53094
.;I ABMEIC="DQ" S ABMR("NM1",100)=$S($D(^VA(200,ABMIEN)):$P($$NPI^XUSNPI("Individual_ID",+ABMIEN),U),1:$P($G(ABMP("PRV","S",ABMIEN)),U,3)) Q ;abm*2.6*9 HEAT53094 ;abm*2.6*10 HEAT80154
.I ABMEIC="DQ" S ABMR("NM1",100)=$S(((+ABMIEN'=0)&$D(^VA(200,+ABMIEN))):$P($$NPI^XUSNPI("Individual_ID",+ABMIEN),U),1:$P($G(ABMP("PRV","S",ABMIEN)),U,3)) Q ;abm*2.6*10 HEAT80154
.;S ABMR("NM1",100)=$P($$NPI^XUSNPI("Individual_ID",+ABM("PRV")),U) Q ;abm*2.6*20 IHS/SD/SDR HEAT270943
.;start new abm*2.6*20 IHS/SD/SDR HEAT270943
.I $P($$NPI^XUSNPI("Individual_ID",+ABM("PRV")),U)>1 S ABMR("NM1",100)=$P($$NPI^XUSNPI("Individual_ID",+ABM("PRV")),U) Q
.S ABMR("NM1",100)=$P($$NPI^XUSNPI("Organization_ID",+ABMP("LDFN")),U)
.;end new abm*2.6*20 IHS/SD/SDR HEAT270943
;
; Payer
I ABMEIC="PR" D
.K Y
.;S ABMR("NM1",100)=$$RCID^ABMUTLP(ABMP("INS")) ;abm*2.6*8
.;start old code abm*2.6*9 HEAT55022
.;;start new code abm*2.6*8 HEAT45044
.;I $D(^ABMRECVR("C",ABMP("INS"))) D
.;.S ABMCHIEN=$O(^ABMRECVR("C",ABMP("INS"),0))
.;.S:ABMCHIEN ABMR("NM1",100)=$P($G(^ABMRECVR(ABMCHIEN,1,ABMP("INS"),0)),U,2)
.;I ABMR("NM1",100)="" S ABMR("NM1",100)=$P($G(^ABMNINS(DUZ(2),ABMP("INS"),1,ABMP("VTYP"),0)),U,19)
.;I ABMR("NM1",100)="" S ABMR("NM1",100)=$$RCID^ABMUTLP(ABMP("INS"))
.;;end new code HEAT45044
.;end old code start new code HEAT55022
.I $D(^ABMRECVR("C",ABMNIEN)) D
..Q:$G(ABMLOOP)="2330B" ;write what is in insurer file for this loop
..S ABMCHIEN=$O(^ABMRECVR("C",ABMNIEN,0))
..S:ABMCHIEN ABMR("NM1",100)=$P($G(^ABMRECVR(ABMCHIEN,1,ABMNIEN,0)),U,2)
.I ABMR("NM1",100)="" S ABMR("NM1",100)=$P($G(^ABMNINS(DUZ(2),ABMNIEN,1,ABMP("VTYP"),0)),U,19)
.I ABMR("NM1",100)="" S ABMR("NM1",100)=$$RCID^ABMUTLP(ABMNIEN)
.;end new code HEAT55022
.S:$TR(ABMR("NM1",100)," ")="" ABMR("NM1",100)=99999
;
; Insured or Subscriber
I ABMEIC="IL" D
.S ABMR("NM1",100)=$G(ABMP("SNUM",ABMPST))
.Q:ABMR("NM1",100)'=""
.S ABMR("NM1",100)=$$PNUM^ABMUTLP(ABMP("BDFN"))
;
; Facility
I ABMEIC="77" D
.I ABMNPIU="N"!(ABMNPIU="B") D Q
..S ABMLNPI=$S($P($G(^ABMNINS(ABMP("LDFN"),ABMP("INS"),1,ABMP("VTYP"),1)),U,8)'="":$P(^ABMNINS(ABMP("LDFN"),ABMP("INS"),1,ABMP("VTYP"),1),U,8),$P($G(^ABMDPARM(ABMP("LDFN"),1,2)),U,12)'="":$P(^ABMDPARM(ABMP("LDFN"),1,2),U,12),1:ABMP("LDFN"))
..S ABMR("NM1",100)=$S($P($$NPI^XUSNPI("Organization_ID",+ABMLNPI),U)>0:$P($$NPI^XUSNPI("Organization_ID",+ABMLNPI),U),1:"")
.S ABMR("NM1",100)=$$EIN^ABMUTLF(ABMP("LDFN"))
S ABMR("NM1",100)=$$AN^ABMUTL8(ABMR("NM1",100))
Q
;
110 ;NM110 - Entity Relationship Code (Not used)
S ABMR("NM1",110)=""
Q
;
120 ;NM111 - Entity Identifier Code (Not used)
S ABMR("NM1",120)=""
Q
;
130 ;NM112 - Name Last or Organization Name (Not used)
S ABMR("NM1",130)=""
Q
ABME5NM1 ; IHS/ASDST/DMJ - 837 NM1 Segment
+1 ;;2.6;IHS Third Party Billing System;**6,8,9,10,11,20**;NOV 12, 2009;Build 317
+2 ;Submitter Name
+3 ;IHS/SD/SDR 2.6*20 - HEAT270943 - Made change to default NM109 to the origanization/facility NPI if the provider doesn't have an NPI
+4 ;
EP(X,Y) ;EP - START HERE
+1 ;x=entity identifier
+2 ;y=file ien (optional)
+3 SET ABMEIC=X
+4 SET ABMNIEN=$GET(Y)
+5 KILL ABMREC("NM1"),ABMR("NM1")
+6 SET ABME("RTYPE")="NM1"
+7 DO LOOP
+8 KILL ABME,ABMEIC
+9 QUIT
+10 ;
LOOP ;LOOP HERE
+1 FOR I=10:10:120
Begin DoDot:1
+2 DO @I
+3 IF $DATA(^ABMEXLM("AA",+$GET(ABMP("INS")),+$GET(ABMP("EXP")),ABME("RTYPE"),I))
DO @(^(I))
+4 IF $GET(ABMREC("NM1"))'=""
SET ABMREC("NM1")=ABMREC("NM1")_"*"
+5 SET ABMREC("NM1")=$GET(ABMREC("NM1"))_ABMR("NM1",I)
End DoDot:1
+6 IF '$DATA(^ABMEXLM("AA",+$GET(ABMP("INS")),+$GET(ABMP("EXP")),ABME("RTYPE"),I))
DO 837^ABMUTL8
+7 QUIT
+8 ;
10 ;segment
+1 SET ABMR("NM1",10)="NM1"
+2 QUIT
+3 ;
20 ;NM101 - Entity Identifier Code
+1 SET ABMR("NM1",20)=ABMEIC
+2 QUIT
+3 ;
30 ;NM102 - Entity Type Qualifier
+1 SET ABMR("NM1",30)=1
+2 IF "40^41^85^87^PR^77^PW^45"[ABMEIC
SET ABMR("NM1",30)=2
+3 QUIT
+4 ;
40 ;NM103 - Name Last or Organization Name
+1 ;
+2 SET ABMR("NM1",40)=""
+3 ;
+4 ; Receiver
+5 IF ABMEIC=40
Begin DoDot:1
+6 ;S ABMR("NM1",40)=$P($G(^AUTNINS(ABMP("INS"),2)),"^",13) ;abm*2.6*8
+7 ;start new code abm*2.6*6 HEAT28891
+8 IF $DATA(^ABMRECVR("C",ABMP("INS")))
Begin DoDot:2
+9 SET ABMCHIEN=$ORDER(^ABMRECVR("C",ABMP("INS"),0))
+10 SET ABMR("NM1",40)=$PIECE($GET(^ABMRECVR(ABMCHIEN,1,ABMP("INS"),0)),U,3)
+11 KILL ABMCHIEN
End DoDot:2
+12 ;end new code HEAT28891
+13 ;abm*2.6*8
IF ABMR("NM1",40)=""
SET ABMR("NM1",40)=$PIECE($GET(^AUTNINS(ABMP("INS"),2)),"^",13)
+14 IF ABMR("NM1",40)=""
SET ABMR("NM1",40)=$PIECE($GET(^AUTNINS(ABMP("INS"),0)),U)
End DoDot:1
+15 ;
+16 ; Submitter ^ Billing Provider
+17 IF "41^85"[ABMEIC
Begin DoDot:1
+18 SET ABMR("NM1",40)=$PIECE($GET(^DIC(4,DUZ(2),0)),U)
End DoDot:1
+19 ;
+20 ; Patient
+21 IF ABMEIC="QC"
Begin DoDot:1
+22 SET ABMR("NM1",40)=$$LNM^ABMUTLN(2,ABMP("PDFN"))
End DoDot:1
+23 ;
+24 ; Provider
+25 IF "71^72^ZZ^82^QB^DK^DN^DQ^P3"[ABMEIC
Begin DoDot:1
+26 IF +ABM("PRV")'=0
Begin DoDot:2
+27 SET ABMR("NM1",40)=$$LNM^ABMUTLN(200,ABM("PRV"))
End DoDot:2
+28 IF '$TEST
SET ABMR("NM1",40)=$PIECE(ABM("PRV"),",")
End DoDot:1
+29 ;
+30 ; Payer
+31 IF ABMEIC="PR"
Begin DoDot:1
+32 SET ABMR("NM1",40)=$PIECE($GET(^ABMNINS(DUZ(2),ABMNIEN,1,ABMP("VTYP"),1)),"^",2)
+33 IF ABMR("NM1",40)=""
SET ABMR("NM1",40)=$PIECE($GET(^AUTNINS(ABMNIEN,2)),"^",13)
+34 IF ABMR("NM1",40)=""
SET ABMR("NM1",40)=$PIECE(^AUTNINS(ABMNIEN,0),U)
End DoDot:1
+35 ;
+36 ; Insured or Subscriber
+37 IF ABMEIC="IL"
Begin DoDot:1
+38 SET ABMR("NM1",40)=$$LNM^ABMUTLN(ABMSFILE,ABMSIEN)
End DoDot:1
+39 ;
+40 ; Facility
+41 IF ABMEIC="77"
Begin DoDot:1
+42 SET ABMR("NM1",40)=$PIECE($GET(^DIC(4,ABMP("LDFN"),0)),U)
End DoDot:1
+43 ;S:$G(ABMP("ITYPE"))'="D" ABMR("NM1",40)=$TR(ABMR("NM1",40),"-"," ") ;abm*2.6*11 HEAT104117
+44 ;
+45 ; Ambulance Drop Off Location
+46 IF ABMEIC="45"
Begin DoDot:1
+47 SET ABMR("NM1",40)=$$GET1^DIQ("9002274.4",ABMP("BDFN"),".127")
End DoDot:1
+48 QUIT
+49 ;
50 ;NM104 - Name First
+1 SET ABMR("NM1",50)=""
+2 ;
+3 ; Patient
+4 IF ABMEIC="QC"
Begin DoDot:1
+5 SET ABMR("NM1",50)=$$FNM^ABMUTLN(2,ABMP("PDFN"))
End DoDot:1
+6 ;
+7 ; Provider
+8 IF "71^72^ZZ^82^QB^DK^DN^DQ^P3"[ABMEIC
Begin DoDot:1
+9 IF +ABM("PRV")'=0
Begin DoDot:2
+10 SET ABMR("NM1",50)=$$FNM^ABMUTLN(200,ABM("PRV"))
End DoDot:2
+11 IF '$TEST
SET ABMR("NM1",50)=$PIECE(ABM("PRV"),",",2)
End DoDot:1
+12 ;
+13 ; Insured or Subscriber
+14 IF ABMEIC="IL"
Begin DoDot:1
+15 SET ABMR("NM1",50)=$$FNM^ABMUTLN(ABMSFILE,ABMSIEN)
End DoDot:1
+16 QUIT
+17 ;
60 ;NM105 - Name Middle
+1 SET ABMR("NM1",60)=""
+2 ;
+3 ; Patient
+4 IF ABMEIC="QC"
Begin DoDot:1
+5 SET ABMR("NM1",60)=$$MI^ABMUTLN(2,ABMP("PDFN"))
End DoDot:1
+6 ;
+7 ; Insured or Subscriber
+8 IF ABMEIC="IL"
Begin DoDot:1
+9 SET ABMR("NM1",60)=$$MI^ABMUTLN(ABMSFILE,ABMSIEN)
End DoDot:1
+10 ;
+11 ; Provider
+12 IF "71^72^ZZ^82^QB^DK^DN^DQ^P3"[ABMEIC
Begin DoDot:1
+13 SET ABMR("NM1",50)=$$MI^ABMUTLN(200,ABM("PRV"))
End DoDot:1
+14 ;
+15 QUIT
+16 ;
70 ;NM106 - Name Prefix (Not Used)
+1 SET ABMR("NM1",70)=""
+2 QUIT
+3 ;
80 ;NM107 - Name Suffix
+1 SET ABMR("NM1",80)=""
+2 ;
+3 ; Patient
+4 IF ABMEIC="QC"
Begin DoDot:1
+5 SET ABMR("NM1",80)=$$SFX^ABMUTLN(2,ABMP("PDFN"))
End DoDot:1
+6 ;
+7 ; Insured or Subscriber
+8 IF ABMEIC="IL"
Begin DoDot:1
+9 SET ABMR("NM1",80)=$$SFX^ABMUTLN(ABMSFILE,ABMSIEN)
End DoDot:1
+10 ;
+11 ; Provider
+12 IF "71^72^ZZ^82^QB^DK^DN^DQ^P3"[ABMEIC
Begin DoDot:1
+13 SET ABMR("NM1",50)=$$SFX^ABMUTLN(200,ABM("PRV"))
End DoDot:1
+14 ;
+15 QUIT
+16 ;
90 ;NM108 - Identification Code Qualifier
+1 SET ABMNPIU=$$NPIUSAGE^ABMUTLF(ABMP("LDFN"),ABMP("INS"))
+2 SET ABMR("NM1",90)=""
+3 IF "40^41"[ABMEIC
SET ABMR("NM1",90)=46
+4 IF ABMEIC=85
SET ABMR("NM1",90)="XX"
+5 IF "71^72^77^ZZ^82^DN^QB^DQ^DK"[ABMEIC
SET ABMR("NM1",90)="XX"
+6 IF ABMEIC="PR"
SET ABMR("NM1",90)="PI"
+7 IF ABMEIC="IL"
SET ABMR("NM1",90)="MI"
+8 QUIT
+9 ;
100 ;NM109 - Identification Code
+1 SET ABMR("NM1",100)=""
+2 IF ABMEIC=40
Begin DoDot:1
+3 ;S ABMR("NM1",100)=$$RCID^ABMUTLP(ABMP("INS")) ;abm*2.6*8
+4 ;start new code abm*2.6*8 HEAT45044
+5 IF $DATA(^ABMRECVR("C",ABMP("INS")))
Begin DoDot:2
+6 SET ABMCHIEN=$ORDER(^ABMRECVR("C",ABMP("INS"),0))
+7 IF ABMCHIEN
SET ABMR("NM1",100)=$PIECE($GET(^ABMRECVR(ABMCHIEN,1,ABMP("INS"),0)),U,2)
End DoDot:2
+8 ;I ABMR("NM1",100)="" S ABMR("NM1",100)=$P($G(^ABMNINS(DUZ(2),ABMP("INS"),1,ABMP("VTYP"),0)),U,19) ;abm*2.6*10 HEAT68447
+9 ;abm*2.6*10 HEAT68447
IF ABMR("NM1",100)=""
SET ABMR("NM1",100)=$PIECE($GET(^ABMNINS(ABMP("LDFN"),ABMP("INS"),1,ABMP("VTYP"),0)),U,19)
+10 IF ABMR("NM1",100)=""
SET ABMR("NM1",100)=$$RCID^ABMUTLP(ABMP("INS"))
+11 ;end new code HEAT45044
End DoDot:1
+12 ;
+13 IF ABMEIC=41
Begin DoDot:1
+14 SET ABMR("NM1",100)=$PIECE($GET(^ABMNINS(DUZ(2),ABMP("INS"),1,ABMP("VTYP"),0)),U,19)
+15 IF ABMR("NM1",100)=""
SET ABMR("NM1",100)=$PIECE($GET(^ABMNINS(DUZ(2),ABMP("INS"),0)),U,2)
End DoDot:1
+16 ;
+17 IF ABMEIC=85
Begin DoDot:1
+18 IF ABMNPIU="N"!(ABMNPIU="B")
Begin DoDot:2
+19 SET ABMLNPI=$SELECT($PIECE($GET(^ABMNINS(ABMP("LDFN"),ABMP("INS"),1,ABMP("VTYP"),1)),U,8)'="":...
... $PIECE(^ABMNINS(ABMP("LDFN"),ABMP("INS"),1,ABMP("VTYP"),1),U,8),$PIECE($GET(^ABMDPARM(ABMP("LDFN"),1,2)),U,12)'="":$PIECE(^ABMDPARM(ABMP("LDFN"),1,2),U,12),1:ABMP("LDFN"))
+20 SET ABMR("NM1",100)=$SELECT($PIECE($$NPI^XUSNPI("Organization_ID",ABMLNPI),U)>0:$PIECE($$NPI^XUSNPI("Organization_ID",ABMLNPI),U),1:"")
End DoDot:2
QUIT
+21 SET ABMR("NM1",100)=$PIECE($GET(^AUTTLOC(DUZ(2),0)),"^",18)
End DoDot:1
+22 ;
+23 ;attending/operating/other provider
+24 IF "71^72^ZZ^82^DN^QB^DQ^DK^P3"[ABMEIC
Begin DoDot:1
+25 ;abm*2.6*9 HEAT53094
IF ABMEIC="DN"
SET ABMR("NM1",100)=$SELECT($DATA(^VA(200,ABMIEN)):$PIECE($$NPI^XUSNPI("Individual_ID",+ABMIEN),U),1:$PIECE($GET(ABMP("PRV","F",ABMIEN)),U,3))
QUIT
+26 ;I ABMEIC="DQ" S ABMR("NM1",100)=$S($D(^VA(200,ABMIEN)):$P($$NPI^XUSNPI("Individual_ID",+ABMIEN),U),1:$P($G(ABMP("PRV","S",ABMIEN)),U,3)) Q ;abm*2.6*9 HEAT53094 ;abm*2.6*10 HEAT80154
+27 ;abm*2.6*10 HEAT80154
IF ABMEIC="DQ"
SET ABMR("NM1",100)=$SELECT(((+ABMIEN'=0)&$DATA(^VA(200,+ABMIEN))):$PIECE($$NPI^XUSNPI("Individual_ID",+ABMIEN),U),1:$PIECE($GET(ABMP("PRV","S",ABMIEN)),U,3))
QUIT
+28 ;S ABMR("NM1",100)=$P($$NPI^XUSNPI("Individual_ID",+ABM("PRV")),U) Q ;abm*2.6*20 IHS/SD/SDR HEAT270943
+29 ;start new abm*2.6*20 IHS/SD/SDR HEAT270943
+30 IF $PIECE($$NPI^XUSNPI("Individual_ID",+ABM("PRV")),U)>1
SET ABMR("NM1",100)=$PIECE($$NPI^XUSNPI("Individual_ID",+ABM("PRV")),U)
QUIT
+31 SET ABMR("NM1",100)=$PIECE($$NPI^XUSNPI("Organization_ID",+ABMP("LDFN")),U)
+32 ;end new abm*2.6*20 IHS/SD/SDR HEAT270943
End DoDot:1
+33 ;
+34 ; Payer
+35 IF ABMEIC="PR"
Begin DoDot:1
+36 KILL Y
+37 ;S ABMR("NM1",100)=$$RCID^ABMUTLP(ABMP("INS")) ;abm*2.6*8
+38 ;start old code abm*2.6*9 HEAT55022
+39 ;;start new code abm*2.6*8 HEAT45044
+40 ;I $D(^ABMRECVR("C",ABMP("INS"))) D
+41 ;.S ABMCHIEN=$O(^ABMRECVR("C",ABMP("INS"),0))
+42 ;.S:ABMCHIEN ABMR("NM1",100)=$P($G(^ABMRECVR(ABMCHIEN,1,ABMP("INS"),0)),U,2)
+43 ;I ABMR("NM1",100)="" S ABMR("NM1",100)=$P($G(^ABMNINS(DUZ(2),ABMP("INS"),1,ABMP("VTYP"),0)),U,19)
+44 ;I ABMR("NM1",100)="" S ABMR("NM1",100)=$$RCID^ABMUTLP(ABMP("INS"))
+45 ;;end new code HEAT45044
+46 ;end old code start new code HEAT55022
+47 IF $DATA(^ABMRECVR("C",ABMNIEN))
Begin DoDot:2
+48 ;write what is in insurer file for this loop
IF $GET(ABMLOOP)="2330B"
QUIT
+49 SET ABMCHIEN=$ORDER(^ABMRECVR("C",ABMNIEN,0))
+50 IF ABMCHIEN
SET ABMR("NM1",100)=$PIECE($GET(^ABMRECVR(ABMCHIEN,1,ABMNIEN,0)),U,2)
End DoDot:2
+51 IF ABMR("NM1",100)=""
SET ABMR("NM1",100)=$PIECE($GET(^ABMNINS(DUZ(2),ABMNIEN,1,ABMP("VTYP"),0)),U,19)
+52 IF ABMR("NM1",100)=""
SET ABMR("NM1",100)=$$RCID^ABMUTLP(ABMNIEN)
+53 ;end new code HEAT55022
+54 IF $TRANSLATE(ABMR("NM1",100)," ")=""
SET ABMR("NM1",100)=99999
End DoDot:1
+55 ;
+56 ; Insured or Subscriber
+57 IF ABMEIC="IL"
Begin DoDot:1
+58 SET ABMR("NM1",100)=$GET(ABMP("SNUM",ABMPST))
+59 IF ABMR("NM1",100)'=""
QUIT
+60 SET ABMR("NM1",100)=$$PNUM^ABMUTLP(ABMP("BDFN"))
End DoDot:1
+61 ;
+62 ; Facility
+63 IF ABMEIC="77"
Begin DoDot:1
+64 IF ABMNPIU="N"!(ABMNPIU="B")
Begin DoDot:2
+65 SET ABMLNPI=$SELECT($PIECE($GET(^ABMNINS(ABMP("LDFN"),ABMP("INS"),1,ABMP("VTYP"),1)),U,8)'="":...
... $PIECE(^ABMNINS(ABMP("LDFN"),ABMP("INS"),1,ABMP("VTYP"),1),U,8),$PIECE($GET(^ABMDPARM(ABMP("LDFN"),1,2)),U,12)'="":$PIECE(^ABMDPARM(ABMP("LDFN"),1,2),U,12),1:ABMP("LDFN"))
+66 SET ABMR("NM1",100)=$SELECT($PIECE($$NPI^XUSNPI("Organization_ID",+ABMLNPI),U)>0:$PIECE($$NPI^XUSNPI("Organization_ID",+ABMLNPI),U),1:"")
End DoDot:2
QUIT
+67 SET ABMR("NM1",100)=$$EIN^ABMUTLF(ABMP("LDFN"))
End DoDot:1
+68 SET ABMR("NM1",100)=$$AN^ABMUTL8(ABMR("NM1",100))
+69 QUIT
+70 ;
110 ;NM110 - Entity Relationship Code (Not used)
+1 SET ABMR("NM1",110)=""
+2 QUIT
+3 ;
120 ;NM111 - Entity Identifier Code (Not used)
+1 SET ABMR("NM1",120)=""
+2 QUIT
+3 ;
130 ;NM112 - Name Last or Organization Name (Not used)
+1 SET ABMR("NM1",130)=""
+2 QUIT