VENPCCUR ; IHS/OIT/GIS - VEN UTILITIES ; RPC CALLS
;;2.6;PCC+;**1,3**;APR 03, 2012;Build 24
;
;
PATIENT(OUT,IN) ; EP - RPC: VEN PCC+ GET PATIENT
; GIVEN A CHART NUMBER, RETURN ALL PATIENT IDENTIFIERS
I '$L($G(IN)) Q
N NAME,DOB,AGE,X,Y,%,HRN,AUPNPAT,AUPNSEX,AUPNDOB,AUPNDAYS,AUPNDOD,B,SSN,PP
S OUT="",HRN=IN,B="|"
S DIC="^AUPNPAT(",X=HRN,DIC(0)="M"
PLK ; EP - FOR ALT PROCESSING OF HRN
D ^DIC I Y=-1 Q
I $G(AUPNDOD) Q ; PATIENT MUST BE ALIVE
I '$G(AUPNPAT) Q
S NAME=$P($G(^DPT(AUPNPAT,0)),U) I '$L(NAME) Q
S DOB=$$FMTE^XLFDT(AUPNDOB,"2D")
S AGE=DT-AUPNDOB\10000
S PPIEN=$P($G(^AUPNPAT(AUPNPAT,0)),U,14),PPIEN=+$$PRV^VENPCCU(PPIEN)
S PPNAME=$P($G(^VA(200,PPIEN,0)),U)
S SSN=$P($G(^DPT(AUPNPAT,0)),U,9)
S OUT=AUPNPAT_B_NAME_B_AGE_B_DOB_B_PPIEN_B_PPNAME_B_AUPNSEX_B_SSN
D ^XBFMK
Q
;
VISIT(OUT,IN) ; EP - RPC: VEN PCC+ GET RECENT VISITS
; GIVEN A DFN, RETURN A TABLE GENERATION STRING THAT WILL SHOW ALL VISITS FOR THIS PT IN PAST 24 HOURS
N START,FIN,%,DFN
S OUT=""
S DFN=+$G(IN) I '$D(^DPT(DFN,0)) Q
S %=$$FMADD^XLFDT(DT,-1),START=$$FMTE^XLFDT(%,"2D")
S %=$$FMADD^XLFDT(DT,+1),FIN=$$FMTE^XLFDT(%,"2D")
S OUT="BMX ADO SS^VISITS^^AA~"_START_"~"_FIN_"~9~~~~"_DFN_"|R"
Q
;
AGE(DFN) ; EP - TRIGGER FUNCTION FOR BMX ADO SCHEMA/PATIENT DEMOGRAPHICS ; GIVEN DFN RETRUN THE AGE
N DOB,AGE
S DOB=$P($G(^DPT(+$G(DFN),0)),U,3) I 'DOB Q ""
S AGE=DT-DOB\10000
Q AGE
;
PP1(VIEN) ; EP - TRIGGER FUNCTION FOR BMX ADO SCHEMA/VISITS ; RETURN PRIMARY PROVIDER IEN
Q $$PP(+$G(VIEN),1)
;
PP2(VIEN) ; EP - TRIGGER FUNCTION FOR BMX ADO SCHEMA/VISITS ; RETURN PRIMARY PROVIDER NAME
Q $$PP(+$G(VIEN),2)
;
PP(VIEN,MODE) ; EP - EXTRACTION FUNCTION ; GIVEN A VISIT IEN, RETURN THE PRIMARY PROVIDER (IF THERE IS ONE): IEN^NAME
I '$D(^AUPNVSIT(+$G(VIEN),0)) Q ""
N VPIEN,NAME,PIEN,TOT
S PVIEN=0,TOT=0
F S PVIEN=$O(^AUPNVPRV("AD",VIEN,PVIEN)) Q:'PVIEN S TOT=TOT+1 I $P($G(^AUPNVPRV(PVIEN,0)),U,4)="P" Q
I 'TOT Q ""
I TOT=1 S PVIEN=$O(^AUPNVPRV("AD",VIEN,0)) I $P($G(^AUPNVPRV(PVIEN,0)),U,4)="S" Q ""
I 'PVIEN Q ""
S PIEN=+$G(^AUPNVPRV(PVIEN,0)) I 'PIEN Q ""
S PIEN=$$PRV^VENPCCU(PIEN) ; FILE 200 CONVERION (IF NECESSARY)
I MODE=1 Q PIEN
S NAME=$P($G(^VA(200,PIEN,0)),U) I '$L(NAME) Q ""
Q NAME
;
VENPCCUR ; IHS/OIT/GIS - VEN UTILITIES ; RPC CALLS
+1 ;;2.6;PCC+;**1,3**;APR 03, 2012;Build 24
+2 ;
+3 ;
PATIENT(OUT,IN) ; EP - RPC: VEN PCC+ GET PATIENT
+1 ; GIVEN A CHART NUMBER, RETURN ALL PATIENT IDENTIFIERS
+2 IF '$LENGTH($GET(IN))
QUIT
+3 NEW NAME,DOB,AGE,X,Y,%,HRN,AUPNPAT,AUPNSEX,AUPNDOB,AUPNDAYS,AUPNDOD,B,SSN,PP
+4 SET OUT=""
SET HRN=IN
SET B="|"
+5 SET DIC="^AUPNPAT("
SET X=HRN
SET DIC(0)="M"
PLK ; EP - FOR ALT PROCESSING OF HRN
+1 DO ^DIC
IF Y=-1
QUIT
+2 ; PATIENT MUST BE ALIVE
IF $GET(AUPNDOD)
QUIT
+3 IF '$GET(AUPNPAT)
QUIT
+4 SET NAME=$PIECE($GET(^DPT(AUPNPAT,0)),U)
IF '$LENGTH(NAME)
QUIT
+5 SET DOB=$$FMTE^XLFDT(AUPNDOB,"2D")
+6 SET AGE=DT-AUPNDOB\10000
+7 SET PPIEN=$PIECE($GET(^AUPNPAT(AUPNPAT,0)),U,14)
SET PPIEN=+$$PRV^VENPCCU(PPIEN)
+8 SET PPNAME=$PIECE($GET(^VA(200,PPIEN,0)),U)
+9 SET SSN=$PIECE($GET(^DPT(AUPNPAT,0)),U,9)
+10 SET OUT=AUPNPAT_B_NAME_B_AGE_B_DOB_B_PPIEN_B_PPNAME_B_AUPNSEX_B_SSN
+11 DO ^XBFMK
+12 QUIT
+13 ;
VISIT(OUT,IN) ; EP - RPC: VEN PCC+ GET RECENT VISITS
+1 ; GIVEN A DFN, RETURN A TABLE GENERATION STRING THAT WILL SHOW ALL VISITS FOR THIS PT IN PAST 24 HOURS
+2 NEW START,FIN,%,DFN
+3 SET OUT=""
+4 SET DFN=+$GET(IN)
IF '$DATA(^DPT(DFN,0))
QUIT
+5 SET %=$$FMADD^XLFDT(DT,-1)
SET START=$$FMTE^XLFDT(%,"2D")
+6 SET %=$$FMADD^XLFDT(DT,+1)
SET FIN=$$FMTE^XLFDT(%,"2D")
+7 SET OUT="BMX ADO SS^VISITS^^AA~"_START_"~"_FIN_"~9~~~~"_DFN_"|R"
+8 QUIT
+9 ;
AGE(DFN) ; EP - TRIGGER FUNCTION FOR BMX ADO SCHEMA/PATIENT DEMOGRAPHICS ; GIVEN DFN RETRUN THE AGE
+1 NEW DOB,AGE
+2 SET DOB=$PIECE($GET(^DPT(+$GET(DFN),0)),U,3)
IF 'DOB
QUIT ""
+3 SET AGE=DT-DOB\10000
+4 QUIT AGE
+5 ;
PP1(VIEN) ; EP - TRIGGER FUNCTION FOR BMX ADO SCHEMA/VISITS ; RETURN PRIMARY PROVIDER IEN
+1 QUIT $$PP(+$GET(VIEN),1)
+2 ;
PP2(VIEN) ; EP - TRIGGER FUNCTION FOR BMX ADO SCHEMA/VISITS ; RETURN PRIMARY PROVIDER NAME
+1 QUIT $$PP(+$GET(VIEN),2)
+2 ;
PP(VIEN,MODE) ; EP - EXTRACTION FUNCTION ; GIVEN A VISIT IEN, RETURN THE PRIMARY PROVIDER (IF THERE IS ONE): IEN^NAME
+1 IF '$DATA(^AUPNVSIT(+$GET(VIEN),0))
QUIT ""
+2 NEW VPIEN,NAME,PIEN,TOT
+3 SET PVIEN=0
SET TOT=0
+4 FOR
SET PVIEN=$ORDER(^AUPNVPRV("AD",VIEN,PVIEN))
IF 'PVIEN
QUIT
SET TOT=TOT+1
IF $PIECE($GET(^AUPNVPRV(PVIEN,0)),U,4)="P"
QUIT
+5 IF 'TOT
QUIT ""
+6 IF TOT=1
SET PVIEN=$ORDER(^AUPNVPRV("AD",VIEN,0))
IF $PIECE($GET(^AUPNVPRV(PVIEN,0)),U,4)="S"
QUIT ""
+7 IF 'PVIEN
QUIT ""
+8 SET PIEN=+$GET(^AUPNVPRV(PVIEN,0))
IF 'PIEN
QUIT ""
+9 ; FILE 200 CONVERION (IF NECESSARY)
SET PIEN=$$PRV^VENPCCU(PIEN)
+10 IF MODE=1
QUIT PIEN
+11 SET NAME=$PIECE($GET(^VA(200,PIEN,0)),U)
IF '$LENGTH(NAME)
QUIT ""
+12 QUIT NAME
+13 ;