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

VENPCCC.m

Go to the documentation of this file.
VENPCCC ; IHS/OIT/GIS - CHECK LIST MANAGEMENT ;
 ;;2.6;PCC+;;NOV 12, 2007
 ;
 ;
 ;
POP(DEFEF,DFN) ; EP - POPULATE CHECKLIST ITEM MM FIELDS
 N DEMO,GIEN,IIEN,STG,MM,C1,C2,TMP,GRP,CKIEN,DOB,SEX,AGE,CAT,LIEN,OGIEN,MN,CNT,FLD,NAME,PRE,POST
 S TMP=$NA(^TMP("VEN PRNT",$J,1))
 I '$O(^VEN(7.41,+$G(DEFEF),17,0)) Q  ; NO CHECKLISTS ASSOCIATED WITH THIS FORM
 S DEMO=$G(^DPT(+$G(DFN),0)) I '$L(DEMO) Q
 S SEX=$P(DEMO,U,2) I SEX'="M",SEX'="F" Q
 S DOB=$P(DEMO,U,3) I 'DOB Q
 S AGE=DT-DOB\10000
 S GRP=$S(AGE<2:1,AGE<13:2,SEX="M":3,1:4)
 S GIEN=0
 F  S GIEN=$O(^VEN(7.41,DEFEF,17,GIEN)) Q:'GIEN  D
 . S LIEN=$P($G(^VEN(7.41,DEFEF,17,GIEN,0)),U) I 'LIEN Q  ; CKLIST SUBFILE IEN
 . S %=$G(^VEN(7.9,LIEN,0)) I '$L(%) Q  ; PATCHED GIS/OIT 10/4/2005 ; CHECKLIST FILE ; PCC+ 2.5 PATCH 1
 . S OGIEN=$P(%,U,2) I 'OGIEN Q  ; CHECKLIST CATEGORY
 . S PRE=$P(%,U,3) S POST=$P(%,U,4) ; PRE AND POST NOW ASSOCIATED WITH THE CHECKLIST - NOT THE ITEM
 . S MN=$P($G(^VEN(7.98,OGIEN,0)),U,3) I MN="" Q  ; MAIL MERGE MNEMONIC
 . S IIEN=0 S CNT=0
 . F  S IIEN=$O(^VEN(7.91,"AB",LIEN,IIEN)) Q:'IIEN  D
 .. S STG=$G(^VEN(7.91,IIEN,0)) I STG="" Q
 .. I '$P(STG,U,GRP+2) Q  ; CK GROUP
 .. S NAME=$P(STG,U) I NAME="" Q
 .. S C1=$P(STG,U,7) S C2=$P(STG,U,8)
 .. S PRE=$P(STG,U,9),POST=$P(STG,U,10)
 .. S CNT=CNT+1
 .. S FLD=MN_CNT S @TMP@(FLD)=PRE_NAME_POST ; CHECKLIST ITEM
 .. I $L(C1) S FLD=MN_CNT_"a" S @TMP@(FLD)=C1 ; PRIMARY CODE - TYPICALLY THE CPT
 .. I $L(C2) S FLD=FLD_CNT_"x" S @TMP@(FLD)=C2 ; SECONDARY CODE
 .. Q
 . Q
 Q
 ; 
