GMPLHS ; SLC/MKB/KER/TC - Extract Prob List Health Summary ;16-Sep-2015 15:57;DU
;;2.0;Problem List;**22,26,35,36,1004**;Aug 25, 1994;Build 10
;
; External References
; DBIA 3106 ^DIC(49
; 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 ICD9 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
;
; ^TMP("GMPLHS",$J,CNT,#,"ICD9") <-Multiple ICD-9-CM codes mapped to a SNOMED-CT concept
; Piece 1: Secondary ICD-9-CM Code
; Piece 2: Secondary ICD-9-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
N SERV,SERVABB,RESDT,CLIN,RECDT,LEXI,LEX,PG,AO,EXP,HNC,MST,CV,SHD,IR,SCS,SCTC,SCTT,ICD,ICDD
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"
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")
;IHS/MSC/MGH removed fields that don't exist
;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")
I $L($G(SCTC)) S SCTT=$$SCTTEXT^GMPLUTL2($G(SCTC),$G(ENTDT),"SCT")
I $L($G(VHATC)) S VHATT=$$SCTTEXT^GMPLUTL2($G(VHATC),$G(ENTDT),"VHAT")
S ICDD=$$ICDDESC^GMPLUTL2($G(ICD),$G(ENTDT))
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)
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
GMPLHS ; SLC/MKB/KER/TC - Extract Prob List Health Summary ;16-Sep-2015 15:57;DU
+1 ;;2.0;Problem List;**22,26,35,36,1004**;Aug 25, 1994;Build 10
+2 ;
+3 ; External References
+4 ; DBIA 3106 ^DIC(49
+5 ; DBIA 10060 ^VA(200
+6 ; DBIA 10015 EN^DIQ1
+7 ;
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 ICD9 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 ;
+24 ; ^TMP("GMPLHS",$J,CNT,#,"ICD9") <-Multiple ICD-9-CM codes mapped to a SNOMED-CT concept
+25 ; Piece 1: Secondary ICD-9-CM Code
+26 ; Piece 2: Secondary ICD-9-CM Description
+27 ;
+28 ; ^TMP("GMPLHS",$J,CNT,"N")
+29 ; Piece 1: Provider Narrative
+30 ;
+31 ; ^TMP("GMPLHS",$J,CNT,"IEN")
+32 ; Piece 1: Pointer to Problem file 9000011
+33 ;
+34 NEW DIC,DIQ,DR,DA,REC,DIAG,LASTMDT,NARR,SITE,ENTDT,STAT,ONSETDT,RPROV,T,VHATC,VHATT
+35 NEW SERV,SERVABB,RESDT,CLIN,RECDT,LEXI,LEX,PG,AO,EXP,HNC,MST,CV,SHD,IR,SCS,SCTC,SCTT,ICD,ICDD
+36 SET DIC=9000011
SET DA=IFN
SET DIQ="REC("
SET DIQ(0)="IE"
+37 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"
+38 DO EN^DIQ1
+39 SET ICD=REC(9000011,DA,.01,"E")
+40 SET DIAG=REC(9000011,DA,.01,"I")
SET LASTMDT=REC(9000011,DA,.03,"I")
+41 SET NARR=REC(9000011,DA,.05,"E")
SET SITE=REC(9000011,DA,.06,"E")
+42 SET ENTDT=REC(9000011,DA,.08,"I")
SET STAT=REC(9000011,DA,.12,"I")
+43 SET ONSETDT=REC(9000011,DA,.13,"I")
+44 SET LEXI=REC(9000011,DA,1.01,"I")
+45 SET LEX=REC(9000011,DA,1.01,"E")
+46 SET RPROV=REC(9000011,DA,1.05,"E")
+47 SET SERV=REC(9000011,DA,1.06,"E")
+48 SET SERVABB=$$SERV(REC(9000011,DA,1.06,"I"),SERV)
+49 SET RESDT=REC(9000011,DA,1.07,"I")
+50 SET CLIN=REC(9000011,DA,1.08,"E")
+51 SET RECDT=REC(9000011,DA,1.09,"I")
+52 SET AO=+REC(9000011,DA,1.11,"I")
+53 SET IR=+REC(9000011,DA,1.12,"I")
+54 SET PG=+REC(9000011,DA,1.13,"I")
+55 SET HNC=+REC(9000011,DA,1.15,"I")
+56 SET MST=+REC(9000011,DA,1.16,"I")
+57 ;IHS/MSC/MGH removed fields that don't exist
+58 ;S CV=+REC(9000011,DA,1.17,"I")
+59 ;S SHD=+REC(9000011,DA,1.18,"I")
+60 SET SCTC=REC(9000011,DA,80001,"I")
+61 SET VHATC=REC(9000011,DA,80003,"I")
+62 IF $LENGTH($GET(SCTC))
SET SCTT=$$SCTTEXT^GMPLUTL2($GET(SCTC),$GET(ENTDT),"SCT")
+63 IF $LENGTH($GET(VHATC))
SET VHATT=$$SCTTEXT^GMPLUTL2($GET(VHATC),$GET(ENTDT),"VHAT")
+64 SET ICDD=$$ICDDESC^GMPLUTL2($GET(ICD),$GET(ENTDT))
+65 KILL SCS
DO SCS^GMPLX1(DA,.SCS)
SET EXP=$GET(SCS(1))
+66 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)
+67 SET ^TMP("GMPLHS",$JOB,GMPCNT,"N")=NARR
SET ^TMP("GMPLHS",$JOB,GMPCNT,"IEN")=IFN
+68 IF +LEXI>0
SET ^TMP("GMPLHS",$JOB,GMPCNT,"L")=LEXI_"^"_LEX
+69 DO DETAIL^GMPLUTL2(IFN,.GMPL)
+70 IF GMPL("ICD9MLTP")'=""
FOR T=1:1:GMPL("ICD9MLTP")
Begin DoDot:1
+71 SET ^TMP("GMPLHS",$JOB,GMPCNT,0,"ICD9")=GMPL("ICD9MLTP")
+72 SET ^TMP("GMPLHS",$JOB,GMPCNT,T,"ICD9")=$PIECE($GET(GMPL("ICD9MLTP",T)),U)_U_$PIECE($GET(GMPL("ICD9MLTP",T)),U,2)
End DoDot:1
+73 IF '$TEST
SET ^TMP("GMPLHS",$JOB,GMPCNT,0,"ICD9")=""
+74 DO GETCOMM(IFN,GMPCNT)
+75 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