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

AMERAGED.m

Go to the documentation of this file.
AMERAGED ; IHS/OIT/SCR 06/22/06 - PATIENT REG ROUTINES
 ;;3.0;ER VISIT SYSTEM;;FEB 23, 2009
 ;
 ;;
NAME(AMERDFN) ; EP - From UPDATPAT^AMERVSIT
 ; Check for PATIENT REG 7.1 PATCH 2
 ;  IF IT IS THERE RETURN VALUE FROM  PATIENT REG API NAME^AGMANERS().
 ;  IF NOT, RETURN VALUE FROM AMERNAME() BELOW 
 ; Check for "AG" version 7.1 PATCH 1
 NEW AMERPTCH,AMERAGPT,AMERPNTR,AMEROK,AMERAGV,AMERRTRN
 S AMERRTRN=""
 S AMERAGV=$$VERSION^XPDUTL("AG")
 I AMERAGV'="7.1" S AMERRTRN=$$AMERNAME(AMERDFN) Q AMERRTRN  ;IF Patient Reg Version is not 7.1, dont' look for patch 2
 S AMERPNTR=$O(^DIC(9.4,"C","AG",0))
 S AMERPTCH=0,AMEROK="NO"
 F  S AMERPTCH=$O(^DIC(9.4,AMERPNTR,22,AMERPTCH)) Q:AMERPTCH=""!(AMEROK="YES")  D
 .I $P($G(^DIC(9.4,AMERPNTR,22,AMERPTCH,0)),U,1)'="7.1" Q  ;ONLY LOOK AT ENTRIES FOR VERSION 7.1
 .S AMERAGPT=""
 .F  S AMERAGPT=$O(^DIC(9.4,AMERPNTR,22,AMERPTCH,"PAH",AMERAGPT)) Q:(AMERAGPT=""!(AMEROK="YES"))  D
 ..I +$G(^DIC(9.4,AMERPNTR,22,AMERPTCH,"PAH",AMERAGPT,0))[2 S AMEROK="YES"
 ..Q
 .Q
 I AMEROK="YES" S AMERRTN=$$NAME^AGMANERS(AMERDFN)
 I AMEROK'="YES" S AMERRTN=$$AMERNAME(AMERDFN)
 Q AMERRTN
 ;
 ; All of the following code will be replaced by NAME^AGMANERS when AG*7.1*2 IS RELEASED
AMERNAME(AMERDFN)  ; ROUTINE TO UPDATE PATIENT DATA IF PATCH 2 OF PATIENT REG 7.1 IS NOT INSTALLED
 N DIC,AMERONAM
 S DFN=AMERDFN
 S AMERONAM=$P($G(^DPT(DFN,0)),U,1)
 D CHKRHI^AG
 I $D(RHIFLAG)  D
 . I RHIFLAG="A" W !,$$S^AGVDF("RVN"),$$S^AGVDF("BLN"),"This patient has Restricted Health Information",$$S^AGVDF("BLF"),$$S^AGVDF("RVF")
 ;ADD ALERT IF PATIENT HAS 'DATE OF DEATH' POPULATED IN VA PATIENT FILE
 I $D(DFN) I $$CHKDEATH^AGEDERR(DFN) W !!?5,"**** ALERT: DATE OF DEATH ON FILE FOR THIS PATIENT!!" H 2
 Q:'$D(DFN)
 S DIR(0)="FOr^1:80",DIR("A")="ENTER NEW NAME",DIR("?")="ENTER NAME THAT SHOULD BE ON THIS RECORD(80 characters max.)"
 S DIR("B")=AMERONAM
 D ^DIR K DIR
 I $D(DUOUT)!$D(DTOUT)!(Y="") K DUOUT,DTOUT,Y Q 0
 Q:Y=AMERONAM 0
 K AG("NEWNAME")
 S X=Y
 S AG("NEWNAME")=Y
 D NAME^AUPNPED
 I '$D(X) D EN^DDIOL("INCORRECT NAME FORMAT","","!!") K AG("NEWNAME") Q 0
 S AG("OLDNAME")=AMERONAM
 D NOW^%DTC S AGDTS=%
 D ADDNAM^AGNAMCHG
 Q:$D(AG("NAMFAIL")) 0
 K DIC,DIE,DA,DR,Y
 S DA=DFN
 S DR=".01///"_AG("NEWNAME")
 S X=$$DIEDPT(DA,DR)
 I $P(^DPT(DFN,0),U)=AG("OLDNAME") D END Q 1
 S AMERHL7="AGHL7"
 S ^XTMP(AMERHL7,DA)=DA
 S AMERH7AG="AGHL7AG"
 S ^XTMP(AMERH7AG,DA,"UPDATE")=""
 S DIR("A")="Do you wish to store "_AG("OLDNAME")_" in the ""OTHER NAMES"" file for future reference to this patient"
 S DIR(0)="Y",DIR("B")="YES"
 D ^DIR
 I $D(DUOUT)!$D(DTOUT)!(Y="") K DUOUT,DTOUT,Y Q 0
 I Y["Y" D
 .S DIE="^DPT("
 .S DA=DFN,DR="1///"_AG("OLDNAME"),DR(2,2.01)=.01
 .S X=$$DIEDPT(DA,DR)
 S ^AGPATCH(AGDTS,DUZ(2),DFN)="",DR=".03///TODAY",$P(^AUPNPAT(DFN,0),U,12)=DUZ,DA=DFN
 D DIEAUPN(DA,DR)
 Q 1
END  ;
 I '$G(AGTDS) S X="NOW" D ^%DT S AGDTS=Y
 I $G(AGPTPG)=0,("N"'[($P(^AUTTSITE(1,0),"^",16))) S ^AGPATCH(AGDTS,DUZ(2),DFN,"ZMFI",0)=""
 I $D(^AGPATCH(AGDTS,DUZ(2),DFN))=10 S ^AGPATCH(AGDTS,DUZ(2),DFN)=""
 I $D(^AGPATCH(AGDTS,DUZ(2),DFN))=0 S ^AGPATCH(AGDTS,DUZ(2),DFN)=""
 K AGDTS
 Q
DIEDPT(DA,DR) ; GIVEN AN ENTRY NUMBER AND A DR STRING, EDIT THE VA PATIENT FILE
 N X,Y,%
 N D,D0,DI,DIC,DICR,DIE,DIG,DIH,DIV,DIU,DIW,DQ
 S DIE="^DPT("
  L +^DPT(DA):3 E  Q
  D ^DIE
  L -^DPT(DA)
  K DIE,DA,DR
  Q X
DIEAUPN(DA,DR) ; GIVEN AN ENTRY NUMBER AND A DR STRING, EDIT THE PATIENT FILE
  N X,Y,%
  N D,D0,DI,DIC,DICR,DIE,DIG,DIH,DIV,DIU,DIW,DQ
  S DIE="^AUPNPAT("
  L +^AUPNPAT:3 E  Q
  D ^DIE
  L -^AUPNPAT
  K DIE,DA,DR
  Q