CONVERT ; EP-CONVERT ORDERABLE SETS/GROUPS TO CHECK LISTS
 I '$O(^VEN(7.9,0)),'$O(^VEN(7.91,0)) ; MAKE SURE THAT THIS IS A VIRGIN CONVERSION
 E  W !,"Conversion has already been completed!  Request cancelled..." Q
 N SIEN,SET,%,%Y
 W "Want to convert order sets and orderables to checklists and items"
 S %=1 D YN^DICN
 I %'=1 W !,"Request cancelled..." Q
 I '$O(^VEN(7.92,0)) S SET="GENERIC CHECK LIST",SIEN="" D CKLIST(SET,SIEN) I 1 ; ORDER SETS HAVE NOT BEEN SET UP YET
 E  S SIEN=0 F  S SIEN=$O(^VEN(7.92,SIEN)) Q:'SIEN  S SET=$P($G(^VEN(7.92,SIEN,0)),U) I $L(SET) D CKLIST(SET,SIEN)
 D ITEMS
 S DIE="^VEN(7.5," S DA=$$CFG^VENPCCU S DR=".17////1"
 L +^VEN(7.5,DA):0 I $T D ^DIE L -^VEN(7.5,DA) ; SET THE "USE CHECKLIST" PARAMETER IN THE CONFIG FILE
 I $O(^VEN(7.91,0)) W !,"Orderables have been successfully converted to checklist items!"
 E  D ^XBFMK Q
 S DA=$O(^DIC(19,"B","VEN CL INITIALIZE CHECKLISTS",0)) I 'DA  D ^XBFMK Q
 S DIE="^DIC(19,",DR="2////Conversion completed..." ; OUT OF ORDER MESSAGE
 L +^DIC(19,DA):0 I $T D ^DIE L -^DIC(19,DA)
 D ^XBFMK
 Q
 ; 
CKLIST(SET,SIEN) ; EP-POPULATE THE CHECKLIST FILE
 N DIC,GIEN,GROUP,X,Y,%,GMN,LIST,TYPE,TIEN,OSIEN,GSTG,PCE
 S DIC="^VEN(7.9,",DLAYGO=19707.9
 S DIE=DIC
 S DR=".02///^S X=TYPE"
 S GIEN=0 S GSTG=""
 F  S GIEN=$O(^VEN(7.98,GIEN)) Q:'GIEN  D  ; WITHIN EACH SET, GET ALL ORDERABLE GROUPS
 . S %=$G(^VEN(7.98,GIEN,0)) I '$L(%) Q
 . S GMN=$P(%,U,2) I '$L(GMN) Q
 . I GMN'="HMR",GMN'="EDU" ; REMINDERS AND PT ED TOPICS ARE NOW HANDLED ELSEWHERE
 . E  Q
 . S LIST=SET_" ("_GMN_")"
 . S X=LIST S DIC(0)="L"
 . D ^DIC I Y=-1 Q  ; SET X GROUP = CHECKLIST
 . S DA=+Y
 . S TYPE="`"_GIEN
 . L +^VEN(7.9,DA):0 I $T D ^DIE L -^VEN(7.9,DA)
 . S:$L(GSTG) GSTG=GSTG_U
 . S GSTG=GSTG_GIEN ; THE GSTG CONTAINS THE IENS OF ALL ORDERABLE GROUPS
 . Q
 I $L(GSTG) D TEMPLATE(SIEN,GSTG) ; REGISER THE NEW CKLISTS IN THE APPROPRIATE TEMPLATE FILES
 Q
 ; 
TEMPLATE(SIEN,GSTG) ; EP-POPULATE THE CHECKLIST SUBFILE IN THE VEN EHP EF TEMPLATES FILE
 ; IF THE TEMPLATE CONTAINS THE ORDER SET, ADD ALL THE ORDER GROUPS TO THE CHECKLIST MULTIPLE
 N DA,DIC,DIE,DR,OSIEN,TIEN,X,PCE
 S TIEN=0,SIEN=$G(SIEN)
 F  S TIEN=$O(^VEN(7.41,TIEN)) Q:'TIEN  D  ; POPULATE THE TEMPLATE FILE
 . S OSIEN=$P($G(^VEN(7.41,TIEN,0)),U,9)
 . I OSIEN'=SIEN Q  ; MUST BE A MATCH (OR IF BOTH ARE BLANK)
 . S DA(1)=TIEN,DIC(0)="L",DLAYGO=19707.4117
 . S DIC="^VEN(7.41,"_DA(1)_",17,",DIC("P")="19707.4117P"
 . F PCE=1:1:$L(GSTG,U) D
 .. S X=$P(GSTG,U,PCE) I 'X Q
 .. S X="`"_X
 .. D ^DIC ; ADD CHECK LISTS TO THE SUBFILE
 .. Q
 . Q
 Q
 ; 
