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

VENPCC3.m

Go to the documentation of this file.
VENPCC3 ; IHS/OIT/GIS - CHECK-IN UTILITIES ;
 ;;2.6;PCC+;;NOV 12, 2007
 ;
 ;
 ;
CK ; EP-CHECK TO BE SURE THE SYSTEM IS RUNNING PROPERLY
 I $L($T(UMSG^VENPCCP2)) Q  ; NEW ERROR MESSAGE PROCESS IN PLACE
 N EIEN,%,X,DIE,DR,DA,DIC,D,DI,DQ,D0,ERROR
 S EIEN=$O(^VEN(7.7,99999999),-1) I 'EIEN Q
 S X=$P($G(^VEN(7.7,EIEN,0)),U,6) I X Q
 S ERROR=$G(^VEN(7.7,EIEN,1))
 I ERROR["out of paper",$G(IO)'=$P($G(^VEN(7.7,EIEN,0)),U,5) Q
 W !!,*7,"ENCOUNTER FORM ERROR DETECTED!!!"
 W !,"""",ERROR,""""
 W !,"PLEASE TAKE APPROPRIATE ACTION",!!
 S DIE="^VEN(7.7,",DA=EIEN,DR=".06////1"
 L +^VEN(7.7):0 I $T D ^DIE L -^VEN(7.7)
 Q
 ;
VISIT(APCDPAT,APCDDATE,APCDLOC,APCDCLN) ; EP-CREATE NEW VISIT, RETURN VISIT IEN
 NEW %,APCDADD,APCDCAT,APCDDOB,APCDDOD,APCDSEX,APCDDFLT,APCDFLC,APCDFVOK,APCDVSIT,AUPNDAYS,AUPNDOB,AUPNDOD,AUPNPAT,AUPNSEX,AUPNVSIT,DI,DFLN,DIG,DIH,DISYS,DIU,DIV,DIW,DQ,DICR,DK,DL,%Q,APCDTYPE
 I '$D(^AUPNPAT(+$G(APCDPAT),0)) Q "MISSING OR INVALID PATIENT DFN"
 S %=+$G(APCDDATE) I %'?7N,%'?7N1"."1.4N Q "MISSING OF INVALID VISIT DATE"
 S %=+$G(APCDLOC) I '$D(^AUTTLOC(%,0)) Q "MISSING OR INVALID LOCATION"
 S APCDTYPE=$P($G(^APCCCTRL(+$G(DUZ(2)),0)),U,4) I APCDTYPE="" Q "MISSING OR INVALID VISIT TYPE"
 S %=+$G(APCDCLN) I '$D(^DIC(40.7,%,0)) Q "MISSING OR INVALID CLINIC TYPE"
 S APCDADD="",APCDFVOK=""
 S %=$P($G(^DIC(40.7,+$G(CLINIC),0)),U) S APCDCAT=$S(%["TELEPHONE":"T",%["CHART REVIEW":"C",1:"A")
 D ^APCDALV
 I $G(APCDFLG) Q "NO VISIT CREATED - FAILED FILEMAN AUDITS"
 Q $G(APCDVSIT)
 ;
CLEAN(OLD,START) ; EP-CLEAN OUT ALL VISITS IN A TIME RANGE WITH NO DEC
 NEW %DT,D0,DA,DIC,DIE,DR,VDATE,VPRV,X,Y
 I $G(OLD)="" S X="T-7",%DT="TX" D ^%DT S OLD=Y
 I $G(START)="" S X="T-90",%DT="TX" D ^%DT S START=Y
 S DIE="^AUPNVSIT(",DR=".11////1"
 S VDATE=START F  S VDATE=$O(^AUPNVSIT("B",VDATE)) Q:'VDATE  Q:VDATE>OLD  S DA=0 F  S DA=$O(^AUPNVSIT("B",VDATE,DA)) Q:'DA  D
 . S X=$G(^AUPNVSIT(DA,0)) I '$L(X) Q
 . I $P(X,U,11) Q  ; VISIT ALREADY DELETED
 . I $P(X,U,9) Q  ; DONT DELETE IF THERE IS A DEC
 . L +^AUPNVSIT(DA):0 I $T D ^DIE L -^AUPNVSIT(DA)
 . W "."
 . Q
 Q
 ;
VCN(VIEN,DEPTIEN) ; EP-GIVEN THE VISIT IEN (VIEN) AND DEPT IEN RETURN THE VCN
 N %
 I '$D(^AUPNVSIT(+$G(VIEN),0)) Q "MISSING OR INVALID VISIT CONTROL NUMBER"
 I '$D(^VEN(7.95,+$G(DEPTIEN),0)) Q "MISSING OR INVALID DEPT IEN"
 NEW CNT,D,D0,DA,DFN,DI,DIC,DIE,DQ,DR,HRN,J,REC,SERVCAT,VCNT,VRN,X
 S %=$P($G(^AUPNVSIT(VIEN,11)),U,3) I %'="" Q % ; VCN ALREADY EXISTS
 S REC=^AUPNVSIT(VIEN,0)
 S DFN=$P(REC,U,5) I '$D(^DPT(+$G(DFN),0)) Q "MISSING OR INVALID DFN"
 S SERVCAT=$P(REC,U,7) I SERVCAT="" Q "MISSING SERVICE CATEGORY"
 S HRN=$$CHART^VENPCC1A(DEPTIEN,DFN) I 'HRN Q "UNABLE TO FIND HRN"
 S CNT=0 F J=0:0 S J=$O(^AUPNVSIT("AC",DFN,J))  Q:'J  S CNT=CNT+1
 F VCNT=CNT:1 S VRN=HRN_"."_VCNT_SERVCAT I '$D(^AUPNVSIT("VCN",VRN)) Q
 S DIE="^AUPNVSIT(",DA=VIEN,DR="1103////^S X=VRN"
 L +^AUPNVSIT(VIEN):5 E  Q "UNABLE TO UPDATE THE VISIT FILE"
 D ^DIE L -^AUPNVSIT(DA)
 Q VRN_U_VIEN
 ; 
OB(DFN) ; EP - CLOSE PREGNANCY LOOP IF NECESSARY
 N CPIEN,BDFN,DD,EDD,EDDT,DT60,X,Y,Z,DIC,DIE,DA,DR,%,TDT,OBIEN
 S CPIEN=$O(^AUPNCPG("B",DFN,999999999),-1) I 'CPIEN Q
 S DD=$P($G(^AUPNCPG(CPIEN,131)),U,1) I DD Q
 S EDD=$P($G(^AUPNCPG(CPIEN,101)),U,1) I 'EDD Q
 S DT60=$$FMADD^XLFDT(EDD,+60) I 'DT60 Q
 I DT<DT60 Q  ; THIS DIALOG ONLY OCCURS IF THE PATIENT IS 60 DAYS POST EDD AND NO DD HAS BEEN RECORDED
EDDT S EDDT=$$FMTE^XLFDT(EDD,2)
ASK W !,"The record indicates that this patient was followed here for prenatal care"
 W !,"and the Estimated Date of Delivery (EDD) was : ",EDDT
 S DIR(0)="SO^Y:YES;N:NO;U:UNKNOWN",DIR("A")="Did the pregnancy result in a delivery" D ^DIR K DIR
 I Y="Y" G DEL
 I Y'="N" D ^XBFMK Q
TERM ; PREG ENDED WITHOUT A DELIVERY
 S DIR(0)="DO^::EP",DIR("A")="When did the pregnancy end"
 S DIR("?")="If you don't know the exact date, enter an approximate date." D ^DIR K DIR
PDT ; PROCESS THE DATE
 I Y'?7N D ^XBFMK Q
 S TDT=Y,DIE=9000051,DA=CPIEN,DR="131.01////^S X=TDT"
 L +^AUPNCPG(DA):1 I  D ^DIE L -^AUPNCPG(DA)
 S OBIEN=$O(^AUPNOBHX("B",DFN,0)) I 'OBIEN D ^XBFMK Q
 I $D(^AUPNOBHX(OBIEN,103,"B",TDT)) Q
 S DA(1)=OBIEN,DIC="^AUPNOBHX("_DA(1)_",103,",DLAYGO=9000050.103,DIC(0)="L",DIC("P")=9000050.103
 S X=TDT
 D ^DIC
 D ^XBFMK
 Q
 ;
DEL ; GET DELIVERY INFO
 N NAME,SEX,BIEN,DOB
 W !,"Is the chlid from this delivery registered here"
 S %=0 D YN^DICN I %'=1 D  Q
 . S DIR(0)="DO^::EP",DIR("A")="What was the delivery date"
 . D ^DIR K DIR I Y'?7N Q
 . D PDT ; PROCESS THE DATE
 . D ^XBFMK
 . Q
KID S DIC=2,DIC(0)="AEQM",DIC("A")="Name or chart # of child"
 D ^DIC I Y=-1  D ^XBFMK Q
 S BIEN=+Y,NAME=$P(Y,U,2),SEX=$P($G(^DPT(BIEN,0)),U,2),DOB=$P($G(^DPT(BIEN,0)),U,3)
 S %=0 W !,"Are you certian this is the correct child"
 D YN^DICN I %'=1 G KID
 S TDT=DOB D PDT
 S DIC("P")=9000051.135,DA(1)=CPIEN,DIC="^AUPNCPG("_DA(1)_",135,",DIC(0)="L",X=NAME
 D ^DIC I Y=-1 D ^XBFMK Q
 S DA=+Y,DIE=DIC,DR=".04////^S X=SEX;.11////^S X=BIEN"
 L +^AUPNCPG(CPIEN,DA(1),135):1 I  D ^DIE L -^AUPNCPG(CPIEN,DA(1),135)
 D ^XBFMK
 Q
 ;