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

SCDXFU02.m

Go to the documentation of this file.
  1. 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
  1. ;
  1. CRTDEL(ENCDATE,DFN,DELDATE,ENCNODE) ;Create entry in DELETED OUTPATIENT
  1. ; ENCOUNTER file (#409.74)
  1. ;
  1. ;Input : ENCDATE - Date/time Outpatient Encounter occurred in
  1. ; FileMan format
  1. ; DFN - Pointer to entry in PATIENT file (#2) that the
  1. ; deleted Outpatient Encounter was for
  1. ; DELDATE - FileMan date/time Outpatient Encounter was deleted
  1. ; (Defaults to NOW)
  1. ; ENCNODE - Zero node of entry in OUTPATIENT ENCOUNTER file
  1. ; (#409.68) that was deleted
  1. ;Output : DELPTR - Pointer to entry in DELETED OUTPATIENT ENCOUNTER
  1. ; file (#409.74)
  1. ; -1^Error - Unable to create entry / bad input
  1. ;
  1. ;Check input
  1. S ENCDATE=+$G(ENCDATE)
  1. Q:('ENCDATE) "-1^Did not pass date/time Outpatient Encounter occurred"
  1. S DFN=+$G(DFN)
  1. Q:('$D(^DPT(DFN,0))) "-1^Did not pass valid pointer to patient"
  1. S DELDATE=+$G(DELDATE)
  1. S:('DELDATE) DELDATE="NOW"
  1. S ENCNODE=$G(ENCNODE)
  1. ;Declare variables
  1. N DIC,DA,DINUM,DLAYGO,DIDEL,DELPTR
  1. ;Create entry
  1. S DIC="^SD(409.74,"
  1. S DIC(0)="L"
  1. S X=ENCDATE
  1. S DIC("DR")=".02////^S X=DFN;.03///^S X=DELDATE;11////^S X=ENCNODE"
  1. S DLAYGO=409.74
  1. K DD,DO D FILE^DICN
  1. ;Get pointer to entry
  1. S DELPTR=+Y
  1. ;Error creating entry
  1. S:(DELPTR<0) DELPTR="-1^Unable to create entry in Deleted Outpatient Encounter file"
  1. ;Done
  1. Q DELPTR
  1. ;
  1. DELDEL(DELPTR) ;Delete entry in DELETED OUTPATIENT ENCOUNTER file (#409.74)
  1. ;
  1. ;Input : DELDEL
  1. ;Output : 0 - Success
  1. ; -1 - Unable to delete entry
  1. ;Note : Success (0) is returned when a valid pointer to the
  1. ; DELETED OUTPATIENT ENCOUNTER ERROR file is not passed
  1. ; (Deleting an entry that doesn't exist is successful)
  1. ; : It is the calling application's responsibility to also
  1. ; delete the related entry in the TRANSMITTED OUTPATIENT
  1. ; ENCOUNTER file (#409.73)
  1. ;
  1. ;Check input
  1. S DELPTR=+$G(DELPTR)
  1. Q:('$D(^SD(409.74,DELPTR,0))) 0
  1. ;Declare variables
  1. N DIK,DA,X,Y,DIC
  1. ;Delete entry
  1. S DIK="^SD(409.74,"
  1. S DA=DELPTR
  1. D ^DIK
  1. ;Done
  1. Q 0
  1. ;
  1. PTR4MID(MID) ;Find entry in TRANSMITTED OUTPATIENT ENCOUNTER file (#409.73)
  1. ; using Message Control ID
  1. ;
  1. ;Input : MID - Message Control ID used when entry was transmitted to
  1. ; National Patient Care Database
  1. ;Output : XMITPTR - Pointer to entry in TRANSMITTED OUTPATIENT
  1. ; ENCOUNTER file (#409.73)
  1. ; 0 - Entry in TRANSMITTED OUTPATIENT ENCOUNTER file with
  1. ; given Message Control ID could not be found
  1. ;
  1. ;Check input
  1. S MID=$G(MID)
  1. Q:(MID="") 0
  1. ;Find entry - done
  1. Q +$O(^SD(409.73,"AACMID",MID,""))
  1. ;
  1. PTRS4BID(BID,ARRAY) ;Find all entries in TRANSMITTED OUTPATIENT ENCOUNTER
  1. ; file (#409.73) with a specified Batch Control ID
  1. ;
  1. ;Input : BID - Batch Control ID used when entries were transmitted
  1. ; to National Patient Care Database
  1. ; ARRAY - Array to place pointers to TRANSMITTED OUTPATIENT
  1. ; ENCOUNTER file (#409.73) into (Full global reference)
  1. ; (Defaults to ^TMP("AMB-CARE",$J,"BID"))
  1. ;Output : None
  1. ; ARRAY(XMITPTR) - Array of pointers to TRANSMITTED OUTPATIENT
  1. ; ENCOUNTER file (#409.73)
  1. ;Note : It is the responsibility of the calling procedure to
  1. ; initialize (i.e. KILL) ARRAY
  1. ;
  1. ;Check input
  1. S BID=$G(BID)
  1. Q:(BID="")
  1. S ARRAY=$G(ARRAY)
  1. S:(ARRAY="") ARRAY="^TMP(""AMB-CARE"","_$J_",""BID"")"
  1. ;Build array of pointers (merge AACBID cross reference into ARRAY)
  1. M @ARRAY=^SD(409.73,"AACBID",BID)
  1. Q
  1. ;
  1. CRTERR(XMITPTR,ERRCODE,NPCD) ;Create entry in TRANSMITTED OUTPATIENT ENCOUNTER
  1. ; ERROR file (#409.75)
  1. ;
  1. ;Input : XMITPTR - Pointer to entry in TRANSMITTED OUTPATIENT
  1. ; ENCOUNTER file (#409.73)
  1. ; ERRCODE - Error code (external format)
  1. ; NPCD - '1' if filed by Austin acknowledgment (optional)
  1. ;
  1. ;Output : ERRPTR - Pointer to entry in TRANSMITTED OUTPATIENT ENCOUNTER
  1. ; ERROR file (#409.75)
  1. ; -1^Error - Unable to create entry / bad input
  1. ;Notes : ERRCODE must be a valid entry in TRANSMITTED OUTPATIENT
  1. ; ENCOUNTER ERROR CODE file (#409.76)
  1. ;
  1. ;Check input
  1. ;Convert code to 'reason unknown' if necessary
  1. I $G(NPCD) D
  1. .I '$L(ERRCODE) S ERRCODE=999 Q
  1. .I '$O(^SD(409.76,"B",ERRCODE,"")) S ERRCODE=999
  1. .Q
  1. S XMITPTR=+$G(XMITPTR)
  1. Q:('$D(^SD(409.73,XMITPTR,0))) "-1^Did not pass valid pointer to Transmitted Outpatient Encounter"
  1. S ERRCODE=$G(ERRCODE)
  1. Q:(ERRCODE="") "-1^Did not pass valid error code"
  1. Q:('$O(^SD(409.76,"B",ERRCODE,""))) "-1^Did not pass valid error code"
  1. ;Declare variables
  1. N DIC,DA,DINUM,DLAYGO,X,Y
  1. ;Create entry
  1. S DIC="^SD(409.75,"
  1. S DIC(0)="L"
  1. S DLAYGO=409.75
  1. S X=XMITPTR
  1. S DIC("DR")=".02///^S X=ERRCODE"
  1. K DD,DO D FILE^DICN
  1. ;Get pointer to entry
  1. S ERRPTR=+Y
  1. ;Error creating entry
  1. S:(ERRPTR<0) ERRPTR="-1^Unable to create entry in Transmitted Outpatient Encounter Error file"
  1. ;Done
  1. Q ERRPTR
  1. ;
  1. DELERR(ERRPTR) ;Delete entry in TRANSMITTED OUTPATIENT ENCOUNTER ERROR
  1. ; file (#409.75)
  1. ;
  1. ;Input : ERRPTR - Pointer to entry in TRANSMITTED OUTPATIENT ENCOUNTER
  1. ; ERROR file (#409.75) to delete
  1. ;Output : 0 - Success
  1. ; -1 - Unable to delete entry
  1. ;Note : Success (0) is returned when a valid pointer to the
  1. ; TRANSMITTED OUTPATIENT ENCOUNTER ERROR file is not passed
  1. ; (Deleting an entry that doesn't exist is successful)
  1. ;
  1. ;Check input
  1. S ERRPTR=+$G(ERRPTR)
  1. Q:('$D(^SD(409.75,ERRPTR,0))) 0
  1. ;Declare variables
  1. N DIK,DA,X,Y,DIC
  1. ;Delete entry
  1. S DIK="^SD(409.75,"
  1. S DA=ERRPTR
  1. D ^DIK
  1. ;Done
  1. Q 0
  1. ;
  1. DELAERR(XMITPTR,ERR) ;Delete all entries in TRANSMITTED OUTPATIENT ENCOUNTER
  1. ; ERROR file (#409.75) for a Transmitted Outpatient Encounter
  1. ;
  1. ;Input : XMITPTR - Pointer to entry in TRANSMITTED OUTPATIENT
  1. ; ENCOUNTER file (#409.73) to delete errors for
  1. ; ERR - Which error to delete.
  1. ; 0 OR NOTHING - delete ALL errors
  1. ; 1 - VISTA errors
  1. ; 2 - NPCDB errors
  1. ; 3 - HL7 errors
  1. ;
  1. ;Output : None
  1. ;
  1. ;Check input
  1. S XMITPTR=+$G(XMITPTR)
  1. S ERR=+$G(ERR)
  1. ;Declare variables
  1. N ERRPTR,TMP
  1. ;Find all entries in Transmitted Outpatient Encounter Error file that
  1. ; point to the Transmitted Outpatient Encounter and delete
  1. S ERRPTR=""
  1. F S ERRPTR=+$O(^SD(409.75,"B",XMITPTR,ERRPTR)) Q:('ERRPTR) DO
  1. .I '+ERR S TMP=$$DELERR(ERRPTR) ;default and all
  1. .N ERTYPE
  1. .S ERTYPE=+$P($G(^SD(409.75,ERRPTR,0)),U,2)
  1. .Q:'ERTYPE
  1. .S ERTYPE=$P($G(^SD(409.76,ERTYPE,0)),U,2)
  1. .I ERR=1,ERTYPE="V" S TMP=$$DELERR(ERRPTR) ;delete vista errors
  1. .I ERR=2,ERTYPE="N" S TMP=$$DELERR(ERRPTR) ;delete NPCDB errors
  1. .I ERR=3,ERTYPE="T" S TMP=$$DELERR(ERRPTR) ;delete HL7 errors
  1. .Q
  1. ;Done
  1. Q