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

RORRP020.m

Go to the documentation of this file.
  1. RORRP020 ;HIOFO/SG,VC - RPC: PATIENT DATA UTILITIES ;4/7/09 9:53am
  1. ;;1.5;CLINICAL CASE REGISTRIES;**1,8,30**;Feb 17, 2006;Build 37
  1. ;
  1. ; This routine uses the following IAs:
  1. ;
  1. ; #2051 LIST^DIC (supported)
  1. ; #2056 GET1^DIQ, GETS^DIQ (supported)
  1. ; #10061 4^VADPT (supported)
  1. ;
  1. ;ROR*1.5*30 OCT 2016 M FERRARESE Changing the dispay for "Sex" to "Birth Sex"
  1. ;
  1. ;
  1. Q
  1. ;
  1. ;***** LOADS THE DATA FROM THE 'PATIENT' FILE (#2)
  1. ;
  1. ; DFN Patient IEN
  1. ;
  1. ; .RORDEM Reference to a local variable where the demographic
  1. ; information is returned to:
  1. ;
  1. ; ^01: Patient IEN (DFN)
  1. ; ^02: Patient Name
  1. ; ^03: Date of Birth (FileMan)
  1. ; ^04: SSN
  1. ; ^05: Date of Death (FileMan)
  1. ; ^06: Birth Sex (F/M)
  1. ;
  1. ; [.RORADR] Reference to a local variable where the patient's
  1. ; address is returned to:
  1. ;
  1. ; ^01: Address (1)
  1. ; ^02: Address (2)
  1. ; ^03: Address (3)
  1. ; ^04: City
  1. ; ^05: State (IEN)
  1. ; ^06: State (Name)
  1. ; ^07: ZIP
  1. ; ^08: ZIP+4
  1. ; ^09: County (IEN)
  1. ; ^10: County (Name)
  1. ; ^11: Home Phone
  1. ;
  1. ; [.VADM] Reference to a local array that is populated by
  1. ; the 4^VADM API inside this function
  1. ;
  1. ; Return Values:
  1. ; <0 Error code
  1. ; 0 Ok
  1. ;
  1. LOAD2(DFN,RORDEM,RORADR,VADM) ;
  1. N I,VA,VAHOW,VAPA,VAROOT D 4^VADPT
  1. ;--- Demographic information
  1. S RORDEM=DFN ; DFN
  1. S $P(RORDEM,U,2)=$G(VADM(1)) ; Name
  1. S $P(RORDEM,U,3)=$P($G(VADM(3)),U) ; DOB
  1. S $P(RORDEM,U,4)=$P($G(VADM(2)),U) ; SSN
  1. S $P(RORDEM,U,5)=$P($G(VADM(6)),U) ; DOD
  1. S $P(RORDEM,U,6)=$P($G(VADM(5)),U) ; Birth Sex
  1. ;--- Patient's address
  1. S RORADR=$G(VAPA(1)) ; Address (1)
  1. S $P(RORADR,U,2)=$G(VAPA(2)) ; Address (2)
  1. S $P(RORADR,U,3)=$G(VAPA(3)) ; Address (3)
  1. S $P(RORADR,U,4)=$G(VAPA(4)) ; City
  1. S $P(RORADR,U,5)=$P($G(VAPA(5)),U,1) ; State IEN
  1. S $P(RORADR,U,6)=$P($G(VAPA(5)),U,2) ; State Name
  1. S $P(RORADR,U,7)=$P($G(VAPA(6)),U,1) ; ZIP
  1. S $P(RORADR,U,8)=$P($G(VAPA(6)),U,2) ; ZIP+4
  1. S $P(RORADR,U,9)=$P($G(VAPA(7)),U,1) ; County IEN
  1. S $P(RORADR,U,10)=$P($G(VAPA(7)),U,2) ; County Name
  1. S $P(RORADR,U,11)=$G(VAPA(8)) ; Home Phone Number
  1. Q 0
  1. ;
  1. ;***** LOADS THE REGISTRY DATA FOR THE PATIENT
  1. ;
  1. ; IEN IEN of the registry record (file #798)
  1. ;
  1. ; .ROR8DST Reference to a local variable where the results
  1. ; are returned to:
  1. ;
  1. ; ^01: Date Entered (FileMan)
  1. ; ^02: Status Code (Field 3, File #798)
  1. ; ^03: Active (0/1)
  1. ; ^04: Do not Send (0/1)
  1. ; ^05: Data Acknowledged Until (FileMan)
  1. ; ^06: Data Extracted Until (FileMan)
  1. ; ^07: Date Selected (FileMan)
  1. ; ^08: Date Confirmed (FileMan)
  1. ; ^09: Location Selected (Institution Name)
  1. ; ^10: Description of the Earliest Selection Rule
  1. ; ^11: reserved
  1. ; ^12: reserved
  1. ; ^13: Action Flags (see the description below)
  1. ;
  1. ; The Action Flags field indicates the actions that
  1. ; can be performed on the patient's record in the
  1. ; registry:
  1. ;
  1. ; C CDC form can be edited/printed
  1. ; D The record can be deleted
  1. ; E The record can be edited
  1. ; O Read-only mode
  1. ;
  1. ; DOD Date of Death (for deceased patients)
  1. ;
  1. ; COMMENT Comment of no more than 100 characters added for
  1. ; Patch 1.5*8 January, 2009
  1. ;
  1. ; Return Values:
  1. ; <0 Error code
  1. ; 0 Ok
  1. ;
  1. LOAD798(IEN,ROR8DST,DOD) ;
  1. N FLAGS,IENS,RC,RORBUF,RORMSG,TMP
  1. S ROR8DST=""
  1. ;
  1. ;--- Check if the patient is in the registry
  1. I (IEN'>0)!($D(^RORDATA(798,+IEN))<10) D Q 0
  1. . S $P(ROR8DST,U,13)=""
  1. ;
  1. ;--- Load values from the registry record
  1. S IENS=(+IEN)_","
  1. ;****************************** ONE LINE OF OLD CODE
  1. ;D GETS^DIQ(798,IENS,"1;2;3;8;9.1;9.2;11","I","RORBUF","RORMSG")
  1. K RORMSG D GETS^DIQ(798,IENS,"1;2;3;8;9.1;9.2;11;12","I","RORBUF","RORMSG")
  1. ;Q:$G(DIERR) $$DBS^RORERR("RORMSG",-9,,,798,IENS)
  1. Q:$G(RORMSG("DIERR")) $$DBS^RORERR("RORMSG",-9,,,798,IENS)
  1. ;
  1. ;--- Registry data
  1. S ROR8DST=$G(RORBUF(798,IENS,1,"I")) ; DATE ENTERED
  1. S $P(ROR8DST,U,2)=+$G(RORBUF(798,IENS,3,"I")) ; STATUS
  1. S $P(ROR8DST,U,3)=+$G(RORBUF(798,IENS,8,"I")) ; ACTIVE
  1. S $P(ROR8DST,U,4)=+$G(RORBUF(798,IENS,11,"I")) ; DON'T SEND
  1. S $P(ROR8DST,U,5)=$G(RORBUF(798,IENS,9.1,"I")) ; ACKNOWLEDGED UNTIL
  1. S $P(ROR8DST,U,6)=$G(RORBUF(798,IENS,9.2,"I")) ; EXTRACTED UNTIL
  1. S $P(ROR8DST,U,8)=$G(RORBUF(798,IENS,2,"I")) ; DATE CONFIRMED
  1. ; -- ADDED COMMENT
  1. S $P(ROR8DST,U,14)=$G(RORBUF(798,IENS,12,"I")) ; COMMENT
  1. ;
  1. ;--- Earliest selection rule
  1. S IENS=","_IENS,TMP="@;.01I;1I;2E" K RORBUF
  1. K RORMSG D LIST^DIC(798.01,IENS,TMP,"PU",1,,,"AD",,,"RORBUF","RORMSG")
  1. ;Q:$G(DIERR) $$DBS^RORERR("RORMSG",-9,,,798.01,IENS)
  1. Q:$G(RORMSG("DIERR")) $$DBS^RORERR("RORMSG",-9,,,798.01,IENS)
  1. I $G(RORBUF("DILIST",0))>0 S RC=0 D Q:RC<0 RC
  1. . S TMP=$G(RORBUF("DILIST",1,0))
  1. . S $P(ROR8DST,U,7)=$P(TMP,U,3) ; DATE
  1. . S $P(ROR8DST,U,9)=$P(TMP,U,4) ; LOCATION
  1. . S IENS=+$P(TMP,U,2)_","
  1. . K RORMSG S TMP=$$GET1^DIQ(798.2,IENS,4,,,"RORMSG")
  1. . ;S:$G(DIERR) RC=$$DBS^RORERR("RORMSG",-9,,,798.2,IENS)
  1. . S:$G(RORMSG("DIERR")) RC=$$DBS^RORERR("RORMSG",-9,,,798.2,IENS)
  1. . S $P(ROR8DST,U,10)=TMP ; SELECTION RULE
  1. ;
  1. ;--- Action flags
  1. ; The actions and modes are enabled/disabled according to the
  1. ; following table:
  1. ;-----------------------------------------------------;
  1. ; Actions ; Status of the patient ;
  1. ; and ;--------------------------------------;
  1. ; Modes ;Not Added;Pending;Active;Inactive;Dead;
  1. ;--------------+---------+-------+------+--------+----;
  1. ; (C)DC ; D ; D ; ; ; ;
  1. ; (D)elete ; D ; ; ; ; ;
  1. ; (E)dit ; D ; ; ; ; ;
  1. ; Read (O)nly ; ; ; ; ; ;
  1. ;-----------------------------------------------------;
  1. ; D the action is disabled if at least one of the marked
  1. ; conditions is true;
  1. ;
  1. ; E the action is enabled if at least one of the marked
  1. ; conditions is true.
  1. ;---
  1. D
  1. . I $P(ROR8DST,U,2)=4 S FLAGS="DE" Q ; Pending
  1. . S FLAGS="CDE"
  1. S $P(ROR8DST,U,13)=FLAGS
  1. Q 0
  1. ;
  1. ;***** PERFORMS THE POST-PROCESSING OF THE LISTS
  1. ;
  1. ; RESULTS Closed root of the array that contains the
  1. ; results of the query
  1. ;
  1. ; REGIEN Registry IEN
  1. ;
  1. ; FLAGS Flags that control the execution
  1. ;
  1. ; Return Values:
  1. ; <0 Error code
  1. ; 0 Ok
  1. ;
  1. POSTPROC(RESULTS,REGIEN,FLAGS) ;
  1. N BUF,DOD,FNP,FO,IEN,IR,PATIEN,RC,TMP
  1. S FNP=($TR(FLAGS,"P")'=FLAGS),FO=(FLAGS["O")
  1. ;--- Process the resulting records
  1. S (IR,RC)=0
  1. F S IR=$O(@RESULTS@(IR)) Q:IR'>0 D Q:RC<0
  1. . S BUF=$G(@RESULTS@(IR,0)),PATIEN=+$P(BUF,U,2)
  1. . I PATIEN'>0 S PATIEN=+BUF Q:PATIEN'>0
  1. . ;--- Load the required fields from the PATIENT file
  1. . Q:$$LOAD2(PATIEN,.BUF)<0
  1. . S DOD=$P(BUF,U,5)
  1. . S @RESULTS@(IR,0)=BUF
  1. . ;--- Add optional registry fields if necessary
  1. . I FO D Q:RC<0
  1. . . ;--- Get the IEN of the registry record
  1. . . S IEN=$$PRRIEN^RORUTL01(PATIEN,REGIEN)
  1. . . ;--- Try to load the data from the ROR REGISTRY RECORD file
  1. . . S RC=$$LOAD798(IEN,.BUF,DOD)
  1. . . S:RC'<0 @RESULTS@(IR,1)="O^"_BUF
  1. ;---
  1. Q $S(RC<0:RC,1:0)