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

PXAIPOV.m

Go to the documentation of this file.
PXAIPOV ;ISL/JVS,PKR,ESW - SET THE DIAGNOSIS/PROBLEM LIST NODES ;09/14/2021
 ;;1.0;PCE PATIENT CARE ENCOUNTER;**28,73,69,108,112,130,124,174,168,203,199,211,228**;Aug 12, 1996;Build 1
 ;
 Q
POV ;--CREATE DIAGNOSIS
 ;
SET ;--SET AND NEW VARIABLES
 N AFTER0,AFTER12,AFTER800,AFTER801,AFTER802,AFTER811,AFTER812,AFTER8A
 N BEFOR0,BEFOR12,BEFOR800,BEFOR801,BEFOR802,BEFOR811,BEFOR812,FPRI
 N EVENTDT,GMPSAVED,IENB,J,LNARR,NOPLLIST,PIECE,POVI,PRI,PRVDR,PXAA,PXAAX,PXAB
 N PXAIVDT,PXBCNT,PXBCNTPL,PXBKY,PXBPMT,PXBSAM,PXBSKY,PXDIGNS,PXKDONE
 N STOP,SUB,VAR
 ;
 K PXAERR
 S PXAERR(8)=PXAK
 S PXAERR(7)="DX/PL"
 ;
 S SUB="" F  S SUB=$O(@PXADATA@("DX/PL",PXAK,SUB)) Q:SUB=""  D
 .S PXAA(SUB)=@PXADATA@("DX/PL",PXAK,SUB)
 ;
 ;--VALIDATE ENOUGH DATA
 D VAL^PXAIPOVV Q:$G(STOP)=1
 ;
