SDESAPPTUTIL ;ALB/TAW - SDED APPOINTMENT UTILITIES ;JULY 18, 2021@15:22
;;5.3;Scheduling;**790**;Aug 13, 1993;Build 11
; This rtn will hold various utilities for dealing with SDEC APPOINTMENTS File (409.84)
Q
MISSINGRES(APPTIEN) ;Try to get a resource from Patient / Clinic file
; This function will get the DFN and Start Time from the appointment file and look at the Appointment sub-file
; under the Patient file to try and find the
; Input:
; APTIEN - (Required) IEN from SDEC Appointment
; Return:
; The resource that shold be associated with the appointment
;
N DFN,CLINICIEN,RESIEN,APPT0,APPTSTART,RESTYPE,RESLIST,RESCNT,X,REC,APPTFOUND
S (APPTFOUND,X,RESIEN,RESCNT)=""
I APPTIEN="" Q "0^APPOINTMENT IEN IS REQUIRED"
S APPT0=$G(^SDEC(409.84,APPTIEN,0))
S DFN=$P(APPT0,U,5)
S APPTSTART=$P(APPT0,U,1)
I DFN="" Q "0^NO DFN FOR THIS APPOINTMENT"
S CLINICIEN=$$GET1^DIQ(2.98,APPTSTART_","_DFN_",",.01,"I")
I CLINICIEN="" Q "0^HOSPITAL LOCATION NOT FOUND IN APPOINTMENT SUB FILE FOR PATIENT"
;
;Confirm the patient does have an active appointment at the Hosp Loc for the Appt Start Date/Time
F S X=$O(^SC(CLINICIEN,"S",APPTSTART,1,X)) Q:X=""!(APPTFOUND) D
.S REC=$G(^SC(CLINICIEN,"S",APPTSTART,1,X,0))
.I $P(REC,"^",1)'=DFN Q
.I $P(REC,"^",9)="C" Q
.S APPTFOUND=1
I 'APPTFOUND Q "0^PATIENT DOES NOT HAVE AN ACTIVE APPT IN THE CLINIC"
;
;Since there can be multiple resources linked to a hospital location, fine the one that is a clinic
F S RESIEN=$O(^SDEC(409.831,"ALOC",CLINICIEN,RESIEN)) Q:RESIEN="" D
.S RESTYPE=$P($G(^SDEC(409.831,RESIEN,0)),"^",11)
.I $P(RESTYPE,";",2)'="SC(" Q ;Must be a Hospital Loc
.S RESLIST($I(RESCNT))=RESIEN
I 'RESCNT Q "0^NO CLINIC RESOURCES FOR THIS HOSPITAL LOCATION"
;I RESCNT>1 Q "0^MULTIPLE CLINIC RESROUCES FOR THIS HOSPITAL LOCATION"
Q RESLIST(1)
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HSDESAPPTUTIL 1871 printed Dec 13, 2024@02:55:44 Page 2
SDESAPPTUTIL ;ALB/TAW - SDED APPOINTMENT UTILITIES ;JULY 18, 2021@15:22
+1 ;;5.3;Scheduling;**790**;Aug 13, 1993;Build 11
+2 ; This rtn will hold various utilities for dealing with SDEC APPOINTMENTS File (409.84)
+3 QUIT
MISSINGRES(APPTIEN) ;Try to get a resource from Patient / Clinic file
+1 ; This function will get the DFN and Start Time from the appointment file and look at the Appointment sub-file
+2 ; under the Patient file to try and find the
+3 ; Input:
+4 ; APTIEN - (Required) IEN from SDEC Appointment
+5 ; Return:
+6 ; The resource that shold be associated with the appointment
+7 ;
+8 NEW DFN,CLINICIEN,RESIEN,APPT0,APPTSTART,RESTYPE,RESLIST,RESCNT,X,REC,APPTFOUND
+9 SET (APPTFOUND,X,RESIEN,RESCNT)=""
+10 IF APPTIEN=""
QUIT "0^APPOINTMENT IEN IS REQUIRED"
+11 SET APPT0=$GET(^SDEC(409.84,APPTIEN,0))
+12 SET DFN=$PIECE(APPT0,U,5)
+13 SET APPTSTART=$PIECE(APPT0,U,1)
+14 IF DFN=""
QUIT "0^NO DFN FOR THIS APPOINTMENT"
+15 SET CLINICIEN=$$GET1^DIQ(2.98,APPTSTART_","_DFN_",",.01,"I")
+16 IF CLINICIEN=""
QUIT "0^HOSPITAL LOCATION NOT FOUND IN APPOINTMENT SUB FILE FOR PATIENT"
+17 ;
+18 ;Confirm the patient does have an active appointment at the Hosp Loc for the Appt Start Date/Time
+19 FOR
SET X=$ORDER(^SC(CLINICIEN,"S",APPTSTART,1,X))
if X=""!(APPTFOUND)
QUIT
Begin DoDot:1
+20 SET REC=$GET(^SC(CLINICIEN,"S",APPTSTART,1,X,0))
+21 IF $PIECE(REC,"^",1)'=DFN
QUIT
+22 IF $PIECE(REC,"^",9)="C"
QUIT
+23 SET APPTFOUND=1
End DoDot:1
+24 IF 'APPTFOUND
QUIT "0^PATIENT DOES NOT HAVE AN ACTIVE APPT IN THE CLINIC"
+25 ;
+26 ;Since there can be multiple resources linked to a hospital location, fine the one that is a clinic
+27 FOR
SET RESIEN=$ORDER(^SDEC(409.831,"ALOC",CLINICIEN,RESIEN))
if RESIEN=""
QUIT
Begin DoDot:1
+28 SET RESTYPE=$PIECE($GET(^SDEC(409.831,RESIEN,0)),"^",11)
+29 ;Must be a Hospital Loc
IF $PIECE(RESTYPE,";",2)'="SC("
QUIT
+30
*** ERROR ***
SET RESLIST($I(RESCNT))=RESIEN
End DoDot:1
+31 IF 'RESCNT
QUIT "0^NO CLINIC RESOURCES FOR THIS HOSPITAL LOCATION"
+32 ;I RESCNT>1 Q "0^MULTIPLE CLINIC RESROUCES FOR THIS HOSPITAL LOCATION"
+33 QUIT RESLIST(1)