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

ACHSTX55.m

Go to the documentation of this file.
ACHSTX55 ; IHS/ADC/GTH - EXPORT DATA (6/9) - RECORD 5(DOCUMENT FOR AO/FI) ;  
 ;;3.1;CONTRACT HEALTH MGMT SYSTEM;;JUN 11, 2001
 ;
 ;
 ;we can be 638, or have parm 2,9 set, but not both
 I ACHSF638="Y",(ACHSF209) S RET=2 Q
 I ACHSTY="P" S RET=3 Q
 I 'ACHSF211 S RET=4 Q
 ;
 S ACHSFAC=ACHSAFAC,ACHSREFT=" "
 ;
 S:$D(^ACHSF(DUZ(2),"D",ACHSDIEN,3)) ACHSREFT=$P(^ACHSF(DUZ(2),"D",ACHSDIEN,3),U,10)
 S ACHSREFT=$E(" "_ACHSREFT_" ",1,2),(ACHSEDOS,ACHSFRDT,ACHSTODT)=$J(" ",6)
 S (ACHSEDOS("5C"),ACHSFRDT("5C"),ACHSTODT("5C"))=$J(" ",8)
 G C3:'$D(^ACHSF(DUZ(2),"D",ACHSDIEN,3))
 S X=^ACHSF(DUZ(2),"D",ACHSDIEN,3)
 ;
 S:+$P(X,U,9)>0 ACHSEDOS=$E($P(X,U,9),2,7),ACHSEDOS("5C")=17000000+$P(X,U,9)
 S:+$P(X,U,1)>0 ACHSFRDT=$E($P(X,U,1),2,7),ACHSFRDT("5C")=17000000+$P(X,U,1)
 S:+$P(X,U,2)>0 ACHSTODT=$E($P(X,U,2),2,7),ACHSTODT("5C")=17000000+$P(X,U,2)
C3 ;
 S ACHSBIND=$S(BLNKT=1:"Y",BLNKT=0:"N",BLNKT:" ")
 ;
 I +CHART>0 S ACHSHRN=CHART G C5
 ;
 S X=$P(ACHSTRAN,U,3)
 I +X<1 S ACHSHRN="" G C5
 ;
 S ACHSHRN=$$HRN^ACHS(X,DUZ(2))
 ;
C5 ;
 S ACHSHRN=$E(ACHSHRN+1000000,2,7)
 ;
 D SETCN S ACHSCN=$E(ACHSCN_$J("",10),1,10)
 ;
C6 ;
 S (X,ACHSTYPE)=$P(ACHSTRAN,U,2)
 S:'$L(X) X=" "
 S ACHSSTS=X_" "
 I ACHSSTS="C " S X=$P(ACHSDOCR,U,12),ACHSSTS=$E(ACHSSTS)_$S((X=2)!(X=3):"P",X=4:"A",1:" ")
 D IPA^ACHSTX8
 S ACHSIPA=$E(ACHSIPA,5,12)
 I ACHSTYPE="C" S ACHSIPA="-"_$E(ACHSIPA,2,8)
 S ACHSESDA=$G(^ACHSF(DUZ(2),"D",ACHSDIEN,1)),ACHSESDA=$E(1000+ACHSESDA,2,4),ACHSRCT=ACHSRCT+1,ACHSRTYP(5)=ACHSRTYP(5)+1
 ;
 S VNDEINSX=VNDEINSF I VNDEINSX="" S VNDEINSX="  "
 ;
 S ^ACHSTXOB(ACHSRCT)="5A"_ACHSDOCN_TYPSER2_ACHSAFAC_ACHSBIND_VNDEIN_VNDEINSX_ACHSHRN_ACHSCN_CAN_OCC_$E(ORDDAT,2,7)_ACHSSTS_ACHSIPA_ACHSESDA_VNDFNFC
 ;
 S PMFF=^ACHSTXOB(ACHSRCT) D ^ACHSTX99
 ;
C7 ; Build Patient name & 3rd party info for 5B record.
 S ACHSRCT=ACHSRCT+1,ACHSRTYP(5)=ACHSRTYP(5)+1
 D ADD5B
 ;
 S ^ACHSTXOB(ACHSRCT)="5B"_ACHSREFT_ACHSEDOS_ACHSFRDT_ACHSTODT_ACHSPATN_ACHS5IN1_ACHS5IN2_TRIBE_ACHSCOMM
 ;
 S PMFF=^ACHSTXOB(ACHSRCT) D ^ACHSTX99
 ;
 S ACHSRCT=ACHSRCT+1,ACHSRTYP(5)=ACHSRTYP(5)+1
 S ^ACHSTXOB(ACHSRCT)="5C"_SCC_($P(ACHSDOCR,U,2)+17000000)_ACHSEDOS("5C")_ACHSFRDT("5C")_ACHSTODT("5C")_$J("",42)
 ;
 S PMFF=^ACHSTXOB(ACHSRCT) D ^ACHSTX99
 Q
 ;
