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

AMHGETP.m

Go to the documentation of this file.
AMHGETP ; IHS/CMI/MAW - AMHG Treatment Plan Add/Edits 3/7/2009 8:49:18 PM ;
 ;;4.0;IHS BEHAVIORAL HEALTH;**1**;JUN 18, 2010;Build 8
 ;
 ;
 ;
DEBUG(RETVAL,AMHSTR) ;-- debug entry point
 D DEBUG^%Serenji("EP^AMHGD(RETVAL,.AMHSTR)")
 Q
 ;
TP(AMHIEN,DM,REC,PAT,DE,PRG,TD,RD,DC,DP,A5,CA,CD,DS,PRBL,GAF,PP) ;EP -- file the treatment plan
 N AMHIENS,AMHFDA,AMHERRR,FL
 S AMHIENS=$S(DM="A":"+1,",1:REC_",")
 S FL=9002011.56
 S AMHFDA(FL,AMHIENS,.03)=TD
 S AMHFDA(FL,AMHIENS,.04)=DP
 S AMHFDA(FL,AMHIENS,.05)=DS
 S AMHFDA(FL,AMHIENS,.06)=CD
 S AMHFDA(FL,AMHIENS,.09)=RD
 S AMHFDA(FL,AMHIENS,.12)=DC
 S AMHFDA(FL,AMHIENS,.16)=CA
 S AMHFDA(FL,AMHIENS,.17)=PRG
 S AMHFDA(FL,AMHIENS,1601)=A5
 S AMHFDA(FL,AMHIENS,1101)=PRBL
 S AMHFDA(FL,AMHIENS,1602)=GAF
 I DM="A" D
 . S AMHFDA(FL,AMHIENS,.01)=DE
 . S AMHFDA(FL,AMHIENS,.02)=PAT
 . D UPDATE^DIE("","AMHFDA","AMHIENS","AMHERRR(1)")
 . I '$D(AMHERRR) S AMHIEN=$G(AMHIENS(1)) Q
 . S AMHER="0~Add Treatment Plan"
 I DM="E" D
 . S AMHFDA(FL,AMHIENS,.01)=DE
 . D FILE^DIE("K","AMHFDA","AMHERRR(1)")
 . I '$D(AMHERRR) S AMHIEN=REC Q
 . S AMHER="0~Edit Treatment Plan"
 I $D(PP) D PPART(AMHIEN,.PP)
 Q
ADDAXIS4(PI,RC) ;EP -- add axis 4
 N AMHFDA,AMHIENS,AMHERRR,AMHAIEN
 S AMHIENS="+2,"_RC_","
 S AMHFDA(9002011.569,AMHIENS,.01)=PI
 D UPDATE^DIE("","AMHFDA","AMHIENS","AMHERRR(1)")
 I $D(AMHERRR) S AMHER="0~Add Axis IV"
 I '$D(AMHERRR) S AMHAIEN=$G(AMHIENS(1))
 Q
 ;
DELAXIS4(REC,A4) ;EP -- check to see if any axis 4 records were deleted during edit
 N ADA,R,A
 S R="~"
 S ADA=0 F  S ADA=$O(A4(ADA)) Q:'ADA  D
 . N A4IEN
 . S A4IEN=$P(A4(ADA),R)
 . S A(A4IEN)=A4IEN
 N IEN
 S IEN=0 F  S IEN=$O(^AMHPTXP(REC,9,IEN)) Q:'IEN  D
 . N AXIS4
 . S AXIS4=$P(^AMHPTXP(REC,9,IEN,0),U)
 . I '$G(A(AXIS4)) D
 .. S DA(1)=REC,DA=IEN,DIK="^AMHPTXP("_DA(1)_",9," D ^DIK
 Q
 ;
A(RC,A,FLD) ;EP -- file wp fields
 ;Q:$G(A)=""
 N AMHWP
 D ARRAYT^AMHGU(.AMHWP,A)  ;parse the text into an array
 N AMHFDA,AMHIENS,AMHERRR
 S AMHIENS=RC_","
 D WP^AMHGU(.AMHERRR,9002011.56,AMHIENS,FLD,.AMHWP)
 Q
 ;
