Home   Package List   Routine Alphabetical List   Global Alphabetical List   FileMan Files List   FileMan Sub-Files List   Package Component Lists   Package-Namespace Mapping  
Routine: VENPCCYV

VENPCCYV.m

Go to the documentation of this file.
VENPCCYV ; IHS/OIT/GIS - COMPONENT FRAMEWORK ; MANAGE VISIT CONTEXT
 ;;2.6;PCC+;**1,3**;APR 03, 2012;Build 24
 ; 
 ;
PPRV(VIEN) ; EP - GIVEN A VISIT IEN, RETURN THE PRIMARY PROVIDER NAME
 ; CALLED BY THE BMX SCHEMA
 I '$D(^AUPNVPRV("AD",+$G(VIEN))) Q ""
 N NAME,PIEN,VPIEN,X,Y,Z,%
 S VPIEN=0,PIEN=""
 F  S VPIEN=$O(^AUPNVPRV("AD",VIEN,VPIEN)) Q:'VPIEN  D  I PIEN Q
 . S X=$G(^AUPNVPRV(VPIEN,0)) I X="" Q
 . S TYPE=$P(X,U,4)
 . I TYPE="P" S PIEN=+X
 . Q
 I 'PIEN S VPIEN=$O(^AUPNVPRV("AD",VIEN,0)) I VPIEN S PIEN=+$G(^AUPNVPRV(VPIEN,0))
 I 'PIEN Q ""
 S PIEN=$$PRV^VENPCCU(PIEN)
 S NAME=$P($G(^VA(200,PIEN,0)),U)
 Q NAME
 ;
PPOV(VIEN) ; EP - GIVEN A VISIT IEN, RETURN THE PRIMARY PURPOSE OF VISIT ICD CODE (NARRATIVE)
 ; CALLED BY BMX SCHEMA
 I '$D(^AUPNVPOV("AD",+$G(VIEN))) Q ""
 N TXT,IIEN,VPIEN,X,Y,Z,%,ICD,NIEN,DX
 S VPIEN=0,IIEN=""
 F  S VPIEN=$O(^AUPNVPOV("AD",VIEN,VPIEN)) Q:'VPIEN  D  I IIEN Q
 . S X=$G(^AUPNVPOV(VPIEN,0)) I X="" Q
 . S TYPE=$P(X,U,12)
 . I TYPE="P" S IIEN=+X
 . Q
 I 'IIEN S VPIEN=$O(^AUPNVPOV("AD",VIEN,0)) I VPIEN S IIEN=+$G(^AUPNVPOV(VPIEN,0))
 I IIEN,VPIEN
 E  Q ""
 S ICD=$P($G(^ICD9(IIEN,0)),U) I '$L(ICD) Q ""
 S NIEN=$P($G(^AUPNVPOV(VPIEN,0)),U,4) I 'NIEN Q ""
 S TXT=$P($G(^AUTNPOV(NIEN,0)),U) I TXT="" Q ""
 I $L(TXT)>20 S TXT=$E(TXT,1,17)_"..."
 S DX=ICD_" ("_TXT_")"
 Q DX
 ;
NEWV(VIEN,TS,NVIEN) ; EP - RPC: VEN CF CLONE VISIT AND RETURN THE NEW VISIT IEN
 ; GIVEN A PAST VISIT IEN AND NEW TIMESTAMP: CREATE A NEW VISIT AND NEW V POV & V PROVIDER ENTRIES
 I $D(^AUPNVSIT(+$G(VIEN),0)),$G(TS)
 E  Q
 N DA,DIK,DIC,DIE,X,Y,Z,%,PRVIEN,POVIEN,NPRVIEN,NPOVIEN
 S POVIEN=$O(^AUPNVPOV("AD",VIEN,0)) I 'POVIEN Q
 S PRVIEN=$O(^AUPNVPRV("AD",VIEN,0)) I 'PRVIEN Q
 ; AT THIS POINT YOU HAVE A VALID SOURCE VISIT AND V FILES
 S NVIEN=$O(^AUPNVSIT(999999999999),-1) I 'NVIEN Q
 S NVIEN=NVIEN+1
 M ^AUPNVSIT(NVIEN)=^AUPNVSIT(VIEN)
 S $P(^AUPNVSIT(NVIEN,0),U)=TS ; RESET VISIT TIMESTAMP
 S DA=NVIEN,DIK="^AUPNVSIT(" D IX1^DIK ; SET THE INDEXES
 S NPOVIEN=$O(^AUPNVPOV(999999999999),-1)+1 ; MAKE NEW V POV ENTRY
 M ^AUPNVPOV(NPOVIEN)=^AUPNVPOV(POVIEN)
 S $P(^AUPNVPOV(NPOVIEN,0),U,3)=NVIEN
 S DA=NPOVIEN,DIK="^AUPNVPOV(" D IX1^DIK
 S NPRVIEN=$O(^AUPNVPRV(999999999999),-1)+1 ; MAKE A NEW V PROVIDER ENTRY
 M ^AUPNVPRV(NPRVIEN)=^AUPNVPRV(PRVIEN)
 S $P(^AUPNVPRV(NPRVIEN,0),U,3)=NVIEN
 S DA=NPRVIEN,DIK="^AUPNVPRV(" D IX1^DIK
 S $P(^AUPNVSIT(NVIEN,0),U,9)=2 ; RESET DEPENDENT ENTRY COUNT
 S $P(^AUPNVSIT(NVIEN,0),U,2)=DT ; RESET DATE VISIT CRATED
 D ^XBFMK
 Q
 ;
VALV(DFN,IENS,MAX,OUT,TOT) ; EP - VALID VISIT ITERATION FOR BMX SCHEMA
 ; ONLY VALID VISITS ARE RETURNED
 I '$O(^AUPNVSIT("AA",+$G(DFN),0)) Q ""
 N IDT,VIEN,CNT,FIN,END,%
 S IDT=0,CNT=0,FIN=0
 S END=9999999-$G(START)
 I 'MAX S MAX=99
 F  Q:FIN  S IDT=$O(^AUPNVSIT("AA",DFN,IDT)) Q:'IDT  S VIEN=999999999999 F  Q:FIN  S VIEN=$O(^AUPNVSIT("AA",DFN,IDT,VIEN),-1) Q:'VIEN  D  Q
 . I IDT>END S FIN=1 Q
 . S X=$G(^AUPNVSIT(VIEN,0)) I '$L(X) Q  ; VISIT DATA MUST EXIST
 . I $P(X,U,11) Q  ; MUST BE AN 'ACTIVE' VISIT - NOT 'DELETED'
 . I $P(X,U,3)="" Q  ; VISIT MUST HAVE A TYPE
 . I '$P(X,U,6) Q  ; MUST HAVE A VALID ENCOUNTER LOCATION
 . I $P(X,U,7)="" Q  ; VISIT MUST HAVE A CATEGORY
 . I $P(X,U,8)="" Q  ; VISIT MUST HAVE A VALID CLINIC FIN
 . ; I '$D(^AUPNVPOV("AD",VIEN)) Q  ; MUST HAVE A POV ; PATCHED BY GIS 4/27/2009
 . I '$D(^AUPNVPRV("AD",VIEN)) Q  ; MUST HAVE A PROVIDER
 . S DA=VIEN,IENS=DA_C
 . D DATA^BMXADOV1(IENS,DA)
 . S CNT=CNT+1
 . I CNT=MAX S FIN=1
 . Q
 Q ""
 ;