source: WorldVistAEHR/trunk/r/ZZREGIONAL-A1C-A5C-CRHD-RGED-RGUT-RGWB-RG/RGRPC.m@ 1742

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

initial load of WorldVistAEHR

File size: 3.4 KB
Line 
1RGRPC ;BIRMIO/CMC-RG RPC API ;3 MAY 07
2 ;;1.0;CLINICAL INFO RESOURCE NETWORK;**48**;30 Apr 99;Build 3
3 ;
4 ;
5EN(RETURN,ICN,SSN,DFN,BRANGE,ERANGE) ;
6 ;RETURN IS THE ARRAY TO HOLD THE RESULTS
7 ;ICN is the Integration Control Number of the patient to find exceptions for (optional)
8 ;SSN is the social of the patient to find exceptions for (optional)
9 ;DFN is the internal entry number of the patient in the PATIENT (#2) file to find exceptions for (optional)
10 ;Either ICN, SSN or DFN must be present
11 ;BRANGE is the BEGINNING date range specified to find exceptions for the patient
12 ;ERANGE is the ENDING date range specified to find exceptions for the patient
13 ;
14 ;S ^XTMP("CMC")=ICN_"^"_SSN_"^"_DFN_"^"_BRANGE_"^"_ERANGE FOR DEBUGGING
15 I $G(ICN)=""&$G(SSN)=""&$G(DFN)="" S RETURN="-1^Patient not specified" Q
16 I $G(BRANGE)="" S BRANGE=DT
17 I $G(ERANGE)="" S ERANGE=DT
18 I BRANGE>ERANGE S RETURN="-1^Beginning date is newer than End date" Q
19 ;
20 I $G(DFN)="" D
21 .;need to get DFN
22 .I $G(SSN)'="" S ICN=$$GETICNS^MPIF002(SSN)
23 .I $G(ICN)'="" S DFN=$$GETDFN^MPIF001(ICN)
24 I $G(DFN)=""!(+$G(DFN)=-1) S RETURN="-1^Can't find Patient" Q
25 ;
26 ; check if this data can be returned and if sensative pt bulletin needed
27 N SENS D PTSEC^DGSEC4(.SENS,DFN,1,"Remote Procedure from MPI^RPC from MPI for RG Exception Information")
28 N NOT D NOTICE^DGSEC4(.NOT,DFN,"Remote Procedure from MPI^RPC from MPI for RG Exception Information")
29 I SENS(1)=3!(SENS(1)=4)!(SENS(1)=-1) S RETURN="-1^SENSATIVE PT ISSUE "_SENS(2)_" DFN= "_DFN_" ICN= "_ICN Q
30 ;
31 ;are there any exceptions for this patient?
32 N TYP,CNT,IEN,IEN2,ETYP,WHO,X,Y,DIC,WTYP,WSTAT,MCNT S TYP="",CNT=1,MCNT=0
33 F S TYP=$O(^RGHL7(991.1,"ADFN",TYP)) Q:TYP="" D
34 .I $D(^RGHL7(991.1,"ADFN",TYP,DFN)) D
35 ..S IEN=0 F S IEN=$O(^RGHL7(991.1,"ADFN",TYP,DFN,IEN)) Q:IEN="" D
36 ...S IEN2="",ETYP="" F S IEN2=$O(^RGHL7(991.1,"ADFN",TYP,DFN,IEN,IEN2)) Q:'IEN2 D
37 ....S NODE=$G(^RGHL7(991.1,IEN,1,IEN2,0))
38 ....S NODE10=$G(^RGHL7(991.1,IEN,1,IEN2,10))
39 ....S LOGGED=$P(^RGHL7(991.1,IEN,0),"^",2)
40 ....I $P(LOGGED,".")<BRANGE!($P(LOGGED,".")>ERANGE) Q
41 ....S RETURN(CNT)="Exception Number: "_$P($G(^RGHL7(991.1,IEN,0)),"^"),CNT=CNT+1,MCNT=MCNT+1
42 ....K Y S Y=LOGGED I Y'="" D DD^%DT
43 ....S RETURN(CNT)="Exception logged on: "_Y,CNT=CNT+1
44 ....S WTYP=$G(^RGHL7(991.11,TYP,10))
45 ....S RETURN(CNT)="Exception Type: "_TYP_" - "_WTYP,CNT=CNT+1
46 ....S RETURN(CNT)="Patient DFN: "_$P(NODE,"^",4),CNT=CNT+1
47 ....S WSTAT=$P(NODE,"^",5) S WSTAT=$S(WSTAT=1:"PROCESSED",WSTAT=0:"NOT PROCESSED",1:"")
48 ....S RETURN(CNT)="Exception Status: "_WSTAT,CNT=CNT+1
49 ....I $P(NODE,"^",5)=1 D
50 .....;MARKED AS PROCESSED
51 .....K Y S Y=$P(NODE,"^",6) I Y'="" D DD^%DT
52 .....S RETURN(CNT)="Date Processed: "_Y,CNT=CNT+1
53 .....S WHO=$P(NODE,"^",7) I WHO'="" K X,Y S DIC="^VA(200,",DIC(0)="ZMO",X="`"_WHO D ^DIC I $G(Y)>1 S WHO=$G(Y(0,0))
54 .....S RETURN(CNT)="Processed by: "_WHO,CNT=CNT+1
55 ....S RETURN(CNT)="Exception Text: "_NODE10,CNT=CNT+1
56 ....I $D(^RGHL7(991.1,IEN,1,IEN2,11)) D
57 .....S RETURN(CNT)="Exception Notes:",CNT=CNT+1
58 .....N IEN3 S IEN3=0 F S IEN3=$O(^RGHL7(991.1,IEN,1,IEN2,11,IEN3)) Q:IEN3="" S RETURN(CNT)=$G(^RGHL7(991.1,IEN,1,IEN2,11,IEN3,0)),CNT=CNT+1
59 ....S RETURN(CNT)="**************************",CNT=CNT+1
60 I CNT=1 S RETURN(0)="-1^No Exceptions found in date range.",RETURN=0
61 S SITE=$$SITE^VASITE
62 N PT S PT=$S(ICN'="":"ICN= "_ICN,DFN'="":"DFN= "_DFN,SSN'="":"SSN= "_SSN)
63 I CNT>1 S RETURN(0)=MCNT_" exceptions found for "_PT_" at "_$P(SITE,"^",2)_" ("_$P(SITE,"^",3)_")",RETURN=MCNT
64 Q
Note: See TracBrowser for help on using the repository browser.