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

ORLP3AUC.m

Go to the documentation of this file.
  1. ORLP3AUC ; SLC/CLA - Automatically load clinic patients into team lists ;9/11/96 [12/28/99 2:45pm]
  1. ;;3.0;ORDER ENTRY/RESULTS REPORTING;**9,47**;Dec 17, 1997
  1. ; Re-created by PKS, 7/99.
  1. ;
  1. ; This code checks the ^TMP file that is written by the
  1. ; SC CLINIC ENROLL/DISCHARGE EVENT DRIVER protocol. That
  1. ; protocol in turn calls the protocol ORU AUTOLIST CLINIC,
  1. ; which calls this routine. When control is returned to
  1. ; SC CLINIC ENROLL/DISCHARGE EVENT DRIVER, the ^TMP entries
  1. ; are deleted. They can be viewed by breaking out before
  1. ; that point for testing [^TMP($J,"SC CED")].
  1. ;
  1. ; (NOTE: At the time of re-creation of this routine, existing code
  1. ; would not allow a user to enter a clinic enrollment or clinic
  1. ; discharge date later than the current day. Thus, no post-date
  1. ; checking is included in this routine.)
  1. ;
  1. EN ; Called by protocol: ORU AUTOLIST CLINIC. Updates Team Lists
  1. ; where the Autolink is a clinic.
  1. ;
  1. ; Variables used -
  1. ;
  1. ; By tags called (in ORLP3AC1):
  1. ;
  1. ; ORTL = OE/RR TEAM LIST file.
  1. ; ORTEAM = Team List.
  1. ; ORAL = Team List Autolink.
  1. ; ORVAL = Team List Autolink node data value.
  1. ; ORTYPE = Type of Autolink.
  1. ; ORLINK = Autolink holder variable.
  1. ; LNAME = Team List textual name.
  1. ; VP = Array for call to PTS^ORLP2.
  1. ;
  1. ; By this tag (and by tags called as needed):
  1. ;
  1. ; ORPT = Patient number.
  1. ; ORBARY = Array of "B" index clinics.
  1. ; ORCL = Clinic.
  1. ; ORBRCD = "BEFORE" clinic record number.
  1. ; ORARCD = "AFTER" clinic record number.
  1. ; ORBLAST = Last record in ^TMP file for "BEFORE" clinic.
  1. ; ORALAST = Last record in ^TMP file for "AFTER" clinic.
  1. ; ORBEFORE = Data in "BEFORE" record.
  1. ; ORAFTER = Data in "AFTER" record.
  1. ; ORBEDATE = "BEFORE" clinic enrollment date.
  1. ; ORBDDATE = "BEFORE" clinic discharge date.
  1. ; ORAEDATE = "AFTER" clinic enrollment date.
  1. ; ORADDATE = "AFTER" clinic discharge date.
  1. ;
  1. N ORTL,ORPT,ORBARY,ORCL,ORBRCD,ORARCD,ORBLAST,ORALAST,ORBEFORE,ORAFTER,ORBEDATE,ORBDDATE,ORAEDATE,ORADDATE
  1. S ORTL="100.21" ; Assign for use by ADD and DELETE tags.
  1. ;
  1. ; Check for existence of ^TMP entries:
  1. I '$D(^TMP($J,"SC CED")) Q
  1. ;
  1. ; Process each patient in the ^TMP file:
  1. S ORPT=0 ; Initialize.
  1. F S ORPT=$O(^TMP($J,"SC CED",ORPT)) Q:'ORPT D
  1. .;
  1. .; Build an array of clinics for each patient in the ^TMP file:
  1. .K ORBARY ; Clean up each time through.
  1. .;
  1. .; Order through the "B" index records for this patient:
  1. .S ORCL=0 ; Initialize.
  1. .F S ORCL=$O(^TMP($J,"SC CED",ORPT,"BEFORE","B",ORCL)) Q:'+ORCL DO ; Each "BEFORE" "B" record for clinics.
  1. ..S ORBARY(ORCL)="" ; Set array element for each "BEFORE" clinic.
  1. .S ORCL=0 ; Re-initialize.
  1. .F S ORCL=$O(^TMP($J,"SC CED",ORPT,"AFTER","B",ORCL)) Q:'+ORCL D ; Each "AFTER" "B" record for clinics.
  1. ..S ORBARY(ORCL)="" ; Set array element for each "AFTER" clinic.
  1. .; The previous array should contain only one entry for each clinic,
  1. .; whether from "BEFORE" or "AFTER" entries - (dupes overwritten).
  1. .;
  1. .; Check for valid data again:
  1. .I '$D(ORBARY) Q ; If nothing to process, done.
  1. .;
  1. .; Write data entries for "BEFORE" and "AFTER" based on ^TMP data:
  1. .S ORCL=0 ; Initialize.
  1. .F S ORCL=$O(ORBARY(ORCL)) Q:'+ORCL D ; Array entries.
  1. ..I $D(^TMP($J,"SC CED",ORPT,"BEFORE","B",ORCL)) S ORBARY(ORCL)=$O(^TMP($J,"SC CED",ORPT,"BEFORE","B",ORCL,"")) ; Set array element to ^TMP "BEFORE" "B" x-ref record number.
  1. ..S ORBARY(ORCL)=ORBARY(ORCL)_"^" ; Add delimiter.
  1. ..I $D(^TMP($J,"SC CED",ORPT,"AFTER","B",ORCL)) S ORBARY(ORCL)=ORBARY(ORCL)_$O(^TMP($J,"SC CED",ORPT,"AFTER","B",ORCL,"")) ; Set array element to ^TMP "AFTER" "B" x-ref record number.
  1. .;
  1. .; Array entries like the following should now exist:
  1. .;
  1. .; ORBARY(5)=1^1 | Clinic 5 has "BEFORE" and "AFTER" entries.
  1. .; ORBARY(16)=^3 | Clinic 16 has only an "AFTER" entry.
  1. .; (Etc.)
  1. .; ORBARY(11)=2^ | No "AFTER" entry - should never happen!
  1. .;
  1. .; Process each clinic listed for this patient:
  1. .S ORCL=0 ; Initialize.
  1. .F S ORCL=$O(ORBARY(ORCL)) Q:'+ORCL D ; Each clinic.
  1. ..;
  1. ..; Check for no "AFTER" records:
  1. ..;I $P($G(ORBARY(ORCL)),"^",2)="" Q ; Shouldn't happen!
  1. ..;
  1. ..; Get "BEFORE" and "AFTER" record entries for this clinic:
  1. ..S ORBRCD="",ORARCD="" ; Initialize.
  1. ..S ORBRCD=$P(ORBARY(ORCL),"^") ; Assign "BEFORE" record number, if any.
  1. ..S ORARCD=$P(ORBARY(ORCL),"^",2) ; Assign "AFTER" record number, if any.
  1. ..;
  1. ..; Find the last records for each case, as applicable:
  1. ..S ORBLAST="",ORALAST="" ; Initialize.
  1. ..I $G(ORBRCD) S ORBLAST=$O(^TMP($J,"SC CED",ORPT,"BEFORE",ORBRCD,1,ORBLAST),-1) ; Last "BEFORE" record.
  1. ..I $G(ORARCD) S ORALAST=$O(^TMP($J,"SC CED",ORPT,"AFTER",ORARCD,1,ORALAST),-1) ; Last "AFTER" record.
  1. ..;
  1. ..; Get BEFORE and AFTER data from last records for each clinic:
  1. ..S ORBEFORE="",ORAFTER="" ; Initialize.
  1. ..I $G(ORBLAST) S ORBEFORE=$G(^TMP($J,"SC CED",ORPT,"BEFORE",ORBRCD,1,ORBLAST,0)) ; Get "BEFORE" data.
  1. ..I $G(ORALAST) S ORAFTER=$G(^TMP($J,"SC CED",ORPT,"AFTER",ORARCD,1,ORALAST,0)) ; Get "AFTER" data.
  1. ..;
  1. ..; With "BEFORE" and "AFTER" data, process Team Lists -
  1. ..;
  1. ..; If no changes, there's nothing to do for this clinic:
  1. ..I ORBEFORE=ORAFTER Q
  1. ..;
  1. ..; Get date information in each case as applicable:
  1. ..S ORBEDATE=$P($G(ORBEFORE),"^") ; "BEFORE" enroll date.
  1. ..S ORBEDATE=$P($G(ORBEDATE),".") ; Remove time, if any.
  1. ..S ORBDDATE=$P($G(ORBEFORE),"^",3) ; "BEFORE" d/c date.
  1. ..S ORAEDATE=$P($G(ORAFTER),"^") ; "AFTER" date.
  1. ..S ORAEDATE=$P($G(ORAEDATE),".") ; Remove time, if any.
  1. ..S ORADDATE=$P($G(ORAFTER),"^",3) ; "AFTER" d/c date.
  1. ..; (All four dates should now be set, even if to null.)
  1. ..;
  1. ..; Now call the ADD or DELETE tags in ORLP3AC1 as appropriate -
  1. ..;
  1. ..; If no "AFTER" d/c and enroll <> "BEFORE" enroll, call add:
  1. ..I (ORADDATE="")&(ORAEDATE'=ORBEDATE) D ADD^ORLP3AC1
  1. ..;
  1. ..; If "AFTER" d/c exists and <> "BEFORE" d/c, call delete:
  1. ..I (ORADDATE'="")&(ORADDATE'=ORBDDATE) D DELETE^ORLP3AC1
  1. ;
  1. K ORBARY ; Clean up.
  1. Q
  1. ;