ITEMS ; EP-CONVERT ORDERABLES TO CHECKLIST ITEMS
 ; GO THRU ALL THE ORDERABLES, CONVERT EACH TO A CHECKLIST ITEM
 N GIEN,GRP,CKIEN,IGRP,OIEN,%,CAT,MMMN,PMN,ONAME,STG,SIEN,SNAME,CNAME,C1,C2,MN,NAME,PRE,POST
 N DIC,DIE,DR,DA,X,Y
 S GIEN=0
MNIX F  S GIEN=$O(^VEN(7.98,GIEN)) Q:'GIEN  D  ; MAKE INDEX FOR MAIL MERGE/PREFERENCE MNEMONICS
 . S MMMN=$P($G(^VEN(7.98,GIEN,0)),U,3) ; MAIL MERGE MNEMONIC
 . I '$L(MMMN) Q
 . I MMMN'="y",MMMN'="h"
 . E  Q
 . S PMN=$P(^VEN(7.98,GIEN,0),U,2) ; PREFERENCE MNEMONIC
 . I '$L(PMN) Q
 . S MN(MMMN)=PMN
 . Q
COI ; CONVERT ORDERABLES TO ITEMS
 S (DIC,DIE)="^VEN(7.91,",DIC(0)="LX",DLAYGO=19707.91
 S ONAME="" F  S ONAME=$O(^VEN(7.93,"B",ONAME)) Q:ONAME=""  S OIEN=$O(^VEN(7.93,"B",ONAME,0)) I OIEN  D
 . S STG=$G(^VEN(7.93,OIEN,0)) I '$L(STG) Q
 . S SIEN=+$P(STG,U,2) I 'SIEN S SNAME="GENERIC CHECK LIST"
 . E  S SNAME=$P($G(^VEN(7.92,SIEN,0)),U) I '$L(SNAME) Q
 . S CAT=$P(STG,U,10) I CAT="" Q
 . S MMMN=$E(CAT,2) I MMMN="" Q
 . S GRP=+CAT I GRP,GRP=GRP\1,GRP>0,GRP<5
 . E  Q
 . S PMN=$G(MN(MMMN)) I PMN="" Q
 . S CNAME=SNAME_" ("_PMN_")"
 . S CKIEN=$O(^VEN(7.9,"B",CNAME,0)) I 'CKIEN Q
 . S C1=$P(STG,U,6) S C2=$P(STG,U,7) ; CODES
 . S PRE="",POST="",NAME=ONAME
 . S %=$E(NAME) I %="_"!(%=" ") D  ; GET PRE STRING
 .. F I=1:1:$L(NAME) Q:$E(NAME,I)?1A
 .. S PRE=$E(NAME,1,I-1) S NAME=$E(NNAME,I,999)
 .. Q
 . S %=$E(NAME,$L(NAME)) I %="_"!(%=" ") D
 .. S %=$L(NAME)
 .. F I=%:-1:1 Q:$E(NAME,I)?1A
 .. S POST=$E(NAME,I+1,%) S NAME=$E(NAME,1,I)
 .. Q
 . S X=$$NAME(NAME) ; STANDARDIZE NAME WITH CAPS
 . D ^DIC I Y=-1 Q
 . S DA=+Y
 . D CSUB(CKIEN,DA) ; POPULATE THE CHECKLIST MULTIPLE
 . S DR=$$DR(DA,GRP,C1,C2,CKIEN) I DR="" Q  ; MAKE DR STRING
 . L +^VEN(7.91,DA):0 I $T D ^DIE L -^VEN(7.91,DA)
 . F  S OIEN=$O(^VEN(7.93,"B",ONAME,OIEN)) Q:'OIEN  D  ; UPDATE ITEM WITH THE OTHER ENTRIES OF THE SAME NAME
 .. S %=$G(^VEN(7.93,OIEN,0)) I '$L(%) Q
 .. S CAT=$P(%,U,10) I CAT="" Q
 .. S GRP=+CAT I GRP,GRP=GRP\1,GRP>0,GRP<5
 .. E  Q
 .. S C1=$P(%,U,6) S C2=$P(%,U,7)
 .. I PRE="" S PRE=$P(%,U,4)
 .. S PRE=$E(PRE,1,9) S POST=$E(POST,1,9)
 .. S DR=$$DR(DA,GRP,C1,C2,CKIEN,PRE,POST) I DR="" Q
 .. L +^VEN(7.91,DA):0 I $T D ^DIE L -^VEN(7.91,DA)
 .. Q
 . Q
 D ^XBFMK
 Q
 ;
