AMERP ; GENERATED FROM 'AMER BRIEF' PRINT TEMPLATE (#3423) ; 06/24/09 ; (FILE 9009080, MARGIN=79)
G BEGIN
N W !
T W:$X ! I '$D(DIOT(2)),DN,$D(IOSL),$S('$D(DIWF):1,$P(DIWF,"B",2):$P(DIWF,"B",2),1:1)+$Y'<IOSL,$D(^UTILITY($J,1))#2,^(1)?1U1P1E.E X ^(1)
S DISTP=DISTP+1,DILCT=DILCT+1 D:'(DISTP#100) CSTP^DIO2
Q
DT I $G(DUZ("LANG"))>1,Y W $$OUT^DIALOGU(Y,"DD") Q
I Y W $P("JAN^FEB^MAR^APR^MAY^JUN^JUL^AUG^SEP^OCT^NOV^DEC",U,$E(Y,4,5))_" " W:Y#100 $J(Y#100\1,2)_"," W Y\10000+1700 W:Y#1 " "_$E(Y_0,9,10)_":"_$E(Y_"000",11,12) Q
W Y Q
M D @DIXX
Q
BEGIN ;
S:'$D(DN) DN=1 S DISTP=$G(DISTP),DILCT=$G(DILCT)
I $D(DXS)<9 M DXS=^DIPT(3423,"DXS")
S I(0)="^AMERVSIT(",J(0)=9009080
D N:$X>0 Q:'DN W ?0 S DIP(1)=$S($D(^AMERVSIT(D0,0)):^(0),1:"") S X=$P(DIP(1),U,1) S:X X=$E(X,4,5)_"/"_$E(X,6,7)_"/"_$E(X,2,3) K DIP K:DN Y W $E(X,1,8)
D N:$X>9 Q:'DN W ?9 X DXS(1,9.2) S X=$E($P(X,".",2)_"0000",1,4),%=X>1159 S:X>1259 X=X-1200 S X=X\100_":"_$E(X#100+100,2,3)_" "_$E("AP",%+1)_"M" K DIP K:DN Y W $E(X,1,8)
S X=$G(^AMERVSIT(D0,0)) D N:$X>18 Q:'DN W ?18 S Y=$P(X,U,2) S Y=$S(Y="":Y,$D(^AUPNPAT(Y,0))#2:$P(^(0),U),1:Y) S Y=$S(Y="":Y,$D(^DPT(Y,0))#2:$P(^(0),U),1:Y) W $E(Y,1,14)
D N:$X>33 Q:'DN W ?33,$E($P(X,U,13),1,6)
D N:$X>40 Q:'DN W ?40 S DIP(1)=$S($D(^AMERVSIT(D0,0)):^(0),1:"") S X=$P(DIP(1),U,12) S:X X=$E(X,4,5)_"/"_$E(X,6,7)_"/"_$E(X,2,3) K DIP K:DN Y W $E(X,1,8)
D N:$X>49 Q:'DN W ?49 X DXS(2,9.3) S X=X_Y K DIP K:DN Y W $E(X,1,12)
S X=$G(^AMERVSIT(D0,5.1)) D N:$X>62 Q:'DN W ?62,$E($P(X,U,3),1,16)
K Y
Q
HEAD ;
W !,?62,"PRIMARY DX"
W !,?0,"DATE",?9,"TIME",?18,"PATIENT",?33,"CHART",?40,"DOB",?49,"PHYSICIAN",?62,"NARRATIVE"
W !,"-------------------------------------------------------------------------------",!!
AMERP ; GENERATED FROM 'AMER BRIEF' PRINT TEMPLATE (#3423) ; 06/24/09 ; (FILE 9009080, MARGIN=79)
+1 GOTO BEGIN
N WRITE !
T IF $X
WRITE !
IF '$DATA(DIOT(2))
IF DN
IF $DATA(IOSL)
IF $SELECT('$DATA(DIWF):1,$PIECE(DIWF,"B",2):$PIECE(DIWF,"B",2),1:1)+$Y'<IOSL
IF $DATA(^UTILITY($JOB,1))#2
IF ^(1)?1U1P1E.E
XECUTE ^(1)
+1 SET DISTP=DISTP+1
SET DILCT=DILCT+1
IF '(DISTP#100)
DO CSTP^DIO2
+2 QUIT
DT IF $GET(DUZ("LANG"))>1
IF Y
WRITE $$OUT^DIALOGU(Y,"DD")
QUIT
+1 IF Y
WRITE $PIECE("JAN^FEB^MAR^APR^MAY^JUN^JUL^AUG^SEP^OCT^NOV^DEC",U,$EXTRACT(Y,4,5))_" "
IF Y#100
WRITE $JUSTIFY(Y#100\1,2)_","
WRITE Y\10000+1700
IF Y#1
WRITE " "_$EXTRACT(Y_0,9,10)_":"_$EXTRACT(Y_"000",11,12)
QUIT
+2 WRITE Y
QUIT
M DO @DIXX
+1 QUIT
BEGIN ;
+1 IF '$DATA(DN)
SET DN=1
SET DISTP=$GET(DISTP)
SET DILCT=$GET(DILCT)
+2 IF $DATA(DXS)<9
MERGE DXS=^DIPT(3423,"DXS")
+3 SET I(0)="^AMERVSIT("
SET J(0)=9009080
+4 IF $X>0
DO N
IF 'DN
QUIT
WRITE ?0
SET DIP(1)=$SELECT($DATA(^AMERVSIT(D0,0)):^(0),1:"")
SET X=$PIECE(DIP(1),U,1)
IF X
SET X=$EXTRACT(X,4,5)_"/"_$EXTRACT(X,6,7)_"/"_$EXTRACT(X,2,3)
KILL DIP
IF DN
KILL Y
WRITE $EXTRACT(X,1,8)
+5 IF $X>9
DO N
IF 'DN
QUIT
WRITE ?9
XECUTE DXS(1,9.2)
SET X=$EXTRACT($PIECE(X,".",2)_"0000",1,4)
SET %=X>1159
IF X>1259
SET X=X-1200
SET X=X\100_":"_$EXTRACT(X#100+100,2,3)_" "_$EXTRACT("AP",%+1)_"M"
KILL DIP
IF DN
KILL Y
WRITE $EXTRACT(X,1,8)
+6 SET X=$GET(^AMERVSIT(D0,0))
IF $X>18
DO N
IF 'DN
QUIT
WRITE ?18
SET Y=$PIECE(X,U,2)
SET Y=$SELECT(Y="":Y,$DATA(^AUPNPAT(Y,0))#2:$PIECE(^(0),U),1:Y)
SET Y=$SELECT(Y="":Y,$DATA(^DPT(Y,0))#2:$PIECE(^(0),U),1:Y)
WRITE $EXTRACT(Y,1,14)
+7 IF $X>33
DO N
IF 'DN
QUIT
WRITE ?33,$EXTRACT($PIECE(X,U,13),1,6)
+8 IF $X>40
DO N
IF 'DN
QUIT
WRITE ?40
SET DIP(1)=$SELECT($DATA(^AMERVSIT(D0,0)):^(0),1:"")
SET X=$PIECE(DIP(1),U,12)
IF X
SET X=$EXTRACT(X,4,5)_"/"_$EXTRACT(X,6,7)_"/"_$EXTRACT(X,2,3)
KILL DIP
IF DN
KILL Y
WRITE $EXTRACT(X,1,8)
+9 IF $X>49
DO N
IF 'DN
QUIT
WRITE ?49
XECUTE DXS(2,9.3)
SET X=X_Y
KILL DIP
IF DN
KILL Y
WRITE $EXTRACT(X,1,12)
+10 SET X=$GET(^AMERVSIT(D0,5.1))
IF $X>62
DO N
IF 'DN
QUIT
WRITE ?62,$EXTRACT($PIECE(X,U,3),1,16)
+11 KILL Y
+12 QUIT
HEAD ;
+1 WRITE !,?62,"PRIMARY DX"
+2 WRITE !,?0,"DATE",?9,"TIME",?18,"PATIENT",?33,"CHART",?40,"DOB",?49,"PHYSICIAN",?62,"NARRATIVE"
+3 WRITE !,"-------------------------------------------------------------------------------",!!