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

BSDSCRPC.m

Go to the documentation of this file.
BSDSCRPC ; IHS/ANMC/LJF - MODS TO PCMM RPC CALLS ; 
 ;;5.3;PIMS;;APR 26, 2002
 ;
PTLOOKUP(BSDV,BSDC) ;EP; called by FINDP^SCUTBK11 for IHS patient lookup
 ; uses code that converts answer to what SCUTBK11 wants
 ;
 ; BSDV = input value sent
 ; BSDC = count of values to return
 ;
 NEW BSDA,I,X,Y
 D LOOKUP(.BSDA,.BSDV,.BSDC)
 K ^TMP("DILIST",$J)
 F I=2:1 S Y=$P(BSDA,$C(30),I) Q:Y=$C(31)  D
 . ;  convert name^hrcn^ssn^dob^ien to ien^name^dob  hrcn^pt id
 . S X=$P(Y,U,5)_U_$P(Y,U)_U_$P(Y,U,4)_$J($P(Y,U,2),10)_U_$P(Y,U,2)
 . S ^TMP("DILIST",$J,I-1,0)=X
 Q
 ;
LOOKUP(BSDY,BSDP,BSDC)  ; Patient Lookup
 ;code blatently stolen from Horace Whitt (PTLOOKRS^BMXRPC4)
 ;
 ;Find up to BSDC patients matching BSDP*
 ;Supports DOB Lookup, SSN Lookup
 ;
 S BSDP=$TR(BSDP,$C(13),"")
 S BSDP=$TR(BSDP,$C(10),"")
 S BSDP=$TR(BSDP,$C(9),"")
 S:BSDC="" BSDC=10
 N BSDHRN,BSDZ,BSDDLIM,BSDRET
 S BSDDLIM="^"
 S BSDRET="T00030NAME^T00030HRN^T00030SSN^D00030DOB^T00030IEN"_$C(30)
 I '+$G(DUZ) S BSDY=BSDRET_$C(31) Q
 I '$D(DUZ(2)) S BSDY=BSDRET_$C(31) Q
 ;
