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

VENPCCQA.m

Go to the documentation of this file.
VENPCCQA ; IHS/OIT/GIS - PRE INSTALL ; HS COMPONENT
 ;;2.6;PCC+;**1,2,3**;APR 03, 2012;Build 24
APCHS6B ; IHS/TUCSON/LAB - PART 6 OF APCHS -- SUMMARY PRODUCTION COMPONENTS
 ;;2.0;IHS RPMS/PCC Health Summary;;JUN 24, 1997
 ;
 ; D PEFLUSH(.OUT,"71270|5|10|2|2524\2528\2539") W ! ZW TOPIC Q
 ; S AGE=60,SEX="M",LINE=0,DFN=1,SEGIEN=-1 F CATIEN=10:1:26 D KBI(CATIEN)
 Q
 ; 
WCE ; ******************** WELL CHILD EXAM * 9000010 *******
 N LINE,ARR
 ; <SETUP>
 X APCHSCKP Q:$D(APCHSQIT)  X:'APCHSNPG APCHSBRK
 ; <DISPLAY>
 D WCESEG(APCHSPAT) ; CREATE THE DISPLAY ARRAY
 D PRINT ; PRINT THE SEGMENT
 ; <CLEANUP>
CLEANUP K APCHSDFN,APCHSN,APCHSICD,APCHSDAT,APCHSNRQ,APCHSICL
 Q
 ; 
LINE(STG) ; EP-CREATE A LINE IN THE SEGMENT
 S LINE=LINE+1
 S LINE(LINE)=STG
 Q
 ;
PRINT ; EP-PRINT RESULTS
 N CNT
 S CNT=0
 F  S CNT=$O(LINE(CNT)) Q:'CNT  D  I $D(APCHSQIT) Q
 . W !
 . X APCHSCKP Q:$D(APCHSQIT)
 . S X=LINE(CNT)
 . W X
 . Q
 Q
 ; 
WCESEG(DFN) ; EP - PRINT ALL WELL CHILD REMINDERS AND LAST RESULTS
 N STG,SEX,AM,DAGE,MOM,X,SEGIEN,DAYS
 S LINE=0
 S STG=$G(^DPT(+$G(DFN),0)) I '$L(STG) Q  ; INVALID DFN
 S SEX=$S($P(STG,U,2)="M":"Male",$P(STG,U,2)="F":"Female",1:"") ; SEX
 S MOM=$P($G(^DPT(DFN,.24)),U,2)
 I MOM="" S MOM=$P($G(^DPT(DFN,.24)),U,3)
 I MOM="" S MOM="??"
 S AM=$$AM(DFN,.DAYS)
 I AM="" Q  ; AGE IN MONTHS ; PATCHED BY GIS 5/7/07
 I 'DAYS S DAYS=1
 S DAGE=$$DAGE(AM) I '$L(DAGE) Q  ; DISPLAY AGE
 S X=SEX_"  "_DAGE_"  Mother: "_MOM D LINE(X) ; INTRO DATA LINE
 I '$L($G(APCHSEGH)) Q  ; SEGMENT NAME MUST EXIST
 I APCHSEGH="BYPASS" S SEGIEN=0
 E  S SEGIEN=$O(^APCHSCMP("B",$G(APCHSEGH),0)) I 'SEGIEN Q  ; SEMENT IEN
WCE1 D REM(DFN,SEGIEN,SEX,DAYS) ; GET REMINDERS FOR EA KB CATEGORY
 D LINE(" ")
 Q
 ; 