RD(REC,D,DP,DS) ;EP -- file review data
 D CLNRV(REC)
 N RDA,R
 S R="~"
 S RDA=0 F  S RDA=$O(D(RDA)) Q:'RDA  D
 . N RSTR,RRD,RRP,RRS,RNRD,RRPI,RRSI
 . S RSTR=$G(D(RDA))
 . S RRD=$P(RSTR,R)
 . S RRP=$P(RSTR,R,2)
 . S RRPI=$S($G(RRP)]"":$O(^VA(200,"B",RRP,0)),1:"")
 . S RRS=$P(RSTR,R,3)
 . S RRSI=$S($G(RRS)]"":$O(^VA(200,"B",RRS,0)),1:"")
 . S RNRD=$P(RSTR,R,4)
 . N AMHFDA,AMHIENS,AMHERRR,FL,AMHRDIEN
 . S FL=9002011.564101
 . S AMHIENS="+2,"_REC_","
 . S AMHIENS(2)=RRD
 . S AMHFDA(FL,AMHIENS,.01)=RRD
 . S AMHFDA(FL,AMHIENS,.02)=RNRD
 . S AMHFDA(FL,AMHIENS,.03)=RRPI
 . S AMHFDA(FL,AMHIENS,.04)=RRSI
 . D UPDATE^DIE("","AMHFDA","AMHIENS","AMHERRR(1)")
 . I '$D(AMHERRR) S AMHRDIEN=$G(AMHIENS(2))
 . I $G(DP(RDA))]"",$E(DP(RDA),1,1)'=" " D PART(REC,AMHRDIEN,.DP,RDA)
 . I $G(DS(RDA))]"",$E(DS(RDA),1,1)'=" " D PS(REC,AMHRDIEN,1,DS(RDA))
 Q
 ;
PART(RC,DIEN,DP,RA) ;-- file the participants
 N PFL
 ;Q:$E(DP(DIEN),1,1)=" "
 S PFL=9002011.574112
 N PDA,I
 F I=1:1 D  Q:$P(DP(RA),"&",I)=""
 . Q:$P(DP(RA),"&",I)=""
 . N PSTR,PART,REL
 . S PSTR=$P(DP(RA),"&",I)
 . S PART=$P(PSTR,"~")
 . S REL=$P(PSTR,"~",2)
 . N AMHPFDA,AMHPERR,AMHPIENS
 . S AMHPIENS="+3,"_DIEN_","_RC_","
 . S AMHPFDA(PFL,AMHPIENS,.01)=PART
 . S AMHPFDA(PFL,AMHPIENS,.02)=REL
 . D UPDATE^DIE("","AMHPFDA","AMHPIENS","AMHPERR(1)")
 . I '$D(AMHPERR) S AMHPIEN=$G(AMHIENS(3))
 Q
 ;
PPART(RC,PP) ;-- file the plan participants
 D CLNPP(RC)
 N PFL
 ;Q:$E(DP(DIEN),1,1)=" "
 S PFL=9002011.561701
 N PDA,I
 S PDA=0 F  S PDA=$O(PP(PDA)) Q:'PDA  D
 . N PSTR,PART,REL
 . S PSTR=$G(PP(PDA))
 . S PART=$P(PSTR,"~")
 . S REL=$P(PSTR,"~",2)
 . N AMHPFDA,AMHPERR,AMHPIENS
 . S AMHPIENS="+2,"_RC_","
 . S AMHPFDA(PFL,AMHPIENS,.01)=PART
 . S AMHPFDA(PFL,AMHPIENS,.02)=REL
 . D UPDATE^DIE("","AMHPFDA","AMHPIENS","AMHPERR(1)")
 . I '$D(AMHPERR) S AMHPIEN=$G(AMHIENS(2))
 Q
 ;
PS(RC,DIEN,FLD,DS) ;-- file the progress summary
 ;TODO nned to find out how to file a WP field in a subfile
 S AMHIENS(2)=DIEN
 S AMHIENS(1)=RC
 Q:$G(DS)=""
 N AMHWP
 D ARRAYT^AMHGU(.AMHWP,DS)  ;parse the text into an array
 ;N AMHSFDA,AMHSIENS,AMHSERR
 N PSDA,CNT
 S CNT=0
 S PSDA=0 F  S PSDA=$O(AMHWP(PSDA)) Q:'PSDA  D
 . S CNT=CNT+1
 . S ^AMHPTXP(RC,41,DIEN,1,PSDA,0)=$G(AMHWP(PSDA))
 S ^AMHPTXP(RC,41,DIEN,1,0)="^^"_CNT_"^"_CNT_"^"_DIEN_"^"
 ;S AMHSIENS="+3,"_DIEN_","_RC_","
 ;D WP^AMHGU(.AMHERRR,9002011.56411,AMHIENS,FLD,.AMHWP)
 Q
 ;
CLNPP(RC) ;-- clean out plan participants
 S DA(1)=RC
 S DIK="^AMHPTXP("_DA(1)_",17,"
 N PDA
 S PDA=0 F  S PDA=$O(^AMHPTXP(RC,17,PDA)) Q:'PDA  D
 . S DA=PDA
 . D ^DIK
 Q
 ;
CLNRV(RC) ;clean out the review data first
 S DA(1)=RC
 S DIK="^AMHPTXP("_DA(1)_",41,"
 N TDA
 S TDA=0 F  S TDA=$O(^AMHPTXP(RC,41,TDA)) Q:'TDA  D
 . S DA=TDA
 . D ^DIK
 Q
 ;