ADD5B ; Add Patient Name & Ins info to 5B record.
 S ACHSPATN=$J(" ",16),ACHSCOMM=$J(" ",7)
 I +PATNUM<1 G ADD5B2
ADD5B1 ; 
 S:$D(^DPT(DFN)) ACHSPATN=$E($P(^DPT(DFN,0),U,1)_$J(" ",16),1,16)
 S ACHSCOMM=$J(" ",7)
 I $P(^AUPNPAT(DFN,11),U,18)]"",$D(^AUTTCOM("B",$P(^(11),U,18))) S ACHSCOMM=$P(^AUTTCOM($O(^AUTTCOM("B",$P(^AUPNPAT(DFN,11),U,18),0)),0),U,8),ACHSCOMM=$E(ACHSCOMM,5,7)_$E(ACHSCOMM,3,4)_$E(ACHSCOMM,1,2)
ADD5B2 ;
 KILL ACHS3C,ACHS5IN1,ACHS5IN2,ACHSX18,ACHSX19
 S ACHSZZI=1,(ACHSX18,ACHSX19,ACHSDEST,ACHS5IN1,ACHS5IN2)="",ACHSR=DFN,ACHS3CFL=0
 ;
 D ^ACHSTX3C:+DFN>0
 ;
ADD5BA ;
 G ADD5BZ:ACHSZZI>ACHS3CFL
 S X=ACHS3C(ACHSZZI)
 S:$E(X,3,10)="MEDICARE" ACHSX18=ACHSX18_$E(X,64,64)_" ",ACHSX18(18)=ACHSZZI
 S:$E(X,3,10)="MEDICAID" ACHSX19=ACHSX19_$E(X,48,49)_" ",ACHSX19(19)=ACHSZZI
 I '$D(ACHSX18(18)) S ACHS5IN1=$E(X,3,22),ACHSX18(18)=ACHSZZI G ADD5BC
 S:'$D(ACHSX19(19)) ACHS5IN2=$E(X,3,22),ACHSX19(19)=ACHSZZI
ADD5BC ;
 S ACHSZZI=ACHSZZI+1
 G ADD5BA
 ;
ADD5BZ ; Write 5B new parts.
 S:ACHSX18'="" ACHS5IN1=$E(ACHS3C(ACHSX18(18)),3,10)_" "_ACHSX18
 S:ACHSX19'="" ACHS5IN2=$E(ACHS3C(ACHSX19(19)),3,10)_" "_ACHSX19
 S ACHS5IN1=$E(ACHS5IN1_$J(" ",16),1,16),ACHS5IN2=$E(ACHS5IN2_$J(" ",16),1,16)
 KILL ACHSZZI
 S RET=0
 Q
 ;
SETCN ;
 ;set the contract number into ACHSCN.  this is complicated.
 ;If there is a contract pointer on this PO, then
 ;  get the contract info from the vendor file and
 ;  extract the numbers.
 ;  If the numbers are found on a certain list, then
 ;    use that number for ACHSCN
 ;  else
 ;    concatenate those numbers onto the ASUFAC, and use that
 ;  endif
 ;else
 ;  if there is an agreement number on this PO, then
 ;    get THAT info from the vendor file.  Concatenate
 ;    it onto the ASUFAC, and use that for ACHSCN
 ;else
 ;  use OM for ACHSCN
 ;endif
 ;fill ACHSCN with blanks to a length of 10
 ;
 ;
 S ACHSCN=""
 I +CNTRPTR,$G(^AUTTVNDR(VNDPTR,"CN",CNTRPTR,0))'="" D  Q
 . S ACHSCN=$P(^AUTTVNDR(VNDPTR,"CN",CNTRPTR,0),U,1),Z=""
 . F ACHSI=1:1:$L(ACHSCN) I $E(ACHSCN,ACHSI)?1N S Z=Z_$E(ACHSCN,ACHSI)
 . I $F("235^239^241^242^243^244^245^246^247^248^249^285",$E(Z,1,3)) S ACHSCN=Z Q
 . S ACHSCN=ACHSARCO_Z
 . Q
 ;
 I +VNAGPTR,$G(^AUTTVNDR(VNDPTR,18,VNAGPTR,0)) D  Q
 . S Y=^AUTTVNDR(VNDPTR,18,VNAGPTR,0),Z=$P(Y,U,10),W=$E($P(Y,U,1),1,2)_$S(Z="PA":"PA",Z="RQ":"R",Z="BPA":"A",1:""),X=$E($P(Y,U,1),3,6)
 . S:Z'="PA" W=W_$E(X,1,4)
 . S:Z="PA" W=W_$E(X,2,4)
 . S ACHSCN=$E(ACHSARCO_W_$J("",10),1,10)
 . Q
 ;
 S ACHSCN="OM"
 Q
 ;