[1779] | 1 | VWREGITT ;Portland\Jim Bell, BFP,LLC Input Template Management 2016
|
---|
| 2 | ;2.0**LOCAL** Copyright April 2016 ad infinitum;;;;;Build 2
|
---|
| 3 | ;*****************************************************************
|
---|
| 4 | ;* Licensed under GNU 2.0 or greater - see license.txt file *
|
---|
| 5 | ;* Program/application is for the management of input templates *
|
---|
| 6 | ;* owned by the user (DUZ). *
|
---|
| 7 | ;* REMINDER: All template fields pertain only to the Patient File*
|
---|
| 8 | ;* (#2)! *
|
---|
| 9 | ;*****************************************************************
|
---|
| 10 | ;
|
---|
| 11 | Q ;No fall through
|
---|
| 12 | ;
|
---|
| 13 | AUTH(TUSER,TNUM) ;Can user edit or is IT CONTROL
|
---|
| 14 | N TMO
|
---|
| 15 | S TMO=$O(^DIC(19,"B","VW REG IT CONTROL",0)) I $D(^VA(200,TUSER,203,"B",TMO)) Q 1
|
---|
| 16 | S TMO=$O(^DIC(19,"B","VW PATIENT REGISTRATION",0))
|
---|
| 17 | I TMO,$P(^DIE(TNUM,0),"^",5)=TUSER Q 1
|
---|
| 18 | Q 0
|
---|
| 19 | ;
|
---|
| 20 | INR() Q $O(RESULT(" "),-1)+1
|
---|
| 21 | ;
|
---|
| 22 | CF(FIELD) ;If a computed field, 0, else 1
|
---|
| 23 | I $P($G(^DD(2,FIELD,0)),"^",2)["C" Q 0
|
---|
| 24 | Q 1
|
---|
| 25 | ;
|
---|
| 26 | EGF(RESULT,TNAME) ;Get fields for client editing via TName
|
---|
| 27 | ;*************************
|
---|
| 28 | ;* Incoming___TNAME(IEN) *
|
---|
| 29 | ;*************************
|
---|
| 30 | K RESULT ;N TNUM,TNAME,PF,SF
|
---|
| 31 | S TNUM=+$P(TNAME,"(",2)
|
---|
| 32 | S TNAME=$P(TNAME,"(")
|
---|
| 33 | I 'TNUM!('$D(^DIE(TNUM))) S RESULT(0)="Template name or number not found in Template file" Q
|
---|
| 34 | ;Check for authorization
|
---|
| 35 | I '$$AUTH(DUZ,TNUM) S RESULT(0)="Sorry, you are not authorized to edit this template." Q
|
---|
| 36 | S RESULT(0)="Editing "_TNAME_"("_TNUM_")"
|
---|
| 37 | S PF=$G(^DIE(TNUM,"DR",1,2))
|
---|
| 38 | F I=1:1:$L(PF,";") D:$P(PF,";",I)
|
---|
| 39 | . S RESULT($$INR)=$P(^DD(2,$P(PF,";",I),0),"^")_"("_$P(PF,";",I)_")"
|
---|
| 40 | . S SDD=+$P(^DD(2,$P(PF,";",I),0),"^",2) D:SDD
|
---|
| 41 | .. S SDN=1 F S SDN=$O(^DIE(TNUM,"DR",SDN)) Q:'SDN S:$O(^(SDN,0))=SDD SF=^(SDD) D
|
---|
| 42 | ... F J=1:1:$L(SF,";") D:$P(SF,";",J)
|
---|
| 43 | .... S SFF=$P(^DIE(TNUM,"DR",SDN,SDD),";",J)
|
---|
| 44 | .... S RESULT($$INR)=" SF "_$P(^DD(SDD,SFF,0),"^")_"("_SFF_";"_SDD_")"
|
---|
| 45 | Q
|
---|
| 46 | ;
|
---|
| 47 | SFLDS ;Get sub-fields and dics
|
---|
| 48 | K MULT N N,X,I,Y
|
---|
| 49 | S Y="",N=0 F S N=$O(TDATA(N)) Q:'+N D
|
---|
| 50 | . Q:TDATA(N)'[" SF" ;Still a major field
|
---|
| 51 | . F I=N:1:$O(TDATA(" "),-1) S X=TDATA(I) Q:X'[" SF" S MULT(+$P(X,";",2),+$P(X,"(",2))=""
|
---|
| 52 | Q
|
---|
| 53 | ;
|
---|
| 54 | FIELDS() ;
|
---|
| 55 | N FLDLIST,N,X,FLD K MULT
|
---|
| 56 | S FLDLIST=""
|
---|
| 57 | S N=0 F S N=$O(TDATA(N)) Q:'+N D:TDATA(N)'[" SF"
|
---|
| 58 | . S FLD=+$P(TDATA(N),"(",2)
|
---|
| 59 | . Q:'$$CF(+$P(TDATA(N),"(",2)) ;Computed field
|
---|
| 60 | . S FLDLIST=FLDLIST_FLD_";"
|
---|
| 61 | ;Collate thru for multiple fields:entry looks like " SF "
|
---|
| 62 | S N=0 F S N=$O(TDATA(N)) Q:'+N D:TDATA(N)[" SF"
|
---|
| 63 | . S X=$P(TDATA(N)," ",3)
|
---|
| 64 | . S SDD=+$P(X,";",2)
|
---|
| 65 | . S SFL=+$P(X,"(",2)
|
---|
| 66 | . S MULT(SDD,SFL)=""
|
---|
| 67 | S N=0 F S N=$O(MULT(N)) Q:'+N D S SUB(N)=MF
|
---|
| 68 | . S MF="",N2=0 F S N2=$O(MULT(N,N2)) Q:'+N2 S MF=MF_N2_";"
|
---|
| 69 | K MULT
|
---|
| 70 | Q FLDLIST
|
---|
| 71 | ;
|
---|
| 72 | RTF(RESULT) ;Send a refresh of regit.txt to client
|
---|
| 73 | K AR,RESULT
|
---|
| 74 | D LTF
|
---|
| 75 | M RESULT=AR
|
---|
| 76 | K AR
|
---|
| 77 | Q
|
---|
| 78 | ;
|
---|
| 79 | LTF ;Load the regit.txt file into AR()
|
---|
| 80 | S HD=$$GET^XPAR("ALL","VW GUI REG TEMPLATE DIRECTORY")
|
---|
| 81 | S FILE="regit.txt"
|
---|
| 82 | S P4=1
|
---|
| 83 | S P5=""
|
---|
| 84 | S X=$$FTG^%ZISH(HD,FILE,$NA(AR(1)),P4,P5)
|
---|
| 85 | Q
|
---|
| 86 | ;
|
---|
| 87 | FTF ;File the AR() to regit.txt
|
---|
| 88 | ZSY "cp "_HD_"regit.txt "_HD_"regitbu.txt"
|
---|
| 89 | S P4=1,P5="",FILE="regit.txt"
|
---|
| 90 | S X=$$GTF^%ZISH($NA(AR(1)),1,HD,FILE)
|
---|
| 91 | Q
|
---|
| 92 | ;
|
---|
| 93 | ITCNTRL(USER) ;Check for control capability and user authorization
|
---|
| 94 | N ITCNTRL
|
---|
| 95 | S ITCNTRL=$O(^DIC(19,"B","VW REG IT CONTROL",0))
|
---|
| 96 | I 'ITCNTRL D Q 0
|
---|
| 97 | . S VAL=0
|
---|
| 98 | . S RESULT(0)="-1^VW REGISTRATION does not appear to be complete."
|
---|
| 99 | . S RESULT(1)="Please contact your Supervisor or IT support."
|
---|
| 100 | . S RESULT(2)="Thank you,"
|
---|
| 101 | . S RESULT(3)="The Management"
|
---|
| 102 | I '$D(^VA(200,USER,203,"B",ITCNTRL)) D Q 0
|
---|
| 103 | . S RESULT(0)="-1^User does not have authorization to modify/create"
|
---|
| 104 | . S RESULT(1)="input templates. Please contact your Supervisor or"
|
---|
| 105 | . S RESULT(2)="IT support. Or, questions can be referred to Jim"
|
---|
| 106 | . S RESULT(3)="Bell at jbellco65@gmail.com"
|
---|
| 107 | . S RESULT(4)="Thank you."
|
---|
| 108 | Q 1
|
---|
| 109 | ;
|
---|
| 110 | EN(RESULT,TDATA) ;
|
---|
| 111 | ;************************************************
|
---|
| 112 | ;* Call from Client *
|
---|
| 113 | ;* TDATA Array: *
|
---|
| 114 | ;* 0____Template Name^DUZ^ACTION^WRITEACCESS *
|
---|
| 115 | ;* 1-n__Field name(number) *
|
---|
| 116 | ;************************************************
|
---|
| 117 | ; -- testing --
|
---|
| 118 | ;M ^DIZ("TDATA",$J)=TDATA
|
---|
| 119 | ;Q
|
---|
| 120 | ; -- end testing --
|
---|
| 121 | ;
|
---|
| 122 | N TNAME,TNUM,ITCNTRL,ACTION,FIELDS,CALLER
|
---|
| 123 | S CALLER=""
|
---|
| 124 | S X="TDATA" F S X=$Q(@X) Q:X="" S @X=$$UP^XLFSTR(@X) ;Upcase everyTHING
|
---|
| 125 | I '$L($G(HD)) S HD=$$GET^XPAR("ALL","VW GUI REG TEMPLATE DIRECTORY")
|
---|
| 126 | S WHO=$P(TDATA(0),"^",2)
|
---|
| 127 | S ITCNTRL=$$ITCNTRL(WHO) ;1=full action;0=create/edit own template(s)
|
---|
| 128 | S TNUM=+$P($P(TDATA(0),"^"),"(",2)
|
---|
| 129 | S TNAME=$P($P(TDATA(0),"^"),"(")
|
---|
| 130 | I TNAME["Editing" S SPEC("Editing ")="",TNAME=$$REPLACE^XLFSTR(TNAME,.SPEC)
|
---|
| 131 | S ACTION=$P(TDATA(0),"^",3)
|
---|
| 132 | S WRITEACC=$S($P(TDATA(0),"^",4)="SELF":$P(^VA(200,DUZ,0),"^",4),1:"")
|
---|
| 133 | S FIELDS=$$FIELDS
|
---|
| 134 | I '$L(ACTION) S RESULT(0)="-1^No action sent. I don't know what to do." Q
|
---|
| 135 | D @ACTION
|
---|
| 136 | Q
|
---|
| 137 | ;
|
---|
| 138 | CREATE ;Create a new input template
|
---|
| 139 | ;******************************
|
---|
| 140 | ;* Check for computed fields *
|
---|
| 141 | ;******************************
|
---|
| 142 | K RESULT N %DT,X,Y
|
---|
| 143 | S %DT="TS",X="NOW" D ^%DT S FDATE=Y
|
---|
| 144 | S X=TNAME,DIC="^DIE(",DIC(0)="LZ" D FILE^DICN
|
---|
| 145 | S $P(^DIE(+Y,0),"^",2)=FDATE,$P(^(0),"^",3)="",$P(^(0),"^",4)=2,$P(^(0),"^",5)=DUZ
|
---|
| 146 | S $P(^DIE(+Y,0),"^",6)=WRITEACC
|
---|
| 147 | C2 S ^DIE(+Y,"DR",1,2)=FIELDS
|
---|
| 148 | ;Do mult fields here
|
---|
| 149 | S N=0 F S N=$O(SUB(N)) Q:'+N D
|
---|
| 150 | . S UP=^DD(N,0,"UP")
|
---|
| 151 | . I UP=2 S ^DIE(+Y,"DR",$O(^DIE(+Y,"DR"," "),-1)+1,N)=SUB(N)
|
---|
| 152 | . E S ^DIE(+Y,"DR",$O(^DIE(+Y,"DR"," "),-1),N)=SUB(N)
|
---|
| 153 | I $P(^DIE(+Y,0),"^")=$P(TDATA(0),"^") S RESULT(0)=$P(Y,"^",2)_" filed"
|
---|
| 154 | Q:CALLER="EDIT"
|
---|
| 155 | S TNUM=+Y,TNAME=$P(Y,"^",2)
|
---|
| 156 | K AR
|
---|
| 157 | D LTF ;Get the regit.txt file loaded into AR()
|
---|
| 158 | S LAST=$O(AR(" "),-1)
|
---|
| 159 | S AR(LAST)=TNAME_"("_TNUM_")"
|
---|
| 160 | S AR(LAST+1)="[ID]"
|
---|
| 161 | ;M ^DIZ("TDATA","AR",$J)=AR ;Testing
|
---|
| 162 | D FTF ;File AR() to regit.txt
|
---|
| 163 | K ^DIZ("TDATA",$J)
|
---|
| 164 | Q
|
---|
| 165 | ;
|
---|
| 166 | EDIT ;Edit existing. Check for allowability
|
---|
| 167 | S Y=TNUM_"^"_TNAME
|
---|
| 168 | EL L -^DIE(TNUM):1 G EL:'$T
|
---|
| 169 | S S=1 F S S=$O(^DIE(TNUM,"DR",S)) Q:'+S D
|
---|
| 170 | . S SUBD=0 F S SUBD=$O(^DIE(TNUM,"DR",S,SUBD)) Q:'+SUBD K ^DIE(TNUM,"DR",S,SUBD)
|
---|
| 171 | S CALLER="EDIT"
|
---|
| 172 | D C2
|
---|
| 173 | L +^DIE(TNUM)
|
---|
| 174 | S DA=TNUM,DIK="^DIE(" D IX^DIK ;Re-index record just in case...
|
---|
| 175 | S RESULT(0)=Y_" modification filed..."
|
---|
| 176 | Q
|
---|
| 177 | ;
|
---|
| 178 | DELETE ;********************************************
|
---|
| 179 | ;* 1. Get the regit.txt contents into AR() *
|
---|
| 180 | ;* 2. Remove the template from the list *
|
---|
| 181 | ;* 3. Refile regit.txt *
|
---|
| 182 | ;********************************************
|
---|
| 183 | K AR
|
---|
| 184 | M AR=RESULT
|
---|
| 185 | K AR(0) ;ID string for EN
|
---|
| 186 | D FTF
|
---|
| 187 | I X S RESULT(0)="Template menu list updated."
|
---|
| 188 | E S RESULT(0)="Template list not updated. Advise Template manager to manually update "_HD_"regit.txt"
|
---|
| 189 | Q
|
---|
| 190 |
|
---|