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

AGCARD.m

Go to the documentation of this file.
AGCARD ; IHS/ASDS/EFG - EMBOSSED CARD ;   
 ;;7.1;PATIENT REGISTRATION;**4,11**;AUG 25,2005;Build 1
 ;IHS/OIT/NKD AG*7.1*11 MU2 UNKNOWN SEX
 D PTLK^AG
DFN ;EP - With a Pre-defined DFN.
 Q:'$D(DFN)!$D(DUOUT)!$D(DFOUT)!$D(DTOUT)
 I $E($P($G(^AUPNPAT(DFN,41,DUZ(2),0)),U,2))="T" D  Q
 . W !,"EMBOSSED CARD CANNOT BE PRINTED DUE TO TEMPORARY CHART NUMBER"
 . D END
 G COPIES:AGOPT(19)="Y"
 D ^AGDATCK S:'$D(AGV("DTOT")) AGV("DTOT")=0
 G COPIES:AGV("DTOT")=0
 F AG=8,9 I $D(AGV("ER",AG)) S AGV("DTOT")=AGV("DTOT")-1
 I AGOPT(14)'="Y",$D(AGV("ER",12)) S AGV("DTOT")=AGV("DTOT")-1
 G PRERR:AGV("DTOT")>0
COPIES W !!!,"How many copies of the EMBOSSED CARD do you want? (1-5) 1// "
 D READ^AG S:$D(DLOUT) Y=1 Q:Y=""
 I +Y<1!(+Y>5) W !!,*7,"Enter a number from 1 through 5.",!! G COPIES
 S AGCOPY=+Y
DEV S %ZIS="OPQ" D ^%ZIS I POP S IOP=ION D ^%ZIS Q
 G:'$D(IO("Q")) START K IO("Q")
 I $D(IO("S"))!($E(IOST)'="P") W *7,!,"Please queue to system printers." D ^%ZISC G DEV
 X ^%ZOSF("UCI") S ZTRTN="START^AGCARD",ZTUCI=Y,ZTDESC="Embossed Card for "_$P($G(^DPT(DFN,0)),U)_"." F G="AGCOPY","DFN" S ZTSAVE(G)=""
 D ^%ZTLOAD G:'$D(ZTSK) DEV K AG,AGCOPY,G,ZTDESC,ZTRTN,ZTSAVE,ZTSK,ZTUCI D ^%ZISC
 Q
PRERR W $$S^AGVDF("IOF")
 W "EMBOSSED CARD CANNOT BE PRINTED DUE TO MISSING or "
 W "INVALID MANDATORY DATA:",!!
 D ^AGBADATA
 G END
START ;EP - TaskMan.
 D:'$D(AGOPT) ^AGVAR G:AGOPT(19)="Y" PRINT
 S AGNAME=$E($P($G(^DPT(DFN,0)),U),1,28)
 S AGDOB=$P($G(^DPT(DFN,0)),U,3)
 S Y=AGDOB D DD^%DT
 S AGDOB=Y
 ;IHS/OIT/NKD AG*7.1*11 MU2 - ALLOW FOR PATIENTS WITH UNKNOWN SEX - DISPLAYS 'U'
 ;S AGSEX=$P($G(^DPT(DFN,0)),U,2),AGSEX=$S(AGSEX="F":2,1:1)
 S AGSEX=$$GET1^DIQ(2,DFN,.02,"I"),AGSEX=$S(AGSEX="F":2,AGSEX="M":1,AGSEX="U":"U",1:1)
 ;S AGSSN=$P($G(^DPT(DFN,0)),U,9)
 ;S:$L(AGSSN)=9 AGSSN=$E(AGSSN,1,3)_"-"_$E(AGSSN,4,5)_"-"_$E(AGSSN,6,9)
 S AGSSN=$$GET1^DIQ(9000001,DFN_",",1107.3)  ;IHS/SD/TPF AG*7.1*4
 S AGFAC=^AUTTLOC(DUZ(2),0),AGFAC=$S($P(AGFAC,U,2)]"":$P(AGFAC,U,2),1:$P($G(^DIC(4,DUZ(2),0)),U)),AGFAC=$E(AGFAC,1,28)
 S X=$P($G(^AUPNPAT(DFN,41,DUZ(2),0)),U,2) S:$L(X)<6 X=$E("000000",1,(6-$L(X)))_X S AGCHART=X
