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

ORWPCE1.m

Go to the documentation of this file.
ORWPCE1  ;ISL/KCM,JER - PCE Calls from CPRS GUI ;Feb 12, 2024@14:45
 ;;3.0;ORDER ENTRY/RESULTS REPORTING;**10,85,116,132,148,187,190,215,243,280,306,361,501,559,405,598,606**;Dec 17, 1997;Build 3
 ;
 ; Reference to DSELECT^GMPLENFM, ^TMP("IB",$J) in ICR #1365
 ; Reference to $$DATA2PCE^PXAPI in ICR #1893
 ; Reference to $$DELVFILE^PXAPI in ICR #1890
 ; Reference to DQSAVE^PXRPC in ICR #6023
 ; Reference to $$NOW^XLFDT in ICR #5747
 ; Reference to FILE^TIUSRVP in ICR #3540
 ; Reference to $$ISADDNDM^TIULC1 in ICR #2323
 ; Reference to FINDVISIT^PXUTLVST in ICR #7435
 ; Reference to ^TIU(8925, in ICR #2937
 ; Reference to ^AUPNVSIT( in ICR #2028
 ;
GETVSIT(VSTR,DFN) ; lookup a visit
 ; Return Visit IEN if there is a Visit that matches the input; otherwise return 0.
 N ORDTE,ORLOC,ORSVC,ORVISIT,ORVISITLIST
 S ORVISIT=0
 I '$G(DFN)!($G(VSTR)="") Q ORVISIT
 ;
 S ORLOC=$P(VSTR,";")
 S ORDTE=$P(VSTR,";",2)
 S ORSVC=$P(VSTR,";",3)
 D FINDVISIT^PXUTLVST(DFN,ORDTE,ORLOC,ORSVC,"","","","",1,.ORVISITLIST)
 I $G(ORVISITLIST(0))>0 S ORVISIT=$G(ORVISITLIST(1))
 ;
 Q ORVISIT
 ;
DQSAVE(ORRESULT,PCELIST,NOTEIEN,GMPLUSER,ORLOC) ; Background Call to DATA2PCE   IA#6443
 I $D(ZTQUEUED) S ZTREQ="@"
 N PKG,PKGNAME,ORPXAPI,ORPCELST,ORPROBLS,ORPXDEL,PKGNAME,PROBLEM,PXAPREDT,PXNODE,PXVSTR,SRC,X,ORAVST,ORPXIMMRD,OK
 N DFN,ERRARR,ERRPROB
 S ORAVST=$P($G(PCELIST(1)),U,5) I +ORAVST S $P(PCELIST(1),U,5)=""
 I +ORAVST>0 D
 .S PXNODE=$G(^AUPNVSIT(ORAVST,0))
 .S PXVSTR=$P(PXNODE,U,6)_";"_$P(PXNODE,U)_";"_$P(PXNODE,U,7)
 .I $P(PXNODE,U,7)'="H" Q
 .I PXVSTR'=$P($G(PCELIST(1)),U,4) S ORAVST=-1
 I +ORAVST<1 S ORAVST=""
 S PKGNAME="ORDER ENTRY/RESULTS REPORTING"
 S PKG=$O(^DIC(9.4,"B","ORDER ENTRY/RESULTS REPORTING",0))
 S SRC="TEXT INTEGRATION UTILITIES"
 M ORPCELST=PCELIST
 S ORRESULT(0)=1
 D DQSAVE^PXRPC(.ORPCELST,.ORPXAPI,.ORPROBLS,.SRC,.ORPXIMMRD)
 S DFN=ORPXAPI("ENCOUNTER",1,"PATIENT")
 S PXAPREDT=0
 I $D(ORPXAPI("PROVIDER")) S PXAPREDT=1
 D DQSAVE1
 Q
 ;
DQSAVE1 ;
 ;Remove any problems to add that the patient already has as active problems
 I $D(ORPROBLS),$D(DFN) D
 . N ORWPROB,ORPROBIX
 . K ^TMP("IB",$J,"INTERFACES","GMP SELECT PATIENT ACTIVE PROBLEMS")
 . D DSELECT^GMPLENFM  ;DBIA 1365
 . S ORPROBIX=0
 . F  S ORPROBIX=$O(^TMP("IB",$J,"INTERFACES","GMP SELECT PATIENT ACTIVE PROBLEMS",ORPROBIX)) Q:'ORPROBIX  D  ;DBIA 1365
 .. S ORWPROB=$P(^TMP("IB",$J,"INTERFACES","GMP SELECT PATIENT ACTIVE PROBLEMS",ORPROBIX),"^",2,3)
 .. S ORWPROB($S($E(ORWPROB,1)="$":$E(ORWPROB,2,255),1:ORWPROB))=""
 . K ^TMP("IB",$J,"INTERFACES","GMP SELECT PATIENT ACTIVE PROBLEMS")
 . Q:'$D(ORWPROB)
 . S ORPROBIX=""
 . F  S ORPROBIX=$O(ORPROBLS(ORPROBIX)) Q:'ORPROBIX  D
 .. S:$D(ORWPROB(ORPROBLS(ORPROBIX))) ORPXAPI("DX/PL",ORPROBIX,"PL ADD")=0
 ;
 I $$MDS(.ORPXAPI,$G(ORLOC)) D
 .N ORTIME
 .S ORTIME=$$NOW^XLFDT
 .S ORPXAPI("ENCOUNTER",1,"CHECKOUT D/T")=ORTIME
DATA2PCE ;
 N TIEN,VISITOK,X0,X12
 S OK=$$DATA2PCE^PXAPI("ORPXAPI",PKG,SRC,.ORAVST,DUZ,0,.ERRARR,PXAPREDT,.ERRPROB)
 S VISITOK=$S(OK=1:1,(OK=-1)&(+ORAVST>0):1,(OK=-5)&(+ORAVST>0):1,1:0)
 I OK<0,OK'=-5 D ERROR(.ORRESULT,.ERRARR,.ERRPROB) ;S ORRESULT(0)=OK
 S ORRESULT(0)=$S(VISITOK=1:1,1:OK)
 S $P(ORRESULT(0),U,2)=ORAVST
 ;NOTEIEN only set on inpatient encounters.
 I VISITOK,+NOTEIEN,$P($G(^TIU(8925,+NOTEIEN,0)),U,13)="H" D
 .N OROK,ORX
 .S ORX(1207)=ORAVST
 .D FILE^TIUSRVP(.OROK,NOTEIEN,.ORX,1)
 .I '$$ISADDNDM^TIULC1(NOTEIEN) Q
 .S X0=$G(^TIU(8925,NOTEIEN,0))
 .I +$P(X0,U,6)>0 D
 ..S TIEN=+$P(X0,U,6)
 ..S X12=$G(^TIU(8925,TIEN,12))
 ..I $P(X12,U,7)>0 Q
 ..S ORX(1207)=ORAVST
 ..D FILE^TIUSRVP(.OROK,TIEN,.ORX,1)
 .I OROK'=1 S ORCNT=1+$O(ORRESULT("?"),-1),ORRESULT(ORCNT)=$P(OROK,U,2)
 S ZTSTAT=0  ; clear sync flag
 ;.N OROK,ORCNT
 ;.D LNKSVST^TIUPXAP3(.OROK,DFN,NOTEIEN,ORAVST)
 ;I OROK'=1 S ORCNT=1+$O(RESULT("?"),-1),RESULT(ORCNT)=$P(OROK,U,2)
 ; Save imm smallpox reading.
 ; Need separate DATA2PCE call, as it is tied to a different Visit.
 I $D(ORPXIMMRD) D
 . N CNT,ORERROR,ORVISIT,OK,ERRARR,ERRPROB
 . S ORERROR=$G(ORPXIMMRD("IMMUNIZATION",1,"ERROR"))
 . S ORVISIT=$G(ORPXIMMRD("IMMUNIZATION",1,"VISIT"))
 . K ORPXIMMRD("IMMUNIZATION",1,"ERROR"),ORPXIMMRD("IMMUNIZATION",1,"VISIT")
 . I ORERROR'="" D  Q
 . . S CNT=+$O(ORRESULT(""),-1)
 . . S CNT=CNT+1
 . . S ORRESULT(CNT)=" "
 . . S CNT=CNT+1
 . . S ORRESULT(CNT)=ORERROR
 . I 'ORVISIT Q
 . S OK=$$DATA2PCE^PXAPI("ORPXIMMRD",PKG,SRC,.ORVISIT,DUZ,0,.ERRARR,"",.ERRPROB)
 . I OK<0,OK'=-5 D
 . . S CNT=+$O(ORRESULT(""),-1)
 . . S CNT=CNT+1
 . . S ORRESULT(CNT)=" "
 . . D ERROR(.ORRESULT,.ERRARR,.ERRPROB)
 . . I +$G(ORRESULT(0))>0 S $P(ORRESULT(0),U,1)=OK
 ;
 Q
 ;
ERROR(ORRESULT,ERRARR,ERRPROB) ;
 N CNT,IDX,MSG
 S CNT=+$O(ORRESULT(""),-1)
 I $D(ERRARR) D
 .D ACOPY^ORERRH("ERRARR","MSG()")
 .S IDX=0 F  S IDX=$O(MSG(IDX)) Q:IDX'>0  S CNT=CNT+1,ORRESULT(CNT)=$P(MSG(IDX),"=",2,10)
 K OUTPUT
 I $D(ERRPROB),'$D(ERRARR) D
 .D ACOPY^ORERRH("ERRPROB","MSG()")
 .S IDX=0 F  S IDX=$O(MSG(IDX)) Q:IDX'>0  S CNT=CNT+1,ORRESULT(CNT)=$P(MSG(IDX),"=",2,10)
 Q
 ;
MDS(X,ORLOC) ; return TRUE if checkout is needed
 I $$CHKOUT^ORWPCE2(ORLOC) Q 1
 N I,ORAUTO,OROK
 S (OROK,I)=0
 F  S I=$O(X("DX/PL",I)) Q:'I  D  Q:OROK
 . I $G(X("DX/PL",I,"DIAGNOSIS")) S OROK=1
 I 'OROK D
 .S I=0 F  S I=$O(X("PROCEDURE",I)) Q:'I  D  Q:OROK
 .. I $G(X("PROCEDURE",I,"PROCEDURE")) S OROK=1
 I $D(X("PROVIDER",1,"NAME")) S OROK=1
 Q OROK
NONCOUNT(ORY,ORLOC) ;  Is the location a non-count clinic? (DBIA #964)
 Q:'ORLOC
 S ORY=$S($P($G(^SC(ORLOC,0)),U,17)="Y":1,1:0)
 Q
 ;