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

AMHGESF.m

Go to the documentation of this file.
AMHGESF ; IHS/CMI/MAW - AMHG Suicide Add/Edits 9:22:26 AM ;
 ;;4.0;IHS BEHAVIORAL HEALTH;;MAY 14, 2010
 ;
 ;
 ;
DEBUG(RETVAL,AMHSTR) ;-- debug entry point
 D DEBUG^%Serenji("EP^AMHGD(RETVAL,.AMHSTR)")
 Q
 ;
SF(AMHIEN,DM,REC,PAT,CN,LCN,DOA,PRV,COA,RS,ES,EDU,EDUL,SB,PA,DSP,DSPO,LOA,LOAO,SU) ;EP - sf
 N FL,AMHIENS,AMHFDA,AMHERRR
 S AMHIENS=$S(DM="A":"+1,",1:REC_",")
 S FL=9002011.65
 S AMHFDA(FL,AMHIENS,.02)=LCN
 S AMHFDA(FL,AMHIENS,.03)=PRV
 S AMHFDA(FL,AMHIENS,.04)=PAT
 S AMHFDA(FL,AMHIENS,.05)=ES
 S AMHFDA(FL,AMHIENS,.06)=DOA
 S AMHFDA(FL,AMHIENS,.07)=COA
 S AMHFDA(FL,AMHIENS,.08)=RS
 S AMHFDA(FL,AMHIENS,.11)=EDU
 S AMHFDA(FL,AMHIENS,.12)=EDUL
 S AMHFDA(FL,AMHIENS,.13)=SB
 S AMHFDA(FL,AMHIENS,.14)=PA
 S AMHFDA(FL,AMHIENS,.15)=LOA
 S AMHFDA(FL,AMHIENS,1401)=LOAO
 S AMHFDA(FL,AMHIENS,1402)=DSPO
 S AMHFDA(FL,AMHIENS,.21)=DT
 S AMHFDA(FL,AMHIENS,.22)=DUZ
 S AMHFDA(FL,AMHIENS,.25)=DSP
 S AMHFDA(FL,AMHIENS,.26)=SU
 I DM="A" D
 . S AMHFDA(FL,AMHIENS,.01)=CN
 . S AMHFDA(FL,AMHIENS,.18)=DT
 . S AMHFDA(FL,AMHIENS,.19)=DUZ
 . D UPDATE^DIE("","AMHFDA","AMHIENS","AMHERRR(0)")
 . I '$D(AMHERRR) S AMHIEN=$G(AMHIENS(1)) Q
 . S AMHER="0~Add Suicide Form"
 I DM="E" D
 . D FILE^DIE("K","AMHFDA","AMHERRR(1)")
 . I '$D(AMHERRR) S AMHIEN=REC Q
 ;D VAUD(AMHIEN)
 Q
 ;
VAUD(RC) ;-- update the audit log
 N AMHFDA,AMHIENS,AMHERRR
 S AMHIENS=""
 S AMHFDA(9002011.6551,"+2,"_RC_",",.01)=$$NOW^XLFDT
 S AMHFDA(9002011.6551,"+2,"_RC_",",.02)=DUZ
 D UPDATE^DIE("","AMHFDA","AMHIENS","AMHERRR(1)")
 Q
 ;
METH(AMHIEN,DM,REC,MO,M,O) ;EP -- add/edit methods
 N FL
 D CLNMTH(REC)
 S FL=9002011.6511
 N AMHDA,R
 S R="~"
 S AMHDA=0 F  S AMHDA=$O(M(AMHDA)) Q:'AMHDA  D
 . N STR,MIEN,AMHMIEN
 . S STR=$G(M(AMHDA))
 . S MIEN=$P(STR,R)
 . I MIEN=7 D OD(REC,MIEN,.O) Q
 . N AMHFDA,AMHIENS,AMHERRR
 . S AMHIENS="+2,"_REC_","
 . S AMHFDA(FL,AMHIENS,.01)=MIEN
 . I MIEN=8 S AMHFDA(FL,AMHIENS,.02)=MO
 . D UPDATE^DIE("","AMHFDA","AMHIENS","AMHERRR(1)")
 . I '$D(AMHERRR) S AMHMIEN=$G(AMHIENS(2)) Q
 . S AMHER="0~Add Suicide Methods"
 Q
 ;
