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

PXAIPRV.m

Go to the documentation of this file.
PXAIPRV ;ISL/JVS,ESW,PKR - SET THE PROVIDER NODES ;08/07/2020
 ;;1.0;PCE PATIENT CARE ENCOUNTER;**5,108,124,211**;Aug 12, 1996;Build 454
 ;
 Q
PRV ;--CREATE PROVIDERS
 ;
SET ;--SET AND NEW VARIABLES
 N AFTER0,AFTER12,AFTER801,AFTER811,AFTER812
 N BEFOR0,BEFOR12,BEFOR801,BEFOR811,BEFOR812
 N NODE,PXAA,PXAB,SUB,PXAAX,IENB,STOP
 ;
 K PXAERR
 S PXAERR(8)=PXAK
 S PXAERR(7)="PROVIDER"
 ;
 S SUB="" F  S SUB=$O(@PXADATA@("PROVIDER",PXAK,SUB)) Q:SUB=""  D
 .S PXAA(SUB)=@PXADATA@("PROVIDER",PXAK,SUB)
 ;
 ;--VALIDATE ENOUGH DATA
 D VAL^PXAIPRVV Q:$G(STOP)
 ;
SETVARA ;--SET VISIT VARIABLES
 S $P(AFTER0,"^",1)=$G(PXAA("NAME"))
 I $G(PXAA("DELETE")) S $P(AFTER0,"^",1)="@"
 S $P(AFTER0,"^",2)=$G(PATIENT)
 S $P(AFTER0,"^",3)=$G(PXAVISIT)
 S $P(AFTER0,"^",4)=$S($G(PXAA("PRIMARY"))=1:"P",1:"S")
 S $P(AFTER0,"^",5)=$S($G(PXAA("ATTENDING"))=1:"A",$G(PXAA("ATTENDING"))=0:"@",1:"")
 S $P(AFTER12,"^",1)=$G(PXAA("EVENT D/T"))
 S $P(AFTER811,"^",1)=$G(PXAA("COMMENT"))
 S $P(AFTER812,"^",2)=$S($G(PXAA("PKG"))'="":PXAA("PKG"),1:$G(PXAPKG))
 S $P(AFTER812,"^",3)=$S($G(PXAA("SOURCE"))'="":PXAA("SOURCE"),1:$G(PXASOURC))
 ;
SETPXKA ;--SET PXK ARRAY AFTER
 S ^TMP("PXK",$J,"PRV",PXAK,0,"AFTER")=AFTER0
 S ^TMP("PXK",$J,"PRV",PXAK,12,"AFTER")=AFTER12
 S ^TMP("PXK",$J,"PRV",PXAK,811,"AFTER")=AFTER811
 S ^TMP("PXK",$J,"PRV",PXAK,812,"AFTER")=AFTER812
 ;
SETVARB ;--SET VARIABLES BEFORE
 ;
 ;--CHECK FOR PRIMARY DESIGNATION
 N ITEM,PXBSKY,PXBKY,PXBSAM,PXBCNT,PRVDR,FPRI
 D PRV^PXBGPRV(PXAVISIT,.PXBSKY,.PXBKY,.PXBSAM,.PXBCNT,.PRVDR,.FPRI)
 ;CHECK NAME
 S PXAAX("NAME")=$P($G(^VA(200,$G(PXAA("NAME")),0)),"^",1)
 ;
 ;--GET IEN FOR 'PXK NODE'
 I $G(PXAA("DELETE"))=1 S PXAAX("NAME")=$P($G(^VA(200,PXAA("NAME"),0)),"^",1)
 S ITEM="" I PXBCNT>0,$G(PXAAX("NAME"))]"" S ITEM=$O(PXBKY(PXAAX("NAME"),0))
 I ITEM]"" S (^TMP("PXK",$J,"PRV",PXAK,"IEN"),IENB)=$O(PXBSKY(ITEM,0))
 ;
 I $G(IENB) D
 .F NODE=0,12,811,812 S ^TMP("PXK",$J,"PRV",PXAK,NODE,"BEFORE")=$G(^AUPNVPRV(IENB,NODE))
 E  D
 .S (BEFOR0,BEFOR12,BEFOR811,BEFOR812)=""
 .;
