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

BQIRGACM.m

Go to the documentation of this file.
BQIRGACM ;HCSD/HSD/ALA-Register Columns ; 19 Feb 2016  9:08 AM
 ;;2.5;ICARE MANAGEMENT SYSTEM;**1**;May 24, 2016;Build 17
 ;
 ;
DXN(BQIDFN,SUBREG) ;EP - Diagnoses
 NEW ACMIEN,VLU,TEXT
 S ACMIEN=$O(^ACM(41.1,"B",SUBREG,""))
 S VLU="",TEXT=""
 F  S VLU=$O(^ACM(44,"AC",ACMIEN,BQIDFN,VLU)) Q:VLU=""  D
 . S TEXT=TEXT_$P(^ACM(44.1,VLU,0),U,1)_$C(10)_$C(13)
 Q $$TKO^BQIUL1(TEXT,$C(10)_$C(13))
 ;
COMP(BQIDFN,SUBREG) ; EP - Complications
 NEW ACMIEN,VLU,TEXT
 S ACMIEN=$O(^ACM(41.1,"B",SUBREG,""))
 S VLU="",TEXT=""
 F  S VLU=$O(^ACM(42,"AC",ACMIEN,BQIDFN,VLU)) Q:VLU=""  D
 . S TEXT=TEXT_$P(^ACM(42.1,VLU,0),U,1)_$C(10)_$C(13)
 Q $$TKO^BQIUL1(TEXT,$C(10)_$C(13))
 ;
ADD(DATA,NAME,DESC) ;EP -- BQI CREATE REGISTER
 NEW UID,X,BQII,PLID,TMP,REGIEN,MSG
 S UID=$S($G(ZTSK):"Z"_ZTSK,1:$J)
 S DATA=$NA(^TMP(UID,"BQIRGCR")) K @DATA
 ;
 NEW $ESTACK,$ETRAP S $ETRAP="D ERR^BQIRGACM D UNWIND^%ZTER" ; SAC 2006 2.2.3.3.2
 ;
 ; Check that REGISTER name is unique
 S BQII=0,RESULT=1,MSG="",RGIEN=""
 S @DATA@(BQII)="I00010RESULT^I00010REG_IEN^T00030MSG"_$C(30)
 ;
 I NAME'="" D  G DONE:$G(MSG)'=""
 . N DA,IENS,ERROR
 . S IENS=$$IENS^DILF(.DA)
 . S TMP=$$FIND1^DIC(9002241.1,"","X",NAME,"","","ERROR")
 . I TMP=0 Q  ; Name not currently in use
 . S MSG="Register name already exists"
 . Q
 ;
 ; Create record
 S DIC(0)="LMQZ",DLAYGO=9002241.1
 S DIC="^ACM(41.1,",X=NAME
 D ^DIC S DA=+Y
 I DA=-1 K DO,DD D FILE^DICN S DA=+Y
 I DA=-1 S MSG="Unable to create register" G DONE
 S UPD(9002241.1,DA_",",1)=DT,UP(9002241.1,DA_",",3.5)=DUZ,UPD(9002241.1,DA_",",9)=DESC
 S UPD(9002241.1,DA_",",5)=0,UPD(9002241.1,DA_",",6)=0,UPD(9002241.1,DA_",",7)=0
 S UPD(9002241.1,DA_",",100)=1,REGIEN=DA
 D FILE^DIE("","UPD","ERROR")
 I '$D(^ACM(41.1,DA,"AU",0)) S ^ACM(41.1,DA,"AU",0)="^9002241.12P^^"
 S (X,DINUM)=DUZ,DA(1)=DA,DIC="^ACM(41.1,"_DA(1)_",""AU"","
 K DO,DD D FILE^DICN
 ;
DONE ; -- exit code
 I $G(MSG)'="" S RESULT=-1
 S BQII=BQII+1,@DATA@(BQII)=RESULT_U_$G(REGIEN)_U_MSG_$C(30)
 S BQII=BQII+1,@DATA@(BQII)=$C(31)
 Q
 ;
APAT(DATA,REGIEN,PLIST) ; EP -- BQI ADD PATIENTS TO REGISTER
 NEW UID,II,X,BN,LIST,BQI,DFN,RESULT
 S UID=$S($G(ZTSK):"Z"_ZTSK,1:$J)
 S DATA=$NA(^TMP("BQIRGAPT",UID))
 K @DATA
 ;
 S II=0
 NEW $ESTACK,$ETRAP S $ETRAP="D ERR^BQIRGACM D UNWIND^%ZTER" ; SAC 2006 2.2.3.3.2
 ;
 S @DATA@(II)="I00010RESULT"_$C(30),RESULT=-1
 I $D(PLIST)>0 D
 . I $D(PLIST)>1 D
 .. S LIST="",BN=""
 .. F  S BN=$O(PLIST(BN)) Q:BN=""  S LIST=LIST_PLIST(BN)
 .. K PLIST S PLIST=LIST
 . F BQI=1:1 S DFN=$P(PLIST,$C(28),BQI) Q:DFN=""  D
 .. S X=REGIEN,DIC="^ACM(41,",DIC(0)="L"
 .. K DD,DO D FILE^DICN K DIC,DIE,DR,DA
 .. S ACMPTNO=+Y
 .. S UPD(9002241,ACMPTNO_",",.02)=DFN,UPD(9002241,ACMPTNO_",",1)="A"
 .. S UPD(9002241,ACMPTNO_",",2)=DT,UPD(9002241,ACMPTNO_",",4)=DT
 . D FILE^DIE("","UPD","ERROR") I '$D(ERROR) S RESULT=1
 S II=II+1,@DATA@(II)=RESULT_$C(30)
 S II=II+1,@DATA@(II)=$C(31)
 Q
 ;
ERR ;
 D ^%ZTER
 NEW Y,ERRDTM
 S Y=$$NOW^XLFDT() X ^DD("DD") S ERRDTM=Y
 S BMXSEC="Recording that an error occurred at "_ERRDTM
 I $D(II),$D(DATA) S II=II+1,@DATA@(II)=$C(31)
 Q