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

VIAASQH.m

Go to the documentation of this file.
  1. VIAASQH ;ALB/CR - RTLS Set Quantity on-hand in GIP ;4/20/16 10:12 pm
  1. ;;1.0;RTLS;**4**;April 22, 2013;Build 21
  1. ;
  1. ; Access to file #441 covered by IA #5921
  1. ; Access to file #445 covered by IA #5923
  1. ; Get unique handle ID string for ^XTMP covered by IA #4770
  1. ; Call to $$UPDATE^PRCPUSA covered by IA #10085
  1. Q
  1. ;
  1. ; -- set quantity on-hand with feed from WaveMark. The
  1. ; transaction can be either a usage ('U'), or a physical count
  1. ; ('P').
  1. ; -- Input required:
  1. ; inventory point name
  1. ; item master #
  1. ; quantity to update quantity on-hand in file #445
  1. ; flag to indicate transaction type: 'U' or 'P' only
  1. ; -- Output:
  1. ; stored in ^XTMP("VIAASQH",$J,0) and passed forward via RETSTA;
  1. ; contains a short message to indicate success. For a failure,
  1. ; the following format is used:
  1. ; "-###^"_failure_message, where '###' is a 3-digit http status
  1. ; code.
  1. ;
  1. ; ********* NOTICE ************
  1. ; -----------------------------------------------------------------
  1. ; the user 'VIAASSERVICE,RTLS APPLICATION PROXY' must be added to the
  1. ; inventory point for the Cathlab before any of the transactions
  1. ; below can be executed properly in GIP
  1. ; -----------------------------------------------------------------
  1. ;
  1. QOH(RETSTA,IPNAME,ITEM,QTY,QOHFLAG) ;
  1. ; RPC [VIAA SET QUANTITY ON HAND]
  1. ;
  1. N A,ITEMIEN,IPIEN,TIMDATE,VIAA,PRCPBALM,%,X,Y ; variables PRCPBALM,% used in IFCAP/GIP
  1. ; clean up ^TMP of old data and ^XTMP if found
  1. S A="" F S A=$O(^TMP(A)) Q:A="" I $E(A,1,7)["VIAASQH" K ^TMP(A),^XTMP(A)
  1. ;
  1. S VIAA=$$HANDLE^XUSRB4("VIAASQH") ; get handle, prepare for entry in ^XTMP
  1. S $P(^XTMP(VIAA,0),U,3)="Quantity On-Hand Set up for GIP"
  1. S X=DT D NOW^%DTC,YX^%DTC S TIMDATE=Y ; current date/time
  1. S ^TMP(VIAA,"Received_Data_From_WaveMark",TIMDATE)=IPNAME_U_ITEM_U_QTY_U_QOHFLAG
  1. I $G(IPNAME)="" S ^XTMP(VIAA,$J,0)="-400^Inventory Point name cannot be null" D EXIT Q
  1. I '$O(^PRCP(445,"B",IPNAME,"")) S ^XTMP(VIAA,$J,0)="-404^"_IPNAME_" is not a legal Inventory Point" D EXIT Q
  1. S IPIEN=$O(^PRCP(445,"B",IPNAME,""))
  1. ;
  1. I +ITEM'=ITEM S ^XTMP(VIAA,$J,0)="-400^Item Master # received is not legal" D EXIT Q
  1. I $G(ITEM)="" S ^XTMP(VIAA,$J,0)="-400^Item Master # cannot be null" D EXIT Q
  1. I +ITEM=0 S ^XTMP(VIAA,$J,0)="-400^Item Master # cannot be zero" D EXIT Q
  1. S ITEMIEN=+$O(^PRC(441,"B",ITEM,""))
  1. I ITEMIEN'=ITEM S ^XTMP(VIAA,$J,0)="-400^Item "_ITEM_" does not exist in the Item Master File" D EXIT Q
  1. I '$D(^PRCP(445,"AE",ITEM,IPIEN,ITEM)) S ^XTMP(VIAA,$J,0)="-404^Item Master #"_ITEM_" is not in Inventory Point "_IPNAME D EXIT Q
  1. ;
  1. I $G(QTY)="" S ^XTMP(VIAA,$J,0)="-400^Invalid quantity on-hand received - cannot be null" D EXIT Q
  1. I QTY<0 S ^XTMP(VIAA,$J,0)="-400^Invalid quantity on-hand "_QTY_" received - cannot be negative" D EXIT Q
  1. I "^U^P^"'[(U_QOHFLAG_U) S ^XTMP(VIAA,$J,0)="-400^'"_QOHFLAG_"' is an invalid transaction flag. Only 'U' or 'P' are allowed" D EXIT Q
  1. ;
  1. ; -- set up variables for GIP call
  1. ; for usage WaveMark will only send a quantity greater than zero to VistA
  1. S X=DT D NOW^%DTC,YX^%DTC S TIMDATE=Y ; current date/time
  1. ; prepare to save result of processing in VistA and pass results to client
  1. ;
  1. I $G(QOHFLAG)="U" D S:$G(%)="" ^XTMP(VIAA,$J,0)="1^Usage transaction in GIP completed for Item Mater #"_ITEM_" on "_TIMDATE D EXIT Q
  1. . S PRCPBALM("I")=IPIEN,PRCPBALM("ITEM")=ITEM,PRCPBALM("QTY")=-QTY
  1. . S PRCPBALM("TYP")="U"
  1. . S PRCPBALM("COM")="WaveMark usage transaction"
  1. . L +^PRCP(445,IPIEN,1,ITEM,0):1 I '$T S ^XTMP(VIAA,$J,0)="-423^The resource that is being accessed is locked - cannot complete usage processing for Item Master #"_ITEM_", on "_TIMDATE D EXIT Q
  1. . S %=$$UPDATE^PRCPUSA(.PRCPBALM) ; update quantity on-hand
  1. . L -^PRCP(445,IPIEN,1,ITEM,0)
  1. . I %'="" S ^TMP(VIAA,"Response from GIP")=%
  1. . I %'="" S ^XTMP(VIAA,$J,0)="-400^GIP Quantity On-Hand not updated - "_% D EXIT Q
  1. ;
  1. I $G(QOHFLAG)="P" D S:$G(%)="" ^XTMP(VIAA,$J,0)="1^Physical Count transaction in GIP completed for Item Master #"_ITEM_" on "_TIMDATE
  1. . S PRCPBALM("I")=IPIEN,PRCPBALM("ITEM")=ITEM
  1. . S PRCPBALM("TYP")="P"
  1. . S PRCPBALM("COM")="WaveMark physical count transaction"
  1. . L +^PRCP(445,IPIEN,1,ITEM,0):1 I '$T S ^XTMP(VIAA,$J,0)="-423^The resource that is being accessed is locked - cannot complete physical count for Item Master #"_ITEM_", on "_TIMDATE D EXIT Q
  1. . S PRCPBALM("QTY")=QTY-$$GET1^DIQ(445.01,ITEM_","_IPIEN_",",7) ; update quantity on-hand
  1. . S %=$$UPDATE^PRCPUSA(.PRCPBALM) ; update quantity on-hand
  1. . L -^PRCP(445,IPIEN,1,ITEM,0)
  1. . I %'="" S ^TMP(VIAA,"Response from GIP")=%
  1. . I %'="" S ^XTMP(VIAA,$J,0)="-400^GIP Quantity On-Hand not updated - "_% D EXIT Q
  1. ;
  1. EXIT S RETSTA=$NA(^XTMP(VIAA,$J))
  1. ; save whatever we processed and answer sent to the calling app
  1. M ^TMP(VIAA,"Saved_Transaction_Header")=^XTMP(VIAA,0)
  1. M ^TMP(VIAA,"Saved_Transaction_Type: "_QOHFLAG)=^XTMP(VIAA,$J)
  1. L -^XTMP(VIAA) ; release lock for $$HANDLE^XUSRB4 call
  1. Q