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

AMHNAVRP.m

Go to the documentation of this file.
AMHNAVRP ; IHS/CMI/LAB - MENTAL HLTH ROUTINE ;
 ;;4.0;IHS BEHAVIORAL HEALTH;**5**;JUN 02, 2010;Build 18
 ;
 ;
 D PRINT1(AMHREF)
 Q
S(Y,F,C,T) ;set up array
 NEW %
 I '$G(F) S F=0
 I '$G(T) S T=0
 ;blank lines
 F F=1:1:F S X="" D S1
 S X=Y
 I $G(C) S L=$L(Y),T=(80-L)/2 D  D S1 Q
 .F %=1:1:(T-1) S X=" "_X
 F %=1:1:T S X=" "_Y
 D S1
 Q
S1 ;
 S %=$P(^TMP("AMHREF",$J,"DCS",0),U)+1,$P(^TMP("AMHREF",$J,"DCS",0),U)=%
 S ^TMP("AMHREF",$J,"DCS",%)=X
 Q
PRINT1(AMHREF) ;EP - CALLED FROM LAST VISIT DISPLAY
 NEW C,AMHX,H,AMHR0,AMHSTOP,AMHTC,AMHTDLT,AMHTDOO,AMHTF,AMHTICL,AMHTILN,AMHTNRQ,AMHTQ,AMHTTXT,F,AMHPAGE
 S AMHPAGE=1
 D EP2(AMHREF) ;set array up
 S AMHSTOP=0,AMHQUIT=0
W ;write out array
 NEW AMHX
 W !!
 S AMHX=0 F  S AMHX=$O(^TMP("AMHREF",$J,"DCS",AMHX)) Q:AMHX'=+AMHX!(AMHSTOP)!(AMHQUIT)  D
 .I $Y>(IOSL-5) D FF Q:AMHQUIT
 .W !,^TMP("AMHREF",$J,"DCS",AMHX)
 .Q
 W !
 K ^TMP("AMHREF",$J,"DCS")
 Q
EP2(AMHREF) ;EP ; up array in ^TMP
 ;
 K ^TMP("AMHREF",$J,"DCS")
 S ^TMP("AMHREF",$J,"DCS",0)=0
 S X="********** CONFIDENTIAL PATIENT INFORMATION **********" D S(X,0,1)
 S X="PSYCHIATRIC HOSPITALIZATION" D S(X,1,1)
 S X="REFERRAL FORM" D S(X,0,1)
 S X="BEHAVIORAL HEALTH COUNSELING SERVICES" D S(X,0,1)
 S X="Phone: (505) 722-1571" D S(X,0,1)
 ;
 S DFN=$P(^AMHRNRF(AMHREF,0),U,2)
 S AMHRIEN=$P(^AMHRNRF(AMHREF,0),U,3)
 S AMHR22=$G(^AMHRNRF(AMHREF,22))
 S AMHR0=^AMHRNRF(AMHREF,0)
 S AMHRDATE=$P(^AMHRNRF(AMHREF,0),U)
 S X="PATIENT NAME: "_$P(^DPT(DFN,0),U),$E(X,50)="GIMC Chart #: "_$$HRN^AUPNPAT(DFN,DUZ(2)) D S(X,2)
 S X="DOB: "_$$DOB^AUPNPAT(DFN,"E"),$E(X,25)="AGE: "_$$AGE^AUPNPAT(DFN,AMHRDATE),$E(X,50)="GENDER: "_$$VAL^XBDIQ1(2,DFN,.02) D S(X,1)
 S X="NOK: "_$$VAL^XBDIQ1(2,DFN,.211),$E(X,35)="RELATIONSHIP: "_$$VAL^XBDIQ1(9000001,DFN,2802)_"     Phone #: "_$$VAL^XBDIQ1(2,DFN,.219) D S(X,1)
 S X="ACCEPTING FACILITY: "_$E($P(^AMHRNRF(AMHREF,0),U,4),1,39),$E(X,60)="Phone: "_$P($G(^AMHRNRF(AMHREF,22)),U,30) D S(X,1)
 S X="ACCEPTING PHYSICIAN: "_$P(^AMHRNRF(AMHREF,0),U,5) D S(X,1)
 S X="CONTRACT CARE APPROVED BY: "_$$VAL^XBDIQ1(9002011.11,AMHREF,.06),$E(X,60)="CATEGORY: "_$$VAL^XBDIQ1(9002011.11,AMHREF,.08) D S(X,1)
 S X="TRANSPORTAION TO FACILITY BY: "_$P(^AMHRNRF(AMHREF,0),U,7) D S(X,1)
 S X="REFERRING PROVIDER: "_$$PPNAME^AMHUTIL(AMHRIEN) D S(X,1)
 S X="CPT CODE: " D S(X,1)
 S Y=0 F  S Y=$O(^AMHRPROC("AD",AMHRIEN,Y)) Q:Y'=+Y  S P=$P(^AMHRPROC(Y,0),U) S X=$P($$CPT^ICPTCOD(P,$P($P(^AMHREC(AMHRIEN,0),U),".")),U,2)_"  "_$P($$CPT^ICPTCOD(P,$P($P(^AMHREC(AMHRIEN,0),U),".")),U,3) D S(X)  ;CSV
