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

APCHS6B.m

Go to the documentation of this file.
APCHS6B ; IHS/CMI/LAB - PART 6 OF APCHS -- SUMMARY PRODUCTION COMPONENTS ;
 ;;2.0;IHS PCC SUITE;**4,10**;MAY 14, 2009;Build 88
 ;
WCE ; ******************** WELL CHILD EXAM * 9000010 *******
 N LINE,ARR
 ; <SETUP>
 ; I '$D(^AUPNVWC("AC",APCHSPAT)) Q
 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) ; 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",$P(STG,U,2)="U":"UNKNOWN",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
 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
 S SEGIEN=$O(^APCHSCMP("B",$G(APCHSEGH),0)) I 'SEGIEN Q  ; SEMENT IEN
 D REM(DFN,SEGIEN,SEX,DAYS) ; GET REMINDERS FOR EA KB CATEGORY
 D LINE(" ")
 Q
 ; 
REM(DFN,SEGIEN,SEX,DAYS) ; 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) ; 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 DAGE,M
 ;I AM<1 Q $$FMDIFF^XLFDT(DT,DOB,1)_" days old"
 I AM<1 Q $$FMDIFF^XLFDT(DT,$P(^DPT(DFN,0),U,3),1)_" days old"
 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")
 Q DAGE
 ;