TRBCD I $E(AGCHART,1)="T" D  Q
 . I '$D(ZTQUEUED) D
 .. W !,"EMBOSSED CARD CANNOT BE PRINTED DUE TO TEMPORARY CHART NUMBER"
 . D END
 . Q
 S AG("TRBCODE")=$S(+$P($G(^AUPNPAT(DFN,11)),U,8):$P($G(^AUTTTRI(+$P($G(^AUPNPAT(DFN,11)),U,8),0)),U,2),1:"999"),AGTRQNT=$P($G(^AUPNPAT(DFN,11)),U,9)
 S AGBLDCD=$S(AGTRQNT="FULL":"001",AGTRQNT="NONE":"005",AGTRQNT="UNSPECIFIED":"006",AGTRQNT="UNKNOWN":"007",1:"000") D FRACT:AGBLDCD="000"&(AGTRQNT["/")
 S DIC=9000001.51,DA=DFN,DR=.03,AG("DRENT")=0 D ^AGDICLK S AGCOMCD="UNKNOWN" I $D(AG("LKDATA")),AG("LKDATA")]"",$D(^AUTTCOM(AG("LKDATA"),0)) S AGCOMCD=$P($G(^(0)),U,8),AGCOMCD=$E(AGCOMCD,5,8)_"-"_$E(AGCOMCD,3,4)_"-"_$E(AGCOMCD,1,2)
PRINT U IO F AG=1:1:AGCOPY W "<" D FORMPRT:AGOPT(19)="Y",CARDP:AGOPT(19)'="Y" W ">",@IOF
END D ^%ZISC
 K AG,AGDOB,AGSEX,AGSSN,AGBLDCD,AGCHART,AGCOMCD,AGCOPY,AGE("CPOS"),DA,DIC,DR,AGFAC,AGLINE,AGLINITM,AG("LKDATA"),AG("LKERR"),AG("LKPRINT"),AGMES,AGNAME,AGOPTRNS,AGV("SFN"),AGV("SFFN"),AG("TRBCODE"),AGTRQNT,X D:$D(ZTQUEUED) KILL^%ZTLOAD
 Q
CARDP ;Print an ID Card.
 W !!,AGFAC,!!,"(",AGCHART,")       ",AGSSN,!!,AGNAME,!,AGDOB,"   "
 W AGSEX,"  ",AG("TRBCODE"),"  ",AGBLDCD,!,"                  ",AGCOMCD
 Q
FRACT Q:+$P(AGTRQNT,"/",2)=0  S AG=$P(AGTRQNT,"/",1)/$P(AGTRQNT,"/",2)
 I AG'<1 S AGBLDCD="001" Q
 I AG'<.5 S AGBLDCD="002" Q
 I AG'<.25 S AGBLDCD="003" Q
 S AGBLDCD="004"
 Q
FORMPRT ;Use this code if the site selects to set their own card format.
 F AGLINE=0:0 S AGLINE=$O(^AGFAC(DUZ(2),99,AGLINE)) Q:'AGLINE  F AG("CHRPOS")=0:0 S AG("CHRPOS")=$O(^AGFAC(DUZ(2),99,AGLINE,1,AG("CHRPOS"))) W:'AG("CHRPOS") ! Q:'AG("CHRPOS")  D PRNTITEM
 K ^UTILITY("DIQ1",$J)
 Q
PRNTITEM K ^UTILITY("DIQ1",$J)
 K DR,DA,AGV,AGE
 S AGE("CPOS")=$P($G(^AGFAC(DUZ(2),99,AGLINE,1,AG("CHRPOS"),0)),U),AG0=$G(^(0)),AG2=$G(^(2)),DIC=$P($G(^(0)),U,2),DR=$P($G(^(0)),U,3),AGV("SFN")=$P($G(^(0)),U,4),AGV("SFFN")=$P($G(^(0)),U,5),AGE("MES1")=$P($G(^(0)),U,6),AGITPOTR="",DA=DFN
 Q:DA=""!(DIC="")!(DR="")
 S AGE("MES2")=$P(AG0,U,7),AGE("IEN1")=$P(AG2,U,2),AGE("IEN2")=$P(AG2,U,3)
 S DA=$S(AGE("MES1")="DUZ(2)":DUZ(2),AGE("MES1")="IEN1":AGE("IEN1"),1:DFN)
 I AGV("SFN")]"" S DR(AGV("SFN"))=AGV("SFFN"),DA(AGV("SFN"))=$S(AGE("MES2")="DUZ(2)":DUZ(2),AGE("MES2")="IEN2":AGE("IEN2"),1:DFN)
 I $D(^AGFAC(DUZ(2),99,AGLINE,1,AG("CHRPOS"),1)) S AGITPOTR=^(1)
 W ?AGE("CPOS") D EN^DIQ1 S:AGV("SFN")]"" DR=AGV("SFFN")
 I $G(AGV("SFN"))="",DIC["(" S DIC=+$P(@(DIC_"0)"),"^",2)
 I $G(AGV("SFN"))'="" S DIC=AGV("SFN"),DA=DA(AGV("SFN"))
 I $D(^UTILITY("DIQ1",$J,DIC,DA,DR)) S X=^(DR) X:AGITPOTR]"" AGITPOTR W X
 K AGE,DR,DA,AGV,AG0,AG2,AGITPOTR
 Q