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

AMHGECOM.m

Go to the documentation of this file.
AMHGECOM ; IHS/CMI/MAW - AMHG Community Add/Edits 3/6/2009 5:57:06 PM ;
 ;;4.0;IHS BEHAVIORAL HEALTH;;MAY 14, 2010
 ;
 ;
 ;
 ;
DEBUG(RETVAL,AMHSTR) ;-- debug entry point
 D DEBUG^%Serenji("EP^AMHGD(RETVAL,.AMHSTR)")
 Q
 ;
MODV(AMHIEN,DM,REC,PP,PRO,TOC,ST,AT,NS,TGT,EDT,LOC,COM,AC,LSS,FLG,CLN) ;EP -- add/update MHSS RECORD entry
 N AMHFDA,AMHIENS,AMHERRR,AMHREC
 S AMHIENS=$S(DM="A":"+1,",1:REC_",")
 S AMHFDA(9002011,AMHIENS,.02)=PRO
 S AMHFDA(9002011,AMHIENS,.04)=LOC
 S AMHFDA(9002011,AMHIENS,.05)=COM
 S AMHFDA(9002011,AMHIENS,.06)=AC
 S AMHFDA(9002011,AMHIENS,.07)=TOC
 S AMHFDA(9002011,AMHIENS,.09)=NS
 S AMHFDA(9002011,AMHIENS,.12)=AT
 S AMHFDA(9002011,AMHIENS,.19)=DUZ
 S AMHFDA(9002011,AMHIENS,.25)=CLN
 S AMHFDA(9002011,AMHIENS,.27)=FLG
 S AMHFDA(9002011,AMHIENS,.31)=LSS
 S AMHFDA(9002011,AMHIENS,.33)="R"
 S AMHFDA(9002011,AMHIENS,1106)=TGT
 S AMHFDA(9002011,AMHIENS,1111)=1
 I DM="A" D  Q
 . S AMHFDA(9002011,AMHIENS,.01)=EDT
 . S AMHFDA(9002011,AMHIENS,.03)=DT
 . ;S AMHFDA(9002011,AMHIENS,.17)="A"
 . S AMHFDA(9002011,AMHIENS,.19)=DUZ
 . S AMHFDA(9002011,AMHIENS,.22)="A"
 . S AMHFDA(9002011.5101,"+2,"_AMHIENS,.01)=$$NOW^XLFDT
 . S AMHFDA(9002011.5101,"+2,"_AMHIENS,.02)=DUZ
 . D UPDATE^DIE("","AMHFDA","AMHIENS","AMHERRR(1)")
 . I $D(AMHERRR) S AMHER="0~Add Visit"
 . S AMHIEN=+$G(AMHIENS(1))
 . D MODPRV^AMHGEVF(PP,DM,AMHIEN,"","P")
 I DM="E" D  Q
 . S AMHIENS(1)=REC
 . ;S AMHFDA(9002011,AMHIENS,.17)="E"
 . S AMHFDA(9002011,AMHIENS,.21)=DT
 . S AMHFDA(9002011,AMHIENS,.22)="M"
 . S AMHFDA(9002011,AMHIENS,.28)=DUZ
 . D FILE^DIE("K","AMHFDA","AMHERRR(1)")
 . I $D(AMHERRR) S AMHER="0~Edit Visit"
 . S AMHIEN=REC
 . D MODPRV^AMHGEVF(PP,DM,AMHIEN,"","P")
 . D VAUD(REC)  ;update the audit log
 Q
 ;
VAUD(RC) ;-- update the audit log
 N AMHFDA,AMHIENS,AMHERRR
 S AMHIENS=""
 S AMHFDA(9002011,RC_",",.21)=DT
 S AMHFDA(9002011,RC_",",.28)=DUZ
 S AMHFDA(9002011.5101,"+2,"_RC_",",.01)=$$NOW^XLFDT
 S AMHFDA(9002011.5101,"+2,"_RC_",",.02)=DUZ
 D UPDATE^DIE("","AMHFDA","AMHIENS","AMHERRR(1)")
 Q
 ;
POV(D,RC,P,A2) ;EP -- add/modify pov
 N AMHDA,R
 S R="~"
 S AMHDA=0 F  S AMHDA=$O(A2(AMHDA)) Q:'AMHDA  D
 . N STR,PIEN,PCODE,PNARR
 . S STR=$G(A2(AMHDA))
 . S PIEN=$P(STR,R)
 . S PCODE=$P(STR,R,2)
 . S PNARR=$P(STR,R,3)
 . I $G(PNARR)]"" D
 ..S AMHN=$$FNDNARR^AMHGU(PNARR,1)
 . I D="A" D ADDPOV^AMHGEVF(PIEN,P,RC,AMHN) Q
 . I D="E" D  Q
 .. N AMHPREC
 .. S AMHPREC=$$FNDPOV^AMHGU(PIEN,RC)
 .. I 'AMHPREC D ADDPOV^AMHGEVF(PIEN,P,RC,AMHN) Q
 .. D EDITPOV^AMHGEVF(AMHPREC,AMHN)
 I D="E" D  Q
 . D DELPOV^AMHGEVF(RC,.A2)
 Q
 ;
MODPA(PI,PAT,RC,OTH) ;EP -- add a prevention activity
 Q:$$FNDPA^AMHGU(RC,PI)
 N AMHFDA,AMHIENS,AMHERRR,AMHPIEN
 S AMHIENS="+1,"
 S AMHFDA(9002011.09,AMHIENS,.01)=PI
 S AMHFDA(9002011.09,AMHIENS,.02)=PAT
 S AMHFDA(9002011.09,AMHIENS,.03)=RC
 S AMHFDA(9002011.09,AMHIENS,.04)=OTH
 D UPDATE^DIE("","AMHFDA","AMHIENS","AMHERRR(1)")
 I $D(AMHERRR) S AMHER="0~Add Prevention Activity"
 S AMHPIEN=$G(AMHIENS(1))
 Q
 ;
DELPA(REC,PAC) ;EP -- check to see if any cpt records were deleted during edit
 N ADA,R,PA
 S R="~"
 S ADA=0 F  S ADA=$O(PAC(ADA)) Q:'ADA  D
 . N PAIEN
 . S PAIEN=$P(PAC(ADA),R)
 . S P(PAIEN)=PAIEN
 N IEN
 S IEN=0 F  S IEN=$O(^AMHRPA("AD",REC,IEN)) Q:'IEN  D
 . N PAI
 . S PAI=$P(^AMHRPA(IEN,0),U)
 . I '$G(P(PAI)) D
 .. S DIK="^AMHRPA(",DA=IEN D ^DIK
 Q
 ;