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

MAGT7SO.m

Go to the documentation of this file.
  1. MAGT7SO ;WOIFO/MLH/PMK/JSL - telepathology - create HL7 message to DPS - segment build - ORC ; 3 Jan 2015 4:15 PM
  1. ;;3.0;IMAGING;**138,156**;Mar 19, 2002;Build 10;Jan 3, 2015
  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. ORCSEG(SEGELTS,FILE,STATE,IENS,ACNUMB) ; FUNCTION - main entry point - create an ORC segment
  1. N I ; scratch loop index
  1. N X ; scratch return from extrinsic functions
  1. N ENTBY ; entered by name
  1. N ORDPVDRNO ; ordering provider number
  1. N MAGNAMLKUPELTS ; attribute array for new person name retrieval call to $$HLNAME^XLFNAME
  1. N ORDPVDRNAM ; ordering provider name
  1. N DIQRET ; return array from GETS^DIQ
  1. N ENTORG ; entering organization
  1. N FLDORCTRLCD S FLDORCTRLCD=1 ; order control code field
  1. N FLDPLORDNO S FLDPLORDNO=2 ; placer order number field
  1. N FLDORSTATUS S FLDORSTATUS=5 ; order status code field
  1. N FLDDTXACT S FLDDTXACT=9 ; date/time of transaction field
  1. N FLDENTBY S FLDENTBY=10 ; entered by field
  1. N FLDORDPVDR S FLDORDPVDR=12 ; ordering provider field
  1. N FLDCALBKPHN S FLDCALBKPHN=14 ; call back phone number field
  1. N FLDORCTRLRSN S FLDORCTRLRSN=16 ; order control code reason field
  1. N FLDENTORG S FLDENTORG=17 ; entering organization field
  1. N FLDORDFACNAM S FLDORDFACNAM=21 ; ordering facility name field
  1. N ORCTRL,ORSTATUS,ORREASON ; order control, status, and reason fields
  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,"ORC",0) ; segment type
  1. I STATE="NEW" S ORCTRL="NW",ORREASON="NEWORDR" ; "NW" = new order
  1. E I STATE="EDIT" S ORCTRL="XO",ORSTATUS="IP",ORREASON="CHANGEORDR"
  1. E I STATE="COMPLETED" S ORCTRL="SC",ORSTATUS="CM",ORREASON="INTCMPLT"
  1. E I STATE="CANCELLED" S ORCTRL="CA",ORSTATUS="CA",ORREASON="CANCELLED"
  1. D
  1. . D Q:ERRSTAT ; ORC-1-order control code
  1. . . D SET^HLOAPI(.SEGELTS,ORCTRL,FLDORCTRLCD) ; IA #4716
  1. . . Q
  1. . D Q:ERRSTAT ; ORC-2-placer order number
  1. . . D SET^HLOAPI(.SEGELTS,ACNUMB,FLDPLORDNO) ; IA #4716
  1. . . Q
  1. . I $D(ORSTATUS) D Q:ERRSTAT ; ORC-5-order status code
  1. . . D SET^HLOAPI(.SEGELTS,ORSTATUS,FLDORSTATUS) ; IA #4716
  1. . . Q
  1. . D Q:ERRSTAT ; ORC-9-date/time of transaction
  1. . . D SETTS^HLOAPI4(.SEGELTS,$$NOW^XLFDT,FLDDTXACT) ; IA #4853
  1. . . Q
  1. . D Q:ERRSTAT ; ORC-10-entered by
  1. . . S ERRSTAT=$$NPNAME^MAG7UNM(.ENTBY,DUZ)
  1. . . D:'ERRSTAT
  1. . . . D SET^HLOAPI(.SEGELTS,DUZ,FLDENTBY,1) ; IA #4716
  1. . . . D SET^HLOAPI(.SEGELTS,$G(ENTBY("FAMILY")),FLDENTBY,2) ; IA #4716
  1. . . . D SET^HLOAPI(.SEGELTS,$G(ENTBY("GIVEN")),FLDENTBY,3) ; IA #4716
  1. . . . D SET^HLOAPI(.SEGELTS,$G(ENTBY("MIDDLE")),FLDENTBY,4) ; IA #4716
  1. . . . Q
  1. . . Q
  1. . D Q:ERRSTAT ; ORC-12-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) ; IA #4716
  1. . . . D SET^HLOAPI(.SEGELTS,$G(ORDPVDRNAM("FAMILY")),FLDORDPVDR,2) ; IA #4716
  1. . . . D SET^HLOAPI(.SEGELTS,$G(ORDPVDRNAM("GIVEN")),FLDORDPVDR,3) ; IA #4716
  1. . . . D SET^HLOAPI(.SEGELTS,$G(ORDPVDRNAM("MIDDLE")),FLDORDPVDR,4) ; IA #4716
  1. . . . Q
  1. . . Q
  1. . D Q:ERRSTAT ; ORC-14-call back phone number
  1. . . S ERRSTAT=$$CALLBACK^MAGT7SO(.SEGELTS,ORDPVDRNO,FLDCALBKPHN)
  1. . . Q
  1. . I $D(ORREASON) D Q:ERRSTAT ; ORC-16-order control code reason> <-- SUGGEST DROPPING
  1. . . D SET^HLOAPI(.SEGELTS,ORREASON,FLDORCTRLRSN)
  1. . . Q
  1. . D Q:ERRSTAT ; ORC-17-entering organization ; ICR # 10060
  1. . . K ERRMSG
  1. . . D GETS^DIQ(200,$G(DUZ)_",",29,"EI","DIQRET","ERRMSG")
  1. . . D:$G(ERRMSG) ; error in GETS^DIQ call
  1. . . . S ERRSTAT="-21`FileMan error ("_$G(ERRMSG(1))_":"_$G(ERRMSG(1,"TEXT",1))_")"
  1. . . . Q
  1. . . D:'ERRSTAT
  1. . . . S ENTORG("ID")=$G(DIQRET(200,$G(DUZ)_",",29,"I"))
  1. . . . S ENTORG("TEXT")=$G(DIQRET(200,$G(DUZ)_",",29,"E"))
  1. . . . S ENTORG("SYSTEM")="VISTA49"
  1. . . . D SETCE^HLOAPI4(.SEGELTS,.ENTORG,FLDENTORG)
  1. . . . Q
  1. . . Q
  1. . D Q:ERRSTAT ; ORC-21-ordering facility name
  1. . . N LOCATION,NAME
  1. . . S LOCATION=$$KSP^XUPARAM("INST")
  1. . . S NAME=$$GET1^DIQ(4,LOCATION,.01)
  1. . . D SET^HLOAPI(.SEGELTS,NAME,FLDORDFACNAM,1) ; organization name - IA #4716
  1. . . D SET^HLOAPI(.SEGELTS,LOCATION,FLDORDFACNAM,3) ; organization identifier (DIVISION ien) - IA #4716
  1. . . D SET^HLOAPI(.SEGELTS,"FI",FLDORDFACNAM,7) ; abbreviation for facility id - IA #4716
  1. . . D SET^HLOAPI(.SEGELTS,$$STATNUMB^MAGDFCNV(),FLDORDFACNAM,10) ; organization identifier (Station Number) - IA #4716
  1. . . Q
  1. . Q
  1. Q ERRSTAT
  1. ;
  1. CALLBACK(SEGELTS,ORDPVDRNO,FLDCALBKPHN) ; call back phone number (in both ORC and OBR segments)
  1. N CALBAKFON ; call back phone array
  1. N IREP
  1. ;
  1. N ERRSTAT S ERRSTAT=0 ; error status - assume nothing to report
  1. ;
  1. Q:'ORDPVDRNO ERRSTAT ; ignore situations where the ordering provider is unknown
  1. ;
  1. S ERRSTAT=$$NPFON^MAG7UFO("CALBAKFON",ORDPVDRNO)
  1. F IREP=1:1:8 D:$D(CALBAKFON(IREP)) ; allow up to 8 phone numbers
  1. . D SET^HLOAPI(.SEGELTS,CALBAKFON(IREP,2,1),FLDCALBKPHN,2,1,IREP) ; IA #4716
  1. . D SET^HLOAPI(.SEGELTS,CALBAKFON(IREP,3,1),FLDCALBKPHN,3,1,IREP) ; IA #4716
  1. . D SET^HLOAPI(.SEGELTS,CALBAKFON(IREP,1,1),FLDCALBKPHN,12,1,IREP) ; IA #4716
  1. . Q
  1. Q ERRSTAT