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

EDPQPCE.m

Go to the documentation of this file.
EDPQPCE ;SLC/KCM - Retrieve PCE information for ED Visits ; 9/20/21 11:53am
 ;;2.0;EMERGENCY DEPARTMENT;**6,2,16**;Feb 24, 2012;Build 6
 ;
DXPRI(AREA,LOG) ; return primary diagnosis
 N DXLST
 D DXALL(AREA,LOG,.DXLST)
 Q $G(DXLST(1)) ;$P( ,U,2)
 ;
DXALL(AREA,LOG,DXLST) ; build list of diagnoses for a visit
 N EDPVISIT S EDPVISIT=$P(^EDP(230,LOG,0),U,12)
 I EDPVISIT,$P($G(^EDPB(231.9,AREA,1)),U,2) D DXPCE(EDPVISIT,.DXLST) I 1
 E  D DXFREE(LOG,.DXLST)
 Q
DXPCE(EDPVISIT,DXLST) ; return a list of diagnoses from PCE
 ; DRP 04062012 ADD ICD10 API CALLS EDP*2.0*2 Begin
 N I,X,CODE,NAME,DX,EDPLVDT,EDPLCIEN,EDPLCTYPE
 K ^TMP("PXKENC",$J)
 D ENCEVENT^PXAPI(EDPVISIT)
 S I=0,DX=0 F  S I=$O(^TMP("PXKENC",$J,EDPVISIT,"POV",I)) Q:'I  D
 . S X=^TMP("PXKENC",$J,EDPVISIT,"POV",I,0)
 . S EDPLVDT=$P($G(^TMP("PXKENC",$J,EDPVISIT,"VST",EDPVISIT,0)),U,1)
 . S EDPLCTYPE=$$VER^EDPLEX($$CSYS^EDPLEX(EDPLVDT))
 . S EDPLCIEN=$P(X,U)
 . S CODE=$P($$ICDDATA^EDPLEX("DIAG",EDPLCIEN,EDPLVDT),U,2) ; DRP 
 . ;DRP end EDP*2.0*2 changes
 . S NAME=$G(^AUTNPOV($P(X,U,4),0))
 . I 'NAME S NAME=$$LD^ICDEX(80,EDPLCIEN,EDPLCTYPE) ; *16
 . S:NAME'[EDPLCTYPE NAME=NAME_" ("_$G(EDPLCTYPE)_" "_CODE_")"
 . S DX=DX+1,DX($S($P(X,U,12)="P":DX,1:DX*10000))=CODE_U_NAME_U_EDPLCTYPE
 S X="",DXLST=DX F I=1:1 S X=$O(DX(X)) Q:X=""  S DXLST(I)=DX(X)
 Q
DXFREE(LOG,DXLST) ; return free text diagnoses from ED LOG file
 N I,CODE,NAME,X4,DX,EDPLVDT,EDPLCIEN,EDPLCTYPE
 S I=0,DX=0 F  S I=$O(^EDP(230,LOG,4,I)) Q:'I  D
 . S X4=^EDP(230,LOG,4,I,0)
 . ; DRP 04062012 ADD ICD10 API CALLS EDP*2.0*2 Begin
 . S EDPLVDT=$P(^EDP(230,LOG,0),U,8) ;added this line DRP
 . S EDPLCIEN=$P(X4,U,2) S:EDPLCIEN CODE=$P($$ICDDATA^EDPLEX("DIAG",EDPLCIEN,EDPLVDT),U,2)
 . S:$G(CODE)'="" EDPLCTYPE=$$VER^EDPLEX($$CSYS^EDPLEX(EDPLVDT))
 . S NAME=$P(X4,U,1)
 . S:NAME'[$G(EDPLCTYPE) NAME=NAME_" ("_$G(EDPLCTYPE)_" "_$G(CODE)_")" ; drp added this line
 . S DX=DX+1,DX($S(+$P(X4,U,3):DX,1:DX*10000))=$G(CODE)_U_NAME_U_$G(EDPLCTYPE)
 . ;DRP end EDP*2.0*2 changes
 S X="",DXLST=DX F I=1:1 S X=$O(DX(X)) Q:X=""  S DXLST(I)=DX(X)
 Q
DXFREE2(LOG,DXLST) ; return ONLY the free text diagnosis
 N I,CODE,NAME,X4,DX
 S I=0,DX=0 F  S I=$O(^EDP(230,LOG,4,I)) Q:'I  D
 . S X4=^EDP(230,LOG,4,I,0)
 . S NAME=$P(X4,U,1)
 . S DX=DX+1,DX($S(+$P(X4,U,3):DX,1:DX*10000))=NAME
 S X="",DXLST=DX F I=1:1 S X=$O(DX(X)) Q:X=""  S DXLST(I)=DX(X)
 Q