NAME(NAME) ; EP - CAPITALIZE THE 1ST LETTER OF EVERY WORD
 N L,I,F,X,Y,A
 I '$L($G(NAME)) Q ""
 I NAME?1.U Q NAME
 S NAME=$$LOW^XLFSTR(NAME),A=""
 S L=$L(NAME),F=0,Y=1
 F I=1:1:L S X=$E(NAME,I) D
 . I Y,X?1L S Y=0,X=$$UP^XLFSTR(X),A=A_X Q  ; CAP THE IST LETTER
 . I X=" " S F=1,A=A_X Q
 . I F,X?1L S F=0,X=$$UP^XLFSTR(X) ; CAP THE IT LETTER AFTER A SPACE
 . S A=A_X
 . Q
 Q A
 ; 
CSUB(X,Y) ; EP - MAKE ENTRY IN CHECKIN GROUP SUBFILE
 N DIC,DIE,DA,DR
 I '$D(^VEN(7.9,+$G(X),0)) Q
 I '$G(Y) Q
 S DA(1)=Y
 S DIC="^VEN(7.91,"_DA(1)_",2,"
 S DIC(0)="L",DIC("P")="19707.912P",DLAYGO=19707.912
 S X="`"_X
 D ^DIC
 D ^XBFMK
 Q
 ; 
DR(DA,GRP,C1,C2,CKIEN,PRE,POST) ; EP - MAKE DR STG
 N DR,STG
 S %=$G(GRP) I '% Q
 S DR=".0"_(%+2)_"////1"
 S STG=$G(^VEN(7.91,+$G(DA),0)) I STG="" Q
 I $D(^VEN(7.9,+$G(CKIEN),0)) D  ; SET PROPERTIES RELATED TO THE CHECKLIST
 . I $P(STG,U,2)="" S DR=DR_";.02////"_CKIEN
 . I $L($G(PRE)),$P(^VEN(7.9,CKIEN,0),U,3)="" S $P(^(0),U,3)=PRE ; SET PRE FOR THE CHECKLIST - IF NECESSARY
 . I $L($G(POST)),$P(^VEN(7.9,CKIEN,0),U,4)="" S $P(^(0),U,4)=POST ; SET POST FOR THE CHECKLIST - IF NECESSARY
 . Q
 I $L($G(C1)),$P(STG,U,7)="",C1'[":",C1'[";" S DR=DR_";.07////"_C1
 I $L($G(C2)),$P(STG,U,8)="",C2'[":",C2'[";" S DR=DR_";.08////"_C2
 Q DR
 ; 
MM(DA) ; EP - COMPUTE MM FIELD VALUE
 N GIEN,IEN,CNT,MM
 S MM=""
 S GIEN=$P($G(^VEN(7.91,+$G(DA),0)),U,2) I 'GIEN Q MM
 S MN=$P($G(^VEN(7.98,GIEN,0)),U,3) I '$L(MN) Q
 S CNT=0,IEN=0
 F  S IEN=$O(^VEN(7.91,"AC",GIEN,IEN)) Q:'IEN  S CNT=CNT+1 I IEN=DA Q
 I 'CNT Q MM
 S MM=MN_CNT
 Q MM
 ;
CL(OUT,IN) ; EP - RPC: VEN PCC+ GET CL CATEGORIES
 ; RETURN THE ADO TEBLE GEN STRING TO VIEW CHECKLIST CATEGORIES
 S OUT=""
 Q
 ; 
CLI(OUT,IN) ; EP - RPC: VNE PCC+ GET CL ITEMS
 ; RETURN THE ADO TEBLE GEN STRING TO VIEW CHECKLIST ITEMS
 S OUT=""
 I '$D(^VEN(7.9,+$G(IN),0)) Q
 S OUT="BMX ADO SS^VEN CL ITEMS^^AB~"_IN_"~"_IN_"~999999"
 Q
 ;