CIAOQN ;MSC/IND/PLS - TIU QUICK NOTES ;04-May-2006 08:19;DKM
;;1.1;VUECENTRIC COMPONENTS;**010002**;12-Aug-2004 22:06
;;Copyright 2000-2006, Medsphere Systems Corporation
;=================================================================
; Quick Note management API
MANAGE(DATA,ACTION,NAME,VAL,ENT) ;
N ENT1
S ENT1=$S(ENT="DIV":+DUZ(2)_";DIC(4,",1:+DUZ_";VA(200,")
S DATA=$$VALIDATE(.NAME,ACTION="C",.ENT)
Q:DATA
I ACTION="C" D SETLST(.DATA,NAME) Q
I ACTION="R" D RENLST(.DATA,NAME,.VAL) Q
I ACTION="S" D SETLST(.DATA,NAME,.VAL) Q
I ACTION="D" D DELLST(.DATA,NAME) Q
S DATA="-1^Unknown action"
Q
; Validate Quick Note Name
VALIDATE(NAME,DUP,ENT) ;
N L
S NAME=$$TRIM^CIAU(NAME),L=$L(NAME),DUP=+$G(DUP)
Q:L<3!(L>30) "-1^Quick Note name must be 3-30 characters in length."
Q:NAME'?.(1A,1N,1"_",1" ",1"-",1"(",1")") "-1^Quick Note name contains invalid characters."
I DUP,$$GETIEN(NAME) Q "-1^Quick Note name already exists."
I 'DUP,'$$GETIEN(NAME) Q "-1^Quick Note name not found."
Q ""
; Rename existing Quick Note
; OLD - Existing Instance name (aka Quick Note name)
; NEW - New Quick Name name
RENLST(DATA,OLD,NEW) ;
S DATA=$$VALIDATE(NEW,1)
D:'DATA REP^XPAR(ENT,$$PARAM,$$GETNAME(OLD),NEW,.DATA)
D:'DATA CHG^XPAR(ENT,$$PARAM,NEW,NEW,.DATA)
Q
; Set Quick Note
SETLST(DATA,NAME,VAL) ;
Q:'$L(NAME)
S:NAME=+NAME NAME=$$GETNAME(NAME)
S VAL=NAME
S:$D(VAL)'=11 VAL(1,0)=""
D EN^XPAR(ENT,$$PARAM,NAME,.VAL,.DATA)
Q
; Delete Quick Note
; NAME - Quick Note Name
DELLST(DATA,NAME) ;
D DEL^XPAR(ENT,$$PARAM,$$GETNAME(NAME),.DATA)
Q
; Return parameter name/ien
PARAM(X) Q $S($G(X):$$FIND1^DIC(8989.51,,"X",$$PARAM),1:"CIAOQN QNOTES")
; Return IEN to file 8989.5
GETIEN(NAME) ;
Q $S(NAME=+NAME:NAME,1:$O(^XTV(8989.5,"AC",$$PARAM(1),ENT1,NAME,0)))
; Returns instance name for 8989.5 IEN
GETNAME(IEN) ;
Q $S(IEN=+IEN:$$GET1^DIQ(8989.5,IEN_",",.03),1:IEN)
;
; Return TIU Template Node
; Input: TIEN - IEN to ^TIU(8927
GETTEMPL(DATA,TIEN) ;
S DATA=""
S:'TIEN TIEN=$O(^TIU(8927,"B",TIEN,0))
Q:'TIEN
S DATA=$$NODEDATA^TIUSRVT(TIEN)
Q
; Returns 1 if template selection allowed
TMPLSCRN(NODE) ;
I $P(NODE,U,3)="G"!($P(NODE,U,3)="T") Q 1
Q 0
; Return Class for given Document Title
GETDOCCL(DATA,DIEN) ;
S DATA=""
S:'DIEN DIEN=$O(^TIU(8925.1,"B",DIEN,0))
Q:'DIEN
S DATA=$$DOCCLASS^TIULC1(DIEN)
Q
; Returns available New Person entries for CoSigner
GCSIGLST(DATA,FROM,DIR,TITLE,AUTHOR,DATE) ;EP
N I,IEN,CNT
S I=0,CNT=44,DATE=$G(DATE)
F Q:I'<CNT S FROM=$O(^VA(200,"B",FROM),DIR) Q:FROM="" D
.S IEN="" F S IEN=$O(^VA(200,"B",FROM,IEN),DIR) Q:'IEN D
..I $$VCOSIG(IEN,TITLE,DATE) D
...S I=I+1,DATA(I)=IEN_U_FROM
Q
; Returns flag indicating the availability of the new person to cosign note
VCOSIG(NPIEN,TITLEIEN,ACTDATE) ;EP
N VAL
S VAL=1
I ACTDATE>0,$$GET^XUA4A72(NPIEN,DATE)<1 D
.S VAL=0
E D
.; A non-Provider may NOT be selected
.I +$$PROVIDER^TIUPXAP1(NPIEN,DT)'>0 S VAL=0
.; Others who require Cosignature may NOT be selected
.E I +$$REQCOSIG^TIULP(TITLEIEN,0,NPIEN) S VAL=0
.; Author may NOT be selected
.E I NPIEN=AUTHOR S VAL=0
Q VAL
; Return need for cosignature
REQCOS(DATA,TIUTYP,TIUSER) ; EP
S DATA=$$REQCOSIG^TIULP(TIUTYP,0,+$G(TIUSER))
Q
CIAOQN ;MSC/IND/PLS - TIU QUICK NOTES ;04-May-2006 08:19;DKM
+1 ;;1.1;VUECENTRIC COMPONENTS;**010002**;12-Aug-2004 22:06
+2 ;;Copyright 2000-2006, Medsphere Systems Corporation
+3 ;=================================================================
+4 ; Quick Note management API
MANAGE(DATA,ACTION,NAME,VAL,ENT) ;
+1 NEW ENT1
+2 SET ENT1=$SELECT(ENT="DIV":+DUZ(2)_";DIC(4,",1:+DUZ_";VA(200,")
+3 SET DATA=$$VALIDATE(.NAME,ACTION="C",.ENT)
+4 IF DATA
QUIT
+5 IF ACTION="C"
DO SETLST(.DATA,NAME)
QUIT
+6 IF ACTION="R"
DO RENLST(.DATA,NAME,.VAL)
QUIT
+7 IF ACTION="S"
DO SETLST(.DATA,NAME,.VAL)
QUIT
+8 IF ACTION="D"
DO DELLST(.DATA,NAME)
QUIT
+9 SET DATA="-1^Unknown action"
+10 QUIT
+11 ; Validate Quick Note Name
VALIDATE(NAME,DUP,ENT) ;
+1 NEW L
+2 SET NAME=$$TRIM^CIAU(NAME)
SET L=$LENGTH(NAME)
SET DUP=+$GET(DUP)
+3 IF L<3!(L>30)
QUIT "-1^Quick Note name must be 3-30 characters in length."
+4 IF NAME'?.(1A,1N,1"_",1" ",1"-",1"(",1")")
QUIT "-1^Quick Note name contains invalid characters."
+5 IF DUP
IF $$GETIEN(NAME)
QUIT "-1^Quick Note name already exists."
+6 IF 'DUP
IF '$$GETIEN(NAME)
QUIT "-1^Quick Note name not found."
+7 QUIT ""
+8 ; Rename existing Quick Note
+9 ; OLD - Existing Instance name (aka Quick Note name)
+10 ; NEW - New Quick Name name
RENLST(DATA,OLD,NEW) ;
+1 SET DATA=$$VALIDATE(NEW,1)
+2 IF 'DATA
DO REP^XPAR(ENT,$$PARAM,$$GETNAME(OLD),NEW,.DATA)
+3 IF 'DATA
DO CHG^XPAR(ENT,$$PARAM,NEW,NEW,.DATA)
+4 QUIT
+5 ; Set Quick Note
SETLST(DATA,NAME,VAL) ;
+1 IF '$LENGTH(NAME)
QUIT
+2 IF NAME=+NAME
SET NAME=$$GETNAME(NAME)
+3 SET VAL=NAME
+4 IF $DATA(VAL)'=11
SET VAL(1,0)=""
+5 DO EN^XPAR(ENT,$$PARAM,NAME,.VAL,.DATA)
+6 QUIT
+7 ; Delete Quick Note
+8 ; NAME - Quick Note Name
DELLST(DATA,NAME) ;
+1 DO DEL^XPAR(ENT,$$PARAM,$$GETNAME(NAME),.DATA)
+2 QUIT
+3 ; Return parameter name/ien
PARAM(X) QUIT $SELECT($GET(X):$$FIND1^DIC(8989.51,,"X",$$PARAM),1:"CIAOQN QNOTES")
+1 ; Return IEN to file 8989.5
GETIEN(NAME) ;
+1 QUIT $SELECT(NAME=+NAME:NAME,1:$ORDER(^XTV(8989.5,"AC",$$PARAM(1),ENT1,NAME,0)))
+2 ; Returns instance name for 8989.5 IEN
GETNAME(IEN) ;
+1 QUIT $SELECT(IEN=+IEN:$$GET1^DIQ(8989.5,IEN_",",.03),1:IEN)
+2 ;
+3 ; Return TIU Template Node
+4 ; Input: TIEN - IEN to ^TIU(8927
GETTEMPL(DATA,TIEN) ;
+1 SET DATA=""
+2 IF 'TIEN
SET TIEN=$ORDER(^TIU(8927,"B",TIEN,0))
+3 IF 'TIEN
QUIT
+4 SET DATA=$$NODEDATA^TIUSRVT(TIEN)
+5 QUIT
+6 ; Returns 1 if template selection allowed
TMPLSCRN(NODE) ;
+1 IF $PIECE(NODE,U,3)="G"!($PIECE(NODE,U,3)="T")
QUIT 1
+2 QUIT 0
+3 ; Return Class for given Document Title
GETDOCCL(DATA,DIEN) ;
+1 SET DATA=""
+2 IF 'DIEN
SET DIEN=$ORDER(^TIU(8925.1,"B",DIEN,0))
+3 IF 'DIEN
QUIT
+4 SET DATA=$$DOCCLASS^TIULC1(DIEN)
+5 QUIT
+6 ; Returns available New Person entries for CoSigner
GCSIGLST(DATA,FROM,DIR,TITLE,AUTHOR,DATE) ;EP
+1 NEW I,IEN,CNT
+2 SET I=0
SET CNT=44
SET DATE=$GET(DATE)
+3 FOR
IF I'<CNT
QUIT
SET FROM=$ORDER(^VA(200,"B",FROM),DIR)
IF FROM=""
QUIT
Begin DoDot:1
+4 SET IEN=""
FOR
SET IEN=$ORDER(^VA(200,"B",FROM,IEN),DIR)
IF 'IEN
QUIT
Begin DoDot:2
+5 IF $$VCOSIG(IEN,TITLE,DATE)
Begin DoDot:3
+6 SET I=I+1
SET DATA(I)=IEN_U_FROM
End DoDot:3
End DoDot:2
End DoDot:1
+7 QUIT
+8 ; Returns flag indicating the availability of the new person to cosign note
VCOSIG(NPIEN,TITLEIEN,ACTDATE) ;EP
+1 NEW VAL
+2 SET VAL=1
+3 IF ACTDATE>0
IF $$GET^XUA4A72(NPIEN,DATE)<1
Begin DoDot:1
+4 SET VAL=0
End DoDot:1
+5 IF '$TEST
Begin DoDot:1
+6 ; A non-Provider may NOT be selected
+7 IF +$$PROVIDER^TIUPXAP1(NPIEN,DT)'>0
SET VAL=0
+8 ; Others who require Cosignature may NOT be selected
+9 IF '$TEST
IF +$$REQCOSIG^TIULP(TITLEIEN,0,NPIEN)
SET VAL=0
+10 ; Author may NOT be selected
+11 IF '$TEST
IF NPIEN=AUTHOR
SET VAL=0
End DoDot:1
+12 QUIT VAL
+13 ; Return need for cosignature
REQCOS(DATA,TIUTYP,TIUSER) ; EP
+1 SET DATA=$$REQCOSIG^TIULP(TIUTYP,0,+$GET(TIUSER))
+2 QUIT