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

BQIPLADR.m

Go to the documentation of this file.
BQIPLADR ;VNGT/HS/ALA-Mail Merge RPC ; 12 May 2008  2:39 PM
 ;;2.1;ICARE MANAGEMENT SYSTEM;;Feb 07, 2011
 ;
 ;
EN(DATA,OWNR,PLIEN,PLIST) ; EP - BQI MAIL MERGE LIST
 ; Input
 ;   PLIST - List of patient IENs separated by $C(28)
 ;DUZ is assumed to be the user signed onto iCare.
 ;DFN is the Patient internal entry number
 ;
 NEW UID,II,ADATA,APCLPCNT,APCLPRNT,CITY,ZIP,STATE
 S UID=$S($G(ZTSK):"Z"_ZTSK,1:$J)
 S DATA=$NA(^TMP("BQIPLADR",UID))
 K @DATA
 ;
 S II=0
 NEW $ESTACK,$ETRAP S $ETRAP="D ERR^BQIPLADR D UNWIND^%ZTER" ; SAC 2006 2.2.3.3.2
 ;
 D HDR
 S PLIST=$G(PLIST,""),OWNR=$G(OWNR,""),PLIEN=$G(PLIEN,"")
 ;
 I OWNR'="" D  G DONE
 . S DFN=0
 . F  S DFN=$O(^BQICARE(OWNR,1,PLIEN,40,DFN)) Q:'DFN  D PARS
 ;
 I PLIST="" D
 . S LIST="",BN=""
 . F  S BN=$O(PLIST(BN)) Q:BN=""  S LIST=LIST_PLIST(BN)
 . K PLIST
 . S PLIST=LIST
 . K LIST
 F BQI=1:1 S DFN=$P(PLIST,$C(28),BQI) Q:DFN=""  D PARS
 ;
DONE ;
 S II=II+1,@DATA@(II)=$C(31)
 Q
 ;
ERR ;
 D ^%ZTER
 N 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
 ;
HDR ;
 S @DATA@(II)="T00040Name^T00080Address_Line_1^T00080Address_Line_2^T00080Address_Line_3^T00015City^T00002State^T00010Zipcode^"
 S @DATA@(II)=@DATA@(II)_"T00020Home_Phone^T00020Business_Phone^T00020Alternate_Phone^T00030Community_of_Residence"_$C(30)
 Q
 ;
PARS ;
 NEW DA,EXE,X,NAME,ADR,APCLPRNM,PHN1,PHN2,COMM,PHN3
 S DA=$O(^APCLVSTS("B","First, Last Name",""))
 S EXE=^APCLVSTS(DA,3)
 X EXE
 S NAME=X
 S II=II+1,@DATA@(II)=NAME
 S DA=$O(^APCLVSTS("B","Mlg Address-Complete","")) I DA="" Q
 S EXE=^APCLVSTS(DA,3)
 X EXE
 S ADR=""
 S LAST=$O(APCLPRNM(""),-1)
 S ADATA=APCLPRNM(LAST) K APCLPRNM(LAST)
 ;
 F  S ADR=$O(APCLPRNM(ADR)) Q:ADR=""  D
 . S $P(@DATA@(II),U,1+ADR)=APCLPRNM(ADR)
 I APCLPCNT<4 S @DATA@(II)=@DATA@(II)_U
 I APCLPCNT<3 S @DATA@(II)=@DATA@(II)_U
 ;
 S CITY=$P(ADATA,",",1),RN=$L(ADATA," ")
 S ZIP=$P(ADATA," ",RN)
 S DA=$O(^APCLVSTS("B","Mlg Address-State Abbrv","")) I DA="" Q
 S EXE=^APCLVSTS(DA,3)
 X EXE
 S STATE=APCLPRNT
 S PHN1=$P($G(^DPT(DFN,.13)),U,1),PHN2=$P($G(^DPT(DFN,.13)),U,2)
 S PHN3=$P($G(^AUPNPAT(DFN,18)),U,1)
 S COMM=$$GET1^DIQ(9000001,DFN_",",1117,"E")
 S @DATA@(II)=@DATA@(II)_U_CITY_U_STATE_U_ZIP_U_PHN1_U_PHN2_U_PHN3_U_COMM_$C(30)
 Q
 ;
GLS(DATA,FAKE) ;EP -- BQI GET MAIL MERGE GLOSSARY
 ;
 NEW UID,II,STIEN,IEN
 ;
 S UID=$S($G(ZTSK):"Z"_ZTSK,1:$J)
 S DATA=$NA(^TMP("BQIMMHLP",UID))
 K @DATA
 ;
 S II=0
 NEW $ESTACK,$ETRAP S $ETRAP="D ERR^BQICAHLP D UNWIND^%ZTER" ; SAC 2006 2.2.3.3.2
 ;
 S @DATA@(II)="T32767TEXT"_$C(30)
 S STIEN=$$SPM^BQIGPUTL()
 S IEN=0
 F  S IEN=$O(^BQI(90508,STIEN,17,IEN)) Q:'IEN  D
 . S II=II+1,@DATA@(II)=^BQI(90508,STIEN,17,IEN,0)
 S @DATA@(II)=@DATA@(II)_$C(30)
 S II=II+1,@DATA@(II)=$C(31)
 Q