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

INHPSA.m

Go to the documentation of this file.
  1. INHPSA ; FRW ; 10 Jun 99 14:45; Interface Control Program - Main Application Interface
  1. ;;3.01;BHL IHS Interfaces with GIS;;JUL 01, 2001
  1. ;COPYRIGHT 1991-2000 SAIC
  1. ;
  1. Q
  1. ;
  1. PROCINT(INTER,INPAR,INNAME,INDATA,INMESS) ;Process one interface
  1. ;This is called as the control routine for most interfaces
  1. ;Called from PROC^INHPSAM
  1. ;INPUT:
  1. ; INTER - interface application identifier
  1. ; INPAR - array of parameters
  1. ; INNAME - name of application
  1. ; INDATA - executable MUMPS code to get data array
  1. ; should leave data in the array INDAT
  1. ; INMESS - executable code to be done after the load is complete
  1. ;
  1. N HDR,INMTF,INTIME
  1. S INNAME=$G(INNAME),INTER=$G(INTER),INDATA=$G(INDATA),INMESS=$G(INMESS)
  1. Q:'$L(INTER) 0
  1. N INERR,INDAT
  1. S INERR=""
  1. ;Get default name
  1. S:'$L(INNAME) INNAME=$P($G(INPAR("APPL",INTER)),U)
  1. ;
  1. S INMTF=$$GETMTF(),INTIME=$$CDATASC^%ZTFDT($H,1,1)
  1. S HDR(1)="INMTF,?(IOM-27),INTIME,"" PAGE:"",$J(INPAGE,4)"
  1. S HDR(2)="""Interface Name: "_INNAME_""""
  1. S HDR(3)="",$P(HDR(3),"-",IOM)="",HDR(3)=""""_HDR(3)_""",!"
  1. D HEADER^INHMG
  1. ;
  1. ;Create array of data for application
  1. K INDAT
  1. ;Check for custom defined data builder code
  1. I $L(INDATA) X INDATA I INERR D T^INHMG1 W "ERROR: ",INNAME," - no action taken" S INERR=1 Q 0
  1. ;Execute standard data builder
  1. I '$L(INDATA) I '$$CREDAT(.INDAT) D T^INHMG1 W "ERROR: Unable to create data array." S INERR=1 Q 0
  1. ;Process application
  1. D ONE(INTER,.INDAT,.INPAR) Q:$G(DUOUT) $S('INERR:1,1:0)
  1. ;post-processing logic
  1. D:INPAR("ACT")'=2 POST^INHPSA2(INTER,INMESS)
  1. I INPAR("ACT")=2,$G(INDISCRP) D DISCREP^INHPSA4(ININT,.INDAT)
  1. ;Quit positive if no errors, null if errors encoutnered
  1. Q $S('INERR:1,1:0)
  1. ;
  1. ONE(INTER,INDAT,INPAR) ;Activate/Deactivate one interface
  1. ;INPUT:
  1. ; INTER - interface application to activate
  1. ; INDAT - data array of control file records for application (PBR)
  1. ; INPAR - array of parameters (pass by ref)
  1. ;
  1. ;Background Process(es)
  1. D BACK(INTER,.INDAT,.INPAR)
  1. ;Transaction Type(s)
  1. D TT(INTER,.INDAT,.INPAR) Q:$G(DUOOUT)
  1. ;Script Generator Messages
  1. D MSG(INTER,.INDAT,.INPAR)
  1. ;
  1. Q
  1. ;
  1. MSG(INTER,INDAT,INPAR) ;Script Generator Messages
  1. ;
  1. ;Not currently supported - assumes all messages will be active
  1. Q
  1. ;
  1. MSGONE(DA,INST) ;Activate/Deactivate one message //??? where is this called from
  1. ;
  1. S INST=+$G(INST) N DIE,DR,INSTMSG
  1. S INSTMSG=$S('INST:"DEACTIVATED",1:"ACTIVATED")
  1. ;Set INACTIVE flag
  1. S DIE=4011,DR=".08///"_$S('INST:1,1:0) D ^DIE
  1. W:'$G(INVERBOS) !,"Script Generator Message: ",$P(^INTHL7M(DA,0),U)," ",INSTMSG
  1. Q
  1. ;
  1. ;?? Compile Message
  1. ;?? Should transaction types for messages also be deactivated
  1. ;?? Should scripts for message also be deactivated
  1. ;?? Should anything be done with the Message Replication File - DEFER
  1. Q
  1. ;
  1. BACK(INTER,INDAT,INPAR) ;Background Process(es)
  1. ;
  1. ;Activate background process
  1. N INREC S INREC=0
  1. F S INREC=$O(INDAT(INTER,4004,INREC)) Q:'INREC S:'$$BPCONE(INREC,+$G(INPAR("ACT"))) INERR=1
  1. ;
  1. Q
  1. ;
  1. BPCONE(DA,INST) ;Activate/Deactivate one background process
  1. ;INPUT:
  1. ; DA - entry to process in INDAT
  1. ; INST - what to do 0 - deactivate (def) ; 1 - activate, 2 - show
  1. ;
  1. N DIC,X,Y,DIE,DR,INSTMSG,INNAME
  1. S INST=+$G(INST)
  1. S (INNAME,X)=$P($G(INDAT(INTER,4004,DA)),U,1),DIC=4004,DIC(0)="",Y=$$DIC(DIC,X,"",DIC(0)),DA=+Y
  1. I INNAME'=$P(Y,U,2) D T^INHMG1 W "ERROR: Wanted background process ",INNAME," but found ",$P(Y,U,2)," (",+Y,")." Q 0
  1. I DA<0 D T^INHMG1 W "ERROR: Background Process: ",INNAME," not found." Q 0
  1. I INST=2 D Q 1
  1. .S INSTMSG=$S('$P($G(^INTHPC(DA,0)),U,2):"INACTIVE",1:"ACTIVE")
  1. .D T^INHMG1 W "Background Process: ",$P(^INTHPC(DA,0),U),?68,INSTMSG
  1. ;
  1. S INSTMSG=$S('INST:"DEACTIVATED",1:"ACTIVATED")
  1. S DIE=4004,DR=".02///"_INST
  1. ;If activated, then check debug level
  1. I INST,+$P($G(^INTHPC(DA,9)),U,1)'=0 D
  1. .D T^INHMG1 W "Debug will be turned off for Background Process: ",INNAME
  1. .S DR=DR_";"_9.01_"///0"
  1. D ^DIE
  1. I +$P($G(^INTHPC(DA,9)),U,1)'=0 D T^INHMG1 W "Warning: Background Process: ",INNAME," debug is still ON"
  1. I $P($G(^INTHPC(DA,0)),U,2)'=INST D T^INHMG1 W "ERROR: Background Process: ",INNAME," not ",INSTMSG S INERR=1 Q 0
  1. I '$G(INVERBOS) D T^INHMG1 W "Background Process: ",$P(^INTHPC(DA,0),U),?68,INSTMSG
  1. Q 1
  1. ;
  1. ;Need to handle other data nodes for record if present
  1. ;
  1. TT(INTER,INDAT,INPAR) ;Transaction Types
  1. ;
  1. ;De/Activate Transaction Type
  1. N INREC S INREC=0
  1. F S INREC=$O(INDAT(INTER,4000,INREC)) Q:'INREC S:'$$TTONE(INREC,+$G(INPAR("ACT"))) INERR=1 Q:$G(DUOUT)
  1. ;
  1. Q
  1. ;
  1. TTONE(DA,INST) ;Deactivate/activate one transaction type
  1. ;
  1. N DIC,X,Y,DIE,DR,INSTMSG,INNAME
  1. N INHIER ;this array is used to show the transaction hierarchy
  1. S INHIER("PARENT")=""
  1. S INHIER("CHILD")=""
  1. S INHIER("BASE")=""
  1. ;
  1. S INST=+$G(INST)
  1. ;Quit if deactivating and suppress deactivation flag is set
  1. Q:'INST&$P($G(INDAT(INTER,4000,DA)),U,2) 1
  1. ;Quit if activating and suppress activation flag is set
  1. Q:INST&$P($G(INDAT(INTER,4000,DA)),U,3) 1
  1. S (INNAME,X)=$P($G(INDAT(INTER,4000,DA)),U,1),DIC=4000,DIC(0)="",Y=$$DIC(DIC,X,"",DIC(0)),DA=+Y
  1. I INNAME'=$P(Y,U,2) D T^INHMG1 W "ERROR: Wanted transaction type ",INNAME," but found ",$P(Y,U,2)," (",+Y,")." Q 0
  1. I DA<0 D T^INHMG1 W "ERROR: Transaction Type: ",INNAME," not found." Q 0
  1. Q:'$$TTEDT(DA,INST,.INHIER,"CHILD") 0
  1. ;
  1. ;Process Base (if DA is Replicant TT)
  1. Q:'$$TTBASE^INHPSA4(DA,INST,.INHIER) 0
  1. ;
  1. ;Process Parent
  1. Q:'$$TTPAR(DA,INST,.INHIER) 0
  1. D WRITE^INHPSA4(.INHIER,INST)
  1. ;
  1. Q 1
  1. ;
  1. TTPAR(DA,INST,INHIER) ;Process parent transaction types
  1. ;DA - ien of child transaction type
  1. ;
  1. N INCHTT,INPATT,OK,INCUST,TT
  1. Q:'$D(^INRHT(+$G(DA),0)) 0
  1. S INCHTT=+DA,INPATT=+$P(^INRHT(DA,0),U,6)
  1. ;If no parent quit with no error
  1. Q:'INPATT 1
  1. ;If parent doesn't exist quit with error
  1. I '$D(^INRHT(INPATT,0)) D T^INHMG1 W "ERROR: Parent transaction type deleted for ",$P($G(^INRHT(+DA,0)),U,1)," ",INPATT Q 0
  1. ;
  1. ;Get current status of parent
  1. S INCUST=$P(^INRHT(INPATT,0),U,5)
  1. ;
  1. ;Perform activation process
  1. I INST=1 D:'INCUST
  1. . ;Parent is NOT active - check for active children
  1. . S TT="" F S TT=$O(^INRHT("AC",INPATT,TT)) Q:'TT D
  1. .. ;no warning if TT is calling child or is inactive
  1. .. Q:(TT=DA)!('$P($G(^INRHT(TT,0)),U,5))
  1. .. D T^INHMG1 W "WARNING: Transaction type ",$P(^INRHT(TT,0),U)," was active. "
  1. .. D T^INHMG1 W " Messages will now be generated for this transaction type."
  1. ;
  1. ;Perform deactivation process
  1. I 'INST S OK=1 D:INCUST Q:'OK 1 ; exit if NOT OK to deactivate parent
  1. . ;Parent is active - check for active children
  1. . ;no deactivation if TT is NOT the calling child & is active
  1. . S TT="" F S TT=$O(^INRHT("AC",INPATT,TT)) Q:'TT I TT'=DA,$P($G(^INRHT(TT,0)),U,5) S OK=0 Q
  1. ;
  1. ; De/Activate parent TT
  1. Q:'$$TTEDT(INPATT,INST,.INHIER,"PARENT") 0
  1. ;
  1. Q 1
  1. ;
  1. TTEDT(DA,INST,INHIER,INODE) ;Edit transaction type
  1. ;
  1. S:INST'=2 INSTMSG=$S('INST:"DEACTIVATED",1:"ACTIVATED")
  1. I INST'=2 S DIE=4000,DR=".05///"_INST D ^DIE
  1. I INST'=2,$P($G(^INRHT(DA,0)),U,5)'=INST D T^INHMG1 W "ERROR: Transaction Type: ",INNAME," not ",INSTMSG Q 0
  1. S:INST=2 INSTMSG=$S($P($G(^INRHT(DA,0)),U,5)=1:"ACTIVE",1:"INACTIVE")
  1. S INHIER(INODE)=DA
  1. Q 1
  1. ;
  1. ;Should anything be done with the Message Replication File - DEFER
  1. ;Should script be recompiled if activating - probably
  1. ;
  1. CREDAT(INDAT) ;Create data array of control records
  1. ;
  1. N INERR,L1,TXT S INERR=1
  1. ;Load data into array
  1. F LI=1:1 S TXT=$P($$TEXT^INHPSA1(INTER,LI),";;",2,99) Q:'TXT I '$$LOAD(.INDAT,TXT,INTER) S INERR=0
  1. Q INERR
  1. ;
  1. LOAD(INDAT,TXT,INTER) ;Load a node of data into data array
  1. ;INPUT:
  1. ; INDAT - data array of control file records for application (PBR)
  1. ; TXT - line of data to load into array (from INHPSA1)
  1. ; foramt -> file # ^ node ^ data
  1. ; INTER - interface application
  1. ;
  1. N INREC
  1. ;Check for comment line
  1. Q:$E(TXT,1)[";" 1
  1. ;Error if no file has been defined
  1. Q:'TXT 0
  1. ;Set record counter to last record used for file
  1. S INREC=$G(INDAT(INTER,+TXT))
  1. ;Check for new record (2nd piece = null)
  1. I '$L($P(TXT,U,2)) D Q 1
  1. . ;Increment record counter
  1. . S INREC=INREC+1,INDAT(INTER,+TXT)=INREC
  1. . ;Used for the lookup value to DIC call
  1. . S INDAT(INTER,+TXT,INREC)=$P(TXT,U,3,99)
  1. ;Capture any data nodes
  1. S INDAT(INTER,+TXT,INREC,+$P(TXT,U,2))=$P(TXT,U,3,99)
  1. Q 1
  1. ;
  1. DIC(DIC,X,DLAYGO,%IPS,DOA,%L,DINUM) ;dic lookup
  1. ;
  1. ; 10/17/95 Matches lookup in DIC^INHSYS05 (which may not be present
  1. ; during GIS s/w installation).
  1. ;
  1. ;input:
  1. ; DIC - Global Root: Can be a string or file number
  1. ; If a file number, this function returns -1
  1. ; when looking at a multiple
  1. ; X - Stuff this bud
  1. ; DLAYGO - file number and formatting
  1. ; %IPS - input parameter string; see DIC(0) documentation
  1. ; DOA - array of previous DA values; passed by referrence
  1. ; %L - current level
  1. ; DINUM (opt) - force this ien
  1. ;output:
  1. ; Y - What DIC returns
  1. N G,DA,I,Y
  1. I DIC Q:DIC'>0!($G(DOA)&$G(%L)) -1 S DIC=$G(^DIC(DIC,0,"GL")) Q:DIC="" -1
  1. I $G(DOA),($G(%L)) D
  1. .F I=%L:-1:2 S DA(I)=DOA(I-1)
  1. .S DA(1)=DOA
  1. S G=DIC_"0)" S:'$D(@G) @G="^"_DLAYGO_"^^"
  1. ;Ugly cross ref lookup since ^DIC chokes on >30 Xact match lookups
  1. I $L(X)>30 S Y=$O(@(DIC_"""B"","""_X_""","""")")) Q $S(Y:Y_U_$P(@(DIC_Y_",0)"),U),1:-1)
  1. S DIC(0)=%IPS
  1. I '$D(DINUM) D ^DIC
  1. I $D(DINUM) D ^DICN
  1. Q Y
  1. ;
  1. GETMTF() ;Get the name of the primary MTF (only one per CHCS system)
  1. N Y,X
  1. S Y=$G(^DD("SITE",1)) Q:'Y ""
  1. S X=$P($G(^DIC(4,Y,0)),U)
  1. Q X
  1. ;