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

INHVA2.m

Go to the documentation of this file.
  1. INHVA2 ;FRW ; 6 Mar 92 18:07
  1. ;;3.01;BHL IHS Interfaces with GIS;;JUL 01, 2001
  1. ;COPYRIGHT 1991-2000 SAIC
  1. Q
  1. ;
  1. MAP(INFUNC,INVAL,INLAYGO,INDELIM,INSYS,INDR,INDS) ;Data transform/update
  1. ;This function will transform a remote value to a local value.
  1. ;It will also update the local data files (i.e. hosp. loc., etc.), and
  1. ;the data element value map file (#4090.1)
  1. ;
  1. ;INPUT:
  1. ; INFUNC - mapping function (file #4090.2) (req.)
  1. ; internal or external value
  1. ; INVAL - value to transform (req.)
  1. ; remote record id _ delimeter _ remote record name
  1. ; INLAYGO - is laygo allowed on mapped file and value map file (opt.)
  1. ; 1 => allowed ; 0 => NOT allowed (default)
  1. ; INDELIM - delimeter used to piece apart INVAL (opt.)
  1. ; default = value of SUBDELIM (from GIS) or '\'
  1. ; INSYS - sending system to transform from ('VA' or 'SC') (opt.)
  1. ; default comes from value of INMODE (from GIS)
  1. ; INDR - DR string to apply to newly created entries in the
  1. ; target file. (optional)
  1. ;
  1. ; INDS - Code executed before DIC lookup to make new entry (opt)
  1. ;
  1. ; INMODE - indicates direction of transaction
  1. ; I => IN ; O => OUT
  1. ; SUBDELIM - indicates delimete for data value field
  1. ;
  1. ;OUTPUT:
  1. ; function value - record id ^ record name ^ new entry indicator
  1. ; or NULL if lookup failed
  1. ;
  1. ;LOCAL:
  1. ; INHPOP - indicates if an error has occured (truth value)
  1. ; INLOC - local record id _ ^ _ local record name
  1. ; INEWDAT - indicates if new entry was added to mapped file
  1. ; INEWMAP - indicates if new entry was added to value map file (4090.1)
  1. ; INDIC - indicates corresponding file # on local system for data map function
  1. ;
  1. ;*NOTE* Error handling may need to be evaluated. If this funciton returns NULL then maybe an error should be flagged
  1. ;
  1. ST ;Starting point
  1. Q:'$L($G(INFUNC))!'$L($G(INVAL)) ""
  1. N INHPOP,DIC,INLOC,INEWDAT,INEWMAP,INDIC
  1. ;Verify data mapping function is correct
  1. I INFUNC'=+INFUNC K DIC S DIC="^INVD(4090.2,",DIC(0)="X",X=INFUNC D ^DIC Q:+Y<0 "" S INFUNC=+Y
  1. Q:'$D(^INVD(4090.2,INFUNC,0)) ""
  1. ;Initialize variables
  1. S (INHPOP,INEWMAP,INEWDAT)=0,INLAYGO=+$G(INLAYGO),INDELIM=$S($L($G(INDELIM)):INDELIM,$L($G(SUBDELIM)):SUBDELIM,1:"\")
  1. ;Determine sending system
  1. ;*NOTE* This needs to be smarter - will only support SC in some cases
  1. S INSYS=$S($L($G(INSYS)):INSYS,$G(INMODE)="I":$S($$SYS^INHUTIL1="SC":"VA",1:"SC"),$G(INMODE)="O":$$SYS^INHUTIL1,1:"") Q:(INSYS'="VA")&(INSYS'="SC") ""
  1. ;
  1. TR ;Transform existing data map
  1. S INDIC=$P($G(^INVD(4090.2,INFUNC,$S(INSYS="VA":"SC",1:"VA"))),U,1)
  1. S INLOC=$$TRANS^INHVA(INSYS,INFUNC,$P(INVAL,INDELIM,1),$S(INDIC'=2:$P(INVAL,INDELIM,2),1:""))
  1. Q:$L(INLOC) INLOC
  1. Q:'INLAYGO ""
  1. ;
  1. ;Only data map functions that correspond to files on the local system
  1. ; will continue from here
  1. ;
  1. UDAT ;Update mapped file
  1. K DIC S (INDIC,DIC)=$P($G(^INVD(4090.2,INFUNC,$S(INSYS="VA":"SC",1:"VA"))),U,1) Q:'INDIC "" S DIC(0)="XL",X=""""_$P(INVAL,INDELIM,2)_"""" X $G(INDS) D ^DIC Q:Y<0 "" S INLOC=$P(Y,U,1,2),INEWDAT=$P(Y,U,3)
  1. ;Perform edit on newly created entry
  1. I $G(INDR)]"" S DIE=DIC,DA=+Y,DR=INDR D ^DIE
  1. ;
  1. UMAP ;Update value map file (#4090.1)
  1. K DIC S DIC="^INVD(4090.1,",DIC(0)="XL",X=""""_INDIC_"-"_$S(INSYS="VA":$P(INVAL,INDELIM,1),1:$P(INLOC,U,1))_"""" D ^DIC Q:+Y<0 ""
  1. ;Edit new entry
  1. S INEWMAP=$P(Y,U,3),DA=+Y,DIE=DIC,DR="[INH AUTO UPDATE ON "_$S(INSYS="VA":"SC",1:"VA")_"]" D ^DIE
  1. ;Check for errors during edit
  1. I $D(Y)#2
  1. ;
  1. ;*NOTE* Error needs to be flagged somewhere (bulletin or GIS) if:
  1. ; Problems occured during edit
  1. ; New entry added to mapped file but not to value map file
  1. ;
  1. ;*NOTE* Need to send bulletin to someone (postmaster)
  1. ; Should inidcate if mapped file was updated (and values)
  1. ; Should indicate if 4090.1 was updated (and values)
  1. ; Tell user to verify many to one relationship for map function
  1. ;
  1. Q INLOC
  1. ;
  1. TEST ;Test it
  1. R !!!,"Map function: ",INFUNC:DTIME
  1. Q:INFUNC=U
  1. R !,"Remote value (ien\name): ",INVAL:DTIME
  1. R !,"Laygo (1 or 0): ",INLAYGO:DTIME
  1. S X=$$MAP(INFUNC,INVAL,INLAYGO,"","VA")
  1. W !,"Function Value => ",X
  1. G TEST
  1. ;
  1. ;