REM(DFN,SEGIEN,SEX,DAYS) ; EP - REMINDERS
 N CATIEN,KBIEN,CAT,K,HDR,AGE,ARR,X,CNT,TOT,STG,ORD,CIEN,KTYPE,KIEN,MOD,PEIEN
 N START,STOP,TITLE,TOT,DOM,ORD,DNAME,DORD,D
 S AGE=$G(DAYS) I 'AGE Q
 S SEX=$E(SEX) ; SCREEN BY SEX
 S DOM=0
 F  S DOM=$O(^VEN(7.13,DOM)) Q:'DOM  D
 . S %=$G(^VEN(7.13,DOM,0)) I '$L(%) Q
 . I '$P(%,U,7) Q  ; SKIP INACTIVE DOMAINE
 . S DNAME=$P(%,U)
 . S DORD=$P(%,U,5)
 . I 'DORD S DORD=100+(DOM*5)
 . S CAT=0
 . F  S CAT=$O(^VEN(7.13,DOM,1,CAT)) Q:'CAT  D  ; CREATE THE ORDINAL ARRAY
 .. S %=$G(^VEN(7.13,DOM,1,CAT,0))
 .. S CATIEN=+% I 'CATIEN Q
 .. S ORD=$P(%,U,2)
 .. I 'ORD S ORD=100+CAT ; MAKE SURE EVERY CAT HAS AN ORDER - EVEN IF ONE IS NOT OFFICIALLY ASSIGNED
 .. S ORD(DORD,ORD)=CATIEN
 .. Q
 . Q
 S DORD=0
 F  S DORD=$O(ORD(DORD)) Q:'DORD  D
 . S ORD=0
 . F  S ORD=$O(ORD(DORD,ORD)) Q:'ORD  S CATIEN=ORD(DORD,ORD) D KBI(CATIEN)
 . Q
 Q
 ; 
KBI(CATIEN) ; EP - GET KB ITEMS
 N LASTLINE,ARR
 S K=$G(^VEN(7.11,CATIEN,0)) I '$L(K) Q
 S HDR=$P(K,U,9) ; CATEGORY HEADER
 S KTYPE=$P(K,U,11) ; TYPE OF KB ITEM: PT ED, DEVEL, SCREENING, ETC.
 D LINE(" "),LINE(HDR) ; SET THE SPACER AND HEADER LINES FOR THIS CATEGORY OF ITEMS
 S LASTLINE=LINE
 S KIEN=0,TOT=0 K ARR
 F  S KIEN=$O(^VEN(7.12,"B",CATIEN,KIEN)) Q:'KIEN  D  ; CHECK EA. ENTRY IN THE KNOWLEDGE CATEGORY
 . S STG=$G(^VEN(7.12,KIEN,0)) I '$L(STG) Q
 . I $P(STG,U,11) Q  ; INACTIVE ITEM
 . S START=$P(STG,U,5) I AGE<START Q
 . S STOP=$P(STG,U,6) I AGE>STOP Q
 . S %=$P(STG,U,10) I $L(%),%'=SEX Q
 . S TITLE=$P(STG,U,2) I '$L(TITLE) Q
 . S MOD=$P(STG,U,12)
 . I $L(MOD) S TITLE=TITLE_" ("_MOD_")"
 . I MOD,KTYPE=2 S ARR(MOD)="__ "_TITLE Q  ; STORE DEV ITEM LINES IN TEMP ARRAY FOR SORTING AND QUIT HERE
 . ; PROCEED IF SECONDARY SORTING IS NOT REQUIRED
 . S TOT(CATIEN)=$G(TOT(CATIEN))+1
 . I $L($T(LAST^VENPCCK)) D LAST^VENPCCK(CATIEN,KIEN,DFN,.TITLE)
 . S X="__ "_TOT(CATIEN)_". "_TITLE
 . I $G(SEGIEN)=-1 S X=X_"|"_KIEN ; HIJACKED PROCESS SO APPEND ITEM IEN
 . D LINE(X) ; SET THE ITEM NODE
 . Q
 I $D(ARR) D  ; SORT BY %ILE
 . S MOD=999
 . F  S MOD=$O(ARR(MOD),-1) Q:MOD=""  S X=ARR(MOD) D LINE(X)
 . K ARR
 . Q
NOITEMS I LINE'=LASTLINE Q
 S LINE=LINE-2
 K LINE(LINE+1),LINE(LINE+2) ; NOTHING FOUND UNDER THIS KB CATEGORY SO REMOVER CAT HEADER
 Q
 ;
AM(DFN,DAYS) ; EP - GIVEN A DFN, RETURN THE PTS CURRENT AGE IN MONTHS
 N DOB,DIFF,MD,YD,DD,M
 S DOB=$P($G(^DPT(DFN,0)),U,3) I 'DOB Q ""
 I DOB>DT Q ""  ; INVALID DOB
 S (DAYS,D)=$$FMDIFF^XLFDT(DT,DOB,1)
 I D<8 Q 0
 I D<15 Q .25
 I D<22 Q .5
 I D<29 Q .75
 S YD=$E(DT,1,3)-$E(DOB,1,3)
 S MD=$E(DT,4,5)-$E(DOB,4,5)
 S DD=$E(DT,6,7)-$E(DOB,6,7)
 I DD<0 S MD=MD-1
 I MD<1 S MD=MD+12,YD=YD-1
 S M=MD+(YD*12)
 I M<2 Q 1
 Q M
 ;
