new RIM2CSV^GPLRIMA to output a spreadsheet of CCR/CCD/RIM variables
This commit is contained in:
parent
ef1ec0a366
commit
0d40f4972f
30
p/C0CRNF.m
30
p/C0CRNF.m
|
@ -69,6 +69,8 @@ GETNOLD(GRTN,GFILE,GIEN,GNN) ; GET FIELDS FOR ACCESS BY NAME
|
|||
Q
|
||||
;
|
||||
GETN1(GRTN,GFILE,GREF,GNDX,GNN) ; NEW GET ;GPL ; RETURN A FIELD VALUE MAP
|
||||
; THE FOLLOWING COMMENTS ARE WRONG.. THIS ROUTINE STILL RETURNS AN RNF1
|
||||
; FORMAT ARRAY @GRTN@("FIELD NAME")="FILE^FIELD#^VALUE" ;GPL
|
||||
; GETN IS AN EXTRINSIC WHICH RETURNS THE NEXT IEN AFTER THE CURRENT GIEN
|
||||
; GRTN, PASSED BY NAME, RETURNS A FIELD MAP AND A VALUE MAP
|
||||
; .. FIELD MAP @GRTN@("F","FIELDNAME^FILE^FIELD#")=""
|
||||
|
@ -87,7 +89,6 @@ GETN1(GRTN,GFILE,GREF,GNDX,GNN) ; NEW GET ;GPL ; RETURN A FIELD VALUE MAP
|
|||
;
|
||||
;
|
||||
N GIEN,GF
|
||||
|
||||
S GF=$$FILEREF(GFILE) ;CLOSED FILE REFERENCE FOR FILE NUMBER GFILE
|
||||
I ('$D(GNDX))!(GNDX="") S GIEN=GREF ; IF NO INDEX USED, GREF IS THE IEN
|
||||
E D ; WE ARE USING AN INDEX
|
||||
|
@ -102,6 +103,7 @@ GETN1(GRTN,GFILE,GREF,GNDX,GNN) ; NEW GET ;GPL ; RETURN A FIELD VALUE MAP
|
|||
E S C0CNN=1 ; NON-NULL IS TRUE (ONLY POPULATED FIELDS RETURNED)
|
||||
S C0CREF=GIEN_"," ; OPEN ROOT REFERENCE INTO FILE
|
||||
D CLEAN^DILF ; MAKE SURE WE ARE CLEANED UP
|
||||
K C0CTMP
|
||||
D GETS^DIQ(GFILE,C0CREF,"**","","C0CTMP")
|
||||
D FIELDS(GRTN,GFILE) ;GET ALL THE FIELD NAMES FOR THE FILE
|
||||
S @GRTN@(0)=GFILE_"^RNF1^"_GIEN_"^"_DT_"^"_$J_"^"_DUZ ; STRUCTURE SIGNATURE
|
||||
|
@ -112,7 +114,13 @@ GETN1(GRTN,GFILE,GREF,GNDX,GNN) ; NEW GET ;GPL ; RETURN A FIELD VALUE MAP
|
|||
. . ;W C0CJ," ",C0CI,!
|
||||
. . S C0CNAME=$P(^DD(C0CJ,C0CI,0),"^",1) ;PULL THE FIELD NAME
|
||||
. . S C0CVALUE=C0CTMP(C0CJ,C0CREF,C0CI) ;
|
||||
. . I C0CVALUE["C0CTMP" S C0CVALUE=C0CTMP(C0CJ,C0CREF,C0CI,1) ;1ST LINE OF WP
|
||||
. . I C0CVALUE["C0CTMP" D ; WP FIELD
|
||||
. . . N ZT,ZWP S ZWP=0 ;ITERATOR
|
||||
. . . S C0CVALUE="" ; INITIALIZE
|
||||
. . . F S ZWP=$O(C0CTMP(C0CJ,C0CREF,C0CI,ZWP)) Q:'ZWP D ;
|
||||
. . . . S ZT=" "_C0CTMP(C0CJ,C0CREF,C0CI,ZWP) ;LINE OF WP
|
||||
. . . . S ZT=$TR(ZT,"^""","|'") ;HACK TO GET RID OF ^ AND " IN TEXT "
|
||||
. . . . S C0CVALUE=C0CVALUE_ZT ;
|
||||
. . S $P(@GRTN@(C0CNAME),"^",3)=C0CVALUE ;RETURN VALUE IN P3
|
||||
I C0CNN D ; IF ONLY NON-NULL VALUES ARE TO BE RETURNED
|
||||
. S C0CI=""
|
||||
|
@ -226,10 +234,15 @@ FILE2CSV(FNUM,FVN) ; WRITES OUT A FILEMAN FILE TO CSV
|
|||
D GETN2(G1,FNUM) ; GET THE MATRIX
|
||||
D RNF2CSV(G2,G1,FVN) ; PREPARE THE CVS FILE
|
||||
K @G1
|
||||
W $$OUTPUT^GPLXPATH(@G2@(1),"FILE_"_FNUM_".csv",^TMP("GPLCCR","ODIR"))
|
||||
D FILEOUT(G2,"FILE_"_FNUM_".csv")
|
||||
K @G2
|
||||
Q
|
||||
;
|
||||
FILEOUT(FOARY,FONAM) ; WRITE OUT A FILE
|
||||
;
|
||||
W $$OUTPUT^GPLXPATH($NA(@FOARY@(1)),FONAM,^TMP("GPLCCR","ODIR"))
|
||||
Q
|
||||
;
|
||||
FILEREF(FNUM) ; EXTRINSIC THAT RETURNS A CLOSED ROOT FOR FILE NUMBER FNUM
|
||||
;
|
||||
N C0CF
|
||||
|
@ -238,6 +251,17 @@ FILEREF(FNUM) ; EXTRINSIC THAT RETURNS A CLOSED ROOT FOR FILE NUMBER FNUM
|
|||
I C0CF["()" S C0CF=$P(C0CF,"()",1)
|
||||
Q C0CF
|
||||
;
|
||||
SKIP ;
|
||||
N TXT,DIERR
|
||||
S TXT=$$GET1^DIQ(8925,TIUIEN,"2","","TXT")
|
||||
I $D(DIERR) D CLEAN^DILF Q
|
||||
W " report_text:",! ;Progress Note Text
|
||||
N LN S LN=0
|
||||
F S LN=$O(TXT(LN)) Q:'LN D
|
||||
. W " text"_LN_": "_TXT(LN),!
|
||||
. Q
|
||||
Q
|
||||
;
|
||||
ZFILE(ZFN,ZTAB) ; EXTRINSIC TO RETURN FILE NUMBER FOR FIELD NAME PASSED
|
||||
; BY VALUE IN ZFN. FILE NUMBER IS PIECE 1 OF @ZTAB@(ZFN)
|
||||
; IF ZTAB IS NULL, IT DEFAULTS TO C0CA
|
||||
|
|
13
p/GPLCCR.m
13
p/GPLCCR.m
|
@ -38,7 +38,7 @@ XPAT(DFN,DIR,FN) ; EXPORT ONE PATIENT TO A FILE
|
|||
D CCRRPC(.CCRGLO,DFN,"CCR","","","")
|
||||
S OARY=$NA(^TMP("GPLCCR",$J,DFN,"CCR",1))
|
||||
S ONAM=UFN
|
||||
I UFN="" S ONAM="PAT_"_DFN_"_CCR_V1_0_7.xml"
|
||||
I UFN="" S ONAM="PAT_"_DFN_"_CCR_V1_0_10.xml"
|
||||
S ODIRGLB=$NA(^TMP("GPLCCR","ODIR"))
|
||||
I '$D(@ODIRGLB) D ; IF NOT ODIR HAS BEEN SET
|
||||
. ;S @ODIRGLB="/home/glilly/CCROUT"
|
||||
|
@ -141,7 +141,8 @@ HDRMAP(CXML,DFN,IHDR) ; MAP HEADER VARIABLES: FROM, TO ECT
|
|||
N VMAP S VMAP=$NA(^TMP("GPLCCR",$J,DFN,"HEADER"))
|
||||
; K @VMAP
|
||||
S @VMAP@("DATETIME")=$$FMDTOUTC^CCRUTIL($$NOW^XLFDT,"DT")
|
||||
I IHDR="" D ; HEADER ARRAY IS NOT PROVIDED, USE DEFAULTS
|
||||
; I IHDR="" D ; HEADER ARRAY IS NOT PROVIDED, USE DEFAULTS
|
||||
D ; ALWAYS MAP THESE VARIABLES
|
||||
. S @VMAP@("ACTORPATIENT")="ACTORPATIENT_"_DFN
|
||||
. S @VMAP@("ACTORFROM")="ACTORORGANIZATION_"_DUZ ; FROM DUZ - ???
|
||||
. S @VMAP@("ACTORFROM2")="ACTORSYSTEM_1" ; SECOND FROM IS THE SYSTEM
|
||||
|
@ -149,11 +150,15 @@ HDRMAP(CXML,DFN,IHDR) ; MAP HEADER VARIABLES: FROM, TO ECT
|
|||
. S @VMAP@("PURPOSEDESCRIPTION")="CEND PHR" ; FOR TEST PURPOSES
|
||||
. S @VMAP@("ACTORTOTEXT")="Patient" ; FOR TEST PURPOSES
|
||||
. ; THIS IS THE USE CASE FOR THE PHR WHERE "TO" IS THE PATIENT
|
||||
I IHDR'="" D ; HEADER VALUES ARE PROVIDED
|
||||
. D CP^GPLXPATH(IHDR,VMAP) ; COPY HEADER VARIABLES TO MAP ARRAY
|
||||
;I IHDR'="" D ; HEADER VALUES ARE PROVIDED
|
||||
;. D CP^GPLXPATH(IHDR,VMAP) ; COPY HEADER VARIABLES TO MAP ARRAY
|
||||
N CTMP
|
||||
D MAP^GPLXPATH(CXML,VMAP,"CTMP")
|
||||
D CP^GPLXPATH("CTMP",CXML)
|
||||
N HRIMVARS ;
|
||||
S HRIMVARS=$NA(^TMP("GPLRIM","VARS",DFN,"HEADER")) ; TO PERSIST VARS
|
||||
M @HRIMVARS@(1)=@VMAP ; PERSIST THE HEADER VARIABLES IN RIM TABLE
|
||||
S @HRIMVARS@(0)=1 ; ONLY ONE SET OF HEADERS PER PATIENT
|
||||
Q
|
||||
;
|
||||
ACTLST(AXML,ACTRTN) ; RETURN THE ACTOR LIST FOR THE XML IN AXML
|
||||
|
|
42
p/GPLRIMA.m
42
p/GPLRIMA.m
|
@ -51,9 +51,9 @@ ANALYZE(BEGDFN,DFNCNT) ; RIM COHERANCE ANALYSIS ROUTINE
|
|||
I +RIMDFN=0 D Q ; AT THE END OF THE PATIENTS
|
||||
. W "END OF PATIENT LIST, CALL RESET^GPLRIMA",!
|
||||
F RIMI=1:1:DFNCNT D Q:+RIMDFN=0 ; FOR DFNCNT NUMBER OF PATIENTS OR END
|
||||
. K @RIMBASE@("VARS",RIMDFN) ; CLEAR OUT OLD VARS
|
||||
. D CCRRPC^GPLCCR(.CCRGLO,RIMDFN,"CCR","","","") ;PROCESS THE CCR
|
||||
. W RIMDFN,!
|
||||
. K @RIMBASE@("VARS",RIMDFN) ; CLEAR OUT OLD VARS
|
||||
. ;
|
||||
. ; COPY ALL THE VARIABLES TO THE RIM MAP AREA INDEXED BY PATIENT
|
||||
. ;
|
||||
|
@ -410,7 +410,7 @@ RPCGV(RTN,DFN,WHICH) ; RPC GET VARS
|
|||
S RTN(0)=0 ; DEFAULT NOTHING IS RETURNED
|
||||
N ZZGI
|
||||
I WHICH="ALL" D ; VARIABLES FROM ALL SECTIONS
|
||||
. F ZZGI="PROBLEMS","VITALS","MEDS","ALERTS","RESULTS" D ; EACH SECTION
|
||||
. F ZZGI="HEADER","PROBLEMS","VITALS","MEDS","ALERTS","RESULTS" D ;
|
||||
. . D ZGVWRK(ZZGI) ; DO EACH SECTION
|
||||
E D ZGVWRK(WHICH) ; ONLY ONE SECTION ASKED FOR
|
||||
Q
|
||||
|
@ -426,7 +426,7 @@ ZGVWRK(ZWHICH) ; DO ONE SECTION FOR RPCGV
|
|||
. . K ZZGA N ZZGA ; TEMP ARRAY FOR SECTION VARS
|
||||
. . K ZZGN2 N ZZGN2 ; NAME FOR MULTIPLE
|
||||
. . S ZZGN2=$NA(@ZZGN@(ZGVI))
|
||||
. . ; W ZZGN2,!,$O(@ZZGN2@("")),!
|
||||
. . W ZZGN2,!,$O(@ZZGN2@("")),!
|
||||
. . D H2ARY^GPLXPATH("ZZGA",ZZGN2,ZGVI) ; CONVERT HASH TO ARRAY
|
||||
. . ; D PARY^GPLXPATH("ZZGA")
|
||||
. . D PUSHA^GPLXPATH("RTN","ZZGA") ; PUSH ARRAY INTO RETURN
|
||||
|
@ -434,7 +434,7 @@ ZGVWRK(ZWHICH) ; DO ONE SECTION FOR RPCGV
|
|||
;
|
||||
DPATV(DFN,IWHICH) ; DISPLAY VARS FOR PATIENT DFN THAT ARE MAINTAINED IN GPLRIM
|
||||
; ALONG WITH SAMPLE VALUES.
|
||||
; IWHICH IS "ALL","MEDS","VITALS","PROBLEMS","ALERTS","RESULTS"
|
||||
; IWHICH IS "ALL","MEDS","VITALS","PROBLEMS","ALERTS","RESULTS","HEADER"
|
||||
N GTMP
|
||||
I '$D(^TMP("GPLRIM","ATTR",DFN)) D ; RIM VARS NOT PRESENT
|
||||
. D ANALYZE(DFN,1) ; REFRESH THE RIM VARIABLES
|
||||
|
@ -443,3 +443,37 @@ DPATV(DFN,IWHICH) ; DISPLAY VARS FOR PATIENT DFN THAT ARE MAINTAINED IN GPLRIM
|
|||
D PARY^GPLXPATH("GTMP")
|
||||
Q
|
||||
;
|
||||
RIM2RNF(R2RTN,DFN,RWHICH) ; CONVERTS RIM VARIABLES TO RNF2 FORMAT
|
||||
; RETURN IN R2RTN, WHICH IS PASSED BY NAME
|
||||
; RWHICH IS RIM SECTION TO RETURN, DEFAULTS TO "ALL"
|
||||
;
|
||||
I '$D(RWHICH) S RWHICH="ALL"
|
||||
;N R2TMP
|
||||
I '$D(^TMP("GPLRIM","ATTR",DFN)) D ; RIM VARS NOT PRESENT
|
||||
. D ANALYZE(DFN,1) ; REFRESH THE RIM VARIABLES
|
||||
D RPCGV(.R2TMP,DFN,RWHICH) ; RETRIEVE ALL THE VARIABLES I AN ARRAY
|
||||
N R2I,R2J,R2X,R2X1,R2X2,R2Y,R2Z
|
||||
F R2I=1:1:R2TMP(0) D ; FOR EVERY LINE OF THE ARRAY
|
||||
. S R2X=$P(R2TMP(R2I),"^",1) ; OCCURANCE
|
||||
. S R2Y=$P(R2TMP(R2I),"^",2) ; VARIABLE NAME
|
||||
. I $L(R2Y)<4 Q ; SKIP SHORT VARIABLES (THEY ARE FOR DEBUGGING)
|
||||
. S R2Z=$P(R2TMP(R2I),"^",3) ; VALUE
|
||||
. I R2X[";" D ; THERES MULTIPLES
|
||||
. . S R2X1=$P(R2X,";",1) ; FIRST INDEX
|
||||
. . S R2X2=$P(R2X,";",2) ; SECOND INDEX
|
||||
. . S R2J=R2Y_"["_R2X2_"]" ; BUILD THE VARIABLE NAME
|
||||
. . S @R2RTN@("F",R2J,1)="" ; PUT VARIABLE NAME IN FIELD MAP
|
||||
. . S @R2RTN@("V",R2X1,R2J,1)=R2Z ; PUT THE VALUE IN THE ARRAY
|
||||
. E D ; NO SUB-MULTIPLES
|
||||
. . S @R2RTN@("F",R2Y,1)="" ; PUT VARIABLE NAME IN FIELD MAP
|
||||
. . S @R2RTN@("V",R2X,R2Y,1)=R2Z ; PUT THE VALUE IN THE ARRAY
|
||||
Q
|
||||
;
|
||||
RIM2CSV(DFN) ; WRITE THE RIM VARIABLES FOR A PATIENT TO A CSV FILE
|
||||
;
|
||||
N R2CTMP,R2CARY
|
||||
D RIM2RNF("R2CTMP",DFN) ; CONVERT VARIABLES TO RNF FORMAT
|
||||
D RNF2CSV^C0CRNF("R2CARY","R2CTMP","NV") ; CONVERT RNF TO CSV FORMAT
|
||||
D FILEOUT^C0CRNF("R2CARY","VARS-"_DFN_".csv")
|
||||
Q
|
||||
;
|
||||
|
|
Loading…
Reference in New Issue