XBFUNC2	; IHS/ADC/GTH - FUNCTION LIBRARY : PCC RELATED FUNCTIONS ; [ 02/07/97   3:02 PM ]
	;;4.0;XB;;Jul 20, 2009;Build 2
	;
	;
PCCPPINT(XBVISIT)	;PEP - Return primary provider ien in VA(200
	NEW X,Y,Z,XBX,DIC,DR,DA,DIQ,XBY
	S XBX=0
	F  S XBX=$O(^AUPNVPRV("AD",XBVISIT,XBX)) Q:XBX'=+XBX  I $P(^AUPNVPRV(XBX,0),U,4)="P" S XBY=+^AUPNVPRV(XBX,0) Q
	I '$G(XBY) Q ""
	Q XBY
	;
PCCPPN(XBVISIT)	;PEP - Return a visit's primary provider (NAME)
	NEW X,Y,Z,XBX,DIC,DR,DA,DIQ,XBY
	S XBX=0
	F  S XBX=$O(^AUPNVPRV("AD",XBVISIT,XBX)) Q:XBX'=+XBX  I $P(^AUPNVPRV(XBX,0),U,4)="P" S XBY=XBX Q
	I '$G(XBY) Q "NONE ENTERED"
	S XBX=$$VAL^XBDIQ1(9000010.06,XBY,.01)
	Q:XBX="" "NONE ENTERED"
	Q XBX
	;
PCCPPI(XBVISIT)	;PEP - Return a visit's primary provider (INITIALS)
	NEW X,Y,Z,XBX,DIC,DR,DA,DIQ,XBY
	S XBX=0
	F  S XBX=$O(^AUPNVPRV("AD",XBVISIT,XBX)) Q:XBX'=+XBX  I $P(^AUPNVPRV(XBX,0),U,4)="P" S XBY=+^AUPNVPRV(XBX,0) Q
	I '$G(XBY) Q "???"
	S XBX=$$VAL^XBDIQ1($S($P($G(^AUTTSITE(1,0)),U,22):200,1:6),XBY,1)
	Q:XBX="" "???"
	Q XBX
	;
PCCPPCLS(XBVISIT,FORM)	;PEP - Return a visit's primary provider class (CODE)
	NEW X,Y,Z,XBX,DIC,DR,DA,DIQ,XBY,XBCODE
	S XBX=0
	F  S XBX=$O(^AUPNVPRV("AD",XBVISIT,XBX)) Q:XBX'=+XBX  I $P(^AUPNVPRV(XBX,0),U,4)="P" S XBY=+^AUPNVPRV(XBX,0) Q
	I '$G(XBY) Q "???"
	S:$G(FORM)="I" DIQ(0)="I"
	S DA=XBY,DIC=$S($P($G(^AUTTSITE(1,0)),U,22):200,1:6),DR=$S($P($G(^AUTTSITE(1,0)),U,22):53.5,1:2),DIQ="XBX"
	D EN^DIQ1
	I $P($G(^AUTTSITE(1,0)),U,22) S XBX=$S($G(FORM)="I":$G(XBX(200,XBY,"53.5","I")),1:$G(XBX(200,XBY,"53.5")))
	I '$P($G(^AUTTSITE(1,0)),U,22) S XBX=$S($G(FORM)="I":$G(XBX(6,XBY,"2","I")),1:$G(XBX(6,XBY,"2")))
	I XBX="" Q "???"
	Q XBX
	;
PCCPPCLC(XBVISIT)	;PEP - Return a visit's primary provider class (CODE)
	NEW X,Y,Z,XBX,DIC,DR,DA,DIQ,XBCODE,XBY,XBN
	S XBX=0
	F  S XBX=$O(^AUPNVPRV("AD",XBVISIT,XBX)) Q:XBX'=+XBX  I $P(^AUPNVPRV(XBX,0),U,4)="P" S XBY=+^AUPNVPRV(XBX,0) Q
	I '$G(XBY) Q "???"
	S DA=XBY,DIC=200,DR="53.5",DIQ="XBX",DIQ(0)="I"
	D EN^DIQ1
	S XBX=$G(XBX(200,XBY,"53.5","I"))
	Q:XBX="" "???"
	S DIC=7,DR="9999999.01",DA=XBX,DIQ="XBCODE"
	D EN^DIQ1
	S XBX=XBCODE(7,XBX,"9999999.01","I")
	Q XBX
	;
PCCPPAFF(XBVISIT,FORM)	;PEP - Return a visit's primary provider (affiliation)
	NEW X,Y,Z,XBX,DIC,DR,DA,DIQ,XBY,XBN
	S XBX=0
	F  S XBX=$O(^AUPNVPRV("AD",XBVISIT,XBX)) Q:XBX'=+XBX  I $P(^AUPNVPRV(XBX,0),U,4)="P" S XBY=+^AUPNVPRV(XBX,0) Q
	I '$G(XBY) Q "???"
	S:$G(FORM)="I" DIQ(0)="I"
	S DA=XBY,DIC=$S($P($G(^AUTTSITE(1,0)),U,22):200,1:6),DR="9999999.01",DIQ="XBX"
	D EN^DIQ1
	I $P($G(^AUTTSITE(1,0)),U,22) S XBX=$S($G(FORM)="I":$G(XBX(200,XBY,9999999.01,"I")),1:$G(XBX(200,XBY,9999999.01)))
	I '$P($G(^AUTTSITE(1,0)),U,22) S XBX=$S($G(FORM)="I":$G(XBX(6,XBY,9999999.01,"I")),1:$G(XBX(6,XBY,9999999.01)))
	Q:XBX="" "???"
	Q XBX
	;