OD(RC,MI,O) ;EP -- if overdose file those as well
 N MFL
 S MFL=9002011.651111
 N AMHDA,R,RIEN,SIEN
 S R="~"
 S RIEN=$O(^AMHPSUIC(RC,11,"B",MI,0))
 S SIEN=$S(RIEN:RIEN_","_RC_",",1:"+2,"_RC_",")
 I '$D(O(1)) D  Q
 . N AMHOFDA,AMHOIENS,AMHOERR
 . S AMHOFDA(9002011.6511,SIEN,.01)=MI  ;TODO
 . D UPDATE^DIE("","AMHOFDA","AMHOIENS","AMHOERR(1)")
 . I $D(AMHOERR) S AMHER="0~Add Method Overdose"
 . S AMHIEN=$G(AMHIENS(2))
 S AMHDA=0 F  S AMHDA=$O(O(AMHDA)) Q:'AMHDA  D
 . N AMHOFDA,AMHOIENS,AMHOERR
 . N OSTR,OIEN,OTH
 . S OSTR=$G(O(AMHDA))
 . S OIEN=$P(OSTR,R)
 . S OTH=$P(OSTR,R,3)
 . S AMHOIENS="+3,"_SIEN
 . S AMHOFDA(9002011.6511,SIEN,.01)=MI
 . S AMHOFDA(MFL,AMHOIENS,.01)=OIEN
 . I $E($$GET1^DIQ(9002014.7,OIEN,.01),1,5)="OTHER" S AMHOFDA(MFL,AMHOIENS,.02)=OTH
 . D UPDATE^DIE("","AMHOFDA","AMHOIENS","AMHOERR(1)")
 . I $D(AMHOERR) S AMHER="0~Add Method Overdose"
 . S AMHIEN=$G(AMHIENS(3))
 Q
 ;
CLNMTH(RC) ;-- lets clean the method multiple out first
 S DA(1)=RC
 S DIK="^AMHPSUIC("_DA(1)_",11,"
 N MDA
 S MDA=0 F  S MDA=$O(^AMHPSUIC(RC,11,MDA)) Q:'MDA  D
 . S DA=MDA
 . D ^DIK
 Q
 ;
SUB(AMHIEN,REC,S) ;EP -- add substance involved
 D CLNSD(REC)
 N FL
 S FL=9002011.651501
 N AMHDA,R
 S R="~"
 S AMHDA=0 F  S AMHDA=$O(S(AMHDA)) Q:'AMHDA  D
 . N AMHFDA,AMHIENS,AMHERRR
 . N SSTR,SIEN,SOTH
 . S SSTR=$G(S(AMHDA))
 . S SIEN=$P(SSTR,R)
 . S SOTH=$P(SSTR,R,3)
 . S AMHIENS="+2,"_REC_","
 . S AMHFDA(FL,AMHIENS,.01)=SIEN
 . I $E($$GET1^DIQ(9002014.71,SIEN,.01),1,5)="OTHER" S AMHFDA(FL,AMHIENS,.02)=SOTH
 . D UPDATE^DIE("","AMHFDA","AMHIENS","AMHERRR(1)")
 . I $D(AMHERRR) S AMHER="0~Add Substance Drugs"
 Q
 ;
CLNSD(RC) ;-- lets clean the substance drug multiple out first
 S DA(1)=RC
 S DIK="^AMHPSUIC("_DA(1)_",15,"
 N MDA
 S MDA=0 F  S MDA=$O(^AMHPSUIC(RC,15,MDA)) Q:'MDA  D
 . S DA=MDA
 . D ^DIK
 Q
 ;
CF(AMHIEN,DM,REC,CO,C) ;EP -- add/edit contributing factors
 N FL
 D CLNCF(REC)
 S FL=9002011.6513
 N AMHDA,R
 S R="~"
 S AMHDA=0 F  S AMHDA=$O(C(AMHDA)) Q:'AMHDA  D
 . N STR,CIEN,AMHMIEN
 . S STR=$G(C(AMHDA))
 . S CIEN=$P(STR,R)
 . N AMHFDA,AMHIENS,AMHERRR
 . S AMHIENS="+2,"_REC_","
 . S AMHFDA(FL,AMHIENS,.01)=CIEN
 . I $$GET1^DIQ(9002014.9,CIEN,.01)="OTHER" S AMHFDA(FL,AMHIENS,.02)=CO
 . D UPDATE^DIE("","AMHFDA","AMHIENS","AMHERRR(1)")
 . I '$D(AMHERRR) S AMHMIEN=$G(AMHIENS(2)) Q
 . S AMHER="0~Add Contributing Factors"
 Q
 ;
CLNCF(RC) ;-- lets clean the contributing factors multiple out first
 S DA(1)=RC
 S DIK="^AMHPSUIC("_DA(1)_",13,"
 N MDA
 S MDA=0 F  S MDA=$O(^AMHPSUIC(RC,13,MDA)) Q:'MDA  D
 . S DA=MDA
 . D ^DIK
 Q
 ;
NARR(RC,N) ;EP -- file axis 3 data
 ;Q:$G(N)=""
 N AMHWP
 D ARRAYT^AMHGU(.AMHWP,N)  ;parse the text into an array
 N AMHFDA,AMHIENS,AMHERRR
 S AMHIENS=RC_","
 D WP^AMHGU(.AMHERRR,9002011.65,AMHIENS,4100,.AMHWP)
 Q
 ;