ABME8NM1 ; IHS/ASDST/DMJ - 837 NM1 Segment
;;2.6;IHS 3P BILLING SYSTEM;**6,8**;NOV 12, 2009
;Submitter Name
;
; IHS/SD/SDR v2.5 p5 - 5/17/04 - Added code for referring physician name
; IHS/SD/SDR - V2.5 P8 - IM12246/IM17548
; Added code for Service Facility (77)
; IHS/SD/SDR - v2.5 p8 - task 6
; Added code for ambulance
; IHS/SD/SDR - v2.5 p9 - IM19299
; Check for EMC SUBMITTER ID for visit type, then at header level
; IHS/SD/SDR - v2.5 p9 - IM16962
; Get Subscriber Number for insurer, not just first one
; IHS/SD/SDR - v2.5 p9 - IM19825
; Check for printable name first; then fac to rec. payment
; IHS/SD/SDR - v2.5 p11 - NPI
; IHS/SD/SDR - v2.5 p11 - IM21946
; Correction to CLIA
; IHS/SD/SDR - v2.5 p12 - IM24862
; Made change for satellite NPI (use ABMP("LDFN"), not DUZ(2)).
; IHS/SD/SDR - abm*2.6*6 - HEAT29755 - For locations like ambulance, check if they have their own NPI; if so, use it
;
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)
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^FA"[ABMEIC ABMR("NM1",30)=2
I $G(ABMP("CLIN"))="A3",ABMEIC=77 S ABMR("NM1",30)=2
I $G(ABMOUTLB)=1,ABMEIC=77 S 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)
;
; Pay to Provider
I ABMEIC=87 D
.S ABMR("NM1",40)=$P($G(^ABMDPARM(DUZ(2),1,2)),U,6) ;printable name
.S:ABMR("NM1",40)="" ABMR("NM1",40)=$P($G(^DIC(4,ABMP("PAYDFN"),0)),U) ;fac. to rec. payment
;
; Patient
I ABMEIC="QC" D
.S ABMR("NM1",40)=$$LNM^ABMUTLN(2,ABMP("PDFN"))
;
; Provider
I "71^72^73^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="FA" 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),"-"," ")
;
; Service Facility (reference lab)
I ABMEIC="77" D
.I ABMP("CLIN")="A3" S ABMR("NM1",40)=$P($G(^ABMDBILL(DUZ(2),ABMP("BDFN"),12)),U,2)
.E S ABMR("NM1",40)=$P($G(^AUTTVNDR($P($G(^ABMRLABS(ABMNIEN,0)),U),0)),U)
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^73^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^73^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^73^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 D
.S ABMR("NM1",90)=46
I ABMEIC=85 D
.I ABMNPIU="N"!(ABMNPIU="B") S ABMR("NM1",90)="XX" Q
.S ABMR("NM1",90)=24
I ABMEIC=87 D
.I ABMNPIU="N"!(ABMNPIU="B") S ABMR("NM1",90)="XX" Q
.S ABMR("NM1",90)=24
I "71^72^73^82^DN^QB^DQ^DK"[ABMEIC D
.I ABMNPIU="N"!(ABMNPIU="B") S ABMR("NM1",90)="XX" Q
.S ABMR("NM1",90)="24"
I ABMEIC="PR" D
.S ABMR("NM1",90)="PI"
I ABMEIC="IL" D
.S ABMR("NM1",90)="MI"
I ABMEIC="QC" D
.S ABMR("NM1",90)="MI"
I ABMEIC="FA" D
.I ABMNPIU="N"!(ABMNPIU="B") S ABMR("NM1",90)="XX" Q
.S ABMR("NM1",90)=24
I ABMEIC=77,($G(ABMP("CLIN"))="A3") D
.I ABMNPIU="N"!(ABMNPIU="B") S ABMR("NM1",90)="XX" Q
.S ABMR("NM1",90)=24
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)
.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)
;
I ABMEIC=87 D
.I ABMNPIU="N"!(ABMNPIU="B") D Q
..;IHS/SD/AML 2/25/2011 HEAT29755 - Begin new code
..I ABMP("PAYDFN")'=DUZ(2) D
...S ABMLNPI=$P($G(^ABMDPARM(ABMP("LDFN"),1,2)),U,3)
...I ABMR("NM1",100)="" S ABMLNPI=$P($G(^ABMDPARM(ABMLNPI,1,2)),U,12)
...S ABMR("NM1",100)=$S($P($$NPI^XUSNPI("Organization_ID",ABMLNPI),U)>0:$P($$NPI^XUSNPI("Organization_ID",ABMLNPI),U),1:"")
..I ABMR("NM1",100)="" D
...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:"")
..;IHS/SD/AML 2/25/2011 HEAT29755 - End new code
..;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")) ;IHS/SD/AML 2/25/2011 HEAT29755
.S ABMR("NM1",100)=$P($G(^AUTTLOC(ABMP("PAYDFN"),0)),"^",18)
;
;attending/operating/other provider
I "71^72^73^82^DN^QB^DQ^DK^P3"[ABMEIC D
.I ABMNPIU="N"!(ABMNPIU="B") D
..I ABMEIC="DN" S ABMR("NM1",100)=$P($G(ABMP("PRV","F",ABMIEN)),U,3) Q
..I ABMEIC="DQ" S ABMR("NM1",100)=$P($G(ABMP("PRV","S",ABMIEN)),U,2) Q
..S ABMR("NM1",100)=$P($$NPI^XUSNPI("Individual_ID",+ABM("PRV")),U) Q
.S:ABMR("NM1",100)="" ABMR("NM1",100)=$$EIN^ABMUTLF(DUZ(2))
;
; Payer
I ABMEIC="PR" D
.K Y
.;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)
.I ABMR("NM1",100)="" S ABMR("NM1",100)=$$RCID^ABMUTLP(ABMP("INS"))
.;end new code HEAT45044
.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"))
;
; Patient
I ABMEIC="QC" D
.S ABMR("NM1",100)=$G(ABMP("PNUM",+ABMNIEN))
.S:ABMR("NM1",100)="" ABMR("NM1",100)=$G(ABMP("PNUM"))
;
; Facility
I ABMEIC="FA" 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))
;
I ABMEIC=77,($G(ABMP("CLIN"))="A3") 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"))
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
ABME8NM1 ; IHS/ASDST/DMJ - 837 NM1 Segment
+1 ;;2.6;IHS 3P BILLING SYSTEM;**6,8**;NOV 12, 2009
+2 ;Submitter Name
+3 ;
+4 ; IHS/SD/SDR v2.5 p5 - 5/17/04 - Added code for referring physician name
+5 ; IHS/SD/SDR - V2.5 P8 - IM12246/IM17548
+6 ; Added code for Service Facility (77)
+7 ; IHS/SD/SDR - v2.5 p8 - task 6
+8 ; Added code for ambulance
+9 ; IHS/SD/SDR - v2.5 p9 - IM19299
+10 ; Check for EMC SUBMITTER ID for visit type, then at header level
+11 ; IHS/SD/SDR - v2.5 p9 - IM16962
+12 ; Get Subscriber Number for insurer, not just first one
+13 ; IHS/SD/SDR - v2.5 p9 - IM19825
+14 ; Check for printable name first; then fac to rec. payment
+15 ; IHS/SD/SDR - v2.5 p11 - NPI
+16 ; IHS/SD/SDR - v2.5 p11 - IM21946
+17 ; Correction to CLIA
+18 ; IHS/SD/SDR - v2.5 p12 - IM24862
+19 ; Made change for satellite NPI (use ABMP("LDFN"), not DUZ(2)).
+20 ; IHS/SD/SDR - abm*2.6*6 - HEAT29755 - For locations like ambulance, check if they have their own NPI; if so, use it
+21 ;
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 QUIT
+7 ;
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^FA"[ABMEIC
SET ABMR("NM1",30)=2
+3 IF $GET(ABMP("CLIN"))="A3"
IF ABMEIC=77
SET ABMR("NM1",30)=2
+4 IF $GET(ABMOUTLB)=1
IF ABMEIC=77
SET ABMR("NM1",30)=2
+5 QUIT
+6 ;
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 ; Pay to Provider
+21 IF ABMEIC=87
Begin DoDot:1
+22 ;printable name
SET ABMR("NM1",40)=$PIECE($GET(^ABMDPARM(DUZ(2),1,2)),U,6)
+23 ;fac. to rec. payment
IF ABMR("NM1",40)=""
SET ABMR("NM1",40)=$PIECE($GET(^DIC(4,ABMP("PAYDFN"),0)),U)
End DoDot:1
+24 ;
+25 ; Patient
+26 IF ABMEIC="QC"
Begin DoDot:1
+27 SET ABMR("NM1",40)=$$LNM^ABMUTLN(2,ABMP("PDFN"))
End DoDot:1
+28 ;
+29 ; Provider
+30 IF "71^72^73^82^QB^DK^DN^DQ^P3"[ABMEIC
Begin DoDot:1
+31 IF +ABM("PRV")'=0
Begin DoDot:2
+32 SET ABMR("NM1",40)=$$LNM^ABMUTLN(200,ABM("PRV"))
End DoDot:2
+33 IF '$TEST
SET ABMR("NM1",40)=$PIECE(ABM("PRV"),",")
End DoDot:1
+34 ;
+35 ; Payer
+36 IF ABMEIC="PR"
Begin DoDot:1
+37 SET ABMR("NM1",40)=$PIECE($GET(^ABMNINS(DUZ(2),ABMNIEN,1,ABMP("VTYP"),1)),"^",2)
+38 IF ABMR("NM1",40)=""
SET ABMR("NM1",40)=$PIECE($GET(^AUTNINS(ABMNIEN,2)),"^",13)
+39 IF ABMR("NM1",40)=""
SET ABMR("NM1",40)=$PIECE(^AUTNINS(ABMNIEN,0),U)
End DoDot:1
+40 ;
+41 ; Insured or Subscriber
+42 IF ABMEIC="IL"
Begin DoDot:1
+43 SET ABMR("NM1",40)=$$LNM^ABMUTLN(ABMSFILE,ABMSIEN)
End DoDot:1
+44 ;
+45 ; Facility
+46 IF ABMEIC="FA"
Begin DoDot:1
+47 SET ABMR("NM1",40)=$PIECE($GET(^DIC(4,ABMP("LDFN"),0)),U)
End DoDot:1
+48 IF $GET(ABMP("ITYPE"))'="D"
SET ABMR("NM1",40)=$TRANSLATE(ABMR("NM1",40),"-"," ")
+49 ;
+50 ; Service Facility (reference lab)
+51 IF ABMEIC="77"
Begin DoDot:1
+52 IF ABMP("CLIN")="A3"
SET ABMR("NM1",40)=$PIECE($GET(^ABMDBILL(DUZ(2),ABMP("BDFN"),12)),U,2)
+53 IF '$TEST
SET ABMR("NM1",40)=$PIECE($GET(^AUTTVNDR($PIECE($GET(^ABMRLABS(ABMNIEN,0)),U),0)),U)
End DoDot:1
+54 QUIT
+55 ;
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^73^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^73^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^73^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
Begin DoDot:1
+4 SET ABMR("NM1",90)=46
End DoDot:1
+5 IF ABMEIC=85
Begin DoDot:1
+6 IF ABMNPIU="N"!(ABMNPIU="B")
SET ABMR("NM1",90)="XX"
QUIT
+7 SET ABMR("NM1",90)=24
End DoDot:1
+8 IF ABMEIC=87
Begin DoDot:1
+9 IF ABMNPIU="N"!(ABMNPIU="B")
SET ABMR("NM1",90)="XX"
QUIT
+10 SET ABMR("NM1",90)=24
End DoDot:1
+11 IF "71^72^73^82^DN^QB^DQ^DK"[ABMEIC
Begin DoDot:1
+12 IF ABMNPIU="N"!(ABMNPIU="B")
SET ABMR("NM1",90)="XX"
QUIT
+13 SET ABMR("NM1",90)="24"
End DoDot:1
+14 IF ABMEIC="PR"
Begin DoDot:1
+15 SET ABMR("NM1",90)="PI"
End DoDot:1
+16 IF ABMEIC="IL"
Begin DoDot:1
+17 SET ABMR("NM1",90)="MI"
End DoDot:1
+18 IF ABMEIC="QC"
Begin DoDot:1
+19 SET ABMR("NM1",90)="MI"
End DoDot:1
+20 IF ABMEIC="FA"
Begin DoDot:1
+21 IF ABMNPIU="N"!(ABMNPIU="B")
SET ABMR("NM1",90)="XX"
QUIT
+22 SET ABMR("NM1",90)=24
End DoDot:1
+23 IF ABMEIC=77
IF ($GET(ABMP("CLIN"))="A3")
Begin DoDot:1
+24 IF ABMNPIU="N"!(ABMNPIU="B")
SET ABMR("NM1",90)="XX"
QUIT
+25 SET ABMR("NM1",90)=24
End DoDot:1
+26 QUIT
+27 ;
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 IF ABMR("NM1",100)=""
SET ABMR("NM1",100)=$PIECE($GET(^ABMNINS(DUZ(2),ABMP("INS"),1,ABMP("VTYP"),0)),U,19)
+9 IF ABMR("NM1",100)=""
SET ABMR("NM1",100)=$$RCID^ABMUTLP(ABMP("INS"))
+10 ;end new code HEAT45044
End DoDot:1
+11 ;
+12 IF ABMEIC=41
Begin DoDot:1
+13 SET ABMR("NM1",100)=$PIECE($GET(^ABMNINS(DUZ(2),ABMP("INS"),1,ABMP("VTYP"),0)),U,19)
+14 IF ABMR("NM1",100)=""
SET ABMR("NM1",100)=$PIECE($GET(^ABMNINS(DUZ(2),ABMP("INS"),0)),U,2)
End DoDot:1
+15 ;
+16 IF ABMEIC=85
Begin DoDot:1
+17 IF ABMNPIU="N"!(ABMNPIU="B")
Begin DoDot:2
+18 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"))
+19 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
+20 SET ABMR("NM1",100)=$PIECE($GET(^AUTTLOC(DUZ(2),0)),"^",18)
End DoDot:1
+21 ;
+22 IF ABMEIC=87
Begin DoDot:1
+23 IF ABMNPIU="N"!(ABMNPIU="B")
Begin DoDot:2
+24 ;IHS/SD/AML 2/25/2011 HEAT29755 - Begin new code
+25 IF ABMP("PAYDFN")'=DUZ(2)
Begin DoDot:3
+26 SET ABMLNPI=$PIECE($GET(^ABMDPARM(ABMP("LDFN"),1,2)),U,3)
+27 IF ABMR("NM1",100)=""
SET ABMLNPI=$PIECE($GET(^ABMDPARM(ABMLNPI,1,2)),U,12)
+28 SET ABMR("NM1",100)=$SELECT($PIECE($$NPI^XUSNPI("Organization_ID",ABMLNPI),U)>0:$PIECE($$NPI^XUSNPI("Organization_ID",ABMLNPI),U),1:"")
End DoDot:3
+29 IF ABMR("NM1",100)=""
Begin DoDot:3
+30 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"))
+31 SET ABMR("NM1",100)=$SELECT($PIECE($$NPI^XUSNPI("Organization_ID",ABMLNPI),U)>0:$PIECE($$NPI^XUSNPI("Organization_ID",ABMLNPI),U),1:"")
End DoDot:3
+32 ;IHS/SD/AML 2/25/2011 HEAT29755 - End new code
+33 ;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")) ;IHS
/SD/AML 2/25/2011 HEAT29755
End DoDot:2
QUIT
+34 SET ABMR("NM1",100)=$PIECE($GET(^AUTTLOC(ABMP("PAYDFN"),0)),"^",18)
End DoDot:1
+35 ;
+36 ;attending/operating/other provider
+37 IF "71^72^73^82^DN^QB^DQ^DK^P3"[ABMEIC
Begin DoDot:1
+38 IF ABMNPIU="N"!(ABMNPIU="B")
Begin DoDot:2
+39 IF ABMEIC="DN"
SET ABMR("NM1",100)=$PIECE($GET(ABMP("PRV","F",ABMIEN)),U,3)
QUIT
+40 IF ABMEIC="DQ"
SET ABMR("NM1",100)=$PIECE($GET(ABMP("PRV","S",ABMIEN)),U,2)
QUIT
+41 SET ABMR("NM1",100)=$PIECE($$NPI^XUSNPI("Individual_ID",+ABM("PRV")),U)
QUIT
End DoDot:2
+42 IF ABMR("NM1",100)=""
SET ABMR("NM1",100)=$$EIN^ABMUTLF(DUZ(2))
End DoDot:1
+43 ;
+44 ; Payer
+45 IF ABMEIC="PR"
Begin DoDot:1
+46 KILL Y
+47 ;S ABMR("NM1",100)=$$RCID^ABMUTLP(ABMP("INS")) ;abm*2.6*8
+48 ;start new code abm*2.6*8 HEAT45044
+49 IF $DATA(^ABMRECVR("C",ABMP("INS")))
Begin DoDot:2
+50 SET ABMCHIEN=$ORDER(^ABMRECVR("C",ABMP("INS"),0))
+51 IF ABMCHIEN
SET ABMR("NM1",100)=$PIECE($GET(^ABMRECVR(ABMCHIEN,1,ABMP("INS"),0)),U,2)
End DoDot:2
+52 IF ABMR("NM1",100)=""
SET ABMR("NM1",100)=$PIECE($GET(^ABMNINS(DUZ(2),ABMP("INS"),1,ABMP("VTYP"),0)),U,19)
+53 IF ABMR("NM1",100)=""
SET ABMR("NM1",100)=$$RCID^ABMUTLP(ABMP("INS"))
+54 ;end new code HEAT45044
+55 IF $TRANSLATE(ABMR("NM1",100)," ")=""
SET ABMR("NM1",100)=99999
End DoDot:1
+56 ;
+57 ; Insured or Subscriber
+58 IF ABMEIC="IL"
Begin DoDot:1
+59 SET ABMR("NM1",100)=$GET(ABMP("SNUM",ABMPST))
+60 IF ABMR("NM1",100)'=""
QUIT
+61 SET ABMR("NM1",100)=$$PNUM^ABMUTLP(ABMP("BDFN"))
End DoDot:1
+62 ;
+63 ; Patient
+64 IF ABMEIC="QC"
Begin DoDot:1
+65 SET ABMR("NM1",100)=$GET(ABMP("PNUM",+ABMNIEN))
+66 IF ABMR("NM1",100)=""
SET ABMR("NM1",100)=$GET(ABMP("PNUM"))
End DoDot:1
+67 ;
+68 ; Facility
+69 IF ABMEIC="FA"
Begin DoDot:1
+70 IF ABMNPIU="N"!(ABMNPIU="B")
Begin DoDot:2
+71 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"))
+72 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
+73 SET ABMR("NM1",100)=$$EIN^ABMUTLF(ABMP("LDFN"))
End DoDot:1
+74 SET ABMR("NM1",100)=$$AN^ABMUTL8(ABMR("NM1",100))
+75 ;
+76 IF ABMEIC=77
IF ($GET(ABMP("CLIN"))="A3")
Begin DoDot:1
+77 IF ABMNPIU="N"!(ABMNPIU="B")
Begin DoDot:2
+78 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"))
+79 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
+80 SET ABMR("NM1",100)=$$EIN^ABMUTLF(ABMP("LDFN"))
End DoDot:1
+81 QUIT
+82 ;
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