source: WorldVistAEHR/trunk/r/AUTOMATED_MED_INFO_EXCHANGE-DVBA-DVBC/DVBAB84.m@ 1311

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

initial load of WorldVistAEHR

File size: 5.4 KB
RevLine 
[613]1DVBAB84 ;ALB - CAPRI REMOTE NEW PERSON FILE ;03/15/05
2 ;;2.7;AMIE;**90**;Apr 10, 1995
3 ;
4START(MSG) ;RPC DVBAB NEW PERSON FILE
5 K ^TMP("DVBAB200",$J)
6 N DATA,VAR,VAR1,DVBDIV,DVBDIVN,DVBRPT,CNT
7 S DATA="",CNT=0,MSG=$NA(^TMP("DVBAB200",$J))
8 F S DATA=$O(^VA(200,"B",DATA)) Q:DATA="" D
9 . S VAR=""
10 . F S VAR=$O(^VA(200,"B",DATA,VAR)) Q:VAR="" D
11 . . D GETS^DIQ(200,VAR_",",".01","E","DVBRPT")
12 . . I $P($G(^VA(200,VAR,2,0)),"^",3)'="" D Q
13 . . . S VAR1=""
14 . . . F S VAR1=$O(^VA(200,VAR,2,"B",VAR1)) Q:VAR1="" D
15 . . . . S DVBDIV=$$GET1^DIQ(200.02,VAR1_","_VAR_",",.01,"I")
16 . . . . S DVBDIVN=$$GET1^DIQ(200.02,VAR1_","_VAR_",",.01,"E")
17 . . . . S ^TMP("DVBAB200",$J,CNT)=VAR_"^"_DVBRPT(200,VAR_",",.01,"E")_"^"_DVBDIV_"^"_DVBDIVN_$C(13)
18 . . . . S CNT=CNT+1
19 . . S ^TMP("DVBAB200",$J,CNT)=VAR_"^"_DVBRPT(200,VAR_",",.01,"E")_"^"_"^"_$C(13)
20 . . S CNT=CNT+1
21 Q
22DUZ2(Y,NUM) ;RPC DVBAB SET DUZ2
23 N X,Z S NUM=$G(NUM),Y=1,X="0^STATION NUMBER "
24 I NUM="" S Y=X_"IS REQUIRED"
25 I '$D(^DIC(4,"D",NUM))&Y S Y=X_"DOES NOT EXIST"
26 Q:'Y S Y=$O(^DIC(4,"D",NUM,"")),Z=""
27 S:Y]"" Z=$G(^DIC(4,Y,0))
28 I Y=""!(Z="") S Y=X_"HAS A BAD X-REF" Q
29 S DUZ(2)=Y,Y=Y_U_$P(Z,U)
30 Q
31DUP(Y,NAM,DOB,SSN) ;RPC DVBAB FIND DUPS
32 N E,C,N,D,S,A,B,M S B=" - Must be ",M=B_"at least 1 argument"
33 S NAM=$$N0($G(NAM)),DOB=$P($G(DOB),"."),SSN=$$U($G(SSN))
34 S (C,N,D,S)=0,E="-1^Invalid Argument: ",Y=$NA(^TMP("DVBDUP",$J,DUZ)) K @Y
35 I '$L(NAM_DOB_SSN) S C=E_"None Passed"_M
36 S:'C&DOB&'$L(NAM_SSN) C=E_$P(M," ",3,8)_" passed with DOB"
37 S:'C N=$$VN(NAM) I N S C=E_"NAM"_B_"LAST,FIRST or IEN"
38 S:'C D=$$VD(DOB) I D S C=E_"DOB"_B_"FileMan format"
39 S:'C S=$$VS(SSN) I S>0 S C=E_"SSN"_B_"9 digits, 1U4N format, or P (for pseudo-SSN)"
40 I C S @Y@(0)=C Q
41 S:S<0 SSN=$$S(NAM,DOB)
42 D DN(.N,NAM),DD(.D,DOB,NAM,SSN),DS(.S,SSN,NAM,DOB),WT(Y,.A,.N,.D,.S)
43 Q
44DN(A,N) I N=""!A S A=0 Q ;Dup Name checks
45 N K,M S A=0,M=$$N2(N),K=$$N1(M)_"zzzzzzzzzz"
46 F S K=$O(^DPT("B",K)) Q:$$N2(K)'=M D:$$M("N",K,N,,,5) D0(.A,"B",K)
47 Q
48DD(A,D,N,S) I A!'D S A=0 Q ;Dup DOB checks
49 N K,M,F S A=0,M=$E(D,1,5),K=M-1_99
50 F S K=$O(^DPT("ADOB",K)) Q:$E(K,1,5)'=M D
51 .S F=0 I N]"",$$M("DN",K,N,D,,7) S F=1
52 .I 'F,S]"",$$M("DS",K,,D,S,7) S F=1
53 .D:F D0(.A,"ADOB",K)
54 Q
55DS(A,S,N,D) N F,K,M,X,R,P I A!'S S A=0 Q ;Dup SSN checks
56 S A=0,P=$L(S),R=P-4,M=$E(S,1,R),K=M-1_9999,X=$S(P=5:"BS5",1:"SSN")
57 F S K=$O(^DPT(X,K)) Q:$E(K,1,R)'=M D
58 .S F=$$M("S",K,,,S,P) I F D D0(.A,X,K) Q
59 .Q:N=""&'D Q:'$$FF(S,K)
60 .I D,$$MD(K,D,1) D D0(.A,X,K,3,D) Q
61 .I N]"",$$MN(K,N,1) D D0(.A,X,K,1,N)
62 Q
63D0(A,X,Y,P,V) N I,C,Z S I="",C="N D S",P=$G(P),V=$G(V)
64 F S I=$O(^DPT(X,Y,I)) Q:'I D
65 .S Z=$G(^DPT(I,0)) Q:Z=""
66 .I P,'$$M($E(C,P),$P(Z,U,P),V,V,V,5) Q
67 .S A=A+1,A(I)=Z
68 Q
69VN(X) Q:X="" 0 Q X'?2.U1","2.U ;Validate Name
70VD(X) Q:X="" 0 Q:X'?7N 1 N M,D S M=$E(X,4,5),D=$E(X,6,7) ;Validate DOB
71 Q:M<1!(M>12)!(D<0) 1 Q (D>$$D(M,$E(X,1,3)))
72VS(X) Q:X="" 0 Q:$E(X,$L(X))="P" -1 N L S L=$L(X) ;Validate SSN
73 Q:L=5&(X'?1A4N)!(L=9&(X'?9N))!(L<5)!(L>9) 1
74 Q:$E(X,1,5)="00000" 0 ;Test Patient
75 Q $E(X,1)=9!($E(X,1,3)="000") ;Can't begin with 9 or 000
76MN(X,N,F) S F=$G(F)_U_($$N2(X,2)=$$N2(N,2)) Q:'F $P(F,U,2) Q $$N2(X)=$$N2(N) ;Match Name
77MD(X,D,F) S F=$G(F)_U_($E(X,4,5)=$E(D,4,5)) Q:'F $P(F,U,2) Q $E(X,1,3)=$E(D,1,3) ;Match DOB
78MS(X,S) N I,K S K=0,X=$$L4(X),S=$$L4(S) ;Match SSN
79 F I=1:1:4 S K=$E(X,I)=$E(S,I)+K
80 Q:K>1 1 ;2 nums, same spot
81 Q $$S4(X)=$$S4(S) ;ALL 4 nums, any spot
82M(Y,X,N,D,S,L) N A,B,C,Z S (A,B,C)=0,Z=$L(X),L=+$G(L) Q:Z<L 0
83 S:Y["N" A=$$MN(X,N) S:Y["D" B=$$MD(X,D) S:Y["S" C=$$MS(X,S)
84 Q:Y="N" A Q:Y="D" B Q:Y="S" C Q:Y'["N" B&C
85 Q:Y'["D" A&C Q:Y'["S" A&B Q A&B&C
86WT(Y,A,N,D,S) N C S C=$$W0(.A,.N,.D,.S),@Y@(0)=C Q:'C ;Weights
87 N I,J,K,L S (C,I,J,K,L)=""
88 F S I=$O(A(I)) Q:'I F S J=$O(A(I,J)) Q:'J D
89 .S K=K+1,K(-J,$P(A(I,J),U),K)=I_U_A(I,J)
90 F S I=$O(K(I)) Q:'I F S J=$O(K(I,J)) Q:J="" D
91 .F S L=$O(K(I,J,L)) Q:'L S C=C+1,@Y@(C)=K(I,J,L)
92 Q
93W0(A,N,D,S) Q:N&D&S $$W3(.A,.N,.D,.S) Q:N&S&'D $$W2(.A,.N,.S)
94 Q:D&S&'N $$W2(.A,.D,.S) Q:N&D&'S $$W2(.A,.N,.D)
95 Q:S&'N&'D $$W1(.A,.S) Q:N&'D&'S $$W1(.A,.N) ;Q:D&'N&'S $$W1(.A,.D)
96 Q 0
97W1(A,X) N I,C S (I,C)=0 ;Weighting 1
98 F S I=$O(X(I)) Q:'I S C=C+1,A(I,1)=X(I)
99 Q C
100W2(A,X,Y) N I,C S (I,C)=0 ;Weighting 2
101 F S I=$O(X(I)) Q:'I S C=C+1 D
102 .I $D(Y(I)) S A(I,2)=Y(I)
103 .E S A(I,1)=X(I)
104 F S I=$O(Y(I)) Q:'I S:'$D(X(I)) C=C+1,A(I,1)=Y(I)
105 Q C
106W3(A,X,Y,Z) N I,C S (I,C)=0 ;Weighting 3
107 F S I=$O(X(I)) Q:'I S C=C+1 D
108 .I $D(Y(I)) D Q
109 ..I $D(Z(I)) S A(I,3)=Z(I)
110 ..E S A(I,2)=Y(I)
111 .I $D(Z(I)) S A(I,2)=Z(I)
112 .E S A(I,1)=X(I)
113 Q C+$$W2(.A,.Y,.Z)
114N0(X) Q:X="" "" I X?.1"`"1.N S:X["`" X=$P(X,"`",2) S X=$P($G(^DPT(X,0)),U)
115 Q $$U($$P(X,", "))
116N1(X) Q $E(X,1,$L(X)-1)_$C($A($E(X,$L(X)))-1)
117N2(X,Y) Q $E($$P($P(X,",",$G(Y,1)),2),1,2)
118U(X) Q $TR(X,"abcdefghijklmnopqrstuvwxyz","ABCDEFGHIJKLMNOPQRSTUVWXYZ")
119L4(X) N L S L=$L(X) S:$E(X,L)="P" L=L-1,X=$E(X,1,L) Q $E(X,L-3,L)
120D(M,Y) Q:M=2 28+$$L(Y+1700) Q 31-((M<7&'(M#2))!(M>7&(M#2)))
121L(Y) Q Y#100!('(Y#400)&'(Y#4))
122C(X) S X=$A($E(X,1))-65\3+1 Q:X<0 0 Q X
123P(X,C,L) N I,Y,Z S Z="",Y=X,C=$G(C,U),L=$G(L,$L(Y))
124 F I=1:1:$L(Y) Q:$L(Z)=L S X=$E(Y,I) S:X?1U!(C[X) Z=Z_X
125 Q Z
126S(N,D) N L1,L2,L3 S:$G(D)="" D=2000000 ;PSEU^DGRPDD1
127 S L3=$$C(N),L1=$$C($P(N," ",2)),L2=$$C($P(N,",",2))
128 Q L2_L1_L3_$E(D,4,7)_$E(D,2,3)_"P"
129A(X) Q $S(X<0:X*-1,1:X)
130FF(X,Y) N I,K S X=$$L4(X),Y=$$L4(Y),K=0
131 F I=1:1:4 S:$$A($E(X,I)-$E(Y,I))<2 K=K+1
132 Q K>2
133S4(X) N I,J,K,L,M S L=$L(X)
134 F I=2:1:L S J=I,K=$E(X,I) D
135 .F Q:J=1 S M=$E(X,J-1) Q:M'>K S $E(X,J)=M,J=J-1
136 .S $E(X,J)=K
137 Q X
Note: See TracBrowser for help on using the repository browser.