POV ;
 S X="PURPOSE OF VISIT CODES: " D S(X,1)
 S (AMHX,C)=0 F  S AMHX=$O(^AMHRPRO("AD",AMHRIEN,AMHX)) Q:AMHX'=+AMHX  D
 .S AMHTNRQ="",$E(AMHTNRQ,1)=$P(^AMHPROB($P(^AMHRPRO(AMHX,0),U),0),U),$E(AMHTNRQ,16)=$P(^AMHPROB($P(^AMHRPRO(AMHX,0),U),0),U,2),AMHTICL=8,AMHTTXT="" D PRTTXT
 .S AMHTNRQ=$$GET1^DIQ(9002011.01,AMHX,.04),AMHTICL=23,AMHTTXT="" D
 ..I AMHTNRQ=$P(^AMHPROB($P(^AMHRPRO(AMHX,0),U),0),U,2) Q
 ..D PRTTXT
 .S C=C+2
 .Q
 ;F I=C:1:3 S X="" D S(X)
 S X="*     *     *     *     *     *     *     *     *     *     *     *     *" D S(X,1)
 S X="REASON FOR REFERRAL: "_$$VAL^XBDIQ1(9002011.11,AMHREF,.09) D S(X,1)
T ;
 S X="HISTORY OF PRESENT PROBLEM:" D S(X,1)
 S AMHX=0 F  S AMHX=$O(^AMHRNRF(AMHREF,81,AMHX)) Q:AMHX'=+AMHX  D
 .S X="",$E(X,2)=^AMHRNRF(AMHREF,81,AMHX,0) D S(X)
 .Q
CM ;
 S X="CURRENT MEDICATIONS:" D S(X,1)
 S AMHX=0 F  S AMHX=$O(^AMHRNRF(AMHREF,82,AMHX)) Q:AMHX'=+AMHX  D
 .S X="",$E(X,2)=^AMHRNRF(AMHREF,82,AMHX,0) D S(X)
 .Q
 S X="PATIENT'S/FAMILY'S PSYCHIATRIC HISTORY:" D S(X,1)
 S AMHX=0 F  S AMHX=$O(^AMHRNRF(AMHREF,83,AMHX)) Q:AMHX'=+AMHX  D
 .S X="",$E(X,2)=^AMHRNRF(AMHREF,83,AMHX,0) D S(X)
 .Q
 S X="PATIENT HAS BEEN MEDICALLY CLEARED: "_$$VAL^XBDIQ1(9002011.11,AMHREF,.11) D S(X,1)
 S X="CURRENT MEDICAL PROBLEMS:" D S(X,1)
 S AMHX=0 F  S AMHX=$O(^AMHRNRF(AMHREF,84,AMHX)) Q:AMHX'=+AMHX  D
 .S X="",$E(X,2)=^AMHRNRF(AMHREF,84,AMHX,0) D S(X)
 .Q
MSE ;mental status exam
 S X="MENTAL STATUS EXAM:" D S(X,1)
 S X="",$E(X,3)="APPEARANCE:  "_$$VAL^XBDIQ1(9002011.11,AMHREF,2201) D S(X)
 S X="",$E(X,3)="ATTITUDE TOWARDS EXAMINER:"
 S AMHX=0 F  S AMHX=$O(^AMHRNRF(AMHREF,41,AMHX)) Q:AMHX'=+AMHX  S Y=$P(^AMHRNRF(AMHREF,41,AMHX,0),U),X=X_"  "_$$EXTSET^XBFUNC(9002011.1141,.01,Y)
 D S(X)
 S X="",$E(X,3)="EYE CONTACT:  "_$$VAL^XBDIQ1(9002011.11,AMHREF,2203) D S(X)
 S X="",$E(X,3)="ORIENTATION - TIME:  "_$$VAL^XBDIQ1(9002011.11,AMHREF,2204) D S(X)
 S X="",$E(X,3)="ORIENTATION - PLACE:  "_$$VAL^XBDIQ1(9002011.11,AMHREF,2205) D S(X)
 S X="",$E(X,3)="ORIENTATION - PERSON:  "_$$VAL^XBDIQ1(9002011.11,AMHREF,2206) D S(X)
 S X="",$E(X,3)="ORIENTATION - SITUATION:  "_$$VAL^XBDIQ1(9002011.11,AMHREF,2207) D S(X)
 S X="",$E(X,3)="CONCENTRATION:  "_$$VAL^XBDIQ1(9002011.11,AMHREF,2208) D S(X)
