C0Q1P2 ; VEN/SMH - Kids utilities for C0Q 1.0 patch 1 ; 7/16/12 11:05am
 ;;1.0;QUALITY MEASURES;*1*;July 13, 2112;
 ; Licensed under package license. See Documentation
 ;
 ; PEPs: PRE, TRAN, POST
 ;
PRE ; Unified Pre; PEP
 D PREREM
 QUIT
TRAN ; Unified Tran; PEP
 QUIT
POST ; Unified Post; PEP
 D POSTREM
 QUIT
 ;
 ; Rest of entry points are private
 ; 
 ; 
ARRAY(MODE,ARRAY)	;List of exchange entries used by delete and install
	;
	N LN S LN=1
	;
	; NQF 0024-alt-core_wt-kids
	; NB: Commented out. Reminder needs to be re-done to include BMI %tile
	; S ARRAY(LN,1)="MU NQF0024 BMI_MK"
	; I MODE S ARRAY(LN,2)="07/06/2011@15:11:46"
	; S LN=LN+1
	;
	; NQF 0013-core-HTN
	S ARRAY(LN,1)="MU NQF0013 HTN_MK"
	I MODE S ARRAY(LN,2)="07/06/2011@15:08:53"
	S LN=LN+1
	;
	; NQF 0028a-core-tobacco-access
	; NQF 0028b-core-tobaocc-intervention
	; Both are in the first; dialog is in the second.
	S ARRAY(LN,1)="MU NQF0028 TOBACCO_MK"
	I MODE S ARRAY(LN,2)="07/06/2011@15:14:49"
	S LN=LN+1
	S ARRAY(LN,1)="MU NQF0028AB MANAGEMENT DI"
	I MODE S ARRAY(LN,2)="06/08/2011@16:50:31"
	S LN=LN+1
	;
	; NQF 0041-alt-core-flu
	S ARRAY(LN,1)="MU NQF0041 FLU_MK"
	I MODE S ARRAY(LN,2)="07/06/2011@15:26:59"
	S LN=LN+1
	;
	; NQF 0059-option1-DM-Hbalc
	; NQF 0061-option3-DM-BP
	; NQF 0064-option2-DM-LDL
	; All are in One Reminder Exchange entry
	S ARRAY(LN,1)="MU NQF0059_61_64_SMH"
	I MODE S ARRAY(LN,2)="07/16/2012@10:46:17"
	S LN=LN+1
	Q
	;
	;===============================================================
DELEI	;If the Exchange File entry already exists delete it.
	N ARRAY,IC,IND,LIST,LUVALUE,NUM
	D ARRAY(1,.ARRAY)
	S IC=0
	F  S IC=$O(ARRAY(IC)) Q:'IC  D
	.S LUVALUE(1)=ARRAY(IC,1)
	.D FIND^DIC(811.8,"","","U",.LUVALUE,"","","","","LIST")
	.I '$D(LIST) Q
	.S NUM=$P(LIST("DILIST",0),U,1)
	.I NUM'=0 D
	..F IND=1:1:NUM D
	... N DA,DIK
	... S DIK="^PXD(811.8,"
	... S DA=LIST("DILIST",2,IND)
	... D ^DIK
	Q
	;
	;===============================================================
EXFINC(Y)	;Return a 1 if the Exchange file entry is in the list to
	;include in the build. This is used in the build to determine which
	;entries to include.
	N ARRAY,FOUND,IEN,IC,LUVALUE
	D ARRAY(1,.ARRAY)
	S FOUND=0
	S IC=0
	F  S IC=+$O(ARRAY(IC)) Q:(IC=0)!(FOUND)  D
	. M LUVALUE=ARRAY(IC)
	. S IEN=+$$FIND1^DIC(811.8,"","KU",.LUVALUE)
	. I IEN=Y S FOUND=1 Q
	Q FOUND
	;
PREREM	;
	D DELEI
	Q
POSTREM	;
	D SMEXINS
	Q
	;===============================================================
SMEXINS	;Silent mode install.
	N ARRAY,IC,IEN,LUVALUE,PXRMINST
	S PXRMINST=1
	D ARRAY(1,.ARRAY)
	S IC=0
	F  S IC=$O(ARRAY(IC)) Q:'IC  D
	.M LUVALUE=ARRAY(IC)
	.S IEN=+$$FIND1^DIC(811.8,"","KU",.LUVALUE)
	.I IEN'=0 D
	.. N TEXT
	.. I LUVALUE(1)["PARAMETER" S TEXT="Installing entry "_LUVALUE(1)
	.. E  S TEXT="Installing reminder exchange entry "_LUVALUE(1)
	.. D BMES^XPDUTL(TEXT)
	.. D INSTALL^PXRMEXSI(IEN,"I",1)
	Q
	;
CRPL(PLNAME,C0QERR) ; Private ; $$ ; Create Patient List
 ; Input: PLNAME: By Value: Patient List Name
 ;        C0QERR: By Ref:   Error Array
 ; Output: IEN of Patient List, or -1 for error
 N C0QFDA,C0QIENS ; FDA, return IEN
 S C0QFDA(810.5,"?+1,",.01)=PLNAME ; Patient List Name
 S C0QFDA(810.5,"?+1,",.07)="`"_DUZ    ; Creator
 S C0QFDA(810.5,"?+1,",.08)="PUB"  ; Type: Public
 S C0QFDA(810.5,"?+1,",100)="L"    ; Class: Local
 D UPDATE^DIE("E",$NA(C0QFDA),$NA(C0QIENS),$NA(C0QERR)) ; External Flag
 I $G(C0QIENS(1)) QUIT C0QIENS(1)
 E  QUIT -1
