GMPLHS ; SLC/MKB/KER/TC - Extract Prob List Health Summary ;11/27/12 09:17
;;2.0;Problem List;**22,26,35,36,42**;Aug 25, 1994;Build 46
;
; External References
; DBIA 3106 ^DIC(49
; ICR 5747 $$CSI/SAB^ICDEX
; DBIA 10060 ^VA(200
; DBIA 10015 EN^DIQ1
;
GETLIST(GMPDFN,STATUS) ; Define List
N GMPLIST,GMPLVIEW,GMPARAM,GMPTOTAL K ^TMP("GMPLHS",$J) Q:+GMPDFN'>0
S GMPARAM("QUIET")=1,GMPARAM("REV")=$P($G(^GMPL(125.99,1,0)),U,5)="R"
S GMPLVIEW("ACT")=STATUS,GMPLVIEW("PROV")=0,GMPLVIEW("VIEW")=""
D GETPLIST^GMPLMGR1(.GMPLIST,.GMPTOTAL,.GMPLVIEW)
BUILD ; Build list for selected patient
; Sets Global Array:
; ^TMP("GMPLHS",$J,STATUS,0)
;
; Piece 1: GMPCNT # of entries extracted
; 2: GMPTOTAL # of entries that exist
N IFN,GMPCNT,NUM S (NUM,GMPCNT)=0 F S NUM=$O(GMPLIST(NUM)) Q:NUM'>0 D
. S IFN=+GMPLIST(NUM) Q:IFN'>0 D GETPROB(IFN)
I $G(GMPCNT)'>0 K ^TMP("GMPLHS",$J) Q
S ^TMP("GMPLHS",$J,STATUS,0)=GMPCNT_U_GMPTOTAL
Q
GETPROB(IFN) ; Get problem data and set it to ^TMP array
; Sets Global Arrays:
; ^TMP("GMPLHS",$J,CNT,0)
; Piece 1: Pointer to ICD file #80
; 2: Internal Date Last Modified
; 3: Facility Name
; 4: Internal Date Entered
; 5: Internal Status (A/I/"")
; 6: Internal Date of Onset
; 7: Responsible Provider Name
; 8: Service Name
; 9: Service Abbreviation
; 10: Internal Date Resolved
; 11: Clinic Name
; 12: Internal Date Recorded
; 13: Problem Term (from Lexicon)
; 14: Exposure String (AO/IR/EC/HNC/MST/CV/SHD)
; 15: SNOMED-CT Concept Code
; 16: SNOMED-CT Preferred Text
; 17: Primary ICD Code
; 18: Primary ICD Description
; 19: VHAT Concept Code
; 20: VHAT Preferred Text
; 21: Date of Interest
; 22: Coding System
;
; ^TMP("GMPLHS",$J,CNT,#,"ICD9") <-Multiple ICD-9/10-CM codes mapped to a SNOMED-CT concept
; Piece 1: Secondary ICD-9/10-CM Code
; Piece 2: Secondary ICD-9/10-CM Description
;
; ^TMP("GMPLHS",$J,CNT,"N")
; Piece 1: Provider Narrative
;
; ^TMP("GMPLHS",$J,CNT,"IEN")
; Piece 1: Pointer to Problem file 9000011
;
N DIC,DIQ,DR,DA,REC,DIAG,LASTMDT,NARR,SITE,ENTDT,STAT,ONSETDT,RPROV,T,VHATC,VHATT,DTINT,CSYS
N SERV,SERVABB,RESDT,CLIN,RECDT,LEXI,LEX,PG,AO,EXP,HNC,MST,CV,SHD,IR,SCS,SCTC,SCTT,ICD,ICDD,GMPL
S DIC=9000011,DA=IFN,DIQ="REC(",DIQ(0)="IE"
S DR=".01;.03;.05;.06;.08;.12;.13;1.01;1.05;1.06;1.07;1.08;1.09;1.11;1.12;1.13;1.15;1.16;1.17;1.18;80001;80003;80201;80202"
D EN^DIQ1
S ICD=REC(9000011,DA,.01,"E")
S DIAG=REC(9000011,DA,.01,"I"),LASTMDT=REC(9000011,DA,.03,"I")
S NARR=REC(9000011,DA,.05,"E"),SITE=REC(9000011,DA,.06,"E")
S ENTDT=REC(9000011,DA,.08,"I"),STAT=REC(9000011,DA,.12,"I")
S ONSETDT=REC(9000011,DA,.13,"I")
S LEXI=REC(9000011,DA,1.01,"I")
S LEX=REC(9000011,DA,1.01,"E")
S RPROV=REC(9000011,DA,1.05,"E")
S SERV=REC(9000011,DA,1.06,"E")
S SERVABB=$$SERV(REC(9000011,DA,1.06,"I"),SERV)
S RESDT=REC(9000011,DA,1.07,"I")
S CLIN=REC(9000011,DA,1.08,"E")
S RECDT=REC(9000011,DA,1.09,"I")
S AO=+REC(9000011,DA,1.11,"I")
S IR=+REC(9000011,DA,1.12,"I")
S PG=+REC(9000011,DA,1.13,"I")
S HNC=+REC(9000011,DA,1.15,"I")
S MST=+REC(9000011,DA,1.16,"I")
S CV=+REC(9000011,DA,1.17,"I")
S SHD=+REC(9000011,DA,1.18,"I")
S SCTC=REC(9000011,DA,80001,"I")
S VHATC=REC(9000011,DA,80003,"I")
S DTINT=$S(+REC(9000011,DA,80201,"I"):REC(9000011,DA,80201,"I"),1:ENTDT)
S CSYS=$S(REC(9000011,DA,80202,"I")]"":REC(9000011,DA,80202,"I"),1:$$SAB^ICDEX($$CSI^ICDEX(80,DIAG),DTINT))
I $L($G(SCTC)) S SCTT=$P($$SCTTEXT^GMPLUTL2($G(SCTC),$G(ENTDT),"SCT"),U)
I $L($G(VHATC)) S VHATT=$$SCTTEXT^GMPLUTL2($G(VHATC),$G(ENTDT),"VHAT")
S ICDD=$$ICDDESC^GMPLUTL2($G(ICD),$G(DTINT),$G(CSYS))
K SCS D SCS^GMPLX1(DA,.SCS) S EXP=$G(SCS(1))
S GMPCNT=+$G(GMPCNT)+1,^TMP("GMPLHS",$J,GMPCNT,0)=DIAG_U_LASTMDT_U_SITE_U_ENTDT_U_STAT_U_ONSETDT_U_RPROV_U_SERV_U_SERVABB_U_RESDT_U_CLIN_U_RECDT_U_LEX_U_EXP_U_SCTC_U_$G(SCTT)_U_$G(ICD)_U_$G(ICDD)_U_VHATC_U_$G(VHATT)_U_DTINT_U_CSYS
S ^TMP("GMPLHS",$J,GMPCNT,"N")=NARR,^TMP("GMPLHS",$J,GMPCNT,"IEN")=IFN
S:+LEXI>0 ^TMP("GMPLHS",$J,GMPCNT,"L")=LEXI_"^"_LEX
D DETAIL^GMPLUTL2(IFN,.GMPL)
I GMPL("ICD9MLTP")'="" F T=1:1:GMPL("ICD9MLTP") D
. S ^TMP("GMPLHS",$J,GMPCNT,0,"ICD9")=GMPL("ICD9MLTP")
. S ^TMP("GMPLHS",$J,GMPCNT,T,"ICD9")=$P($G(GMPL("ICD9MLTP",T)),U)_U_$P($G(GMPL("ICD9MLTP",T)),U,2)
E S ^TMP("GMPLHS",$J,GMPCNT,0,"ICD9")=""
D GETCOMM(IFN,GMPCNT)
Q
GETCOMM(IFN,CNT) ; Get Active Comments for a Note
; Sets Global Array:
; ^TMP("GMPLHS",$J,CNT,"C",LOCATION,NOTE NMBR,0)
;
; Piece 1: Note Narrative
; 2: Internal Date Note Added
; 3; Name of Note's Author
;
N IFN2,IFN3,LOC,NODE S LOC=0 Q:$D(^AUPNPROB(IFN,11))'>0 S IFN2=0
F S IFN2=$O(^AUPNPROB(IFN,11,IFN2)) Q:IFN2'>0 D
. Q:$D(^AUPNPROB(IFN,11,IFN2,11))'>0
. S LOC=+$G(^AUPNPROB(IFN,11,IFN2,0)),IFN3=0
. F S IFN3=$O(^AUPNPROB(IFN,11,IFN2,11,IFN3)) Q:IFN3'>0 D
. . S NODE=$G(^AUPNPROB(IFN,11,IFN2,11,IFN3,0)) Q:$P(NODE,U,4)']""
. . S ^TMP("GMPLHS",$J,CNT,"C",LOC,$P(NODE,U),0)=$P(NODE,U,3)_U_$P(NODE,U,5)_U_$P($G(^VA(200,+$P(NODE,U,6),0)),U)
Q
SERV(X,SERV) ; Returns Service Name Abbreviation
N ABBREV S ABBREV=$P($G(^DIC(49,+X,0)),U,2) S:ABBREV="" ABBREV=$E($G(SERV),1,5)
Q ABBREV
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HGMPLHS 5490 printed Nov 22, 2024@17:40:06 Page 2
GMPLHS ; SLC/MKB/KER/TC - Extract Prob List Health Summary ;11/27/12 09:17
+1 ;;2.0;Problem List;**22,26,35,36,42**;Aug 25, 1994;Build 46
+2 ;
+3 ; External References
+4 ; DBIA 3106 ^DIC(49
+5 ; ICR 5747 $$CSI/SAB^ICDEX
+6 ; DBIA 10060 ^VA(200
+7 ; DBIA 10015 EN^DIQ1
+8 ;
GETLIST(GMPDFN,STATUS) ; Define List
+1 NEW GMPLIST,GMPLVIEW,GMPARAM,GMPTOTAL
KILL ^TMP("GMPLHS",$JOB)
if +GMPDFN'>0
QUIT
+2 SET GMPARAM("QUIET")=1
SET GMPARAM("REV")=$PIECE($GET(^GMPL(125.99,1,0)),U,5)="R"
+3 SET GMPLVIEW("ACT")=STATUS
SET GMPLVIEW("PROV")=0
SET GMPLVIEW("VIEW")=""
+4 DO GETPLIST^GMPLMGR1(.GMPLIST,.GMPTOTAL,.GMPLVIEW)
BUILD ; Build list for selected patient
+1 ; Sets Global Array:
+2 ; ^TMP("GMPLHS",$J,STATUS,0)
+3 ;
+4 ; Piece 1: GMPCNT # of entries extracted
+5 ; 2: GMPTOTAL # of entries that exist
+6 NEW IFN,GMPCNT,NUM
SET (NUM,GMPCNT)=0
FOR
SET NUM=$ORDER(GMPLIST(NUM))
if NUM'>0
QUIT
Begin DoDot:1
+7 SET IFN=+GMPLIST(NUM)
if IFN'>0
QUIT
DO GETPROB(IFN)
End DoDot:1
+8 IF $GET(GMPCNT)'>0
KILL ^TMP("GMPLHS",$JOB)
QUIT
+9 SET ^TMP("GMPLHS",$JOB,STATUS,0)=GMPCNT_U_GMPTOTAL
+10 QUIT
GETPROB(IFN) ; Get problem data and set it to ^TMP array
+1 ; Sets Global Arrays:
+2 ; ^TMP("GMPLHS",$J,CNT,0)
+3 ; Piece 1: Pointer to ICD file #80
+4 ; 2: Internal Date Last Modified
+5 ; 3: Facility Name
+6 ; 4: Internal Date Entered
+7 ; 5: Internal Status (A/I/"")
+8 ; 6: Internal Date of Onset
+9 ; 7: Responsible Provider Name
+10 ; 8: Service Name
+11 ; 9: Service Abbreviation
+12 ; 10: Internal Date Resolved
+13 ; 11: Clinic Name
+14 ; 12: Internal Date Recorded
+15 ; 13: Problem Term (from Lexicon)
+16 ; 14: Exposure String (AO/IR/EC/HNC/MST/CV/SHD)
+17 ; 15: SNOMED-CT Concept Code
+18 ; 16: SNOMED-CT Preferred Text
+19 ; 17: Primary ICD Code
+20 ; 18: Primary ICD Description
+21 ; 19: VHAT Concept Code
+22 ; 20: VHAT Preferred Text
+23 ; 21: Date of Interest
+24 ; 22: Coding System
+25 ;
+26 ; ^TMP("GMPLHS",$J,CNT,#,"ICD9") <-Multiple ICD-9/10-CM codes mapped to a SNOMED-CT concept
+27 ; Piece 1: Secondary ICD-9/10-CM Code
+28 ; Piece 2: Secondary ICD-9/10-CM Description
+29 ;
+30 ; ^TMP("GMPLHS",$J,CNT,"N")
+31 ; Piece 1: Provider Narrative
+32 ;
+33 ; ^TMP("GMPLHS",$J,CNT,"IEN")
+34 ; Piece 1: Pointer to Problem file 9000011
+35 ;
+36 NEW DIC,DIQ,DR,DA,REC,DIAG,LASTMDT,NARR,SITE,ENTDT,STAT,ONSETDT,RPROV,T,VHATC,VHATT,DTINT,CSYS
+37 NEW SERV,SERVABB,RESDT,CLIN,RECDT,LEXI,LEX,PG,AO,EXP,HNC,MST,CV,SHD,IR,SCS,SCTC,SCTT,ICD,ICDD,GMPL
+38 SET DIC=9000011
SET DA=IFN
SET DIQ="REC("
SET DIQ(0)="IE"
+39 SET DR=".01;.03;.05;.06;.08;.12;.13;1.01;1.05;1.06;1.07;1.08;1.09;1.11;1.12;1.13;1.15;1.16;1.17;1.18;80001;80003;80201;80202"
+40 DO EN^DIQ1
+41 SET ICD=REC(9000011,DA,.01,"E")
+42 SET DIAG=REC(9000011,DA,.01,"I")
SET LASTMDT=REC(9000011,DA,.03,"I")
+43 SET NARR=REC(9000011,DA,.05,"E")
SET SITE=REC(9000011,DA,.06,"E")
+44 SET ENTDT=REC(9000011,DA,.08,"I")
SET STAT=REC(9000011,DA,.12,"I")
+45 SET ONSETDT=REC(9000011,DA,.13,"I")
+46 SET LEXI=REC(9000011,DA,1.01,"I")
+47 SET LEX=REC(9000011,DA,1.01,"E")
+48 SET RPROV=REC(9000011,DA,1.05,"E")
+49 SET SERV=REC(9000011,DA,1.06,"E")
+50 SET SERVABB=$$SERV(REC(9000011,DA,1.06,"I"),SERV)
+51 SET RESDT=REC(9000011,DA,1.07,"I")
+52 SET CLIN=REC(9000011,DA,1.08,"E")
+53 SET RECDT=REC(9000011,DA,1.09,"I")
+54 SET AO=+REC(9000011,DA,1.11,"I")
+55 SET IR=+REC(9000011,DA,1.12,"I")
+56 SET PG=+REC(9000011,DA,1.13,"I")
+57 SET HNC=+REC(9000011,DA,1.15,"I")
+58 SET MST=+REC(9000011,DA,1.16,"I")
+59 SET CV=+REC(9000011,DA,1.17,"I")
+60 SET SHD=+REC(9000011,DA,1.18,"I")
+61 SET SCTC=REC(9000011,DA,80001,"I")
+62 SET VHATC=REC(9000011,DA,80003,"I")
+63 SET DTINT=$SELECT(+REC(9000011,DA,80201,"I"):REC(9000011,DA,80201,"I"),1:ENTDT)
+64 SET CSYS=$SELECT(REC(9000011,DA,80202,"I")]"":REC(9000011,DA,80202,"I"),1:$$SAB^ICDEX($$CSI^ICDEX(80,DIAG),DTINT))
+65 IF $LENGTH($GET(SCTC))
SET SCTT=$PIECE($$SCTTEXT^GMPLUTL2($GET(SCTC),$GET(ENTDT),"SCT"),U)
+66 IF $LENGTH($GET(VHATC))
SET VHATT=$$SCTTEXT^GMPLUTL2($GET(VHATC),$GET(ENTDT),"VHAT")
+67 SET ICDD=$$ICDDESC^GMPLUTL2($GET(ICD),$GET(DTINT),$GET(CSYS))
+68 KILL SCS
DO SCS^GMPLX1(DA,.SCS)
SET EXP=$GET(SCS(1))
+69 SET GMPCNT=+$GET(GMPCNT)+1
SET ^TMP("GMPLHS",$JOB,GMPCNT,0)=DIAG_U_LASTMDT_U_SITE_U_ENTDT_U_STAT_U_ONSETDT_U_RPROV_U_SERV_U_SERVABB_U_RESDT_U_CLIN_U_RECDT_U_LEX_U_EXP_U_SCTC_U_$GET(SCTT)_U_$GET(ICD)_U_$GET(ICDD)_U_VHATC_U_$GET(VHATT)_U_DTINT_U_CSYS
+70 SET ^TMP("GMPLHS",$JOB,GMPCNT,"N")=NARR
SET ^TMP("GMPLHS",$JOB,GMPCNT,"IEN")=IFN
+71 if +LEXI>0
SET ^TMP("GMPLHS",$JOB,GMPCNT,"L")=LEXI_"^"_LEX
+72 DO DETAIL^GMPLUTL2(IFN,.GMPL)
+73 IF GMPL("ICD9MLTP")'=""
FOR T=1:1:GMPL("ICD9MLTP")
Begin DoDot:1
+74 SET ^TMP("GMPLHS",$JOB,GMPCNT,0,"ICD9")=GMPL("ICD9MLTP")
+75 SET ^TMP("GMPLHS",$JOB,GMPCNT,T,"ICD9")=$PIECE($GET(GMPL("ICD9MLTP",T)),U)_U_$PIECE($GET(GMPL("ICD9MLTP",T)),U,2)
End DoDot:1
+76 IF '$TEST
SET ^TMP("GMPLHS",$JOB,GMPCNT,0,"ICD9")=""
+77 DO GETCOMM(IFN,GMPCNT)
+78 QUIT
GETCOMM(IFN,CNT) ; Get Active Comments for a Note
+1 ; Sets Global Array:
+2 ; ^TMP("GMPLHS",$J,CNT,"C",LOCATION,NOTE NMBR,0)
+3 ;
+4 ; Piece 1: Note Narrative
+5 ; 2: Internal Date Note Added
+6 ; 3; Name of Note's Author
+7 ;
+8 NEW IFN2,IFN3,LOC,NODE
SET LOC=0
if $DATA(^AUPNPROB(IFN,11))'>0
QUIT
SET IFN2=0
+9 FOR
SET IFN2=$ORDER(^AUPNPROB(IFN,11,IFN2))
if IFN2'>0
QUIT
Begin DoDot:1
+10 if $DATA(^AUPNPROB(IFN,11,IFN2,11))'>0
QUIT
+11 SET LOC=+$GET(^AUPNPROB(IFN,11,IFN2,0))
SET IFN3=0
+12 FOR
SET IFN3=$ORDER(^AUPNPROB(IFN,11,IFN2,11,IFN3))
if IFN3'>0
QUIT
Begin DoDot:2
+13 SET NODE=$GET(^AUPNPROB(IFN,11,IFN2,11,IFN3,0))
if $PIECE(NODE,U,4)']""
QUIT
+14 SET ^TMP("GMPLHS",$JOB,CNT,"C",LOC,$PIECE(NODE,U),0)=$PIECE(NODE,U,3)_U_$PIECE(NODE,U,5)_U_$PIECE($GET(^VA(200,+$PIECE(NODE,U,6),0)),U)
End DoDot:2
End DoDot:1
+15 QUIT
SERV(X,SERV) ; Returns Service Name Abbreviation
+1 NEW ABBREV
SET ABBREV=$PIECE($GET(^DIC(49,+X,0)),U,2)
if ABBREV=""
SET ABBREV=$EXTRACT($GET(SERV),1,5)
+2 QUIT ABBREV