MA S X="",$E(X,3)="MOTOR ACTIVITY:"
 S AMHX=0 F  S AMHX=$O(^AMHRNRF(AMHREF,42,AMHX)) Q:AMHX'=+AMHX  S Y=$P(^AMHRNRF(AMHREF,42,AMHX,0),U),X=X_"  "_$$EXTSET^XBFUNC(9002011.1142,.01,Y)
 D S(X)
 S X="",$E(X,3)="SPEECH:"
 S AMHX=0 F  S AMHX=$O(^AMHRNRF(AMHREF,43,AMHX)) Q:AMHX'=+AMHX  S Y=$P(^AMHRNRF(AMHREF,43,AMHX,0),U),X=X_"  "_$$EXTSET^XBFUNC(9002011.1143,.01,Y)
 D S(X)
 S X="",$E(X,3)="AFFECT:  "_$$VAL^XBDIQ1(9002011.11,AMHREF,2211) D S(X)
 S X="",$E(X,3)="MOOD:"
 S AMHX=0 F  S AMHX=$O(^AMHRNRF(AMHREF,44,AMHX)) Q:AMHX'=+AMHX  S Y=$P(^AMHRNRF(AMHREF,44,AMHX,0),U),X=X_"  "_$$EXTSET^XBFUNC(9002011.1144,.01,Y)
 D S(X)
 S X="",$E(X,3)="THOUGHT PROCESS:  "_$$VAL^XBDIQ1(9002011.11,AMHREF,2201) D S(X)
 S X="",$E(X,3)="CONTENT:" S AMHC=0
 S AMHX=0 F  S AMHX=$O(^AMHRNRF(AMHREF,45,AMHX)) Q:AMHX'=+AMHX!(AMHC>2)  S X=X_"  "_$P(^AMHTREFC($P(^AMHRNRF(AMHREF,45,AMHX,0),U,1),0),U) S AMHC=AMHC+1
 D S(X)
 S X="" I $O(^AMHRNRF(AMHREF,45,AMHX)) D
 .S X="",$E(X,5)=" " F  S AMHX=$O(^AMHRNRF(AMHREF,45,AMHX)) Q:AMHX'=+AMHX  S X=X_"  "_$P(^AMHTREFC($P(^AMHRNRF(AMHREF,45,AMHX,0),U,1),0),U)
 .S X="     "_X D S(X)
 S X="",$E(X,3)="PERCEPTION:  "_$$VAL^XBDIQ1(9002011.11,AMHREF,2201) D S(X)
 S X="",$E(X,3)="MEMORY - RECENT:  "_$$VAL^XBDIQ1(9002011.11,AMHREF,2214) D S(X)
 S X="",$E(X,3)="MEMORY - REMOTE:  "_$$VAL^XBDIQ1(9002011.11,AMHREF,2215) D S(X)
 S X="",$E(X,3)="JUDGMENT  "_$$VAL^XBDIQ1(9002011.11,AMHREF,2216) D S(X)
 S X="",$E(X,3)="INSIGHT:  "_$$VAL^XBDIQ1(9002011.11,AMHREF,2217) D S(X)
 S X="",$E(X,3)="IMPULSE CONTROL:  "_$$VAL^XBDIQ1(9002011.11,AMHREF,2218) D S(X)
 F AMHF=2219:1:2226 S X="",$E(X,3)=$P(^DD(9002011.11,AMHF,0),U)_":  "_$$VAL^XBDIQ1(9002011.11,AMHREF,AMHF) D S(X)
