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

LA7QRY.m

Go to the documentation of this file.
  1. LA7QRY ;VA/DALOI/JMC - Lab HL7 Query Utility ; 13-Aug-2013 09:09 ; MKK
  1. ;;5.2;AUTOMATED LAB INSTRUMENTS;**46,1018,69,1027,68,1033**;NOV 1, 1997
  1. ;
  1. ; Reference to variable DIQUIET supported by DBIA #2098
  1. ; Reference to ^DPT("SSN") global supported by DBIA #10035
  1. ;
  1. Q
  1. ;
  1. GCPR(LA7PTID,LA7SDT,LA7EDT,LA7SC,LA7SPEC,LA7QERR,LA7DEST,LA7HL7) ; Entry point for Government Computerized Patient Record query
  1. ;
  1. ; Call with LA7PTID = patient identifier, either SSN or MPI/ICN or medical record number.
  1. ; if MPI/ICN then should be full ICN (10 digit number followed by "V" and six digit checksum)
  1. ; Pass in the 2nd piece of this variable the type of identifier:
  1. ; SS = Social Security number
  1. ; PI = VA MPI Integration Control Number
  1. ; MR = medical record number of patient in file PATIENT/IHS (#9000001)
  1. ; Example: 1000720100V271387^PI
  1. ; 123456789^SS
  1. ; 123456789^MR
  1. ;
  1. ; LA7SDT = start date of query (FileMan D/T,time optional)
  1. ; LA7EDT = end date of query (FileMan D/T, time optional)
  1. ; (FileMan D/T^type of date ("CD" or "RAD")
  1. ; Both start and end date values can pass a parameter in the second piece to indicate that the date values are for specimen collection date/time (CD) or results available date (RAD)
  1. ; Example: LA7SDT="2991001.1239^CD"
  1. ; LA7EDT="2991002.0331^CD"
  1. ; LA7SDT="3010201^RAD"
  1. ; LA7EDT="3010201^RAD"
  1. ;
  1. ; LA7SC = Array of search codes, either NLT or LOINC (code^coding system ("NLT" or "LN");
  1. ; Example: LA7SC(1)="89628.0000^NLT"
  1. ; LA7SC(2)="84330.0000^NLT"
  1. ; LA7SC(3)="84295.0000^NLT"
  1. ; LA7SC(4)="14749-6^LN"
  1. ;
  1. ; = The "*" (wildcard) for any code;
  1. ; Example: LA7SC="*"
  1. ;
  1. ; = A list of subscripts (separated by commas) from where the results will be extracted ("CH", "MI", "SP", "EM", "CY").
  1. ; Example: LA7SC="CH,MI" (CH and MI results only)
  1. ;
  1. ; Pass in the 2nd piece of LA7SC the indicator (1) to return VUID when available.
  1. ; Example: LA7SC="*^1) or LA7SC="CH,MI^1"
  1. ;
  1. ; LA7SPEC = array of specimen types using HL7 source table 0070 or "*" (wildcard) for any code
  1. ; Currently specimen type only supported for CH and MI subscripted tests.
  1. ; Example: LA7SPEC="*"
  1. ; or
  1. ; LA7SPEC(1)="UR"
  1. ; LA7SPEC(2)="SER"
  1. ; LA7SPEC(3)="PLAS"
  1. ;
  1. ; LA7QERR = array (by reference) to return any errors
  1. ;
  1. ; LA7DEST = closed root global reference to return search results (optional). If this parameter is omitted or equals an empty string, then node ^TMP("HLS",$J) is used.
  1. ; Example: LA7DEST=$NA(^TMP("ZZTMP",$J))
  1. ;
  1. ; LA7HL7 = HL7 field separator and encoding characters (4) to use to encode results (optional).
  1. ; If undefined or incomplete (length<5) then uses field separator = "|" and encoding characters ="^\~&"
  1. ;
  1. ; Returns LA7DEST = contains global reference of search results in HL7 message structure, usually ^TMP("HLS",$J)
  1. ;
  1. ; LA7QERR = array (by reference) containing any errors
  1. ;
  1. N DFN,DIQUIET,LA761,LA76248,LA7CODE,LA7INTYP,LA7NLT,LA7NOMSG,LA7PTYP,LA7QUIT,LA7SCDE,LA7X,LRDFN,LRIDT,LRSS,LRSSLST
  1. ;
  1. D CLEANUP
  1. S U="^",DT=$$DT^XLFDT,DTIME=$$DTIME^XUP($G(DUZ))
  1. S GBL=$S($G(LA7DEST)'="":LA7DEST,1:"^TMP(""HLS"","_$J_")")
  1. K LA7QERR
  1. ; Prevent FileMan from issuing any unwanted WRITE(s).
  1. S DIQUIET=1
  1. ; Currently not using file #62.48 for configuration information.
  1. S (LA76248,LA7INTYP)=0
  1. ;
  1. ; Setup DUZ array to 'non-human' user LRLAB,HL if DUZ not valid
  1. ; Handle calls from non-VistA packages.
  1. I $G(DUZ)<1 D
  1. . S LA7X=$$FIND1^DIC(200,"","OX","LRLAB,HL","B","")
  1. . I LA7X<1 D Q
  1. . D DUZ^XUP(LA7X)
  1. ;
  1. ; Identify patient, quit if error
  1. D PATID^LA7QRY2
  1. I $D(LA7QERR) Q ""
  1. ;
  1. ; Move LA7SC into local variable to check and modify if necessary.
  1. M LA7SCDE=LA7SC
  1. ;
  1. ; Resolve search codes to lab datanames
  1. S LA7SCDE=$G(LA7SCDE)
  1. ;
  1. ; Set flag to return VUID when available
  1. I $P(LA7SCDE,"^",2)=1 S LA7INTYP=30
  1. ;
  1. ; Parse list of subscripts if any.
  1. D SCLIST^LA7QRY2($P(LA7SCDE,"^"),.LRSSLST)
  1. Q:$D(LA7QERR) ""
  1. ;
  1. ; If passing specific subscripts but no specific search codes then use wildcard ("*") for search codes.
  1. I LA7SCDE'="",$P(LA7SCDE,"^")'="*",'$O(LA7SCDE(0)) S $P(LA7SCDE,"^")="*"
  1. I $P(LA7SCDE,"^")'="*",$O(LA7SCDE(0)) D CHKSC^LA7QRY1
  1. ;
  1. ; Convert specimen codes to file #61 Topography entries
  1. S LA7SPEC=$G(LA7SPEC)
  1. I LA7SPEC'="*" D SPEC^LA7QRY1
  1. ;
  1. ; Search by collection or results available date
  1. I $P(LA7SDT,"^",2)="" S $P(LA7SDT,"^",2)="CD"
  1. I $P(LA7SDT,"^",2)="RAD" D BRAD^LA7QRY2
  1. I $P(LA7SDT,"^",2)="CD" D BCD^LA7QRY2
  1. ;
  1. I '$D(^TMP("LA7-QRY",$J)) D
  1. . S LA7QERR(99)="No results found for requested parameters"
  1. . S GBL=""
  1. E S LA7NOMSG=1 D BUILDMSG^LA7QRY1
  1. ;
  1. D CLEANUP
  1. ;
  1. Q GBL
  1. ;
  1. ;
  1. CLEANUP ; Cleanup TMP nodes that are used.
  1. ;
  1. N I
  1. F I="LA7-61","LA7-DN","LA7-INST-DNS","LA7-LN","LA7-NLT","LA7-QRY" K ^TMP(I,$J)
  1. D KVAR^LRX
  1. ;
  1. Q