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

VAFCMGU0.m

Go to the documentation of this file.
  1. VAFCMGU0 ;ALB/JRP-MERGE SCREEN UTILITIES ;10/18/96
  1. ;;5.3;Registration;**149,295,479**;Aug 13, 1993
  1. ;
  1. REPEAT(CHAR,TIMES) ;Repeat a string
  1. ;
  1. ;INPUT : CHAR - Character to repeat
  1. ; TIMES - Number of times to repeat CHAR
  1. ;OUTPUT : s - String of CHAR that is TIMES long
  1. ; "" - Error (bad input)
  1. ;
  1. ;Check input
  1. Q:($G(CHAR)="") ""
  1. Q:((+$G(TIMES))=0) ""
  1. ;Return string
  1. Q $TR($J("",TIMES)," ",CHAR)
  1. ;
  1. INSERT(INSTR,OUTSTR,COLUMN,LENGTH) ;Insert a string into another
  1. ;
  1. ;INPUT : INSTR - String to insert
  1. ; OUTSTR - String to insert into
  1. ; COLUMN - Where to begin insertion (defaults to end of OUTSTR)
  1. ; LENGTH - Number of characters to clear from OUTSTR
  1. ; (defaults to length of INSTR)
  1. ;OUTPUT : s - INSTR will be placed into OUTSTR starting at COLUMN
  1. ; using LENGTH characters
  1. ; "" - Error (bad input)
  1. ;
  1. ;NOTE : This module is based on $$SETSTR^VALM1
  1. ;
  1. ;Check input
  1. Q:('$D(INSTR)) ""
  1. Q:('$D(OUTSTR)) ""
  1. S:('$D(COLUMN)) COLUMN=$L(OUTSTR)+1
  1. S:('$D(LENGTH)) LENGTH=$L(INSTR)
  1. ;Declare variables
  1. N FRONT,END
  1. ;Get front portion of new string
  1. S FRONT=$E((OUTSTR_$J("",COLUMN-1)),1,(COLUMN-1))
  1. ;Get ending portion of new string
  1. S END=$E(OUTSTR,(COLUMN+LENGTH),$L(OUTSTR))
  1. ;Insert string
  1. Q FRONT_$E((INSTR_$J("",LENGTH)),1,LENGTH)_END
  1. ;
  1. CENTER(CNTRSTR,MARGIN) ;Center a string
  1. ;
  1. ;INPUT : CNTRSTR - String to center
  1. ; MARGIN - Margin width to center within (defaults to 80)
  1. ;OUTPUT : s - INSTR will be centered in a margin width of MARGIN
  1. ; "" - Error (bad input)
  1. ;NOTES : A margin width of 80 will be used when MARGIN<1
  1. ; : CNTRSTR will be returned when $L(CNTRSTR)>MARGIN
  1. ;
  1. ;Check input
  1. Q:($G(CNTRSTR)="") ""
  1. S:($G(MARGIN)<1) MARGIN=80
  1. ;Center the string
  1. Q $$INSERT(CNTRSTR,"",((MARGIN\2)-($L(CNTRSTR)\2)))
  1. ;
  1. IN2EXDT(DATE,STYLE) ;Converts dates from internal to external format
  1. ;
  1. ;Input : DATE - Date in FileMan format
  1. ; STYLE - Flag indicating output style
  1. ; If 0, return date in format MM-DD-YYYY (Default)
  1. ; If 1, return date in format MMM DD, YYYY
  1. ; (MMM -> first three characters of month)
  1. ;Output : External date in specified format
  1. ;Notes : Time will NOT be included, even if present on input
  1. ; : NULL ("") is returned on bad input
  1. ;
  1. ;Check input
  1. S DATE=+$P($G(DATE),".",1)
  1. Q:('DATE) ""
  1. Q:(DATE'?7N) ""
  1. S STYLE=+$G(STYLE)
  1. ;Return date in MM-DD-YYYY format
  1. Q:('STYLE) $E(DATE,4,5)_"-"_$E(DATE,6,7)_"-"_($E(DATE,1,3)+1700)
  1. ;Declare variables
  1. N Y,%DT
  1. ;Return date in MMM DD, YYYY format
  1. S Y=DATE
  1. D DD^%DT
  1. Q Y
  1. ;
  1. EX2INDT(DATE) ;Converts dates from external to internal format
  1. ;
  1. ;Input : Date in external format
  1. ;Output : Date in FileMan format
  1. ;Notes : Time will be included if present on input
  1. ; : NULL ("") is returned on bad input
  1. ;
  1. ;Check input
  1. S DATE=$G(DATE)
  1. Q:(DATE="") ""
  1. ;Declare variables
  1. N X,%DT,Y
  1. ;Convert date
  1. S DATE=$P(DATE,"@",1) ;**295 strip time off
  1. I $L(DATE,"/")=3,'$P(DATE,"/",2) S DATE=$P(DATE,"/",1)_"/"_$P(DATE,"/",3) ;**295 imprecise date - ##/00/#### to ##/####
  1. I $L(DATE,"/")=2,'$P(DATE,"/",1) S DATE=$P(DATE,"/",2) ;**295 imprecise date - 00/#### to ####
  1. S X=DATE
  1. S %DT="TS"
  1. D ^%DT
  1. Q:(Y=-1) ""
  1. Q Y
  1. ;
  1. NOW(FMFORM,NOTIME) ;Returns current date/time
  1. ;
  1. ;Input : FMFORM - Flag indicating if FileMan format should be used
  1. ; If 0, return in the format MM-DD-YYYY@HH:MM:SS
  1. ; (default)
  1. ; If 1, return in FileMan format
  1. ; NOTIME - Flag indicating if time should not be included
  1. ; If 0, time will be included in output (default)
  1. ; If 1, time will not be included in output
  1. ;Output : Current date & time in specified format
  1. ;
  1. ;Check input
  1. S FMFORM=+$G(FMFORM)
  1. S NOTIME=+$G(NOTIME)
  1. ;Declare variables
  1. N X,%,%H,%I,OUT
  1. ;Get current date/time
  1. D NOW^%DTC
  1. ;Return date/time in FileMan format
  1. Q:(FMFORM) $S(NOTIME:X,1:%)
  1. ;Return date/time in MM-DD-YYYY@HH:MM:SS format
  1. S %=%_"000000"
  1. S OUT=$E(%,4,5)_"-"_$E(%,6,7)_"-"_(1700+$E(%,1,3))
  1. S:('NOTIME) OUT=OUT_"@"_$E(%,9,10)_":"_$E(%,11,12)_":"_$E(%,13,14)
  1. Q OUT
  1. ;
  1. GETDATA(DFN,GROUP,TARGET,MESSAGE) ;Get local data required to build
  1. ; merge screens for a given patient
  1. ;
  1. ;Input : DFN - Pointer to entry in PATIENT file (#2)
  1. ; GROUP - Group number to get data for (defaults to 1)
  1. ; Group 1 = Name, SSN, date of birth & date of death
  1. ; TARGET - Array to store data in (full global reference)
  1. ; Defaults to ^TMP("VAFC-MERGE-TO",$J,"DATA")
  1. ; MESSAGE - Array to store error data in (full global reference)
  1. ; Defaults to ^TMP("VAFC-MERGE-TO",$J,"MESSAGE")
  1. ;Output : None
  1. ; TARGET & MESSAGE will be in the format defined by FileMan
  1. ; for interaction with the Database Server calls. Refer to
  1. ; the FileMan documentation on GETS^DIQ() for further
  1. ; information.
  1. ;Notes : All data will be in external format
  1. ; : Groups 1 - 4 are currently supported
  1. ; : Initialization of TARGET & MESSAGE is defined by the call
  1. ; to GETS^DIQ(). Refer to the FileMan documentation for
  1. ; further details.
  1. ;
  1. ;Check input
  1. S DFN=+$G(DFN)
  1. S GROUP=+$G(GROUP)
  1. S:((GROUP<1)!(GROUP>4)) GROUP=0
  1. S TARGET=$G(TARGET)
  1. S:(TARGET="") TARGET="^TMP(""VAFC-MERGE-TO"","_$J_",""DATA"")"
  1. S MESSAGE=$G(MESSAGE)
  1. S:(MESSAGE="") MESSAGE="^TMP(""VAFC-MERGE-TO"","_$J_",""MESSAGE"")"
  1. ;Declare variables
  1. N IENS,FIELDS ;,COUNTY ;**479
  1. S IENS=DFN_","
  1. ;S COUNTY=0 ;**479
  1. ;Group 1
  1. S FIELDS=".01;.03;.09;.351"
  1. ;Group 2
  1. I (GROUP=2) D
  1. .S FIELDS=".131;.132" ;".111;.1112;.112;.113;.114;.115;.117;.131;.132" ;**479
  1. .;Remember that COUNTY (field #.117) was retrieved
  1. .;S COUNTY=1 ;**479
  1. ;Group 3
  1. I (GROUP=3) D
  1. .S FIELDS=".02;.05;.08;.211;.219;.2403;.31115"
  1. ;Group 4
  1. I (GROUP=4) D
  1. .S FIELDS=".301;.302;.323;.361;.3612;.3615;.3616;391;1901"
  1. ;Extract data
  1. D GETS^DIQ(2,IENS,FIELDS,"",TARGET,MESSAGE)
  1. ;Accomodate for incorrect extraction of COUNTY (field #.117)
  1. ;S:(COUNTY) @TARGET@(2,IENS,.117)=$$COUNTY(DFN) ;**479
  1. ;Done
  1. Q
  1. ;
  1. COUNTY(DFN) ;Return county name that patient lives in
  1. ;
  1. ;Input : DFN - Pointer to entry in PATIENT file (#2)
  1. ;Output : County - Name of county that patient lives in
  1. ;Notes : NULL is returned on error, bad input, and no county found
  1. ;
  1. ;Check input
  1. S DFN=+$G(DFN)
  1. ;Declare variables
  1. N IENS,PTRCNTY,PTRSTATE,TMP
  1. ;Get pointers to STATE file and COUNTY sub-file
  1. S IENS=DFN_","
  1. D GETS^DIQ(2,IENS,".115;.117","I","TMP","TMP")
  1. S PTRSTATE=+$G(TMP(2,IENS,.115,"I"))
  1. S PTRCNTY=+$G(TMP(2,IENS,.117,"I"))
  1. Q:(('PTRSTATE)!('PTRCNTY)) ""
  1. ;Get county name
  1. S IENS=PTRCNTY_","_PTRSTATE_","
  1. D GETS^DIQ(5.01,IENS,".01","","TMP","TMP")
  1. ;Return county name
  1. Q $G(TMP(5.01,IENS,.01))