source: FOIAVistA/trunk/r/GEN_MED_REC_VITALS-GMRV/GMRVPCE1.m@ 1154

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

initial load of FOIAVistA 6/30/08 version

File size: 4.4 KB
Line 
1GMRVPCE1 ;HIRMFO/RM-PCE Interface code ;8/2/96
2 ;;5.0;GEN. MED. REC. - VITALS;**14**;Oct 31, 2002
3PCE(GMRVSTOR) ; Called from VALIDATE^GMRVPCE0 to validate vitals data, or
4 ; STORE^GMRVPCE0 to store vitals data. The variable GMRVSTOR (req.)
5 ; will determine if called from VALIDATE (0), or STORE (1).
6 ; 08/15/2005 KAM/BAY 107096 added 'Q' for error handling
7 ; 09/23/2005 KAM/BAY 113449 add check for invalid HOS/LOC type
8 ;
9 N GMRVDFN,GMRVDUZ,GMRVHLOC,GMRVPROV,GMRVX
10 S GMRVDFN=$P($G(GMRVDAT("ENCOUNTER")),"^",2)
11 I GMRVDFN'>0!'$D(^DPT(+GMRVDFN,0)) D ERROR(0,0,1,GMRVDFN) Q
12 S GMRVHLOC=$P($G(GMRVDAT("ENCOUNTER")),"^",3)
13 I GMRVHLOC'>0!'$D(^SC(+GMRVHLOC,0)) D ERROR(0,0,2,GMRVHLOC) Q
14 ; 09/26/2005 KAM/BAY 113449 added next line
15 I GMRVHLOC>0,"C,W"'[$P(^SC(+GMRVHLOC,0),"^",3) D ERROR(0,0,8,$$GET1^DIQ(44,GMRVHLOC,.01)_" = "_$$GET1^DIQ(44,GMRVHLOC,2)) Q
16 ;
17 S GMRVDUZ=$P(GMRVDAT("SOURCE"),"^",2) I 'GMRVDUZ S GMRVDUZ=$G(DUZ)
18 I GMRVDUZ'>0!'$D(^VA(200,+GMRVDUZ,0)) D ERROR(0,0,3,GMRVDUZ) Q
19 S GMRVPROV=0
20 F S GMRVPROV=$O(GMRVDAT("VITALS",GMRVPROV)) Q:GMRVPROV'>0 D
21 . S GMRVX=0
22 . F S GMRVX=$O(GMRVDAT("VITALS",GMRVPROV,GMRVX)) Q:GMRVX'>0 D
23 . . D DATA($G(GMRVDAT("VITALS",GMRVPROV,GMRVX)))
24 . . Q
25 . Q
26 Q
27ERROR(PROVIDER,I,CODE,VALUE) ; Given Provider IEN (PROVIDER), subentry (I),
28 ; Error code (CODE) and Rejected value (VALUE), this procedure will
29 ; set the GMRVDAT("ERROR") array with error.
30 ;
31 Q:$G(GMRVSTOR)=1
32 N MSG,NODE,PIECE,X
33 S X=$T(ERRTXT+CODE),MSG=$P(X,";",3),NODE=$P(X,";",4),PIECE=$P(X,";",5)
34 S GMRVDAT("ERROR",NODE,PROVIDER,I,PIECE)=MSG_"^"_VALUE
35 Q
36ERRTXT ; Error messages and <NODE>/<PIECE> information for code passed.
37 ;;Vitals missing/invalid Patient;VITALS;0
38 ;;Vitals missing/invalid Hospital Location;VITALS;0
39 ;;Vitals missing/invalid Source;VITALS;0
40 ;;Vitals missing Data node;VITALS;0
41 ;;Vitals missing/invalid Measurement Type;VITALS;1
42 ;;Vitals missing/invalid Measurement Date;VITALS;4
43 ;;Vitals missing/invalid Measurement;VITALS;2
44 ;;Invalid Hospital Location Type;VITALS;0
45 Q
46DATA(VITALS) ; Process GMRVDAT("VITALS") node. Data in in variable VITALS.
47 ; Present but not passed are GMRVPROV=Provider IEN, GMRVX=subentry
48 ; for GMRVPROV and GMRVSTOR=$S(1:Store data,0:Validate Data).
49 ;
50 N GMRVMTYP,GMRVRATE,GMRVUNIT,GMRVMDT
51 I $G(VITALS)="" D ERROR(GMRVPROV,GMRVX,4,VITALS) Q
52 N GMRVTYP,GMRVRATE,GMRVUNIT,GMRVMDT
53 S GMRVMTYP=$P(VITALS,"^")
54 I '$$VMTYPES^GMRVPCE0(GMRVMTYP) D ERROR(GMRVPROV,GMRVX,5,GMRVMTYP) Q
55 S X=$P(VITALS,"^",4),%DT="TS" D ^%DT K %DT S GMRVMDT=Y
56 I GMRVMDT'>0 D I GMRVMDT'>0 D ERROR(GMRVPROV,GMRVX,6,GMRVMDT) Q
57 . S X=$P($G(GMRVDAT("ENCOUNTER")),"^"),%DT="TSR"
58 . D ^%DT K %DT S GMRVMDT=Y
59 . Q
60 S GMRVRATE=$P(VITALS,"^",2)
61 S GMRVUNIT=$P(VITALS,"^",3) I GMRVUNIT="" D
62 . I GMRVMTYP="HT" S GMRVUNIT="IN"
63 . I GMRVMTYP="WT" S GMRVUNIT="LB"
64 . I GMRVMTYP="TMP" S GMRVUNIT="F"
65 . Q
66 I $S(GMRVRATE="":1,1:'$$RATECHK^GMRVPCE0(GMRVMTYP,GMRVRATE,GMRVUNIT)) D ERROR(GMRVPROV,GMRVX,7,GMRVRATE) Q
67 S GMRVMTYP=$O(^GMRD(120.51,"APCE",GMRVMTYP,""))
68 ; 08/15/2005 KAM 107096 Added 'Q' to next line
69 I GMRVMTYP'>0 D ERROR(GMRVPROV,GMRVX,5,$P(VITALS,"^")) Q
70 D DUPCHK I GMRVSTOR D
71 . N GMRVFDA
72 . S GMRVFDA(99,120.5,"+1,",.01)=GMRVMDT
73 . S GMRVFDA(99,120.5,"+1,",.02)=GMRVDFN
74 . S GMRVFDA(99,120.5,"+1,",.03)=GMRVMTYP
75 . S GMRVFDA(99,120.5,"+1,",.04)=$$NOW^XLFDT()
76 . S GMRVFDA(99,120.5,"+1,",.05)=GMRVHLOC
77 . S GMRVFDA(99,120.5,"+1,",.06)=GMRVDUZ
78 . S GMRVFDA(99,120.5,"+1,",1.2)=GMRVRATE
79 . D UPDATE^DIE("","GMRVFDA(99)")
80 . Q
81 Q
82DUPCHK ; This procedure checks for duplicate data. If data is being
83 ; validated, a warning message will be sent, if data is being stored,
84 ; the old record that is duplicate will be entered in error and the
85 ; new data filed.
86 ;
87 N GMRVDA S GMRVDA=0
88 F S GMRVDA=$O(^GMR(120.5,"AA",GMRVDFN,GMRVMTYP,9999999-GMRVMDT,GMRVDA)) Q:GMRVDA'>0 D:'+$G(^GMR(120.5,GMRVDA,2))
89 . S %=$G(^GMR(120.5,GMRVDA,0))
90 . I $P(%_"^","^",5,9)'=(GMRVHLOC_"^"_GMRVDUZ_"^^"_GMRVRATE_"^") D
91 . . I GMRVSTOR D
92 . . . ;S DIE="^GMR(120.5,",DA=GMRVDA,DR="2////1;3////"_GMRVDUZ D ^DIE
93 . . . N GMRVFDA
94 . . . S GMRVFDA(88,120.5,GMRVDA_",",2)=1,GMRVFDA(88,120.5,GMRVDA_",",3)=GMRVDUZ D FILE^DIE("","GMRVFDA(88)")
95 . . . S GMRVFDA(77,120.506,"?+1,"_GMRVDA_",",.01)=4 D UPDATE^DIE("","GMRVFDA(77)")
96 . . . Q
97 . . I 'GMRVSTOR S GMRVDAT("WARNING","VITALS",GMRVPROV,GMRVX,0)="Duplicate measurement data exists in database! That data was overwritten by this transaction."
98 . Q
99 Q
Note: See TracBrowser for help on using the repository browser.