source: WorldVistAEHR/trunk/r/CLINICAL_REMINDERS-PXRM/PXRMDLR.m@ 619

Last change on this file since 619 was 613, checked in by George Lilly, 15 years ago

initial load of WorldVistAEHR

File size: 3.6 KB
Line 
1PXRMDLR ;SLC/PJH - DIALOG RESULTS LOADER ;05/15/2007
2 ;;2.0;CLINICAL REMINDERS;**6**;Feb 04, 2005;Build 123
3 ;
4 ;Build score related P/N text from score and result group
5 ;
6 ;If not found
7START(ORY,RESULT,ORES) ;
8 I '$G(RESULT) S ORY(1)="-1^no results for this test" Q
9 ;
10 N ARRAY,ERROR,INSERT,OK,SCORE,SUB,YT,X
11 ;
12 I RESULT["~" S RESULT=$P(RESULT,"~")
13 S ERROR=0
14 ;
15 ;Get score using API
16 K ^TMP($J,"YSCOR")
17 I ORES("CODE")'="DOM80" D Q:ERROR
18 .M YT=ORES
19 .F X=1:1:$L(YT("R1")) I $E(YT("R1"),X)'="X" S YT(X)=X_U_$E(YT("R1"),X)
20 .K YT("R1")
21 .D CHECKCR^YTQPXRM4(.ARRAY,.YT)
22 .S OK=0
23 .;D PREVIEW^YTAPI4(.ARRAY,.YT)
24 .I ^TMP($J,"YSCOR",1)'="[DATA]" S ORY(1)="-1^"_^TMP($J,"YSCOR",1)_^TMP($J,"YSCOD",2),ERROR=1 Q
25 .;I ARRAY(1)'="[DATA]" S ORY(1)="-1^"_ARRAY(1)_ARRAY(2),ERROR=1 Q
26 .I $P($G(^TMP($J,"YSCOR",2)),"=",2)'="" S SCORE=$P($G(^TMP($J,"YSCOR",2)),"=",2),OK=1
27 .;S SUB=0,OK=0
28 .;F S SUB=$O(ARRAY(SUB)) Q:'SUB D Q:OK
29 .;.I $P(ARRAY(SUB),U)="S1" S SCORE=$P(ARRAY(SUB),U,3),OK=1
30 .I 'OK S ORY(1)="-1^[ERROR] no score returned",ERROR=1 Q
31 ;
32 ;Except for DOM80
33 I ORES("CODE")="DOM80" D
34 .I $E(ORES("R1"))="Y" S SCORE=1 Q
35 .I $E(ORES("R1"),2,3)="YY",($E(ORES("R1"),4)>1) S SCORE=1 Q
36 .S SCORE=0
37 ;
38 S DFN=$G(ORES("DFN"))
39 S INSERT("SCORE")=SCORE
40 ;
41 ;For AIMS special formatting is required
42 I ORES("CODE")="AIMS" D
43 .N CNT,LITS,RESP,SUM
44 .S LITS(0)="none",LITS(1)="minimal",LITS(2)="mild",LITS(3)="moderate"
45 .S LITS(4)="severe",SUM(2)=0,SUM(3)=0,SUM(4)=0
46 .F CNT=1:1 S RESP=$E(ORES("R1"),CNT) Q:RESP="" D
47 ..S INSERT("R"_CNT)=$G(LITS(RESP))
48 ..I (CNT<8),(234[RESP) S SUM(RESP)=SUM(RESP)+1
49 .F CNT=2,3,4 S INSERT("SUM"_CNT)=SUM(CNT)
50 ;
51TEXT ;
52 I RESULT["~" S RESULT=$P(RESULT,"~")
53 ;Load dialog results into ORY array
54 N DATA,DCON,DITEM,DSEQ,DSUB,DTYP,INS,SEP,TEXT
55 ;Get the result elements
56 S DSEQ=0,OCNT=0
57 F S DSEQ=$O(^PXRMD(801.41,RESULT,10,"B",DSEQ)) Q:'DSEQ D
58 .S DSUB=$O(^PXRMD(801.41,RESULT,10,"B",DSEQ,"")) Q:'DSUB
59 .S DITEM=$P($G(^PXRMD(801.41,RESULT,10,DSUB,0)),U,2) Q:'DITEM
60 .;Get the result element
61 .S DTYP=$P($G(^PXRMD(801.41,DITEM,0)),U,4) Q:DTYP'="T"
62 .;Get the result element condition
63 .S DCON=$P($G(^PXRMD(801.41,DITEM,0)),U,13)
64 .;Skip if condition not satisfied
65 .I DCON'="" S DCON=$TR(DCON,"~"," ") Q:'$$TRUE(SCORE,DCON,DFN)
66 .;Get progress note text if defined
67 .N LAST,NULL,SUB,TEXT S SUB=0,LAST=0
68 .F S SUB=$O(^PXRMD(801.41,DITEM,35,SUB)) Q:'SUB D
69 ..;Insert score into text (if neccessary)
70 ..S TEXT=$G(^PXRMD(801.41,DITEM,35,SUB,0))
71 ..S NULL=0 I ($E(TEXT)=" ")!(TEXT="") S NULL=1
72 ..;Add line breaks if is or preceded by blank line or starts with space
73 ..I ('NULL),LAST S TEXT="<br>"_TEXT
74 ..S TEXT=$$STRREP^PXRMUTIL(TEXT,"\\","<br>")
75 ..S LAST=0 I NULL S TEXT="<br>"_TEXT,LAST=1
76 ..;Check for inserts - note there may be embedded TIU markers too
77 ..N INS
78 ..S INS=""
79 ..F S INS=$O(INSERT(INS)) Q:INS="" D
80 ...S SEP="|"_INS_"|" I '$F(TEXT,SEP) Q
81 ...S TEXT=$P(TEXT,SEP)_$G(INSERT(INS))_$P(TEXT,SEP,2,99)
82 ..S OCNT=OCNT+1,ORY(OCNT)=7_U_TEXT
83 Q
84 ;
85MHDLL(ORES,RESULT,SCORE,DFN) ;
86 S INSERT("SCORE")=SCORE
87 D TEXT
88 Q
89OUT(DATA) ;Display element details
90 N DITEM S DITEM=$P(DATA,U,2) Q:'DITEM
91 W $P($G(^PXRMD(801.41,DITEM,0)),U)
92 W !,$J("Element Condition: ",19)
93 W $TR($P($G(^PXRMD(801.41,DITEM,0)),U,13),"~"," ")
94 W !,$J("Element text:",17)
95 ;Get progress note text if defined
96 N SUB,TEXT S SUB=0
97 F S SUB=$O(^PXRMD(801.41,DITEM,35,SUB)) Q:'SUB D
98 .S TEXT=$G(^PXRMD(801.41,DITEM,35,SUB,0)) W !,?5,TEXT
99 Q
100 ;
101TRUE(V,COND,DFN) ; Check if value meets element condition
102 N RESULT,SEX
103 I COND["SEX" D Q RESULT
104 . S RESULT=0
105 . S SEX=$P($G(^DPT(DFN,0)),U,2)
106 . X COND I S RESULT=1
107 X COND I Q 1
108 Q 0
Note: See TracBrowser for help on using the repository browser.