SETPXKB .;--SET PXK ARRAY BEFORE
 .S ^TMP("PXK",$J,"PRV",PXAK,0,"BEFORE")=BEFOR0
 .S ^TMP("PXK",$J,"PRV",PXAK,12,"BEFORE")=BEFOR12
 .S ^TMP("PXK",$J,"PRV",PXAK,811,"BEFORE")=BEFOR811
 .S ^TMP("PXK",$J,"PRV",PXAK,812,"BEFORE")=BEFOR812
 .S ^TMP("PXK",$J,"PRV",PXAK,"IEN")=""
 ;
 ;Package and Data Source cannot be edited.
 S BEFOR812=^TMP("PXK",$J,"PRV",PXAK,812,"BEFORE")
 I BEFOR812'="" D
 . I AFTER812=BEFOR812 Q
 . I $P(BEFOR812,U,2)'="" S $P(AFTER812,U,2)=$P(BEFOR812,U,2)
 . I $P(BEFOR812,U,3)'="" S $P(AFTER812,U,3)=$P(BEFOR812,U,3)
 . S ^TMP("PXK",$J,"PRV",PXAK,812,"AFTER")=AFTER812
 ;
MISC ;--MISCELLANEOUS NODE
 ;
 Q
OTHER ;---ADD OTHER PROVIDERS TO V PROVIDER FOR OTHER ENTRIES
 ;
 ; generate data, PXBSKY(), about currently filed providers
 ;
 N PXBSKY
 I $G(PXAVISIT) D PRV^PXBGPRV(PXAVISIT,.PXBSKY)
 ;
 N IEN,AFTER0,CNT,PXAK,STOP,FF
 S IEN="",CNT=1000
 ;
 ;---^TMP("PXAIADDPRV",$J,'IEN')=""
 ;
 F  S IEN=$O(^TMP("PXAIADDPRV",$J,IEN)),CNT=CNT+1 Q:IEN=""  D
 .;
 .;verify if an entry for a provider already exists
 .;
 .S STOP=0
 .I $D(^TMP("PXK",$J,"PRV")) S PXAK="" D  Q:STOP
 ..F  S PXAK=$O(^TMP("PXK",$J,"PRV",PXAK)) Q:PXAK=""  D  Q:STOP
 ...I +$G(^TMP("PXK",$J,"PRV",PXAK,0,"AFTER"))=IEN S STOP=1
 .S FF="PXBSKY" F  S FF=$Q(@FF) Q:FF=""  I @FF=IEN S STOP=1 Q
 .Q:STOP
 .;
 .S $P(AFTER0,"^",1)=IEN
 .S $P(AFTER0,"^",2)=$P(^AUPNVSIT(PXAVISIT,0),"^",5)
 .S $P(AFTER0,"^",3)=PXAVISIT
 .S $P(AFTER0,"^",4)="S"
 .S $P(AFTER812,"^",2)=$G(PXAPKG)
 .S $P(AFTER812,"^",3)=$G(PXASOURC)
 .S ^TMP("PXK",$J,"PRV",CNT,0,"AFTER")=$G(AFTER0)
 .S ^TMP("PXK",$J,"PRV",CNT,811,"AFTER")=""
 .S ^TMP("PXK",$J,"PRV",CNT,812,"AFTER")=$G(AFTER812)
 .S ^TMP("PXK",$J,"PRV",CNT,0,"BEFORE")=""
 .S ^TMP("PXK",$J,"PRV",CNT,811,"BEFORE")=""
 .S ^TMP("PXK",$J,"PRV",CNT,812,"BEFORE")=""
 .S ^TMP("PXK",$J,"PRV",CNT,"IEN")=""
 Q
 ;