DS ;
 S X="DIAGNOSTIC SUMMARY:" D S(X,1)
 S X="AXIS I" D S(X,1)
 S AMHX=0 F  S AMHX=$O(^AMHRNRF(AMHREF,85,AMHX)) Q:AMHX'=+AMHX  D
 .S X="",$E(X,2)=^AMHRNRF(AMHREF,85,AMHX,0) D S(X,1)
 S X="AXIS II" D S(X,1)
 S AMHX=0 F  S AMHX=$O(^AMHRNRF(AMHREF,86,AMHX)) Q:AMHX'=+AMHX  D
 .S X="",$E(X,2)=^AMHRNRF(AMHREF,86,AMHX,0) D S(X,1)
 S X="AXIS III" D S(X,1)
 S AMHX=0 F  S AMHX=$O(^AMHRNRF(AMHREF,87,AMHX)) Q:AMHX'=+AMHX  D
 .S X="",$E(X,2)=^AMHRNRF(AMHREF,87,AMHX,0) D S(X,1)
A4 ;AXIS IV/V
 I $O(^AMHREC(AMHRIEN,61,0))!($P(^AMHREC(AMHRIEN,0),U,14)]"") D
 .S X="",$E(X,3)="AXIS IV:  " S Y=0 F  S Y=$O(^AMHREC(AMHRIEN,61,Y)) Q:Y'=+Y  S I=$P(^AMHREC(AMHRIEN,61,Y,0),U) S $E(X,14)=$P(^AMHTAXIV(I,0),U)_" - "_$P(^AMHTAXIV(I,0),U,2) D S(X) S X=""
 .S X="",$E(X,3)="AXIS V:  "_$P(^AMHREC(AMHRIEN,0),U,14) D S(X)
 .Q
 S X="TREATMENT REQUESTS/RECOMMENDATIONS:" D S(X,2)
 S AMHX=0 F  S AMHX=$O(^AMHRNRF(AMHREF,88,AMHX)) Q:AMHX'=+AMHX  D
 .S X="",$E(X,2)=^AMHRNRF(AMHREF,88,AMHX,0) D S(X)
 S X="REFERRING PROVIDER'S SIGNATURE:  __________________________________________" D S(X,5)
 S X="                          DATE:  ___________________________" D S(X,2)
 Q
PRTTXT ; GENERALIZED TEXT PRINTER
 S AMHTDLT=1,AMHTILN=80-AMHTICL-1
 F AMHTQ=0:0 S:AMHTNRQ]""&(($L(AMHTNRQ)+$L(AMHTTXT)+2)<255) AMHTTXT=$S(AMHTTXT]"":AMHTTXT_"; ",1:"")_AMHTNRQ,AMHTNRQ="" Q:AMHTTXT=""  D PRTTXT2
 K AMHTILN,AMHTDLT,AMHTF,AMHTC,AMHTTXT,AMHTDOO
 Q
PRTTXT2 D GETFRAG S X="",$E(X,AMHTICL)=AMHTF D S(X) S AMHTICL=AMHTICL+AMHTDLT,AMHTILN=AMHTILN-AMHTDLT,AMHTDLT=0
 Q
GETFRAG I $L(AMHTTXT)<AMHTILN S AMHTF=AMHTTXT,AMHTTXT="" Q
 F AMHTC=AMHTILN:-1:1 Q:$E(AMHTTXT,AMHTC)=" "
 S AMHTF=$E(AMHTTXT,1,AMHTC-1),AMHTTXT=$E(AMHTTXT,AMHTC+1,255)
 Q
 ;
CTR(X,Y) ;EP - Center X in a field Y wide.
 Q $J("",$S($D(Y):Y,1:IOM)-$L(X)\2)_X
 ;----------
FF ;EP
 I $E(IOST)="C",IO=IO(0) W ! S DIR(0)="EO" D ^DIR K DIR I Y=0!(Y="^")!($D(DTOUT)) S AMHQUIT=1 Q
 ;I $E(IOST)'="C" Q:'DFN  W !!,$TR($J(" ",79)," ","*"),!,$E($P(^DPT(DFN,0),U),1,25),?27,"HRN: " D
 ;.S H=$P($G(^AUPNPAT(DFN,41,DUZ(2),0)),U,2)
 ;.W H,?38,"DOB: ",$$FMTE^XLFDT($P(^DPT(DFN,0),U,3),"2D"),?52,"SSN: ",$P(^DPT(DFN,0),U,9),?67,$$FMTE^XLFDT($P($P(AMHR0,U),"."))
 W:$D(IOF) @IOF W !! S AMHPAGE=AMHPAGE+1 W ?48,$$FMTE^XLFDT($P(AMHR0,U)),?72,"Page "_AMHPAGE,!
 W $$CTR("PSYCHIATRIC HOSPITALIZATION REFERRAL FORM",80),!
 W $$CTR("BEHAVIORAL HEALTH COUNSELING SERVICES",80),!
 W $$CTR("Phone: (505) 722-1571",80),!
 Q