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

GMTSPN.m

Go to the documentation of this file.
GMTSPN ; SLC/KER - Progress Note                     ; 5/17/06 2:06pm
 ;;2.7;Health Summary;**12,28,33,35,45,47,49,55,81**;Oct 20, 1995;Build 23
 ;                          
 ; External References
 ;    DBIA  2902  VISIT^TIULAPIC
 ;    DBIA  2902  MAIN^TIULAPIC
 ;    DBIA 10006  ^DIC
 ;                        
PN ; Progress Note Health Summary Component
 N TIUSTAT,TIUTYPE,TIUNAM,DIC,TIUFPRIV,TIUXREF,GMTSTIUC,X,Y,GMTSREF
 S TIUFPRIV=1,TIUSTAT="ALL",TIUXREF="""APT""",GMTSTIUC="P",(TIUNAM,X)="PROGRESS NOTES"
 S DIC="^TIU(8925.1,",DIC(0)="X",DIC("S")="I $P($G(^(0)),U,4)=""CL"""
 D ^DIC K DIC("S") S:Y>0 TIUTYPE=+Y S GMTSREF="" D MAIN K GMTSREF
 Q
MAIN ; Control branching
 N ADATE,ADMIT,ASUB,ATDATE,ATTNDNG,ATTYPE,ATYPE,AUTHOR,CHILD,CONEED
 N COSAME,COSGEDBY,COSIG,CURIEN,DISCHG,GMTSA,GMTSAI,GMTSAII,GMTSCNT
 N GMTSD,GMTSDIC,GMTSEXSG,GMTSI,GMTSIEN,GMTSID,GMTSIDC,GMTSII,GMTSIQ
 N GMTSJ,GMTSK,GMTSODIC,GMTSPDIC,GMTSTDIC,GMTSPR,GMTSREC,GMTST,GMTSX
 N GMTSXTRA,I,PARIEN,PDATE,PN,PSUB,PTYPE,REASON,SIGNEDBY,STATUS,TSPEC
 N TYPE,X,Y
 K ^TMP("TIU",$J) S GMTSX=1 D EXTIU Q:'$D(^TMP("TIU",$J))  D PNOTE
 K ^TMP("TIU",$J),PN Q
 ;                      
 ; Progress Notes
 ; 
 ; ^TMP("TIU",$J,IDT,0)
 ; ^TMP("TIU",$J,IDT,IEN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EN,"TEXT",0)
 ; ^TMP("TIU",$J,IDT,#,IEN,"ZADD",IEN,"TEXT",#,0)
 ; ^TMP("TIU",$J,IDT,#,IEN,"ZZID",0)
 ; ^TMP("TIU",$J,IDT,#,IEN,"ZZID",#,IEN,FLD,"E")
 ; ^TMP("TIU",$J,IDT,#,IEN,"ZZID",#,IEN,FLD,"I")
 ; ^TMP("TIU",$J,IDT,#,IEN,"ZZID",#,IEN,"TEXT",0)
 ; ^TMP("TIU",$J,IDT,#,IEN,"ZZID",#,IEN,"TEXT",#,0)
 ; ^TMP("TIU",$J,IDT,#,IEN,"ZZID",#,IEN,"ZADD",IEN,FLD,"E")
 ; ^TMP("TIU",$J,IDT,#,IEN,"ZZID",#,IEN,"ZADD",IEN,FLD,"I")
 ; ^TMP("TIU",$J,IDT,#,IEN,"ZZID",#,IEN,"ZADD",IEN,"TEXT",0)
 ; ^TMP("TIU",$J,IDT,#,IEN,"ZZID",#,IEN,"ZADD",IEN,"TEXT",#,0)
 ;                           
PNOTE ; Progress Notes
 D CKP^GMTSUP Q:$D(GMTSQIT)  S GMTSD=0 F  S GMTSD=$O(^TMP("TIU",$J,GMTSD)) Q:+GMTSD=0  D
 . S GMTSODIC="^TMP(""TIU"","_$J_","_GMTSD_"," D NOTE
 Q:$D(GMTSQIT)  D CKP^GMTSUP Q:$D(GMTSQIT)  W ! Q
SNOTE ; Selected Progress Notes
 D CKP^GMTSUP Q:$D(GMTSQIT)  S GMTSD=0 F  S GMTSD=$O(^TMP("TIU",$J,GMTSD)) Q:+GMTSD=0  D
 . N GMTSS S GMTSS=0 F  S GMTSS=$O(^TMP("TIU",$J,GMTSD,GMTSS)) Q:+GMTSS=0  D
 . . S GMTSODIC="^TMP(""TIU"","_$J_","_GMTSD_","_GMTSS_"," D NOTE
 Q:$D(GMTSQIT)  D CKP^GMTSUP Q:$D(GMTSQIT)  W ! Q
 ;                
NOTE ;   Primary Note
 N GMTSTDIC,GMTSI,GMTSXTRA S GMTSI=0
 F  S GMTSI=$O(@(GMTSODIC_GMTSI_")")) Q:+GMTSI=0  D
 . S (GMTSTDIC,GMTSPDIC,GMTSDIC)=GMTSODIC,(PARIEN,CURIEN)=GMTSI
 . S CHILD=+($G(@(GMTSDIC_CURIEN_",""ZZID"",0)"))),TYPE="",GMTSID=0
 . S:$D(@(GMTSDIC_CURIEN_",""ZZID"")")) TYPE="Parent Interdisciplinary Note",GMTSID=1
 . K PN S PN("#")=CURIEN,PN("#",0)="NOTE"
 . D FLDS(GMTSDIC,CURIEN) D:$D(@(GMTSDIC_CURIEN_",""ZZID"")")) ST^GMTSPN1("Begin Interdisciplinary Note")
 . D WARN1^GMTSPN2 D:$E($G(GMTSTIUC),1)'["D" WH^GMTSPN1
 . D:$G(GMTSTIUC)="DCS" WDH^GMTSPN1
 . D:GMTSCNT=1&($G(GMTSTIUC)="DSB") WDBH^GMTSPN1
 . I $G(GMTSTIUC)="DSB" D WDB^GMTSPN1(GMTSDIC,CURIEN) Q
 . D:$D(@(GMTSDIC_CURIEN_",""PROBLEM"")")) WP^GMTSPN1(GMTSDIC,CURIEN)
 . D WT^GMTSPN1(GMTSDIC,CURIEN),WS^GMTSPN2(GMTSDIC,CURIEN),WARN2^GMTSPN2
 . D:+($G(PN("AMENDMNT")))>0 AM^GMTSPN1(GMTSDIC,CURIEN)
 . D BL^GMTSPN2 N GMTSODIC S GMTSODIC=GMTSTDIC_CURIEN_"," D ANOTE,INOTE
 . I GMTSID D ST^GMTSPN1("End Interdisciplinary Note") S GMTSID=0
 Q
ANOTE ;   Addendum to a Progress Note
 N GMTSAI,GMTSXTRA S GMTSAI=0
 F  S GMTSAI=$O(@(GMTSODIC_"""ZADD"","_GMTSAI_")")) Q:+GMTSAI=0  D
 . S (GMTSTDIC,GMTSDIC)=GMTSODIC_"""ZADD"",",CURIEN=GMTSAI
 . K PN S PN("#")=GMTSI_"^"_CURIEN,PN("#",0)="ADDENDUM TO A NOTE",TYPE=""
 . S:$D(@(GMTSPDIC_PARIEN_",""ZZID"")")) TYPE="Addendum to a Parent Interdisciplinary Note"
 . D FLDS(GMTSDIC,CURIEN),WARN1^GMTSPN2,WAH^GMTSPN1
 . D WT^GMTSPN1(GMTSDIC,CURIEN),WS^GMTSPN2(GMTSDIC,CURIEN),WARN2^GMTSPN2,BL^GMTSPN2
 Q
INOTE ;   Interdisciplinary Progress Note
 Q:+($G(@(GMTSODIC_"""ZZID"",0)")))'>0
 N GMTSIQ,GMTSII,GMTSXTRA S GMTSIQ=0
 F  S GMTSIQ=$O(@(GMTSODIC_"""ZZID"","_GMTSIQ_")")) Q:+GMTSIQ=0  D
 . S GMTSTDIC=GMTSODIC N GMTSODIC S GMTSODIC=GMTSTDIC_"""ZZID"","_GMTSIQ_","
 . S GMTSII=0 F  S GMTSII=$O(@(GMTSODIC_GMTSII_")")) Q:+GMTSII=0  D
 . . S GMTSDIC=GMTSODIC,CURIEN=GMTSII
 . . K PN S PN("#")=GMTSI_"^"_CURIEN,PN("#",0)="INTERDISCIPLINARY NOTE"
 . . S TYPE="Child Interdisciplinary Note"
 . . D FLDS(GMTSDIC,CURIEN),ST^GMTSPN1("Interdisciplinary Note Cont.")
 . . D WARN1^GMTSPN2,WIH^GMTSPN1 D:$D(@(GMTSDIC_CURIEN_",""PROBLEM"")")) WP^GMTSPN1(GMTSDIC,CURIEN)
 . . D WT^GMTSPN1(GMTSDIC,CURIEN),WS^GMTSPN2(GMTSDIC,CURIEN)
 . . D WARN2^GMTSPN2 D:+($G(PN("AMENDMNT")))>0 AM^GMTSPN1(GMTSDIC,CURIEN) D BL^GMTSPN2
 . . S GMTSTDIC=GMTSODIC N GMTSODIC S GMTSODIC=GMTSTDIC_GMTSII_",""ZADD"","
 . . D AINOTE
 Q
AINOTE ;   Addendum to an Interdisciplinary Progress Note
 N GMTSAII,GMTSXTRA S GMTSAII=0
 F  S GMTSAII=$O(@(GMTSODIC_GMTSAII_")")) Q:+GMTSAII=0  D
 . S GMTSDIC=GMTSODIC,CURIEN=GMTSAII
 . K PN S PN("#")=GMTSI_"^"_GMTSII_"^"_CURIEN
 . S PN("#",0)="ADDENDUM TO AN INTERDISCIPLINARY NOTE"
 . S TYPE="Addendum to a Child Interdisciplinary Note"
 . D FLDS(GMTSDIC,CURIEN),WARN1^GMTSPN2,WAIH^GMTSPN1,WT^GMTSPN1(GMTSDIC,CURIEN)
 . D WS^GMTSPN2(GMTSDIC,CURIEN),WARN2^GMTSPN2,BL^GMTSPN2
 Q
 ;                           
 ; Get Data
EXTIU ;   Extract Patient/Visit VIA TIU
 N MAX S DFN=+($G(DFN)) Q:DFN=0  S TIUTYPE=+($G(TIUTYPE)) Q:TIUTYPE=0
 S MAX=$S(+($G(GMTSNDM))>0:+($G(GMTSNDM)),1:99999)
 S GMTS1=+($G(GMTS1)) Q:GMTS1=0  S GMTS2=+($G(GMTS2)) Q:GMTS2=0  S GMTSX=+($G(GMTSX))
 I +($G(GMTSPXGO))>0,$L($T(VISIT^TIULAPIC)) D VISIT^TIULAPIC(DFN,TIUTYPE,GMTS1,GMTS2,MAX,+($G(GMTSX))) Q
 D MAIN^TIULAPIC(DFN,TIUTYPE,GMTS1,GMTS2,MAX,+($G(GMTSX)))
 Q
FLDS(X,I) ; Get Fields
 N GMTSDIC,GMTSIEN
 S GMTSDIC=$G(X),GMTSIEN=$G(I) Q:'$L(GMTSIEN)
 Q:$E($P(GMTSDIC,$J,1),1,11)'="^TMP(""TIU"","
 Q:'$D(@($P(GMTSDIC,",",1,($L(GMTSDIC,",")-1))_")"))
 Q:'$D(@(GMTSDIC_GMTSIEN_")"))
 S GMTSDIC=GMTSDIC_GMTSIEN_","
 N GMTSXTRA S GMTSCNT=+$G(GMTSCNT)+1
 S X=$G(@(GMTSDIC_".07,""I"")")) D REGDT4^GMTSU S ADMIT=X
 S X=$G(@(GMTSDIC_".08,""I"")")) D REGDT4^GMTSU S DISCHG=X
 S:+DISCHG'>0 DISCHG="Present"
 S:+ADMIT'>0 ADMIT="Unknown"
 S AUTHOR=$G(@(GMTSDIC_"1202,""E"")"))
 S ATTNDNG=$G(@(GMTSDIC_"1209,""E"")"))
 S TSPEC=$G(@(GMTSDIC_"1402,""E"")"))
 S STATUS=$G(@(GMTSDIC_".05,""E"")"))
 S PN("DATE")=$G(@(GMTSDIC_"1301,""I"")"))
 I PN("DATE")]"" S PN("DATE")=$$EDT^GMTSU(PN("DATE"))
 S REASON="",PN("DOCTYPE")=$G(@(GMTSDIC_".01,""E"")"))
 S PN("VHATYPE")=$G(@(GMTSDIC_"89261,""E"")"))
 S PN("STATUS")=$G(@(GMTSDIC_".05,""E"")"))
 S PN("AUTHOR")=$G(@(GMTSDIC_"1202,""E"")"))
 S PN("EXPSIGNR")=$G(@(GMTSDIC_"1204,""E"")"))
 S PN("LOC")=$G(@(GMTSDIC_"1205,""E"")"))
 S PN("EXPCOSNR")=$G(@(GMTSDIC_"1208,""E"")"))
 S:$G(@(GMTSDIC_"1307,""I"")"))'="" PN("DDATE")=$$ED^GMTSU($G(@(GMTSDIC_"1307,""I"")")))
 S:$G(@(GMTSDIC_"1501,""I"")"))'="" PN("SIGNDATE")=$$ED^GMTSU($G(@(GMTSDIC_"1501,""I"")")))
 S PN("SIGDT")=$G(@(GMTSDIC_"1501,""I"")"))
 I PN("SIGDT")]"" S PN("SIGDT")=$$EDT^GMTSU(PN("SIGDT"))
 S SIGNEDBY=$G(@(GMTSDIC_"1502,""I"")"))
 S PN("SIGBLK")=$G(@(GMTSDIC_"1503,""E"")"))
 S PN("STITLE")=$G(@(GMTSDIC_"1504,""E"")"))
 S PN("COSDT")=$G(@(GMTSDIC_"1507,""I"")"))
 I PN("COSDT")]"" S (COSIG,PN("COSDT"))=$$EDT^GMTSU(PN("COSDT"))
 S COSGEDBY=$G(@(GMTSDIC_"1508,""I"")"))
 S CONEED=0 S:+($G(COSGEDBY))>0 CONEED=1
 S PN("COBLK")=$G(@(GMTSDIC_"1509,""E"")"))
 S PN("COTITLE")=$G(@(GMTSDIC_"1510,""E"")"))
 S COSAME=$S(+($G(SIGNEDBY))>0&(+($G(SIGNEDBY))=+($G(COSGEDBY))):1,1:0)
 S:CONEED>0 CONEED=$S(COSAME=1:0,1:CONEED)
 S PN("SUBJ")=$G(@(GMTSDIC_"1701,""E"")"))
 I $G(@(GMTSDIC_"1505,""I"")"))="C" D
 . S PN("SCHART")="Signed on Chart by:",PN("SCHARTBY")="."
 . S:$G(@(GMTSDIC_"1512,""E"")"))'="" PN("SCHARTBY")=$G(@(GMTSDIC_"1512,""E"")"))
 I $E($G(GMTSTIUC),1)'["D",$G(@(GMTSDIC_"1511,""I"")"))="C" D
 . S PN("COCHART")="Cosigned on Chart by:",PN("COCHARTBY")="."
 . S:$G(@(GMTSDIC_"1513,""E"")"))'="" PN("COCHARTBY")=$G(@(GMTSDIC_"1513,""E"")"))
 I $E($G(GMTSTIUC),1)["D",CONEED,$G(@(GMTSDIC_"1511,""I"")"))="C" D
 . S PN("COCHART")="Cosigned on Chart by:",PN("COCHARTBY")="."
 . S:$G(@(GMTSDIC_"1513,""E"")"))'="" PN("COCHARTBY")=$G(@(GMTSDIC_"1513,""E"")"))
 S:$G(@(GMTSDIC_"1202,""I"")"))'=$G(@(GMTSDIC_"1502,""I"")")) PN("AUTH")="AUTHOR:  "_PN("AUTHOR")
 S PN("AMENDMNT")=+($G(@(GMTSDIC_"1601,""I"")")))
 Q