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

ABSPOSP.m

Go to the documentation of this file.
ABSPOSP ; IHS/FCS/DRS - Pharm POS pay/adj batches ;    [ 09/12/2002  10:17 AM ]
 ;;1.0;PHARMACY POINT OF SALE;**3,48**;JUN 21, 2001;Build 38
 ; main entry points and some callable utilities are in here
 Q
TEST ;
 W "Test NEWBATCH: "
 S BATCH=$$NEWBATCH
 W BATCH,! Q:'BATCH
 W "Test GETPMT: ",$$GETPMT(BATCH),!
 W "Test ADDPMT: ",$$ADDPMT(BATCH,100),!
 W "Test ADDPMT: ",$$ADDPMT(BATCH,25.41),! ; should be 125.41
 W "Test GETPMT: ",$$GETPMT(BATCH),!
 Q
NEWBATCH(ECHO) ;EP - create a new batch
 I '$G(ECHO) S ECHO=1
 N FDA,IEN,MSG,FN S FN=9001625.1 ; PAYMENT BATCH file
 N X S X="+1,"
 S FDA(FN,X,.01)=$P(^ABSBPMNT(0),U,3)+1 ; HEADER CONTROL NUMBER
 S FDA(FN,X,.02)=DT ; DATE CREATED
 S FDA(FN,X,.03)=DUZ ; CREATED BY
 S FDA(FN,X,.04)=0 ; PAYMENT CONTROL TOTAL
 S FDA(FN,X,.05)="A" ; active
 S FDA(FN,X,.045)=0 ; CONTRACTUAL ALLOWANCE CONTROL
 S FDA(FN,X,.08)=DT ; DEPOSIT DATE
 D UPDATE^DIE("S","FDA","IEN","MSG")
 I $D(MSG) D LOG^ABSPOSL2("NEWBATCH^ABSPOSP",.MSG) ; /IHS/OIT/RAM ; 12 JUN 17 ; AND LOG IT IF AN ERROR OCCURS.
 I $D(MSG),$G(ECHO) D
 . W "Failed to create the batch!",!
 . D ZWRITE^ABSPOS("MSG")
 . W !
 . D PRESSANY
 Q $G(IEN(1))
PAYMENT(PCNDFN,BATCH,AMOUNT,INSDFN,DEPDATE,RECEIPT,CHECKNUM) ;EP - store a pmt
 D ADDPMT(BATCH,AMOUNT)
 I '$D(RECEIPT) S RECEIPT="EOB"
 I '$D(CHECKNUM) S CHECKNUM=""
 N N S N=$O(^ABSTMP(BATCH,"PMT",PCNDFN,""),-1)+1
 N X S X=AMOUNT_U_INSDFN_U_$P(^AUTNINS(INSDFN,0),U)_U_DEPDATE
 S X=X_U_BATCH_U_RECEIPT_U_CHECKNUM
 S ^ABSTMP(BATCH,"PMT",PCNDFN,N)=X
 S ^ABSTMP(BATCH,"TOT",PCNDFN)=$G(^ABSTMP(BATCH,"TOT",PCNDFN))+AMOUNT
 S ^ABSTMP(BATCH,"PTOT")=$G(^ABSTMP(BATCH,"PTOT"))+AMOUNT
 Q
ADJUST(PCNDFN,BATCH,AMOUNT,REASON) ;EP - store an adjustment
 D ADDADJ(BATCH,AMOUNT) ; add to batch totals
 N N S N=$O(^ABSTMP(BATCH,"ADJ",PCNDFN,""),-1)+1
 N X S X=AMOUNT_U_REASON_U_$$GETAMT(BATCH,.08)_U_BATCH
 S ^ABSTMP(BATCH,"ADJ",PCNDFN,N)=X
 S ^ABSTMP(BATCH,"TOT",PCNDFN)=$G(^ABSTMP(BATCH,"TOT",PCNDFN))+AMOUNT
 Q
GETPMT(BATCH)      Q $$GETAMT(BATCH,.04) ; get PAYMENT CONTROL TOTAL
ADDPMT(BATCH,AMT)      ;
 S X=$$ADDAMT(BATCH,AMT,.04)
 Q:$Q X Q
GETADJ(BATCH)      Q $$GETAMT(BATCH,.045) ; get CONTRACTUAL ALLOWANCE CONTROL
ADDADJ(BATCH,AMT)     ; 
 N X S X=$$ADDAMT(BATCH,AMT,.045)
 Q:$Q X Q
GETAMT(BATCH,FIELD)          ; actually, it works for any field in this file
 N FDA,IEN,MSG,FN S FN=9001625.1
 S X=$$GET1^DIQ(FN,BATCH,FIELD,,,"MSG")
 I $D(MSG) D ZWRITE^ABSPOS("BATCH","FIELD","MSG"),IMPOSS^ABSPOSUE("FM","TI","$$GET1^DIQ failed",,"GETAMT",$T(+0))
 Q X
ADDAMT(BATCH,AMT,FIELD)        ; add to the adjustment total ; either $$ or not
 N X S X=$$GETAMT(BATCH,FIELD)
 S X=$$SETAMT(BATCH,X+AMT,FIELD)
 Q:$Q X Q
SETAMT(BATCH,AMT,FIELD) ;EP - store the adjustment total ; either $$ or not
 N FDA,IEN,MSG,FN S FN=9001625.1    ;; /IHS/OIT/RAM ; ANOTHER FM FILE THAT DOESN'T EXIST IN (AT LEAST) THE TRAINING DATABASES...
 S FDA(FN,BATCH_",",FIELD)=AMT
 D SETAMT1
 Q:$Q AMT Q
SETAMT1 ;
 D FILE^DIE("K","FDA","MSG")
 I $D(MSG) D LOG^ABSPOSL2("SETAMT1^ABSPOSP",.MSG) ; /IHS/OIT/RAM ; 12 JUN 17 ; AND LOG IT IF AN ERROR OCCURS.
 Q:'$D(MSG)  ; success
 D ZWRITE^ABSPOS("FN","BATCH","FIELD","MSG")
 I $$IMPOSS^ABSPOSUE("FM","TRI","FILE^DIE failed",,"SETAMT1",$T(+0))
 Q
PRESSANY D PRESSANY^ABSPOSU5(0,300) Q