- SCDXFU02 ;ALB/JRP - AMB CARE FILE UTILITIES;03-MAY-1996 ; 17 Apr 2000 5:27 PM
- ;;5.3;Scheduling;**44,110,128,66,215**;AUG 13, 1993
- ;
- CRTDEL(ENCDATE,DFN,DELDATE,ENCNODE) ;Create entry in DELETED OUTPATIENT
- ; ENCOUNTER file (#409.74)
- ;
- ;Input : ENCDATE - Date/time Outpatient Encounter occurred in
- ; FileMan format
- ; DFN - Pointer to entry in PATIENT file (#2) that the
- ; deleted Outpatient Encounter was for
- ; DELDATE - FileMan date/time Outpatient Encounter was deleted
- ; (Defaults to NOW)
- ; ENCNODE - Zero node of entry in OUTPATIENT ENCOUNTER file
- ; (#409.68) that was deleted
- ;Output : DELPTR - Pointer to entry in DELETED OUTPATIENT ENCOUNTER
- ; file (#409.74)
- ; -1^Error - Unable to create entry / bad input
- ;
- ;Check input
- S ENCDATE=+$G(ENCDATE)
- Q:('ENCDATE) "-1^Did not pass date/time Outpatient Encounter occurred"
- S DFN=+$G(DFN)
- Q:('$D(^DPT(DFN,0))) "-1^Did not pass valid pointer to patient"
- S DELDATE=+$G(DELDATE)
- S:('DELDATE) DELDATE="NOW"
- S ENCNODE=$G(ENCNODE)
- ;Declare variables
- N DIC,DA,DINUM,DLAYGO,DIDEL,DELPTR
- ;Create entry
- S DIC="^SD(409.74,"
- S DIC(0)="L"
- S X=ENCDATE
- S DIC("DR")=".02////^S X=DFN;.03///^S X=DELDATE;11////^S X=ENCNODE"
- S DLAYGO=409.74
- K DD,DO D FILE^DICN
- ;Get pointer to entry
- S DELPTR=+Y
- ;Error creating entry
- S:(DELPTR<0) DELPTR="-1^Unable to create entry in Deleted Outpatient Encounter file"
- ;Done
- Q DELPTR
- ;
- DELDEL(DELPTR) ;Delete entry in DELETED OUTPATIENT ENCOUNTER file (#409.74)
- ;
- ;Input : DELDEL
- ;Output : 0 - Success
- ; -1 - Unable to delete entry
- ;Note : Success (0) is returned when a valid pointer to the
- ; DELETED OUTPATIENT ENCOUNTER ERROR file is not passed
- ; (Deleting an entry that doesn't exist is successful)
- ; : It is the calling application's responsibility to also
- ; delete the related entry in the TRANSMITTED OUTPATIENT
- ; ENCOUNTER file (#409.73)
- ;
- ;Check input
- S DELPTR=+$G(DELPTR)
- Q:('$D(^SD(409.74,DELPTR,0))) 0
- ;Declare variables
- N DIK,DA,X,Y,DIC
- ;Delete entry
- S DIK="^SD(409.74,"
- S DA=DELPTR
- D ^DIK
- ;Done
- Q 0
- ;
- PTR4MID(MID) ;Find entry in TRANSMITTED OUTPATIENT ENCOUNTER file (#409.73)
- ; using Message Control ID
- ;
- ;Input : MID - Message Control ID used when entry was transmitted to
- ; National Patient Care Database
- ;Output : XMITPTR - Pointer to entry in TRANSMITTED OUTPATIENT
- ; ENCOUNTER file (#409.73)
- ; 0 - Entry in TRANSMITTED OUTPATIENT ENCOUNTER file with
- ; given Message Control ID could not be found
- ;
- ;Check input
- S MID=$G(MID)
- Q:(MID="") 0
- ;Find entry - done
- Q +$O(^SD(409.73,"AACMID",MID,""))
- ;
- PTRS4BID(BID,ARRAY) ;Find all entries in TRANSMITTED OUTPATIENT ENCOUNTER
- ; file (#409.73) with a specified Batch Control ID
- ;
- ;Input : BID - Batch Control ID used when entries were transmitted
- ; to National Patient Care Database
- ; ARRAY - Array to place pointers to TRANSMITTED OUTPATIENT
- ; ENCOUNTER file (#409.73) into (Full global reference)
- ; (Defaults to ^TMP("AMB-CARE",$J,"BID"))
- ;Output : None
- ; ARRAY(XMITPTR) - Array of pointers to TRANSMITTED OUTPATIENT
- ; ENCOUNTER file (#409.73)
- ;Note : It is the responsibility of the calling procedure to
- ; initialize (i.e. KILL) ARRAY
- ;
- ;Check input
- S BID=$G(BID)
- Q:(BID="")
- S ARRAY=$G(ARRAY)
- S:(ARRAY="") ARRAY="^TMP(""AMB-CARE"","_$J_",""BID"")"
- ;Build array of pointers (merge AACBID cross reference into ARRAY)
- M @ARRAY=^SD(409.73,"AACBID",BID)
- Q
- ;
- CRTERR(XMITPTR,ERRCODE,NPCD) ;Create entry in TRANSMITTED OUTPATIENT ENCOUNTER
- ; ERROR file (#409.75)
- ;
- ;Input : XMITPTR - Pointer to entry in TRANSMITTED OUTPATIENT
- ; ENCOUNTER file (#409.73)
- ; ERRCODE - Error code (external format)
- ; NPCD - '1' if filed by Austin acknowledgment (optional)
- ;
- ;Output : ERRPTR - Pointer to entry in TRANSMITTED OUTPATIENT ENCOUNTER
- ; ERROR file (#409.75)
- ; -1^Error - Unable to create entry / bad input
- ;Notes : ERRCODE must be a valid entry in TRANSMITTED OUTPATIENT
- ; ENCOUNTER ERROR CODE file (#409.76)
- ;
- ;Check input
- ;Convert code to 'reason unknown' if necessary
- I $G(NPCD) D
- .I '$L(ERRCODE) S ERRCODE=999 Q
- .I '$O(^SD(409.76,"B",ERRCODE,"")) S ERRCODE=999
- .Q
- S XMITPTR=+$G(XMITPTR)
- Q:('$D(^SD(409.73,XMITPTR,0))) "-1^Did not pass valid pointer to Transmitted Outpatient Encounter"
- S ERRCODE=$G(ERRCODE)
- Q:(ERRCODE="") "-1^Did not pass valid error code"
- Q:('$O(^SD(409.76,"B",ERRCODE,""))) "-1^Did not pass valid error code"
- ;Declare variables
- N DIC,DA,DINUM,DLAYGO,X,Y
- ;Create entry
- S DIC="^SD(409.75,"
- S DIC(0)="L"
- S DLAYGO=409.75
- S X=XMITPTR
- S DIC("DR")=".02///^S X=ERRCODE"
- K DD,DO D FILE^DICN
- ;Get pointer to entry
- S ERRPTR=+Y
- ;Error creating entry
- S:(ERRPTR<0) ERRPTR="-1^Unable to create entry in Transmitted Outpatient Encounter Error file"
- ;Done
- Q ERRPTR
- ;
- DELERR(ERRPTR) ;Delete entry in TRANSMITTED OUTPATIENT ENCOUNTER ERROR
- ; file (#409.75)
- ;
- ;Input : ERRPTR - Pointer to entry in TRANSMITTED OUTPATIENT ENCOUNTER
- ; ERROR file (#409.75) to delete
- ;Output : 0 - Success
- ; -1 - Unable to delete entry
- ;Note : Success (0) is returned when a valid pointer to the
- ; TRANSMITTED OUTPATIENT ENCOUNTER ERROR file is not passed
- ; (Deleting an entry that doesn't exist is successful)
- ;
- ;Check input
- S ERRPTR=+$G(ERRPTR)
- Q:('$D(^SD(409.75,ERRPTR,0))) 0
- ;Declare variables
- N DIK,DA,X,Y,DIC
- ;Delete entry
- S DIK="^SD(409.75,"
- S DA=ERRPTR
- D ^DIK
- ;Done
- Q 0
- ;
- DELAERR(XMITPTR,ERR) ;Delete all entries in TRANSMITTED OUTPATIENT ENCOUNTER
- ; ERROR file (#409.75) for a Transmitted Outpatient Encounter
- ;
- ;Input : XMITPTR - Pointer to entry in TRANSMITTED OUTPATIENT
- ; ENCOUNTER file (#409.73) to delete errors for
- ; ERR - Which error to delete.
- ; 0 OR NOTHING - delete ALL errors
- ; 1 - VISTA errors
- ; 2 - NPCDB errors
- ; 3 - HL7 errors
- ;
- ;Output : None
- ;
- ;Check input
- S XMITPTR=+$G(XMITPTR)
- S ERR=+$G(ERR)
- ;Declare variables
- N ERRPTR,TMP
- ;Find all entries in Transmitted Outpatient Encounter Error file that
- ; point to the Transmitted Outpatient Encounter and delete
- S ERRPTR=""
- F S ERRPTR=+$O(^SD(409.75,"B",XMITPTR,ERRPTR)) Q:('ERRPTR) DO
- .I '+ERR S TMP=$$DELERR(ERRPTR) ;default and all
- .N ERTYPE
- .S ERTYPE=+$P($G(^SD(409.75,ERRPTR,0)),U,2)
- .Q:'ERTYPE
- .S ERTYPE=$P($G(^SD(409.76,ERTYPE,0)),U,2)
- .I ERR=1,ERTYPE="V" S TMP=$$DELERR(ERRPTR) ;delete vista errors
- .I ERR=2,ERTYPE="N" S TMP=$$DELERR(ERRPTR) ;delete NPCDB errors
- .I ERR=3,ERTYPE="T" S TMP=$$DELERR(ERRPTR) ;delete HL7 errors
- .Q
- ;Done
- Q
- --- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HSCDXFU02 7133 printed Feb 19, 2025@00:05:36 Page 2
- SCDXFU02 ;ALB/JRP - AMB CARE FILE UTILITIES;03-MAY-1996 ; 17 Apr 2000 5:27 PM
- +1 ;;5.3;Scheduling;**44,110,128,66,215**;AUG 13, 1993
- +2 ;
- CRTDEL(ENCDATE,DFN,DELDATE,ENCNODE) ;Create entry in DELETED OUTPATIENT
- +1 ; ENCOUNTER file (#409.74)
- +2 ;
- +3 ;Input : ENCDATE - Date/time Outpatient Encounter occurred in
- +4 ; FileMan format
- +5 ; DFN - Pointer to entry in PATIENT file (#2) that the
- +6 ; deleted Outpatient Encounter was for
- +7 ; DELDATE - FileMan date/time Outpatient Encounter was deleted
- +8 ; (Defaults to NOW)
- +9 ; ENCNODE - Zero node of entry in OUTPATIENT ENCOUNTER file
- +10 ; (#409.68) that was deleted
- +11 ;Output : DELPTR - Pointer to entry in DELETED OUTPATIENT ENCOUNTER
- +12 ; file (#409.74)
- +13 ; -1^Error - Unable to create entry / bad input
- +14 ;
- +15 ;Check input
- +16 SET ENCDATE=+$GET(ENCDATE)
- +17 if ('ENCDATE)
- QUIT "-1^Did not pass date/time Outpatient Encounter occurred"
- +18 SET DFN=+$GET(DFN)
- +19 if ('$DATA(^DPT(DFN,0)))
- QUIT "-1^Did not pass valid pointer to patient"
- +20 SET DELDATE=+$GET(DELDATE)
- +21 if ('DELDATE)
- SET DELDATE="NOW"
- +22 SET ENCNODE=$GET(ENCNODE)
- +23 ;Declare variables
- +24 NEW DIC,DA,DINUM,DLAYGO,DIDEL,DELPTR
- +25 ;Create entry
- +26 SET DIC="^SD(409.74,"
- +27 SET DIC(0)="L"
- +28 SET X=ENCDATE
- +29 SET DIC("DR")=".02////^S X=DFN;.03///^S X=DELDATE;11////^S X=ENCNODE"
- +30 SET DLAYGO=409.74
- +31 KILL DD,DO
- DO FILE^DICN
- +32 ;Get pointer to entry
- +33 SET DELPTR=+Y
- +34 ;Error creating entry
- +35 if (DELPTR<0)
- SET DELPTR="-1^Unable to create entry in Deleted Outpatient Encounter file"
- +36 ;Done
- +37 QUIT DELPTR
- +38 ;
- DELDEL(DELPTR) ;Delete entry in DELETED OUTPATIENT ENCOUNTER file (#409.74)
- +1 ;
- +2 ;Input : DELDEL
- +3 ;Output : 0 - Success
- +4 ; -1 - Unable to delete entry
- +5 ;Note : Success (0) is returned when a valid pointer to the
- +6 ; DELETED OUTPATIENT ENCOUNTER ERROR file is not passed
- +7 ; (Deleting an entry that doesn't exist is successful)
- +8 ; : It is the calling application's responsibility to also
- +9 ; delete the related entry in the TRANSMITTED OUTPATIENT
- +10 ; ENCOUNTER file (#409.73)
- +11 ;
- +12 ;Check input
- +13 SET DELPTR=+$GET(DELPTR)
- +14 if ('$DATA(^SD(409.74,DELPTR,0)))
- QUIT 0
- +15 ;Declare variables
- +16 NEW DIK,DA,X,Y,DIC
- +17 ;Delete entry
- +18 SET DIK="^SD(409.74,"
- +19 SET DA=DELPTR
- +20 DO ^DIK
- +21 ;Done
- +22 QUIT 0
- +23 ;
- PTR4MID(MID) ;Find entry in TRANSMITTED OUTPATIENT ENCOUNTER file (#409.73)
- +1 ; using Message Control ID
- +2 ;
- +3 ;Input : MID - Message Control ID used when entry was transmitted to
- +4 ; National Patient Care Database
- +5 ;Output : XMITPTR - Pointer to entry in TRANSMITTED OUTPATIENT
- +6 ; ENCOUNTER file (#409.73)
- +7 ; 0 - Entry in TRANSMITTED OUTPATIENT ENCOUNTER file with
- +8 ; given Message Control ID could not be found
- +9 ;
- +10 ;Check input
- +11 SET MID=$GET(MID)
- +12 if (MID="")
- QUIT 0
- +13 ;Find entry - done
- +14 QUIT +$ORDER(^SD(409.73,"AACMID",MID,""))
- +15 ;
- PTRS4BID(BID,ARRAY) ;Find all entries in TRANSMITTED OUTPATIENT ENCOUNTER
- +1 ; file (#409.73) with a specified Batch Control ID
- +2 ;
- +3 ;Input : BID - Batch Control ID used when entries were transmitted
- +4 ; to National Patient Care Database
- +5 ; ARRAY - Array to place pointers to TRANSMITTED OUTPATIENT
- +6 ; ENCOUNTER file (#409.73) into (Full global reference)
- +7 ; (Defaults to ^TMP("AMB-CARE",$J,"BID"))
- +8 ;Output : None
- +9 ; ARRAY(XMITPTR) - Array of pointers to TRANSMITTED OUTPATIENT
- +10 ; ENCOUNTER file (#409.73)
- +11 ;Note : It is the responsibility of the calling procedure to
- +12 ; initialize (i.e. KILL) ARRAY
- +13 ;
- +14 ;Check input
- +15 SET BID=$GET(BID)
- +16 if (BID="")
- QUIT
- +17 SET ARRAY=$GET(ARRAY)
- +18 if (ARRAY="")
- SET ARRAY="^TMP(""AMB-CARE"","_$JOB_",""BID"")"
- +19 ;Build array of pointers (merge AACBID cross reference into ARRAY)
- +20 MERGE @ARRAY=^SD(409.73,"AACBID",BID)
- +21 QUIT
- +22 ;
- CRTERR(XMITPTR,ERRCODE,NPCD) ;Create entry in TRANSMITTED OUTPATIENT ENCOUNTER
- +1 ; ERROR file (#409.75)
- +2 ;
- +3 ;Input : XMITPTR - Pointer to entry in TRANSMITTED OUTPATIENT
- +4 ; ENCOUNTER file (#409.73)
- +5 ; ERRCODE - Error code (external format)
- +6 ; NPCD - '1' if filed by Austin acknowledgment (optional)
- +7 ;
- +8 ;Output : ERRPTR - Pointer to entry in TRANSMITTED OUTPATIENT ENCOUNTER
- +9 ; ERROR file (#409.75)
- +10 ; -1^Error - Unable to create entry / bad input
- +11 ;Notes : ERRCODE must be a valid entry in TRANSMITTED OUTPATIENT
- +12 ; ENCOUNTER ERROR CODE file (#409.76)
- +13 ;
- +14 ;Check input
- +15 ;Convert code to 'reason unknown' if necessary
- +16 IF $GET(NPCD)
- Begin DoDot:1
- +17 IF '$LENGTH(ERRCODE)
- SET ERRCODE=999
- QUIT
- +18 IF '$ORDER(^SD(409.76,"B",ERRCODE,""))
- SET ERRCODE=999
- +19 QUIT
- End DoDot:1
- +20 SET XMITPTR=+$GET(XMITPTR)
- +21 if ('$DATA(^SD(409.73,XMITPTR,0)))
- QUIT "-1^Did not pass valid pointer to Transmitted Outpatient Encounter"
- +22 SET ERRCODE=$GET(ERRCODE)
- +23 if (ERRCODE="")
- QUIT "-1^Did not pass valid error code"
- +24 if ('$ORDER(^SD(409.76,"B",ERRCODE,"")))
- QUIT "-1^Did not pass valid error code"
- +25 ;Declare variables
- +26 NEW DIC,DA,DINUM,DLAYGO,X,Y
- +27 ;Create entry
- +28 SET DIC="^SD(409.75,"
- +29 SET DIC(0)="L"
- +30 SET DLAYGO=409.75
- +31 SET X=XMITPTR
- +32 SET DIC("DR")=".02///^S X=ERRCODE"
- +33 KILL DD,DO
- DO FILE^DICN
- +34 ;Get pointer to entry
- +35 SET ERRPTR=+Y
- +36 ;Error creating entry
- +37 if (ERRPTR<0)
- SET ERRPTR="-1^Unable to create entry in Transmitted Outpatient Encounter Error file"
- +38 ;Done
- +39 QUIT ERRPTR
- +40 ;
- DELERR(ERRPTR) ;Delete entry in TRANSMITTED OUTPATIENT ENCOUNTER ERROR
- +1 ; file (#409.75)
- +2 ;
- +3 ;Input : ERRPTR - Pointer to entry in TRANSMITTED OUTPATIENT ENCOUNTER
- +4 ; ERROR file (#409.75) to delete
- +5 ;Output : 0 - Success
- +6 ; -1 - Unable to delete entry
- +7 ;Note : Success (0) is returned when a valid pointer to the
- +8 ; TRANSMITTED OUTPATIENT ENCOUNTER ERROR file is not passed
- +9 ; (Deleting an entry that doesn't exist is successful)
- +10 ;
- +11 ;Check input
- +12 SET ERRPTR=+$GET(ERRPTR)
- +13 if ('$DATA(^SD(409.75,ERRPTR,0)))
- QUIT 0
- +14 ;Declare variables
- +15 NEW DIK,DA,X,Y,DIC
- +16 ;Delete entry
- +17 SET DIK="^SD(409.75,"
- +18 SET DA=ERRPTR
- +19 DO ^DIK
- +20 ;Done
- +21 QUIT 0
- +22 ;
- DELAERR(XMITPTR,ERR) ;Delete all entries in TRANSMITTED OUTPATIENT ENCOUNTER
- +1 ; ERROR file (#409.75) for a Transmitted Outpatient Encounter
- +2 ;
- +3 ;Input : XMITPTR - Pointer to entry in TRANSMITTED OUTPATIENT
- +4 ; ENCOUNTER file (#409.73) to delete errors for
- +5 ; ERR - Which error to delete.
- +6 ; 0 OR NOTHING - delete ALL errors
- +7 ; 1 - VISTA errors
- +8 ; 2 - NPCDB errors
- +9 ; 3 - HL7 errors
- +10 ;
- +11 ;Output : None
- +12 ;
- +13 ;Check input
- +14 SET XMITPTR=+$GET(XMITPTR)
- +15 SET ERR=+$GET(ERR)
- +16 ;Declare variables
- +17 NEW ERRPTR,TMP
- +18 ;Find all entries in Transmitted Outpatient Encounter Error file that
- +19 ; point to the Transmitted Outpatient Encounter and delete
- +20 SET ERRPTR=""
- +21 FOR
- SET ERRPTR=+$ORDER(^SD(409.75,"B",XMITPTR,ERRPTR))
- if ('ERRPTR)
- QUIT
- Begin DoDot:1
- +22 ;default and all
- IF '+ERR
- SET TMP=$$DELERR(ERRPTR)
- +23 NEW ERTYPE
- +24 SET ERTYPE=+$PIECE($GET(^SD(409.75,ERRPTR,0)),U,2)
- +25 if 'ERTYPE
- QUIT
- +26 SET ERTYPE=$PIECE($GET(^SD(409.76,ERTYPE,0)),U,2)
- +27 ;delete vista errors
- IF ERR=1
- IF ERTYPE="V"
- SET TMP=$$DELERR(ERRPTR)
- +28 ;delete NPCDB errors
- IF ERR=2
- IF ERTYPE="N"
- SET TMP=$$DELERR(ERRPTR)
- +29 ;delete HL7 errors
- IF ERR=3
- IF ERTYPE="T"
- SET TMP=$$DELERR(ERRPTR)
- +30 QUIT
- End DoDot:1
- +31 ;Done
- +32 QUIT