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

MCARAM6.m

Go to the documentation of this file.
  1. MCARAM6 ;WASH ISC/JKL-MUSE LOOKUP IN DHCP ;5/2/96 12:49
  1. ;;2.3;Medicine;;09/13/1996
  1. ;
  1. ;
  1. ;Lookup for last record in EKG file given a date/time and SSN
  1. ;USAGE: S X=$$LSSN^MCARAM6(A,B,.C)
  1. ;WHERE: A=Date/time of record in FileMan format
  1. ; B=Social Security Number in consecutive digits
  1. ; .C=Array into which data is placed
  1. ; if unsuccessful, returns an error message
  1. ; if successful, returns a function value of 0 and a value array:
  1. ; C("EKG") = IEN of existing EKG record
  1. ; C(1) = PID of patient, field 1, Medical Patient
  1. ; C("NAME") = name of patient
  1. ;
  1. ;variables
  1. ;MCERR = error message
  1. ;
  1. LSSN(MCDT,MCSS,MCP) ;
  1. ; Where MCDT is Date/time of record in FileMan format
  1. ; MCSS is Social Security Number in consecutive digits
  1. ; MCP is array into which data is placed
  1. ;
  1. ; Retrieves PID from SSN X-ref of Patient file
  1. N MCI,DIC,D,X,Y S MCP("EKG")=""
  1. S DIC="^DPT(",DIC(0)="XZ",D="SSN",X=MCSS D IX^DIC
  1. I +Y'>0 S MCERR=$$EMPSSN(MCSS,.Y) I +MCERR=55 Q MCERR
  1. S MCP(1)=+Y,MCP("NAME")=$P(Y(0),U)
  1. I '$D(^MCAR(691.5,"B",MCDT)) S MCERR="12-Date/Time not in EKG file" Q $$LOG^MCARAM7(MCERR)
  1. S MCI=0 F S MCI=$O(^MCAR(691.5,"B",MCDT,MCI)) Q:MCI="" I $D(^MCAR(691.5,"C",MCP(1),MCI)) S MCP("EKG")=MCI
  1. I MCP("EKG")="" S MCERR="15-PID does not exist for Date/Time" Q $$LOG^MCARAM7(MCERR)
  1. Q 0
  1. ;
  1. ERR ;Error return
  1. Q MCERR
  1. ;
  1. EMPSSN(MCSS,Y) ;Determine if unretrievable SSN belongs to an employee
  1. ;USAGE: S X=$$EMPSSN^MCARAM6(A,.B)
  1. ;WHERE: A=Social Security Number
  1. ; if unsuccessful, returns an error message
  1. ; if successful, returns a function value of 0 and an array:
  1. ; B = patient id , B(0) = patient name
  1. ;
  1. N MCEPID,MCEMP,DIC,D,X,Y
  1. S MCERR="55-Social Security Number not in Patient file"
  1. I '$D(^DPT("SSN",MCSS)) Q MCERR
  1. S MCEPID=$O(^DPT("SSN",MCSS,0))
  1. I '$D(^DPT(MCEPID,.36)) G STYPE
  1. ; Retrieves Employee entry from Eligibility Code file
  1. SELIG S DIC="^DIC(8,",DIC(0)="XZ",D="B",X="EMPLOYEE" D IX^DIC
  1. I +Y'>0 G STYPE
  1. S MCEMP=+Y
  1. I ^DPT(MCEPID,.36)=MCEMP,$D(^DPT(MCEPID,0)) S Y=MCEPID,Y(0)=$P(^DPT(MCEPID,0),"^") Q 0
  1. STYPE I '$D(^DPT(MCEPID,"TYPE")) Q MCERR
  1. ; Retrieves Employee entry from Type of Patient file
  1. S DIC="^DG(391,",DIC(0)="XZ",D="B",X="EMPLOYEE" D IX^DIC
  1. I +Y'>0 Q MCERR
  1. S MCEMP=+Y
  1. I ^DPT(MCEPID,"TYPE")=MCEMP,$D(^DPT(MCEPID,0)) S Y=MCEPID,Y(0)=$P(^DPT(MCEPID,0),"^") Q 0
  1. Q MCERR
  1. ;
  1. ;Lookup for last record in EKG file given a date/time and full name
  1. ;USAGE: S X=$$LNAME^MCARAM6(A,B,.C)
  1. ;WHERE: A=Date/time of record in FileMan format
  1. ; B=Full Name in DHCP format
  1. ; .C=Array into which data is placed
  1. ; if unsuccessful, returns an error message
  1. ; if successful, returns a function value of 0 and a value array:
  1. ; C("EKG") = IEN of existing EKG record
  1. ; C(1) = PID of patient, field 1, Medical Patient
  1. ; C("NAME") = name of patient
  1. ;
  1. ;variables
  1. ;MCERR = error message
  1. ;
  1. LNAME(MCDT,MCNAME,MCP) ;
  1. ; Where MCDT is Date/time of record in FileMan format
  1. ; MCNAME is Full Name in DHCP format
  1. ; MCP is array into which data is placed
  1. ;
  1. ; Retrieves PID from Name X-ref of Patient file
  1. N MCI,DIC,D,X,Y S MCP("EKG")=""
  1. S DIC="^DPT(",DIC(0)="XZ",D="B",X=MCNAME D IX^DIC
  1. I +Y'>0 S MCERR=$$EMPNAME(MCNAME,.Y) I +MCERR=56 Q MCERR
  1. S MCP(1)=+Y,MCP("NAME")=$P(Y(0),U)
  1. I '$D(^MCAR(691.5,"B",MCDT)) S MCERR="12-Date/Time not in EKG file" Q $$LOG^MCARAM7(MCERR)
  1. S MCI=0 F S MCI=$O(^MCAR(691.5,"B",MCDT,MCI)) Q:MCI="" I $D(^MCAR(691.5,"C",MCP(1),MCI)) S MCP("EKG")=MCI
  1. I MCP("EKG")="" S MCERR="15-PID does not exist for Date/Time" Q $$LOG^MCARAM7(MCERR)
  1. Q 0
  1. ;
  1. EMPNAME(MCNAME,Y) ;Determine if unretrievable name belongs to an employee
  1. ;USAGE: S X=$$EMPNAME^MCARAM6(A,.B)
  1. ;WHERE: A = Name
  1. ; if unsuccessful, returns an error message
  1. ; if successful, returns a function value of 0 and an array:
  1. ; B = patient id , B(0) = patient name
  1. ;
  1. N MCEPID,MCEMP,DIC,D,X,Y
  1. S MCERR="56-Name does not match Patient file"
  1. I '$D(^DPT("B",MCNAME)) Q MCERR
  1. S MCEPID=$O(^DPT("B",MCNAME,0))
  1. I '$D(^DPT(MCEPID,.36)) G NTYPE
  1. ; Retrieves Employee entry from Eligibility Code file
  1. NELIG S DIC="^DIC(8,",DIC(0)="XZ",D="B",X="EMPLOYEE" D IX^DIC
  1. I +Y'>0 G NTYPE
  1. S MCEMP=+Y
  1. I ^DPT(MCEPID,.36)=MCEMP,$D(^DPT(MCEPID,0)) S Y=MCEPID,Y(0)=$P(^DPT(MCEPID,0),"^") Q 0
  1. NTYPE I '$D(^DPT(MCEPID,"TYPE")) Q MCERR
  1. ; Retrieves Employee entry from Type of Patient file
  1. S DIC="^DG(391,",DIC(0)="XZ",D="B",X="EMPLOYEE" D IX^DIC
  1. I +Y'>0 Q MCERR
  1. S MCEMP=+Y
  1. I ^DPT(MCEPID,"TYPE")=MCEMP,$D(^DPT(MCEPID,0)) S Y=MCEPID,Y(0)=$P(^DPT(MCEPID,0),"^") Q 0
  1. Q MCERR