APSSLIC ;IHS/MSC/MDM - ScriptPro Interface;28-Sep-2007 10:47;SM
;;1.0;IHS SCRIPTPRO INTERFACE;**1**;January 11, 2006
; Call via entry point placed in Transform Field of File 9009033.3
; Direct entry not supported
Q
EP1(APSSPIEN,APSSMETH) ;MDM - Main entry point
;
; Provider IEN required
I '$G(APSSPIEN) Q ""
; Processing Method Required
I '$G(APSSMETH) Q ""
;
; Data from Sub-File LICENSING STATE (#200.541)(multiple) from NEW PERSON File (#200)
; Data from LOCATION FILE (#9999999.06)
;
; APSSPIEN = Provider Internal Entry Number passed from calling routine.
; APSSMETH = Processing Method
;
; Method 1
; Match it to the state the facility is in
; If there is no license for that state then return any valid license
; If no valid license found for any state then return NULL
;
; Method 2
; There is no license for the state the facility is in then,
; return NULL even if other states have a valid license defined.
;
; Method 3
; Return first valid license found regardless of state
; No valid license found, then return NULL
;
;
; APSSENT = Entry in the LICENSING STATE(multiple)
; APSSKEY = Key to the LICENSING STATE(multiple)
; APSSLNO = Active License Number for the Provider
; APSSEDT = The Expiration Date for the Provider's License
; APSSIDT = The Internal Format Expiration Date for the Provider's License used to compare dates
; APSSFLOC= Facility Location (State) as determined by the users facility ID in DUZ(2)
; APSSTATE = License Issuing State
; APSSTMP = Temporary holding variable
; APSSTMP1 = Temporary holding variable
;
N APSSLNO,APSSEDT,APSSDAT,APSSENT,APSSLNO,APSSKEY,APSSENT,APSSIDT,APSSEXIT,APSSFLOC,APSSTATE
N APSSTMP,APSSTMP1
;
; This section processes each entry.
;
S (APSSENT,APSSEXIT)=0,(APSSLNO,APSSTMP)="" ; Initialize working variables
;
; To check for the License based on the state the facility is located in
1 ; the LOCATION file# (9999999.06) must have the state defined in field .23
S APSSFLOC=$$GET1^DIQ(9999999.06,DUZ(2),.23) ; Facility Location (State)
;
; If the processing Method is 1 or 2 and the facility state is NULL then quit processing.
I (APSSMETH=1!(APSSMETH=2)),APSSFLOC="" Q APSSLNO
;
; Order through each file entry for this provider.
F S APSSENT=$O(^VA(200,APSSPIEN,"PS1",APSSENT)) Q:('APSSENT)!(APSSEXIT) D
. ; Initialize the key to the file
. S APSSKEY=APSSENT_","_APSSPIEN_","
. ; Retrieve data using FileMan API
. S APSSTATE=$$GET1^DIQ(200.541,APSSKEY,.01) ; Field .01 License Issuing State
. S APSSTMP=$$GET1^DIQ(200.541,APSSKEY,1) ; Field 1 License Number
. S APSSIDT=$$GET1^DIQ(200.541,APSSKEY,2,"I") ; Field 2 Expiration Date Internal format
. S APSSEDT=$$FMTE^XLFDT(APSSIDT,"5DZ0") ; Field 2 Expiration Date External format conversion
. ;
. ; Processing Method
. I APSSMETH=1 D
. . ; Grab the first valid License regardless of state
. . I (APSSIDT>DT)&(APSSTMP="") S APSSTMP1=APSSTMP
. . ; If the state matches the facility location AND the license is valid stop further processing
. . I (APSSTATE=APSSFLOC)&(APSSIDT>DT) S APSSLNO=APSSTMP,APSSEXIT=1 Q
. . Q
. I APSSMETH=2 D
. . ; If the state matches the facility location AND the license is valid stop further processing
. . I (APSSTATE=APSSFLOC)&(APSSIDT>DT) S APSSLNO=APSSTMP,APSSEXIT=1 Q
. . Q
. I APSSMETH=3 D
. . ; Stop processing any more entries once valid entry is found.
. . I APSSIDT>DT S APSSLNO=APSSTMP,APSSEXIT=1 Q
. . Q
. Q
; If processing Method 1 and no license number was found for the facility location
; but a valid license was found from a different state than that of the
; facility location then use the license that was found.
I (APSSLNO="")&(APSSMETH=1) S APSSLNO=APSSTMP
; Return value
Q APSSLNO
;
SDEA(CLIN) ; Site DEA Number
N INST,SDEA
I CLIN="" Q $$GET1^DIQ(4,+$$SITE^VASITE,52,"E")
S SDEA=""
S INST=$$GET1^DIQ(44,CLIN,3,"I")
S SDEA=$$GET1^DIQ(4,INST,52,"E")
I SDEA="" S SDEA=$$GET1^DIQ(4,+$$SITE^VASITE,52,"E")
Q SDEA
;
SNAME(CLIN) ; Site Name
N INST,SNAME
I 'CLIN Q $P($$SITE^VASITE,U,2)
S INST=$$GET1^DIQ(44,CLIN,3,"I")
S SNAME=$$GET1^DIQ(4,INST,.01,"E")
I SNAME="" S SNAME=$P($$SITE^VASITE,U,2)
Q SNAME
PADDR(PAT) ; Patient Address
N ADDR,ADDR1,ADDR2,ADDR3,CITY,STATE,ZIP,PADDR
S IENS=PAT_","
D GETS^DIQ(2,IENS,".111;.112;.113;.114;.115;.1112","E","PADDR")
S ADDR=$G(PADDR(2,IENS,.111,"E"))_U_$G(PADDR(2,IENS,.112,"E"))_U_$G(PADDR(2,IENS,.113,"E"))_U_$G(PADDR(2,IENS,.114,"E"))_U_$G(PADDR(2,IENS,.115,"E"))_U_$G(PADDR(2,IENS,.1112,"E"))
Q ADDR
APSSLIC ;IHS/MSC/MDM - ScriptPro Interface;28-Sep-2007 10:47;SM
+1 ;;1.0;IHS SCRIPTPRO INTERFACE;**1**;January 11, 2006
+2 ; Call via entry point placed in Transform Field of File 9009033.3
+3 ; Direct entry not supported
+4 QUIT
EP1(APSSPIEN,APSSMETH) ;MDM - Main entry point
+1 ;
+2 ; Provider IEN required
+3 IF '$GET(APSSPIEN)
QUIT ""
+4 ; Processing Method Required
+5 IF '$GET(APSSMETH)
QUIT ""
+6 ;
+7 ; Data from Sub-File LICENSING STATE (#200.541)(multiple) from NEW PERSON File (#200)
+8 ; Data from LOCATION FILE (#9999999.06)
+9 ;
+10 ; APSSPIEN = Provider Internal Entry Number passed from calling routine.
+11 ; APSSMETH = Processing Method
+12 ;
+13 ; Method 1
+14 ; Match it to the state the facility is in
+15 ; If there is no license for that state then return any valid license
+16 ; If no valid license found for any state then return NULL
+17 ;
+18 ; Method 2
+19 ; There is no license for the state the facility is in then,
+20 ; return NULL even if other states have a valid license defined.
+21 ;
+22 ; Method 3
+23 ; Return first valid license found regardless of state
+24 ; No valid license found, then return NULL
+25 ;
+26 ;
+27 ; APSSENT = Entry in the LICENSING STATE(multiple)
+28 ; APSSKEY = Key to the LICENSING STATE(multiple)
+29 ; APSSLNO = Active License Number for the Provider
+30 ; APSSEDT = The Expiration Date for the Provider's License
+31 ; APSSIDT = The Internal Format Expiration Date for the Provider's License used to compare dates
+32 ; APSSFLOC= Facility Location (State) as determined by the users facility ID in DUZ(2)
+33 ; APSSTATE = License Issuing State
+34 ; APSSTMP = Temporary holding variable
+35 ; APSSTMP1 = Temporary holding variable
+36 ;
+37 NEW APSSLNO,APSSEDT,APSSDAT,APSSENT,APSSLNO,APSSKEY,APSSENT,APSSIDT,APSSEXIT,APSSFLOC,APSSTATE
+38 NEW APSSTMP,APSSTMP1
+39 ;
+40 ; This section processes each entry.
+41 ;
+42 ; Initialize working variables
SET (APSSENT,APSSEXIT)=0
SET (APSSLNO,APSSTMP)=""
+43 ;
+44 ; To check for the License based on the state the facility is located in
1 ; the LOCATION file# (9999999.06) must have the state defined in field .23
+1 ; Facility Location (State)
SET APSSFLOC=$$GET1^DIQ(9999999.06,DUZ(2),.23)
+2 ;
+3 ; If the processing Method is 1 or 2 and the facility state is NULL then quit processing.
+4 IF (APSSMETH=1!(APSSMETH=2))
IF APSSFLOC=""
QUIT APSSLNO
+5 ;
+6 ; Order through each file entry for this provider.
+7 FOR
SET APSSENT=$ORDER(^VA(200,APSSPIEN,"PS1",APSSENT))
IF ('APSSENT)!(APSSEXIT)
QUIT
Begin DoDot:1
+8 ; Initialize the key to the file
+9 SET APSSKEY=APSSENT_","_APSSPIEN_","
+10 ; Retrieve data using FileMan API
+11 ; Field .01 License Issuing State
SET APSSTATE=$$GET1^DIQ(200.541,APSSKEY,.01)
+12 ; Field 1 License Number
SET APSSTMP=$$GET1^DIQ(200.541,APSSKEY,1)
+13 ; Field 2 Expiration Date Internal format
SET APSSIDT=$$GET1^DIQ(200.541,APSSKEY,2,"I")
+14 ; Field 2 Expiration Date External format conversion
SET APSSEDT=$$FMTE^XLFDT(APSSIDT,"5DZ0")
+15 ;
+16 ; Processing Method
+17 IF APSSMETH=1
Begin DoDot:2
+18 ; Grab the first valid License regardless of state
+19 IF (APSSIDT>DT)&(APSSTMP="")
SET APSSTMP1=APSSTMP
+20 ; If the state matches the facility location AND the license is valid stop further processing
+21 IF (APSSTATE=APSSFLOC)&(APSSIDT>DT)
SET APSSLNO=APSSTMP
SET APSSEXIT=1
QUIT
+22 QUIT
End DoDot:2
+23 IF APSSMETH=2
Begin DoDot:2
+24 ; If the state matches the facility location AND the license is valid stop further processing
+25 IF (APSSTATE=APSSFLOC)&(APSSIDT>DT)
SET APSSLNO=APSSTMP
SET APSSEXIT=1
QUIT
+26 QUIT
End DoDot:2
+27 IF APSSMETH=3
Begin DoDot:2
+28 ; Stop processing any more entries once valid entry is found.
+29 IF APSSIDT>DT
SET APSSLNO=APSSTMP
SET APSSEXIT=1
QUIT
+30 QUIT
End DoDot:2
+31 QUIT
End DoDot:1
+32 ; If processing Method 1 and no license number was found for the facility location
+33 ; but a valid license was found from a different state than that of the
+34 ; facility location then use the license that was found.
+35 IF (APSSLNO="")&(APSSMETH=1)
SET APSSLNO=APSSTMP
+36 ; Return value
+37 QUIT APSSLNO
+38 ;
SDEA(CLIN) ; Site DEA Number
+1 NEW INST,SDEA
+2 IF CLIN=""
QUIT $$GET1^DIQ(4,+$$SITE^VASITE,52,"E")
+3 SET SDEA=""
+4 SET INST=$$GET1^DIQ(44,CLIN,3,"I")
+5 SET SDEA=$$GET1^DIQ(4,INST,52,"E")
+6 IF SDEA=""
SET SDEA=$$GET1^DIQ(4,+$$SITE^VASITE,52,"E")
+7 QUIT SDEA
+8 ;
SNAME(CLIN) ; Site Name
+1 NEW INST,SNAME
+2 IF 'CLIN
QUIT $PIECE($$SITE^VASITE,U,2)
+3 SET INST=$$GET1^DIQ(44,CLIN,3,"I")
+4 SET SNAME=$$GET1^DIQ(4,INST,.01,"E")
+5 IF SNAME=""
SET SNAME=$PIECE($$SITE^VASITE,U,2)
+6 QUIT SNAME
PADDR(PAT) ; Patient Address
+1 NEW ADDR,ADDR1,ADDR2,ADDR3,CITY,STATE,ZIP,PADDR
+2 SET IENS=PAT_","
+3 DO GETS^DIQ(2,IENS,".111;.112;.113;.114;.115;.1112","E","PADDR")
+4 SET ADDR=$GET(PADDR(2,IENS,.111,"E"))_U_$GET(PADDR(2,IENS,.112,"E"))_U_$GET(PADDR(2,IENS,.113,"E"))_U_$GET(PADDR(2,IENS,.114,"E"))_U_$GET(PADDR(2,IENS,.115,"E"))_U_$GET(PADDR(2,IENS,.1112,"E"))
+5 QUIT ADDR