DOB ;DOB Lookup
 I +DUZ(2),((BSDP?1.2N1"/"1.2N1"/"1.4N)!(BSDP?1.2N1" "1.2N1" "1.4N)!(BSDP?1.2N1"-"1.2N1"-"1.4N)) D  S BSDY=BSDRET_$C(31) Q
 . S X=BSDP S %DT="P" D ^%DT S BSDP=Y Q:'+Y
 . Q:'$D(^DPT("ADOB",BSDP))
 . S BSDIEN=0,BSDXX=1 F  S BSDIEN=$O(^DPT("ADOB",BSDP,BSDIEN)) Q:'+BSDIEN  D
 . . Q:'$D(^DPT(BSDIEN,0))
 . . S BSDDPT=$G(^DPT(BSDIEN,0))
 . . S BSDZ=$P(BSDDPT,U)  ;NAME
 . . S BSDHRN=$P($G(^AUPNPAT(BSDIEN,41,DUZ(2),0)),U,2)  ;CHART
 . . I BSDHRN="" Q  ;NO CHART AT THIS DUZ2
 . . I $P($G(^AUPNPAT(BSDIEN,41,DUZ(2),0)),U,3) S BSDHRN=BSDHRN_"(*)"
 . . S $P(BSDZ,BSDDLIM,2)=BSDHRN
 . . ;
 . . S $P(BSDZ,BSDDLIM,3)=$P(BSDDPT,U,9)  ;SSN
 . . S Y=$P(BSDDPT,U,3) X ^DD("DD")
 . . S $P(BSDZ,BSDDLIM,4)=Y ;DOB
 . . S $P(BSDZ,BSDDLIM,5)=BSDIEN
 . . S BSDXX=BSDXX+1
 . . S BSDRET=BSDRET_BSDZ_$C(30)
 . . Q
 . Q
 ;
 ;Chart# Lookup
 I +DUZ(2),BSDP]"",$D(^AUPNPAT("D",BSDP)) D  S BSDY=BSDRET_$C(30)_$C(31) Q
 . S BSDIEN=0 F  S BSDIEN=$O(^AUPNPAT("D",BSDP,BSDIEN)) Q:'+BSDIEN  I $D(^AUPNPAT("D",BSDP,BSDIEN,DUZ(2))) D  Q
 . . Q:'$D(^DPT(BSDIEN,0))
 . . S BSDDPT=$G(^DPT(BSDIEN,0))
 . . S BSDZ=$P(BSDDPT,U)  ;NAME
 . . S BSDHRN=BSDP ;CHART
 . . I $D(^AUPNPAT(BSDIEN,41,DUZ(2),0)),$P(^(0),U,3) S BSDHRN=BSDHRN_"(*)"
 . . S $P(BSDZ,BSDDLIM,2)=BSDHRN
 . . S $P(BSDZ,BSDDLIM,3)=$P(BSDDPT,U,9)  ;SSN
 . . S Y=$P(BSDDPT,U,3) X ^DD("DD")
 . . S $P(BSDZ,BSDDLIM,4)=Y ;DOB
 . . S $P(BSDZ,BSDDLIM,5)=BSDIEN
 . . S $P(BSDRET,$C(30),2)=BSDZ
 . . Q
 . Q
 ;
 ;SSN Lookup
 I (BSDP?9N)!(BSDP?3N1"-"2N1"-"4N),$D(^DPT("SSN",BSDP)) D  S BSDY=BSDRET_$C(30)_$C(31) Q
 . S BSDIEN=0 F  S BSDIEN=$O(^DPT("SSN",BSDP,BSDIEN)) Q:'+BSDIEN  D  Q
 . . Q:'$D(^DPT(BSDIEN,0))
 . . S BSDDPT=$G(^DPT(BSDIEN,0))
 . . S BSDZ=$P(BSDDPT,U)  ;NAME
 . . S BSDHRN=$P($G(^AUPNPAT(BSDIEN,41,DUZ(2),0)),U,2)  ;CHART
 . . I BSDHRN="" Q  ;NO CHART AT THIS DUZ2
 . . I $P($G(^AUPNPAT(BSDIEN,41,DUZ(2),0)),U,3) S BSDHRN=BSDHRN_"(*)"
 . . S $P(BSDZ,BSDDLIM,2)=BSDHRN
 . . S $P(BSDZ,BSDDLIM,3)=$P(BSDDPT,U,9)  ;SSN
 . . S Y=$P(BSDDPT,U,3) X ^DD("DD")
 . . S $P(BSDZ,BSDDLIM,4)=Y ;DOB
 . . S $P(BSDZ,BSDDLIM,5)=BSDIEN
 . . S $P(BSDRET,$C(30),2)=BSDZ
 . . Q
 . Q
 ;
 S BSDFILE=9000001
 S BSDIENS=""
 S BSDFIELD=".01"
 S BSDFLAGS="M"
 S BSDVALUE=BSDP
 S BSDNUMBR=BSDC
 S BSDINDEX=""
 S BSDSCREN=$S(+DUZ(2):"I $D(^AUPNPAT(Y,41,DUZ(2),0))",1:"")
 S BSDIDEN=""
 S BSDTARG="BSDRSLT"
 S BSDMSG=""
 D FIND^DIC(BSDFILE,BSDIENS,BSDFIELD,BSDFLAGS,BSDVALUE,BSDNUMBR,BSDINDEX,BSDSCREN,BSDIDEN,BSDTARG,BSDMSG)
 I '+$G(BSDRSLT("DILIST",0)) S BSDY=BSDRET_$C(31) Q
 F BSDX=1:1:$P(BSDRSLT("DILIST",0),U) D
 . S BSDIEN=BSDRSLT("DILIST",2,BSDX)
 . S BSDZ=BSDRSLT("DILIST","ID",BSDX,.01)  ;NAME
 . S BSDHRN=$P($G(^AUPNPAT(BSDIEN,41,DUZ(2),0)),U,2)  ;CHART
 . I BSDHRN="" Q  ;NO CHART AT THIS DUZ2
 . I $P($G(^AUPNPAT(BSDIEN,41,DUZ(2),0)),U,3) S BSDHRN=BSDHRN_"(*)"
 . S $P(BSDZ,BSDDLIM,2)=BSDHRN
 . S BSDDPT=$G(^DPT(BSDIEN,0))
 . S $P(BSDZ,BSDDLIM,3)=$P(BSDDPT,U,9)  ;SSN
 . S Y=$P(BSDDPT,U,3) X ^DD("DD")
 . S $P(BSDZ,BSDDLIM,4)=Y ;DOB
 . S $P(BSDZ,BSDDLIM,5)=BSDIEN
 . S $P(BSDRET,$C(30),BSDX+1)=BSDZ
 . Q
 S BSDY=BSDRET_$C(30)_$C(31)
 Q