- VENPCCF ; IHS/FCS/GIS - VEN FLOWCHART UTILITIES ;
- ;;1.1;PCC+;;MAY 30, 2001
- ;
- ; COPYRITE FULL CIRCLE SOFTWARE, 2001
- ;
- KEY(DA) ; POPULATE THE KEY FIELD OF THE VEN EHP EF TEMPLATE FILE
- N X,Y,%,DFN,FCIEN,INST
- S X=$G(^VEN(7.3,DA,0)) I '$L(X) Q ""
- S DFN=+X I '$D(^DPT(DFN,0)) Q ""
- S FCIEN=+$P(X,U,2) I '$D(^VEN(7.3,FCIEN,0)) Q ""
- S INST=$P(X,U,3) I 'INST Q ""
- Q (DFN_";"_FCIEN_";"_INST)
- ;
- ORD(FIEN) ; RETURN COMPONENT ORDER STRING FOR A FLOWCHART (COMPONENT IENS)
- N CIEN,X,Y,%,ATN,ORD,STG
- S CIEN=0 F S CIEN=$O(^VEN(7.31,FIEN,2,CIEN)) Q:'CIEN S X=^(CIEN,0) I $L(X) D
- . S ATN=+X,ORD=$P(X,U,4) I 'ORD S ORD=ATN+1000
- . S Y(ORD)=CIEN
- . Q
- S STG="",ORD=0 F S ORD=$O(Y(ORD)) Q:'ORD S:STG'="" STG=STG_U S STG=STG_Y(ORD)
- Q STG
- ;
- INST(DFN,FIEN) ; RETURN THE MOST RECENT INSTANCE OF A FLOWCHART FOR A PATIENT
- N X,Y
- S X=DFN_";"_FIEN_";"_9999
- S Y=$O(^VEN(7.3,"AKEY",X),-1)
- Q $P(Y,";",3)
- ;
- EFFC(EIEN) ; GIVEN EF IEN RETURN STRING LISTING ALL ASSOCIATED FLOWCHART IENS
- N FIEN,X,Y,STG
- S STG="",FIEN=0
- F S FIEN=$O(^VEN(7.41,EIEN,4,"B",FIEN)) Q:'FIEN S:STG'="" STG=STG_U S STG=STG_FIEN
- Q STG
- ;
- ENT(DFN,FIEN,INST,MAX) ; GIVEN PAT,FLOWCHART IEN AND INSTANCE RETURN THE FLOWCHART ENTRY IENS IN REVERSE CHRONOLOGICAL ORDER UP TO MAX IENS
- I $D(^DPT(+$G(DFN),0)),$D(^VEN(7.31,+$G(FIEN),0))
- E Q
- S INST=$G(INST,1),MAX=$G(MAX,999)
- N KEY,PFIEN,X,Y,STG,DATE,TOT
- S KEY=DFN_";"_FIEN_";"_INST
- S PFIEN=0 F TOT=1:1:MAX S PFIEN=$O(^VEN(7.3,"AKEY",KEY,PFIEN)) Q:'PFIEN S DATE=$P($G(^VEN(7.3,PFIEN,0)),U,4) S X(DATE,PFIEN)=""
- S STG="",DATE=0 F S DATE=$O(X(DATE)) Q:'DATE S:$L(STG) STG=STG_U S STG=STG_$O(X(DATE,0))
- Q STG
- ;
- HDR(FIEN) ; GIVEN A FLOWCHART AND COMPOMENT ORDER STRING RETURN A HEADER STRING
- I '$D(^VEN(7.31,+$G(FIEN),0)) Q ""
- N ATT,X,Y,HED,UNIT,AIEN,CIEN,STG,CSTG
- S CSTG=$$ORD(FIEN) I '$L(CSTG) Q ""
- S STG=""
- F ATT=1:1:$L(CSTG,U) S AIEN=$P(CSTG,U,ATT) D S:$L(STG) STG=STG_U S STG=STG_$G(HDR)
- . S HDR=$P($G(^VEN(7.31,FIEN,2,AIEN,0)),U,3)
- . S CIEN=+$P($G(^VEN(7.31,FIEN,2,AIEN,0)),U,2)
- . I HDR="" S HDR=$P($G(^VEN(7.32,CIEN,0)),U,2)
- . I HDR="" S HDR=$P($G(^VEN(7.32,CIEN,0)),U)
- . S UNIT=$P($G(^VEN(7.32,CIEN,0)),U,3)
- . I $L(HDR),$L(UNIT) S HDR=HDR_" ("_UNIT_")"
- . Q
- Q STG
- ;
- VAL(DFN,FIEN,INST,MAX) ; GIVEN DFN, FLOWCHART IEN, INSTANCE, AND MAX VALS, RETURN VAL STG
- N STG,X,Y,%,ATT,FESTG,OSTG,FEIEN,ENT,VSTG
- I $D(^DPT(+$G(DFN),0)),$D(^VEN(7.31,+$G(FIEN),0))
- E Q ""
- I '$G(INST) S INST=1
- I '$G(MAX) S MAX=999
- S FESTG=$$ENT(DFN,FIEN,INST,MAX) I '$L(FESTG) Q ""
- S STG="",OSTG=$$ORD(FIEN) I '$L(OSTG) Q ""
- F ENT=1:1:$L(FESTG,U) S FEIEN=+$P(FESTG,U,ENT) D S:$L(STG) STG=STG_"|" S STG=STG_VSTG
- . S VSTG=$P($G(^VEN(7.3,FEIEN,0)),U,4) I 'VSTG Q
- . S VSTG=$$DATE(VSTG)
- . F ATT=1:1:$L(OSTG,U) S AIEN=+$P(OSTG,U,ATT) D
- .. S X=$G(^VEN(7.3,FEIEN,1,AIEN,1))
- .. S CIEN=+$P($G(^VEN(7.31,FIEN,2,AIEN,0)),U,2)
- .. S X=$$OT(CIEN,X)
- .. S VSTG=VSTG_U_X
- .. Q
- . Q
- Q STG
- ;
- TEST W $$VAL(1,1,1,99) Q
- DATE(Y) X ^DD("DD") Q Y
- ;
- OT(CIEN,VAL) ; GIVEN A COMPONENT IEN AND VALUE, RETURN THE TRANSFORMED VALUE
- I '$D(^VEN(7.32,+$G(CIEN),0)) Q ""
- I $G(VAL)="" Q ""
- S OT=$G(^VEN(7.32,CIEN,2))
- I '$L(OT) Q VAL
- X ("S VAL=$$"_OT_"(VAL)") Q VAL
- ;
- SYMP(X) ; SYMPTOM SCORE
- N Y
- S Y="FREQUENCY: +"_+X_", THIRST: +"_$P(X,";",2)_",APPETITE: +"_$P(X,";",3)_",FATIGUE: +"_$P(X,";",4)
- Q Y
- ;
- VENPCCF ; IHS/FCS/GIS - VEN FLOWCHART UTILITIES ;
- +1 ;;1.1;PCC+;;MAY 30, 2001
- +2 ;
- +3 ; COPYRITE FULL CIRCLE SOFTWARE, 2001
- +4 ;
- KEY(DA) ; POPULATE THE KEY FIELD OF THE VEN EHP EF TEMPLATE FILE
- +1 NEW X,Y,%,DFN,FCIEN,INST
- +2 SET X=$GET(^VEN(7.3,DA,0))
- IF '$LENGTH(X)
- QUIT ""
- +3 SET DFN=+X
- IF '$DATA(^DPT(DFN,0))
- QUIT ""
- +4 SET FCIEN=+$PIECE(X,U,2)
- IF '$DATA(^VEN(7.3,FCIEN,0))
- QUIT ""
- +5 SET INST=$PIECE(X,U,3)
- IF 'INST
- QUIT ""
- +6 QUIT (DFN_";"_FCIEN_";"_INST)
- +7 ;
- ORD(FIEN) ; RETURN COMPONENT ORDER STRING FOR A FLOWCHART (COMPONENT IENS)
- +1 NEW CIEN,X,Y,%,ATN,ORD,STG
- +2 SET CIEN=0
- FOR
- SET CIEN=$ORDER(^VEN(7.31,FIEN,2,CIEN))
- IF 'CIEN
- QUIT
- SET X=^(CIEN,0)
- IF $LENGTH(X)
- Begin DoDot:1
- +3 SET ATN=+X
- SET ORD=$PIECE(X,U,4)
- IF 'ORD
- SET ORD=ATN+1000
- +4 SET Y(ORD)=CIEN
- +5 QUIT
- End DoDot:1
- +6 SET STG=""
- SET ORD=0
- FOR
- SET ORD=$ORDER(Y(ORD))
- IF 'ORD
- QUIT
- IF STG'=""
- SET STG=STG_U
- SET STG=STG_Y(ORD)
- +7 QUIT STG
- +8 ;
- INST(DFN,FIEN) ; RETURN THE MOST RECENT INSTANCE OF A FLOWCHART FOR A PATIENT
- +1 NEW X,Y
- +2 SET X=DFN_";"_FIEN_";"_9999
- +3 SET Y=$ORDER(^VEN(7.3,"AKEY",X),-1)
- +4 QUIT $PIECE(Y,";",3)
- +5 ;
- EFFC(EIEN) ; GIVEN EF IEN RETURN STRING LISTING ALL ASSOCIATED FLOWCHART IENS
- +1 NEW FIEN,X,Y,STG
- +2 SET STG=""
- SET FIEN=0
- +3 FOR
- SET FIEN=$ORDER(^VEN(7.41,EIEN,4,"B",FIEN))
- IF 'FIEN
- QUIT
- IF STG'=""
- SET STG=STG_U
- SET STG=STG_FIEN
- +4 QUIT STG
- +5 ;
- ENT(DFN,FIEN,INST,MAX) ; GIVEN PAT,FLOWCHART IEN AND INSTANCE RETURN THE FLOWCHART ENTRY IENS IN REVERSE CHRONOLOGICAL ORDER UP TO MAX IENS
- +1 IF $DATA(^DPT(+$GET(DFN),0))
- IF $DATA(^VEN(7.31,+$GET(FIEN),0))
- +2 IF '$TEST
- QUIT
- +3 SET INST=$GET(INST,1)
- SET MAX=$GET(MAX,999)
- +4 NEW KEY,PFIEN,X,Y,STG,DATE,TOT
- +5 SET KEY=DFN_";"_FIEN_";"_INST
- +6 SET PFIEN=0
- FOR TOT=1:1:MAX
- SET PFIEN=$ORDER(^VEN(7.3,"AKEY",KEY,PFIEN))
- IF 'PFIEN
- QUIT
- SET DATE=$PIECE($GET(^VEN(7.3,PFIEN,0)),U,4)
- SET X(DATE,PFIEN)=""
- +7 SET STG=""
- SET DATE=0
- FOR
- SET DATE=$ORDER(X(DATE))
- IF 'DATE
- QUIT
- IF $LENGTH(STG)
- SET STG=STG_U
- SET STG=STG_$ORDER(X(DATE,0))
- +8 QUIT STG
- +9 ;
- HDR(FIEN) ; GIVEN A FLOWCHART AND COMPOMENT ORDER STRING RETURN A HEADER STRING
- +1 IF '$DATA(^VEN(7.31,+$GET(FIEN),0))
- QUIT ""
- +2 NEW ATT,X,Y,HED,UNIT,AIEN,CIEN,STG,CSTG
- +3 SET CSTG=$$ORD(FIEN)
- IF '$LENGTH(CSTG)
- QUIT ""
- +4 SET STG=""
- +5 FOR ATT=1:1:$LENGTH(CSTG,U)
- SET AIEN=$PIECE(CSTG,U,ATT)
- Begin DoDot:1
- +6 SET HDR=$PIECE($GET(^VEN(7.31,FIEN,2,AIEN,0)),U,3)
- +7 SET CIEN=+$PIECE($GET(^VEN(7.31,FIEN,2,AIEN,0)),U,2)
- +8 IF HDR=""
- SET HDR=$PIECE($GET(^VEN(7.32,CIEN,0)),U,2)
- +9 IF HDR=""
- SET HDR=$PIECE($GET(^VEN(7.32,CIEN,0)),U)
- +10 SET UNIT=$PIECE($GET(^VEN(7.32,CIEN,0)),U,3)
- +11 IF $LENGTH(HDR)
- IF $LENGTH(UNIT)
- SET HDR=HDR_" ("_UNIT_")"
- +12 QUIT
- End DoDot:1
- IF $LENGTH(STG)
- SET STG=STG_U
- SET STG=STG_$GET(HDR)
- +13 QUIT STG
- +14 ;
- VAL(DFN,FIEN,INST,MAX) ; GIVEN DFN, FLOWCHART IEN, INSTANCE, AND MAX VALS, RETURN VAL STG
- +1 NEW STG,X,Y,%,ATT,FESTG,OSTG,FEIEN,ENT,VSTG
- +2 IF $DATA(^DPT(+$GET(DFN),0))
- IF $DATA(^VEN(7.31,+$GET(FIEN),0))
- +3 IF '$TEST
- QUIT ""
- +4 IF '$GET(INST)
- SET INST=1
- +5 IF '$GET(MAX)
- SET MAX=999
- +6 SET FESTG=$$ENT(DFN,FIEN,INST,MAX)
- IF '$LENGTH(FESTG)
- QUIT ""
- +7 SET STG=""
- SET OSTG=$$ORD(FIEN)
- IF '$LENGTH(OSTG)
- QUIT ""
- +8 FOR ENT=1:1:$LENGTH(FESTG,U)
- SET FEIEN=+$PIECE(FESTG,U,ENT)
- Begin DoDot:1
- +9 SET VSTG=$PIECE($GET(^VEN(7.3,FEIEN,0)),U,4)
- IF 'VSTG
- QUIT
- +10 SET VSTG=$$DATE(VSTG)
- +11 FOR ATT=1:1:$LENGTH(OSTG,U)
- SET AIEN=+$PIECE(OSTG,U,ATT)
- Begin DoDot:2
- +12 SET X=$GET(^VEN(7.3,FEIEN,1,AIEN,1))
- +13 SET CIEN=+$PIECE($GET(^VEN(7.31,FIEN,2,AIEN,0)),U,2)
- +14 SET X=$$OT(CIEN,X)
- +15 SET VSTG=VSTG_U_X
- +16 QUIT
- End DoDot:2
- +17 QUIT
- End DoDot:1
- IF $LENGTH(STG)
- SET STG=STG_"|"
- SET STG=STG_VSTG
- +18 QUIT STG
- +19 ;
- TEST WRITE $$VAL(1,1,1,99)
- QUIT
- DATE(Y) XECUTE ^DD("DD")
- QUIT Y
- +1 ;
- OT(CIEN,VAL) ; GIVEN A COMPONENT IEN AND VALUE, RETURN THE TRANSFORMED VALUE
- +1 IF '$DATA(^VEN(7.32,+$GET(CIEN),0))
- QUIT ""
- +2 IF $GET(VAL)=""
- QUIT ""
- +3 SET OT=$GET(^VEN(7.32,CIEN,2))
- +4 IF '$LENGTH(OT)
- QUIT VAL
- +5 XECUTE ("S VAL=$$"_OT_"(VAL)")
- QUIT VAL
- +6 ;
- SYMP(X) ; SYMPTOM SCORE
- +1 NEW Y
- +2 SET Y="FREQUENCY: +"_+X_", THIRST: +"_$PIECE(X,";",2)_",APPETITE: +"_$PIECE(X,";",3)_",FATIGUE: +"_$PIECE(X,";",4)
- +3 QUIT Y
- +4 ;