source: BMXNET_RPMS_dotNET_UTILITIES-BMX/trunk/m/BMXADOV2.m@ 1742

Last change on this file since 1742 was 1209, checked in by Sam Habiel, 13 years ago

BMXMON fix; updated all routines to v 2.31

File size: 4.7 KB
Line 
1BMXADOV2 ; IHS/CIHA/GIS - RPC CALL: GENERATE DATA FOR AN ADO DATASET ;
2 ;;2.31;BMX;;Jul 25, 2011
3 ; CUSTOM ITERATORS FOR RPMS
4 ;
5 ;
6 ;
7MEDICARE(PARAM,IENS,MAX,OUT,TOT) ;
8 ; NO PARAM REQUIRED BUT SINCE THIS IS A SUBFILE, THE PATIENT IEN MUST BE IH IENS
9 ; FETCHES THE MOST RECENT MEDICARE RECORD FOR THE PATIENT
10 N DFN,DA,X,Y,%,LIM,DATE,MAX
11 S LIM=DT-10000,DA=0,DATE=0,MAX=0
12 S DFN=$P(IENS,C,2) I 'DFN Q ""
13 F S DA=$O(^AUPNMCR(DFN,11,DA)) Q:'DA D
14 . S X=$G(^AUPNMCR(DFN,11,DA,0))
15 . I +X>DATE S DATE=+X,MAX=DA
16 . Q
17 I 'MAX Q ""
18 S DA=MAX
19 D DATA^BMXADOV1(IENS,DA)
20 Q ""
21 ;
22MCDIEN(DFN) ; EP-GIVEN A PATIENT IEN, RETRUN THE IEN OF THAT PT'S MOST RECENT RECORD IN MEDICAID ELIGIBILITY FILE
23 N MIEN,DA,DATE,MAX,X
24 S DFN=+$G(DFN),MAX="",DATE=0
25 S MIEN=0 F S MIEN=$O(^AUPNMCD("B",DFN,MIEN)) Q:'MIEN D
26 . S DA=0 F S DA=$O(^AUPNMCD(MIEN,11,DA)) Q:'DA D
27 .. S X=+$P($G(^AUPNMCD(MIEN,11,DA,0)),U,2)
28 .. I X>DATE S DATE=X,MAX=MIEN
29 .. Q
30 . Q
31 Q MAX
32 ;
33MEDICAID(PARAM,IENS,MAX,OUT,TOT) ;
34 ; NO PARAM REQUIRED BUT SINCE THIS IS A SUBFILE, THE PATIENT IEN MUST BE IH IENS
35 ; FETCHES THE MOST RECENT MEDICARE RECORD FOR THE PATIENT
36 N MIEN,DA,X,Y,%,LIM,DATE,MAX
37 S LIM=DT-10000,DA=0,DATE=0,MAX=0
38 S MIEN=$P(IENS,C,2) I 'MIEN Q ""
39 F S DA=$O(^AUPNMCD(MIEN,11,DA)) Q:'DA D
40 . S X=$G(^AUPNMCD(MIEN,11,DA,0))
41 . I +X>DATE S DATE=+X,MAX=DA
42 . Q
43 I 'MAX Q ""
44 S DA=MAX
45 D DATA^BMXADOV1(IENS,DA)
46 Q ""
47 ;
48PT(VAL,IENS,MAX,OUT,TOT) ; EP - PATIENT LOOKUP ; GIVEN A LOOKUP VALUE, GENERATE A LIST OF PATIENTS
49 N DFN,BMXNOID,DA,X,Y,%,LIM,FILE,NUM,IXS,GBL,CNT,SS
50 I $G(VAL)="" Q ""
51 S BMXNOID=1
52 I '$G(MAX) S MAX=999
53 I $G(^DD("2","0","ID","IHS0"))="D ^AUPNLKID" S ^("IHS0")="D:'$G(BMXNOID) ^AUPNLKID" ; MUST BE A SILENT CALL
54 S SS="BMX DFN2",GBL=$NA(^TMP(SS,$J)) K @GBL
55 S CNT=0,DFN=0
56 F S DFN=$O(^AUPNPAT("D",VAL,DFN)) Q:'DFN S CNT=CNT+1 S @GBL@("DILIST",2,CNT)=DFN ; FIRST, TRY TO MATCH CHART NUMBER
57 I CNT G PTIT
58 I VAL?3N1"-"2N1"-"4N S VAL=$TR(VAL,"-","") ; TRANSFORM SSN
59 I VAL?9N G PT1
60 S %=$L(VAL),X=$E(VAL,%-1,%)
61 I X?2N S X=VAL,%DT="P" D ^%DT S VAL=Y ; TRANSFORM DATE TO INTERNAL VALUE
62PT1 K @GBL S SS="BMX DFN1",GBL=$NA(^TMP(SS,$J)) K @GBL
63 D FIND^DIC(2,"","","",VAL,999,"B^ADOB^SSN","","",GBL,"")
64 I '$D(^TMP(SS,$J,"DILIST",2)) Q "" ; UNSUCCESSFUL LOOKUP
65PTIT ; ITERATE
66 S CNT=0,NUM=0
67 F S CNT=$O(^TMP(SS,$J,"DILIST",2,CNT)) Q:'CNT S DA=^(CNT) I DA D DATA^BMXADOV1(IENS,DA)
68 I $G(^DD("2","0","ID","IHS0"))="D:'$G(BMXNOID) ^AUPNLKID" S ^("IHS0")="D ^AUPNLKID" ; RESTORE DD NODE
69 ; K @GBL ; CLEANUP
70 Q ""
71 ;
72HRN(DFN) ; EP - GIVEN A PATIENT DFN, RETURN THE LOCAL CHART NUMBER
73 Q $P($G(^AUPNPAT(+$G(DFN),41,+$G(DUZ(2)),0)),U,2)
74 ;
75PVTINS ;
76 ; NO PARAM REQUIRED BUT SINCE THIS IS A SUBFILE, THE PATIENT IEN MUST BE IH IENS
77 N DFN,DA,X,Y,%,LIM
78 S LIM=DT-10000,DA=0
79 S DFN=$P(IENS,C,2) I 'DFN Q ""
80 F S DA=$O(^AUPNPRVT(DFN,11,DA)) Q:'DA D
81 . S X=$G(^AUPNPRVT(DFN,11,DA,0))
82 . I '$L(X) Q
83 . S %=$P(X,U,7)
84 . I '%!(%>LIM) D DATA^BMXADOV1(IENS,DA)
85 . Q
86 Q ""
87 ;
88DUPV(PARAM,IENS,MAX,OUT,TOT) ; EP - DUPLICATE VISIT ITERATION
89 ; PARAM: 'DFN|VISIT TIMESTAMP|TYPE|LOCATION|CATEGORY
90 ; PATIENT DFN AND VISIT TIMESTAMP (EXTERNAL DATE FORMAT) MUST EXIST.
91 ; THE OTHER 3 DUP PARAMETERS WILL BE CHECKED ONLY IF THEY ARE DEFINED.
92 ; ALL DUPS ARE RETURNED. MAX,START,STOP ARE IGNORED
93 N DFN,TIME,TYPE,LOC,CAT,IDT,VIEN,DAY,X,PATIENT,Y,%DT,FMTIME,DA,IENS
94 S DFN=+PARAM,TIME=$P(PARAM,B,2),TYPE=$P(PARAM,B,3),LOC=$P(PARAM,B,4),CAT=$P(PARAM,B,5)
95 I $D(^DPT(+$G(DFN),0)),$L($G(TIME))
96 E Q ""
97 S X=TIME,%DT="T" D ^%DT I Y=-1 Q
98 S FMTIME=Y
99 S (IDT,DAY)=9999999-(FMTIME\1),IDT=IDT-.0000001
100 F S IDT=$O(^AUPNVSIT("AA",DFN,IDT)) Q:$E(IDT,1,7)'=DAY S VIEN=999999999999 F S VIEN=$O(^AUPNVSIT("AA",DFN,IDT,VIEN),-1) Q:'VIEN D
101 . S X=$G(^AUPNVSIT(VIEN,0)) I '$L(X) Q ; VISIT DATA MUST EXIT
102 . I $P(X,U,11) Q ; MUST BE AN 'ACTIVE' VISIT - NOT 'DELETED'
103 . I $L(TYPE),TYPE'=$P(X,U,3) Q
104 . I $L(LOC),LOC'=$P(X,U,6) Q
105 . I $L(CAT),CAT'=$P(X,U,7) Q
106 . S DA=VIEN,IENS=DA_C
107 . D DATA^BMXADOV1(IENS,DA)
108 . Q
109 Q ""
110 ;
111DAIT(DSTG,IENS,MAX,OUT,TOT) ; EP - SET OF IENS ITERATION.
112 ; THE DSTG CONTAINS A "|" SET OF DAS STRINGS
113 ; ALL VALUES ARE RETURNED. MAX IS NOT CHECKED. START AND STOP ARE IRRELEVANT
114 N PCE,DA,XIT,IENS,L,DAS
115 S L=$L(DSTG,B)
116 F PCE=1:1:L S DAS=$P(DSTG,B,PCE) D I $G(XIT) Q
117 . I 'DAS S XIT=1 Q ; NO MORE IENS - THE END OF THE LINE
118 . I DAS'[C S IENS=DAS_C
119 . E S IENS=$$IENS^BMXADOV(DAS)
120 . S DA=+IENS
121 . D DATA^BMXADOV1(IENS,DA)
122 . Q
123 Q ""
124 ;
125APRV(PARAM,IENS,MAX,OUT,TOT) ; EP - RETURN A LIST OF ALL ACTIVE PROVIDERS
126 ; ALL VALUES ARE RETURNED. MAX IS NOT CHECKED. START AND STOP ARE IRRELEVANT
127 N NAME,DA,STG
128 S NAME=""
129 F S NAME=$O(^VA(200,"B",NAME)) Q:NAME="" D
130 . S DA=0
131 . F S DA=$O(^VA(200,"B",NAME,DA)) Q:'DA D
132 .. I $P($G(^VA(200,DA,"PS")),U,4) Q ; CHECK INACTIVE DATE FIELD
133 .. D DATA^BMXADOV1(IENS,DA)
134 .. Q
135 . Q
136 Q ""
137 ;
Note: See TracBrowser for help on using the repository browser.