SETVARA ;--SET VISIT VARIABLES
 S $P(AFTER0,U,1)=$G(PXAA("DIAGNOSIS"))
 I $G(PXAA("DELETE")) S $P(AFTER0,U,1)="@"
 S $P(AFTER0,U,2)=$G(PATIENT),PXAA("PATIENT")=$G(PATIENT)
 S $P(AFTER0,U,3)=$G(PXAVISIT)
 ;If Provider Narrative is not passed it is generated in VAL^PXAIPOVV.
 S $P(AFTER0,U,4)=+$$PROVNARR^PXAPI($G(PXAA("NARRATIVE")),9000010.07)
 I $P(AFTER0,U,4)'>0 D VAL04^PXAIPOVV,ERR^PXAI("NARRATIVE",1) Q:$D(STOP)
 ;PX*1*124
 S PRI=$G(PXAA("PRIMARY"))
 S $P(AFTER0,U,12)=$S(PRI=1:"P",PRI="P":"P",1:"S")
 ;--ADDED FOR PATCH 28
 S $P(AFTER0,U,15)=$G(PXAA("LEXICON TERM"))
 S $P(AFTER0,U,16)=$G(PXAA("PL IEN"))
 S $P(AFTER0,U,17)=$G(PXAA("ORD/RES"))
 ;--END OF NEW PATCH 28
 S $P(AFTER12,U,1)=$G(PXAA("EVENT D/T"))
 S $P(AFTER12,U,2)=$G(PXAA("ORD PROVIDER"))
 S $P(AFTER12,U,4)=$G(PXAA("ENC PROVIDER"))
 ;PX*1*108
 I $G(PXAA("ENC PROVIDER"))]"",'$G(PXAA("DELETE")) D
 .S ^TMP("PXAIADDPRV",$J,$G(PXAA("ENC PROVIDER")))="ENC"
 I $G(PXAA("ORD PROVIDER"))]"",'$G(PXAA("DELETE")) D
 .S ^TMP("PXAIADDPRV",$J,$G(PXAA("ORD PROVIDER")))="ORD"
 ;
 I $G(PXAA("CATEGORY"))="" S $P(AFTER802,U,1)=""
 E  D
 . S $P(AFTER802,U,1)=+$$PROVNARR^PXAPI(PXAA("CATEGORY"),9000010.07)
 . I $P(AFTER802,U,1)'>0 D
 .. D VAL802^PXAIPOVV,ERR^PXAI("CATEGORY",1)
 .. S $P(AFTER802,U,1)=""
 ;
 S $P(AFTER811,U,1)=$G(PXAA("COMMENT"))
 ;
 S $P(AFTER800,U,1)=$G(PXAA("PL SC"))
 S $P(AFTER800,U,2)=$G(PXAA("PL AO"))
 S $P(AFTER800,U,3)=$G(PXAA("PL IR"))
 S $P(AFTER800,U,4)=$G(PXAA("PL EC"))
 S $P(AFTER800,U,5)=$G(PXAA("PL MST"))
 S $P(AFTER800,U,6)=$G(PXAA("PL HNC"))
 S $P(AFTER800,U,7)=$G(PXAA("PL CV"))
 S $P(AFTER800,U,8)=$G(PXAA("PL SHAD"))
 ;
 D SCC^PXUTLSCC(PATIENT,$P($G(^AUPNVSIT(PXAVISIT,0)),U,1),$P($G(^AUPNVSIT(PXAVISIT,0)),U,22),$G(PXAVISIT),AFTER800,.AFTER800)
 ;
 I $G(PXAA("PL SC"))="" S $P(AFTER800,U,1)=""
 I $G(PXAA("PL AO"))="" S $P(AFTER800,U,2)=""
 I $G(PXAA("PL IR"))="" S $P(AFTER800,U,3)=""
 I $G(PXAA("PL EC"))="" S $P(AFTER800,U,4)=""
 I $G(PXAA("PL MST"))="" S $P(AFTER800,U,5)=""
 I $G(PXAA("PL HNC"))="" S $P(AFTER800,U,6)=""
 I $G(PXAA("PL CV"))="" S $P(AFTER800,U,7)=""
 I $G(PXAA("PL SHAD"))="" S $P(AFTER800,U,8)=""
 ;
 S $P(AFTER812,U,2)=$S($G(PXAA("PKG"))'="":PXAA("PKG"),1:$G(PXAPKG))
 S $P(AFTER812,U,3)=$S($G(PXAA("SOURCE"))'="":PXAA("SOURCE"),1:$G(PXASOURC))
 ;
 D PL^PXAIPL
 ;
 ;
SETPXKA ;--SET PXK ARRAY AFTER
 S ^TMP("PXK",$J,"POV",PXAK,0,"AFTER")=$G(AFTER0)
 S ^TMP("PXK",$J,"POV",PXAK,12,"AFTER")=$G(AFTER12)
 S ^TMP("PXK",$J,"POV",PXAK,800,"AFTER")=$G(AFTER800)
 S ^TMP("PXK",$J,"POV",PXAK,802,"AFTER")=$G(AFTER802)
 S ^TMP("PXK",$J,"POV",PXAK,811,"AFTER")=$G(AFTER811)
 S ^TMP("PXK",$J,"POV",PXAK,812,"AFTER")=$G(AFTER812)
 ;
SETVARB ;--SET VARIABLES BEFORE
 ;
 ;--GET IEN FOR 'PXK NODE'
 D POV^PXBGPOV(PXAVISIT)
 I $D(^TMP("PXBGPOVMATCH",$J,$G(PXAA("DIAGNOSIS")))) D
 .S (^TMP("PXK",$J,"POV",PXAK,"IEN"),IENB)=$O(^TMP("PXBGPOVMATCH",$J,$G(PXAA("DIAGNOSIS")),0))
 K ^TMP("PXBGPOVMATCH",$J)
 ;
BEFOR ;
 I $G(IENB) D
 .F PIECE=0,12,800,802,811,812 S ^TMP("PXK",$J,"POV",PXAK,PIECE,"BEFORE")=$G(^AUPNVPOV(IENB,PIECE))
 E  D
 .S (BEFOR0,BEFOR12,BEFOR800,BEFOR802,BEFOR811,BEFOR812)=""
 .;
SETPXKB .;--SET PXK ARRAY BEFORE
 .S ^TMP("PXK",$J,"POV",PXAK,0,"BEFORE")=$G(BEFOR0)
 .S ^TMP("PXK",$J,"POV",PXAK,12,"BEFORE")=$G(BEFOR12)
 .S ^TMP("PXK",$J,"POV",PXAK,800,"BEFORE")=$G(BEFOR800)
 .S ^TMP("PXK",$J,"POV",PXAK,802,"BEFORE")=$G(BEFOR802)
 .S ^TMP("PXK",$J,"POV",PXAK,811,"BEFORE")=$G(BEFOR811)
 .S ^TMP("PXK",$J,"POV",PXAK,812,"BEFORE")=$G(BEFOR812)
 .S ^TMP("PXK",$J,"POV",PXAK,"IEN")=""
 ;
 ;Package and Data Source cannot be edited.
 S BEFOR812=^TMP("PXK",$J,"POV",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,"POV",PXAK,812,"AFTER")=AFTER812
 ;
MISC ;--MISCELLANEOUS NODE
 ;
 Q
 ;
PRIM ;--SET A PROVIDER AS PRIMARY
 ;THIS IS NOT CALLED ANYMORE.
 N PXBCNT,PXBKY,PXBSAM,PXBSKY,PRVDR,FPRI ;108
 D PRV^PXBGPRV(PXAVISIT,.PXBSKY,.PXBKY,.PXBSAM,.PXBCNT,.PRVDR,.FPRI) ;108
 I $D(PRVDR) Q
 I '$D(PXBSKY) Q
 ;
 S $P(AFTER0,U,1)=$P(^AUPNVPRV($O(PXBSKY(1,0)),0),U,1)
 S $P(AFTER0,U,2)=$P(^AUPNVSIT(PXAVISIT,0),U,5)
 S $P(AFTER0,U,3)=PXAVISIT
 S $P(AFTER0,U,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
 K ^TMP("PXBGPOVMATCH",$J)
 Q
 ;
SPOVPRIM(PXADATA,VISITIEN,PXAERR) ;If there is an exisiting primary diagnosis
 ;change it to secondary so the new primary can be set.
 N DIAG,IND,PDNEW
 S IND=0,PDNEW=""
 F  S IND=+$O(@PXADATA@("DX/PL",IND)) Q:IND=0  D
 . S DIAG=$G(@PXADATA@("DX/PL",IND,"DIAGNOSIS"))
 . I DIAG="" Q
 . I $G(@PXADATA@("DX/PL",IND,"PRIMARY"))=1 S PDNEW=DIAG
 I PDNEW="" Q
 ;
 ;There is a new primary diagnosis, set any existing primary to
 ;secondary.
 N FDA,IENS,MSG
 S IND=0
 F  S IND=$O(^AUPNVPOV("AD",VISITIEN,IND)) Q:IND=""  D
 . I $P(^AUPNVPOV(IND,0),U,12)="P" D
 .. S IENS=IND_","
 .. S FDA(9000010.07,IENS,.12)="S"
 .. D FILE^DIE("","FDA","MSG")
 .. I $D(MSG) D  Q
 ... S PXAERR(9)="V POV PRIMARY DIAGNOSIS CHANGE"
 ... S PXAERR(12)=MSG("DIERR",1,"TEXT",1)
 ... S PXAERR(13)="IENS="_IENS
 ... D ERRSET^PXAIPOVV
 Q
 ;