PRIM ;--SET A PROVIDER AS PRIMARY
 N NPRIM,NPROV,PORS,PRIMARY,PROVIDER,PROVIDERLIST,VPRVIEN
 S (NPRIM,NPROV,VPRVIEN)=0
 F  S VPRVIEN=+$O(^AUPNVPRV("AD",PXAVISIT,VPRVIEN)) Q:VPRVIEN=0  D
 . S NPROV=NPROV+1
 . S TEMP=^AUPNVPRV(VPRVIEN,0)
 . S PROVIDER=$P(TEMP,U,1)
 . S PORS=$P(TEMP,U,4)
 . S PROVIDERLIST(PROVIDER)=VPRVIEN_U_PORS
 . I PORS="P" S NPRIM=NPRIM+1
 ;If there is a primary provider or no providers quit.
 I (NPRIM=1)!(NPROV=0) K ^TMP("PXAIADDPRV",$J) Q
 ;No primary provider found, first use the encounter provider with
 ;the lowest DUZ and if there is no encounter provider use the
 ;ordering provider.
 S (PRIMARY,PROVIDER)=""
 F  S PROVIDER=$O(PROVIDERLIST(PROVIDER)) Q:(PRIMARY'="")!(PROVIDER="")  D
 . I $G(^TMP("PXAIADDPRV",$J,PROVIDER))="ENC" S PRIMARY=PROVIDER
 I PRIMARY="" S PRIMARY=$O(PROVIDERLIST(""))
 S VPRVIEN=$P(PROVIDERLIST(PRIMARY),U,1)
 ;
 S PXASOR=$G(^TMP("PXK",$J,"SOR"))
 K ^TMP("PXK",$J)
 S ^TMP("PXK",$J,"SOR")=$G(PXASOR)
 S ^TMP("PXK",$J,"VST",1,"IEN")=PXAVISIT
 ;
 S $P(AFTER0,"^",1)=$P(^AUPNVPRV(VPRVIEN,0),"^",1)
 S $P(AFTER0,"^",2)=$P(^AUPNVSIT(PXAVISIT,0),"^",5)
 S $P(AFTER0,"^",3)=PXAVISIT
 S $P(AFTER0,"^",4)="P"
 S ^TMP("PXK",$J,"PRV",22222,0,"AFTER")=AFTER0
 S ^TMP("PXK",$J,"PRV",22222,0,"BEFORE")=$G(^AUPNVPRV(VPRVIEN,0))
 S ^TMP("PXK",$J,"PRV",22222,"IEN")=VPRVIEN
 D EN1^PXKMAIN
 Q
 ;
OLDPRIM ;--SET A PROVIDER AS PRIMARY,replace by above in PX*2.0*211, kept
 ;as a reference.
 N PXBCNT,PXBKY,PXBSAM,PXBSKY,AFTER0,FPRI,PRVDR,PXASOR
 D PRV^PXBGPRV(PXAVISIT,.PXBSKY,.PXBKY,.PXBSAM,.PXBCNT,.PRVDR,.FPRI)
 I $D(PRVDR) Q
 I '$D(PXBSKY) Q
 ;----ADDED
 S PXASOR=$G(^TMP("PXK",$J,"SOR"))
 K ^TMP("PXK",$J)
 S ^TMP("PXK",$J,"SOR")=$G(PXASOR)
 S ^TMP("PXK",$J,"VST",1,"IEN")=PXAVISIT
 ;-------
 ;
 S $P(AFTER0,"^",1)=$P(^AUPNVPRV($O(PXBSKY(1,0)),0),"^",1)
 S $P(AFTER0,"^",2)=$P(^AUPNVSIT(PXAVISIT,0),"^",5)
 S $P(AFTER0,"^",3)=PXAVISIT
 S $P(AFTER0,"^",4)="P"
 S ^TMP("PXK",$J,"PRV",22222,0,"AFTER")=AFTER0
 S ^TMP("PXK",$J,"PRV",22222,0,"BEFORE")=$G(^AUPNVPRV($O(PXBSKY(1,0)),0))
 S ^TMP("PXK",$J,"PRV",22222,"IEN")=$O(PXBSKY(1,0))
 D EN1^PXKMAIN
 K PXRDR
 Q