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

MAGT7SB.m

Go to the documentation of this file.
  1. MAGT7SB ;WOIFO/MLH/PMK - telepathology - create HL7 message to DPS - segment build - OBR ; 24 Jul 2013 8:23 PM
  1. ;;3.0;IMAGING;**138**;Mar 19, 2002;Build 5380;Sep 03, 2013
  1. ;; Per VHA Directive 2004-038, this routine should not be modified.
  1. ;; +---------------------------------------------------------------+
  1. ;; | Property of the US Government. |
  1. ;; | No permission to copy or redistribute this software is given. |
  1. ;; | Use of unreleased versions of this software requires the user |
  1. ;; | to execute a written test agreement with the VistA Imaging |
  1. ;; | Development Office of the Department of Veterans Affairs, |
  1. ;; | telephone (301) 734-0100. |
  1. ;; | The Food and Drug Administration classifies this software as |
  1. ;; | a medical device. As such, it may not be changed in any way. |
  1. ;; | Modifications to this software may result in an adulterated |
  1. ;; | medical device under 21CFR820, the use of which is considered |
  1. ;; | to be a violation of US Federal Statutes. |
  1. ;; +---------------------------------------------------------------+
  1. ;;
  1. Q
  1. ;
  1. OBRSEG(SEGELTS,FILE,LRSS,IENS,ACNUMB) ; FUNCTION - main entry point - create an OBR segment
  1. N LABTEST ; name of lab test
  1. N SETID S SETID=1 ; set ID value for OBR segment
  1. N FLDSETID S FLDSETID=1 ; set ID field number
  1. N FLDPLORDNO S FLDPLORDNO=2 ; placer order number field number
  1. N FLDUNIVSVCID S FLDUNIVSVCID=4 ; universal service ID field number
  1. N FLDCOLLECTOR S FLDCOLLECTOR=10 ; name of person who collected the specimen
  1. N FLDORDPVDR S FLDORDPVDR=16 ; ordering provider field number
  1. N FLDCALBKPHN S FLDCALBKPHN=17 ; call back phone number field number
  1. N FLDDXSERVID S FLDDXSERVID=24 ; diagnostic service section id
  1. N ORDPVDRNO ; ordering provider number
  1. N ORDPVDRNAM ; ordering provider name
  1. N ERRSTAT S ERRSTAT=0 ; error status - assume nothing to report
  1. ;
  1. K SEGELTS ; always refresh *segment* array (not message array) on entry
  1. ;
  1. D SET^HLOAPI(.SEGELTS,"OBR",0) ; segment type
  1. D ; set up fields, check exit flag after each
  1. . D Q:ERRSTAT ; OBR-1-set ID
  1. . . D SET^HLOAPI(.SEGELTS,SETID,FLDSETID)
  1. . . Q
  1. . D Q:ERRSTAT ; OBR-2-placer order number
  1. . . D SET^HLOAPI(.SEGELTS,ACNUMB,FLDPLORDNO)
  1. . . Q
  1. . D Q:ERRSTAT ; OBR-4-universal service ID
  1. . . D TESTLKUP(LABDATA,.LABTEST)
  1. . . S LABTEST("SYSTEM")="VISTA60"
  1. . . D SETCE^HLOAPI4(.SEGELTS,.LABTEST,FLDUNIVSVCID)
  1. . . Q
  1. . D Q:ERRSTAT ; OBR-10-collector ID
  1. . . N COLLECTOR ; person who collected the specimen
  1. . . ; the data type of this field is XCN (extended composite name)
  1. . . ; unfortunately, the lab package only records it as free text,
  1. . . ; so it is output in sequence 2 as "Family Name"
  1. . . S COLLECTOR=$G(@LABDATA@(FILE("0"),IENS,.011,"I"))
  1. . . D SET^HLOAPI(.SEGELTS,COLLECTOR,FLDCOLLECTOR,2)
  1. . . Q
  1. . D Q:ERRSTAT ; OBR-16-ordering provider
  1. . . S ORDPVDRNO=$$GET1^DIQ(FILE(0),IENS,.07,"I")
  1. . . I 'ORDPVDRNO D SET^HLOAPI(.SEGELTS,"""""",FLDORDPVDR,1) Q ; no ordering provider
  1. . . S ERRSTAT=$$NPNAME^MAG7UNM(.ORDPVDRNAM,ORDPVDRNO)
  1. . . D:'ERRSTAT
  1. . . . D SET^HLOAPI(.SEGELTS,ORDPVDRNO,FLDORDPVDR,1)
  1. . . . D SET^HLOAPI(.SEGELTS,$G(ORDPVDRNAM("FAMILY"),""),FLDORDPVDR,2)
  1. . . . D SET^HLOAPI(.SEGELTS,$G(ORDPVDRNAM("GIVEN"),""),FLDORDPVDR,3)
  1. . . . D SET^HLOAPI(.SEGELTS,$G(ORDPVDRNAM("MIDDLE"),""),FLDORDPVDR,4)
  1. . . . Q
  1. . . Q
  1. . D Q:ERRSTAT ; OBR-17-call back phone number
  1. . . S ERRSTAT=$$CALLBACK^MAGT7SO(.SEGELTS,ORDPVDRNO,FLDCALBKPHN)
  1. . . Q
  1. . D Q:ERRSTAT ; OBR-24-diagnostic service section id
  1. . . N ID
  1. . . S ID=$P(ACNUMB," ",1) ; VA lab service from file #62.2
  1. . . ; Note that for cytology (cytopathology) the abbreviation should be CP and not CY
  1. . . ; We are ignoring that difference because it makes it more complicated for the worklist
  1. . . ; S ID=$S(ID="CY":"CP",1:ID) ; see HL7 2.5.1 Ch 4 section 4.5.3.24
  1. . . D SET^HLOAPI(.SEGELTS,ID,FLDDXSERVID)
  1. . . Q
  1. . Q
  1. ;
  1. Q ERRSTAT
  1. ;
  1. TESTLKUP(LABDATA,LABTEST) ; lookup the test - called by MAGVIM02 as well
  1. N IENS
  1. S IENS=$O(@LABDATA@(FILE("ORDERED TEST"),""))
  1. I IENS'="" D
  1. . S LABTEST=$G(@LABDATA@(FILE("ORDERED TEST"),IENS,13,"I"))
  1. . I LABTEST D
  1. . . S LABTEST("ID")=LABTEST
  1. . . S LABTEST("TEXT")=$$GET1^DIQ(60,LABTEST,.01,"E")
  1. . . Q
  1. . Q
  1. I '$D(LABTEST("ID")) D ; use default test
  1. . S LABTEST("ID")=FILE("PROCEDURE IEN")
  1. . S LABTEST("TEXT")=FILE("PROCEDURE NAME")
  1. . Q
  1. Q