Home   Package List   Routine Alphabetical List   Global Alphabetical List   FileMan Files List   FileMan Sub-Files List   Package Component Lists   Package-Namespace Mapping  
Routine: RGRPC

RGRPC.m

Go to the documentation of this file.
  1. RGRPC ;BIRMIO/CMC-RG RPC API ;3 MAY 07
  1. ;;1.0;CLINICAL INFO RESOURCE NETWORK;**48**;30 Apr 99;Build 3
  1. ;
  1. ;
  1. EN(RETURN,ICN,SSN,DFN,BRANGE,ERANGE) ;
  1. ;RETURN IS THE ARRAY TO HOLD THE RESULTS
  1. ;ICN is the Integration Control Number of the patient to find exceptions for (optional)
  1. ;SSN is the social of the patient to find exceptions for (optional)
  1. ;DFN is the internal entry number of the patient in the PATIENT (#2) file to find exceptions for (optional)
  1. ;Either ICN, SSN or DFN must be present
  1. ;BRANGE is the BEGINNING date range specified to find exceptions for the patient
  1. ;ERANGE is the ENDING date range specified to find exceptions for the patient
  1. ;
  1. ;S ^XTMP("CMC")=ICN_"^"_SSN_"^"_DFN_"^"_BRANGE_"^"_ERANGE FOR DEBUGGING
  1. I $G(ICN)=""&$G(SSN)=""&$G(DFN)="" S RETURN="-1^Patient not specified" Q
  1. I $G(BRANGE)="" S BRANGE=DT
  1. I $G(ERANGE)="" S ERANGE=DT
  1. I BRANGE>ERANGE S RETURN="-1^Beginning date is newer than End date" Q
  1. ;
  1. I $G(DFN)="" D
  1. .;need to get DFN
  1. .I $G(SSN)'="" S ICN=$$GETICNS^MPIF002(SSN)
  1. .I $G(ICN)'="" S DFN=$$GETDFN^MPIF001(ICN)
  1. I $G(DFN)=""!(+$G(DFN)=-1) S RETURN="-1^Can't find Patient" Q
  1. ;
  1. ; check if this data can be returned and if sensative pt bulletin needed
  1. N SENS D PTSEC^DGSEC4(.SENS,DFN,1,"Remote Procedure from MPI^RPC from MPI for RG Exception Information")
  1. N NOT D NOTICE^DGSEC4(.NOT,DFN,"Remote Procedure from MPI^RPC from MPI for RG Exception Information")
  1. I SENS(1)=3!(SENS(1)=4)!(SENS(1)=-1) S RETURN="-1^SENSATIVE PT ISSUE "_SENS(2)_" DFN= "_DFN_" ICN= "_ICN Q
  1. ;
  1. ;are there any exceptions for this patient?
  1. N TYP,CNT,IEN,IEN2,ETYP,WHO,X,Y,DIC,WTYP,WSTAT,MCNT S TYP="",CNT=1,MCNT=0
  1. F S TYP=$O(^RGHL7(991.1,"ADFN",TYP)) Q:TYP="" D
  1. .I $D(^RGHL7(991.1,"ADFN",TYP,DFN)) D
  1. ..S IEN=0 F S IEN=$O(^RGHL7(991.1,"ADFN",TYP,DFN,IEN)) Q:IEN="" D
  1. ...S IEN2="",ETYP="" F S IEN2=$O(^RGHL7(991.1,"ADFN",TYP,DFN,IEN,IEN2)) Q:'IEN2 D
  1. ....S NODE=$G(^RGHL7(991.1,IEN,1,IEN2,0))
  1. ....S NODE10=$G(^RGHL7(991.1,IEN,1,IEN2,10))
  1. ....S LOGGED=$P(^RGHL7(991.1,IEN,0),"^",2)
  1. ....I $P(LOGGED,".")<BRANGE!($P(LOGGED,".")>ERANGE) Q
  1. ....S RETURN(CNT)="Exception Number: "_$P($G(^RGHL7(991.1,IEN,0)),"^"),CNT=CNT+1,MCNT=MCNT+1
  1. ....K Y S Y=LOGGED I Y'="" D DD^%DT
  1. ....S RETURN(CNT)="Exception logged on: "_Y,CNT=CNT+1
  1. ....S WTYP=$G(^RGHL7(991.11,TYP,10))
  1. ....S RETURN(CNT)="Exception Type: "_TYP_" - "_WTYP,CNT=CNT+1
  1. ....S RETURN(CNT)="Patient DFN: "_$P(NODE,"^",4),CNT=CNT+1
  1. ....S WSTAT=$P(NODE,"^",5) S WSTAT=$S(WSTAT=1:"PROCESSED",WSTAT=0:"NOT PROCESSED",1:"")
  1. ....S RETURN(CNT)="Exception Status: "_WSTAT,CNT=CNT+1
  1. ....I $P(NODE,"^",5)=1 D
  1. .....;MARKED AS PROCESSED
  1. .....K Y S Y=$P(NODE,"^",6) I Y'="" D DD^%DT
  1. .....S RETURN(CNT)="Date Processed: "_Y,CNT=CNT+1
  1. .....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))
  1. .....S RETURN(CNT)="Processed by: "_WHO,CNT=CNT+1
  1. ....S RETURN(CNT)="Exception Text: "_NODE10,CNT=CNT+1
  1. ....I $D(^RGHL7(991.1,IEN,1,IEN2,11)) D
  1. .....S RETURN(CNT)="Exception Notes:",CNT=CNT+1
  1. .....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
  1. ....S RETURN(CNT)="**************************",CNT=CNT+1
  1. I CNT=1 S RETURN(0)="-1^No Exceptions found in date range.",RETURN=0
  1. S SITE=$$SITE^VASITE
  1. N PT S PT=$S(ICN'="":"ICN= "_ICN,DFN'="":"DFN= "_DFN,SSN'="":"SSN= "_SSN)
  1. I CNT>1 S RETURN(0)=MCNT_" exceptions found for "_PT_" at "_$P(SITE,"^",2)_" ("_$P(SITE,"^",3)_")",RETURN=MCNT
  1. Q