DAGE(AM) ; EP - GIVEN AN AGE IN MONTHS, RETURN THE DISPLAY AGE
 N M
 I +$G(AM)<1 Q $$FMDIFF^XLFDT(DT,AUPNDOB,1)_" days old" ; PATCHED BY GIS 5/7/07
 S M=(AM#12)
 I AM>35 Q (AM\12)_" years and "_M_" month"_$S(M=1:"",1:"s")
 Q AM_" month"_$S(AM=1:"",1:"s")
 ; 
GUI(OUT,IN) ; EP - RPC: VEN WCM GUI REMINDERS; RETURN THE REMINDER LIST
 ; PATCHED BY GIS 9/5/08
 S OUT="NO REMINDERS"
 I $D(^DPT($G(IN),0))
 E  Q
 N DFN,APCHSEGH,LINE,CNT,X,Y,Z,%
 S DFN=IN,APCHSEGH="BYPASS"
 D WCESEG(DFN) I '$O(LINE(2)) Q
 S CNT=0,OUT=""
 F  S CNT=$O(LINE(CNT)) Q:'CNT  D
 . I $L(OUT) S OUT=OUT_"|"
 . I LINE(CNT)["__ " S LINE(CNT)="  "_$E(LINE(CNT),3,999)
 . S OUT=OUT_LINE(CNT)
 . Q
 Q
 ; 
PEGUI(OUT,IN) ; EP - RPC: VEN WCM GET PT ED ; PATIENT ED TOPICS FOR GUI CHECKLIST
 I $D(^DPT(+$G(IN),0))
 E  Q
 N DFN,AGE,SEX,SEGIEN,CATIEN,CAT,LINE,X,Y,Z,%,STG,DATA,TOPIC,IEN
 S DFN=IN,OUT=""
 S STG=$G(^DPT(+$G(DFN),0)) I '$L(STG) Q  ; INVALID DFN
 S SEX=$S($P(STG,U,2)="M":"Male",$P(STG,U,2)="F":"Female",1:"") ; SEX
 S %=$$AM(DFN,.AGE) I 'AGE S AGE=1
 S CAT="WCAG",LINE=0,SEGIEN=-1
 F  S CAT=$O(^VEN(7.11,"B",CAT)) Q:$E(CAT,1,4)'="WCAG"  S CATIEN=$O(^VEN(7.11,"B",CAT,0)) Q:'CATIEN  D KBI(CATIEN)
 I '$O(LINE(1)) Q
 S LINE=1,DATA="",HDR=""
 F  S LINE=$O(LINE(LINE)) Q:'LINE  D
 . S X=LINE(LINE)
 . I $E(X,1,5)'="PT ED",$E(X,1,2)'="__" Q
 . I $E(X,1,5)="PT ED" D  Q
 .. I $E($G(LINE(LINE+1)),1,2)'="__" Q
 .. S HDR=X
 .. I $L(DATA) S DATA=DATA_"|"
 .. S DATA=DATA_HDR
 .. Q
 . I $E(X,1,2)="__" D
 .. S Y=$P(X,". ",2) I Y="" Q
 .. S TOPIC=$P(Y,"|") I TOPIC="" Q
 .. S IEN=$P(Y,"|",2) I 'IEN Q
 .. S DATA=DATA_"\"_TOPIC_"`"_IEN
 .. Q
 . Q
 I $L(DATA) S OUT=DATA
 Q
 ;
PEFLUSH(OUT,IN) ; EP - RPC:VEN WCM FLUSH PT ED
 S OUT="PT ED UPDATE FAILED"
 I $L($G(IN))
 E  Q
 N X,Y,Z,%,VIEN,USER,TOPIC,SUBTOPIC,MN,TIEN,HDR,DIC,DIE,DR,DLAYGO,LOU,TIME,PECIEN,KBIEN,STG,MAX,PCE,MIN,DFN,B,NOW,UPDATE,STOP
 S VIEN=+IN I 'VIEN Q
 S B="|"
 S DFN=$P($G(^AUPNVSIT(VIEN,0)),U,5) I 'DFN Q
 S USER=$P(IN,B,2) I 'USER Q
 S TIME=$P(IN,B,3)
 S LOU=$P(IN,B,4)
 S STG=$P(IN,B,5) I STG="" Q
 S NOW=$E($$NOW^XLFDT,1,12)
 S MAX=$L(STG,"\"),MIN="",CNT=0
 F PCE=1:1:MAX S KBIEN=$P(STG,"\",PCE) I KBIEN D
 . S X=$G(^VEN(7.12,KBIEN,0)) I X="" Q
 . S SUBTOPIC=$P(X,U,2)
 . S MN=$P($G(^VEN(7.12,KBIEN,2)),U,3) I MN="" Q
 . S TIEN=0
 . F  S TIEN=$O(^AUTTEDT("C",MN,TIEN)) Q:'TIEN  I '$P($G(^AUTTEDT(TIEN,0)),U,3) Q
 . I 'TIEN Q
 . I '$D(TOPIC(TIEN)) S CNT=CNT+1
 . S TOPIC(TIEN,KBIEN)=SUBTOPIC
 . Q
TOPIC I '$O(TOPIC(0)) Q
 S MIN=""
 I TIME,CNT S MIN=TIME/CNT
 I MIN S MIN=$J(MIN,1,0) ; MUST BE AN INTEGER ; PATCHED BY GIS 1/18/2011
 S (DIC,DIE)="^AUPNVPED(",DLAYGO=9000010.16,DIC(0)="LO"
 S DR=".02////^S X=DFN;.03////^S X=VIEN;.06////^S X=LOU;.08////^S X=MIN;1201////^S X=NOW;1204////^S X=USER;.05////^S X=USER"
 S TIEN=0,UPDATE=0
PEF F  S TIEN=$O(TOPIC(TIEN)) Q:'TIEN  D
 . S %=0,STOP=0
 . F  S %=$O(^AUPNVPED("AD",VIEN,%)) Q:'%  I +$G(^AUPNVPED(%,0))=TIEN,$D(^AUPNVPED(%,1)) S UPDATE=1,STOP=1 Q  ; A V PTED ENTRY EXISTS FOR THIS VISIT/TOPIC ; WAIT FOR 2ND PASS
 . I STOP D ST(%,TIEN) Q
 . S X="""`"_TIEN_"""" ; NO V PT ED ENTRIES FOUND FOR THIS VISIT AND TOPIC, SO FORCE NEW ENTRY
 . D ^DIC I Y=-1 Q
 . S DA=+Y
 . L +^AUPNVPED(DA):1 I  D ^DIE L -^AUPNVPED(DA)
 . D ST(DA,TIEN)
 . Q
 I UPDATE D UPDATE ; SECOND PASS TO RE-CALC UPDATED FIELDS
 D ^XBFMK
 S OUT="OK"
 Q
 ;
ST(IEN,TIEN) ; ENTER SUBTOPICS INTO SUBFILE
 I $G(IEN),$G(TIEN)
 E  Q
 N DIC,DA,X,KBIEN
 S KBIEN=0,DA(1)=IEN,DIC="^AUPNVPED("_DA(1)_",1,",(DLAYGO,DIC("P"))=9000010.161,DIC(0)="LO"
 F  S KBIEN=$O(TOPIC(TIEN,KBIEN)) Q:'KBIEN  D
 . S X=TOPIC(TIEN,KBIEN) I X="" Q
 . S X=$E(X,1,80)
 . D ^DIC
 . Q
 Q
 ; 
UPDATE ; EP - UPDATE EXISTING V PT ED ENTRIES ; SECOND PASS
 N DA,CNT,MIN
 S DA=0,CNT=0
 F  S DA=$O(^AUPNVPED("AD",VIEN,DA)) Q:'DA  I $D(^AUPNVPED(DA,1)) S CNT=CNT+1
 I 'CNT Q
 S DR=".06////^S X=LOU;.08////^S X=MIN;1201////^S X=NOW;1204////^S X=USER;.05////^S X=USER"
 S DIE="^AUPNVPED("
 S MIN=""
 I TIME,CNT S MIN=TIME/CNT
 I MIN S MIN=$J(MIN,1,0) ; MUST BE AN INTEGER ; PATCHED BY GIS 1/18/2011
 S DA=0
 F  S DA=$O(^AUPNVPED("AD",VIEN,DA)) Q:'DA  I $D(^AUPNVPED(DA,1)) L +^AUPNVPED(DA):1 I  D ^DIE  L -^AUPNVPED(DA)
 Q
 ;