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

AMER1A.m

Go to the documentation of this file.
AMER1A ; IHS/ANMC/GIS -ISC - OVERFLOW FROM AMER1 ; 
 ;;3.0;ER VISIT SYSTEM;**2,5,8,9**;MAR 03, 2009;Build 4
 ;
QA1 ; ENTRY POINT FROM AMER1 ;NAME
 S DIC=2,DIC(0)="AEMQ"
 S DIC("A")="Enter the patient's NAME or LOCAL CHART NUMBER: "
 D ^DIC K DIC,AUPNPAT,AUPNDOB,AUPNDOD,AUPNDAYS,AUPNSEX
 I $D(DTOUT) K DTOUT S AMERQUIT="" Q
 I Y'=-1 S AMERDFN=+Y
 I Y'=-1,$D(^AMERADM("B",+Y)) S AMERRUN="EDIT" Q
 I Y'=-1 S Y=+Y Q
 I Y=-1,X'="" S AMERQUIT="" Q
 W !!,*7,"Do you want to register a new patient"
 S %=2 D YN^DICN I $D(DTOUT)!($E(%Y)=U) K DTOUT S AMERQUIT="" Q
 I "Nn"[$E(%Y) S AMERQUIT="" Q
 W !!,"Are you absolutely sure that this patient has never been registered",!,"here before"
 S %=2 D YN^DICN I $D(DTOUT)!($E(%Y)=U) K DTOUT S AMERQUIT="" Q
 I "Nn"[$E(%Y) D MSG G QA1
 S AMERRUN="REG"
 Q
 ;
MSG ; ENTRY POINT FROM AMER
 W !!!,"There are several tricks you can use to find this patient.  Try entering a"
 W !,"partial name like 'DOE,JO' instead of 'DOE,JOHN'.  Ask about other first"
 W !,"names and married names.  Try entering a date of birth in the format 9/9/99."
 W !,"This should narrow down the list of possible choices."
 W !!!
 Q
 ;
CHECK I '$D(^AMERADM("B")) W !!!,*7,"Sorry...I have no record of any current admissions to the ER.",!!! Q  ; EP FROM ^AMER2
PICK ;
 N A,B,C,Y,F,N,%,E,G
 K ^TMP("AMER TEMP",$J)
 W !,"The following patients are currently admitted to the ER =>",!!
 ;IHS/OIT/SCR - patch 2 start changes to order display
 ;W ?3,"NAME",?18,"DOB",?31,"CHART",?40,"ADMISSION",?59,"PRESENTING COMPLAINT"
 ;S %="",I=0,$P(%,"-",80)="" W !,%
 ;F N=0:0 S N=$O(^AMERADM(N)) Q:'N  S A=^(N,0) D PW
 S I=$$ADMDISP()  ;RETURNS THE COUNT
 ;Q:I<1
 I I<1 S AMERQUIT=""  ;IHS/OIT/SCR 10/14/09 patch 2 beta1
 W !
 Q
 ;PW ;
 ;I $D(AMERTRG),$P(^AMERADM(N,0),U,19)?1N.N Q
 ;S I=I+1,B=$P(^DPT(N,0),U),B=I_") "_$E(B,1,13),C=$P(A,U,9),E=$P(A,U,2),F=$P(A,U,10),G=$P(A,U,8),^TMP("AMER TEMP",$J,I,N)=""
 ;S F=$E(F,1,20),Y=E X ^DD("DD") S E=Y,Y=G X ^DD("DD") S G=Y
 ;W !,B,?18,G,?31,C,?40,E,?59,F
 ;Q
 ;IHS/OIT/SCR - patch 2 end changes to order display
ACT ; ENTRY POINT FROM MENU
 I $D(IOF) W @IOF
 D CHECK
 S DIR(0)="E",DIR("A")="Press 'Return to continue" D ^DIR
 I $D(IOF) W @IOF
 K DIR(0),DIR("A")
 Q
 ;
ADMDISP() ;IHS/OIT/SCR patch 2: Provides a toggle for display order
 N DIR,Y,AMERNUM
 S AMERNUM=-1
 S AMERNUM=$$SORTADM(1)
 W !
 ;IHS/OIT/SCR 10/15/09 patch 2 beta1 added next two lines
 I AMERNUM=0 W !,"All patients have been processed" Q AMERNUM
 I AMERNUM=1 Q AMERNUM
 S DIR(0)="Y",DIR("A")="Would you like to sort by ADMISSION time" S DIR("B")="N"
 D ^DIR
 I +Y=1 D
 .S AMERNUM=$$SORTADM(2)
 .W !
 .S DIR(0)="Y",DIR("A")="Would you like to sort by PATIENT NAME " S DIR("B")="N"
 .D ^DIR
 .I +Y=1 S AMERNUM=$$ADMDISP()
 .W !
 .Q
 Q AMERNUM
 ;
SORTADM(AMERSORT) ;IHS/OIT/SCR patch 2: Displays ER ADMISSION in identified order 
 N AMERNAME,AMERINDX,AMERARRY,AMERDOB,AMERCHRT,AMERCOMP,AMERTIME,AMERIDX2,AMERTIMF,AMERCNT
 I $G(AMERSORT)="" S AMERSORT=1
 S AMERINDX=0
 S AMERIDX2=0
 I AMERSORT=1 D
 .;SORT BY NAME
 .K ^TMP("AMER TEMP",$J)
 .F  S AMERINDX=$O(^AMERADM(AMERINDX)) Q:AMERINDX="B"  D
 ..I $D(AMERTRG),$P(^AMERADM(AMERINDX,0),U,19)?1N.N Q   ;IHS/OIT/SCR 10/14/09 patch 2 beta1
 ..S AMERNAME=$P($G(^DPT(AMERINDX,0)),"^",1)
 ..Q:AMERNAME=""
 ..I $G(AMERARRY(AMERNAME))'="" D
 ...S AMERARRY(AMERNAME,AMERIDX2)=AMERINDX
 ...S AMERIDX2=AMERIDX2+1
 ...Q
 ..I $G(AMERARRY(AMERNAME))="" D
 ...S AMERIDX2=0
 ...S AMERARRY(AMERNAME)=AMERINDX
 ..Q
 .S AMERCNT=0
 .Q:'$D(AMERARRY)  ;IHS/OIT/SCR 10/14/09 patch 2 beta1
 .W !!,?3,"NAME",?18,"DOB",?31,"CHART",?40,"ADMISSION",?59,"PRESENTING COMPLAINT",!
 .S AMERINDX=""
 .F  S AMERINDX=$O(AMERARRY(AMERINDX)) Q:AMERINDX=""  D
 ..S AMERNAME=AMERINDX
 ..S AMERCNT=AMERCNT+1
 ..S AMERDPT=$G(AMERARRY(AMERNAME))
 ..S ^TMP("AMER TEMP",$J,AMERCNT,AMERDPT)=""
 ..S AMERDOB=$P($G(^AMERADM(AMERDPT,0)),"^",8)
 ..S Y=AMERDOB X ^DD("DD") S AMERDOB=Y  ;FORMAT DATE
 ..S AMERCHRT=$P($G(^AMERADM(AMERDPT,0)),"^",9)
 ..S AMERTIME=$P($G(^AMERADM(AMERDPT,0)),"^",2)
 ..S Y=AMERTIME X ^DD("DD") S AMERTIME=Y
 ..;AMER*3.0*8;Switched to field 23
 ..;S AMERCOMP=$P($G(^AMERADM(AMERDPT,0)),"^",10)
 ..S AMERCOMP=$P($G(^AMERADM(AMERDPT,23)),"^",1)
 ..S AMERCOMP=$E(AMERCOMP,1,21)
 ..S AMERNAME=$E(AMERNAME,1,13)
 ..W !,AMERCNT_")",?3,AMERNAME,?18,AMERDOB,?31,AMERCHRT,?40,AMERTIME,?59,AMERCOMP
 ..;
 ..;AMER*3*5;Added auditing call
 ..D LOG^AMERBUSA("P","Q","AMER1A","AMER: ER Patient Listing",AMERDPT)
 ..; 
 ..S AMERIDX2=0
 ..F  S AMERIDX2=$O(AMERARRY(AMERINDX,AMERIDX2)) Q:AMERIDX2=""  D
 ...S AMERCNT=AMERCNT+1
 ...S AMERTIME=AMERINDX
 ...S AMERDPT=$G(AMERARRY(AMERNAME,AMERIDX2))
 ...S ^TMP("AMER TEMP",$J,AMERCNT,AMERDPT)=""
 ...S AMERNAME=AMERINDX
 ...S AMERNAME=$E(AMERNAME,1,13)
 ...S AMERDOB=$P($G(^AMERADM(AMERDPT,0)),"^",8)
 ...S Y=AMERDOB X ^DD("DD") S AMERDOB=Y  ;FORMAT DATE
 ...S AMERCHRT=$P($G(^AMERADM(AMERDPT,0)),"^",9)
 ...S Y=AMERTIME X ^DD("DD") S AMERTIME=Y
 ...;AMER*3.0*9;Switched to field 23
 ...;S AMERCOMP=$P($G(^AMERADM(AMERDPT,0)),"^",10)
 ...S AMERCOMP=$P($G(^AMERADM(AMERDPT,23)),"^",1)
 ...S AMERCOMP=$E(AMERCOMP,1,21)
 ...W !,AMERCNT_")",?3,AMERNAME,?18,AMERDOB,?31,AMERCHRT,?40,AMERTIME,?59,AMERCOMP
 ...Q
 ..Q
 .Q
 I AMERSORT=2 D
 .;SORT BY ADMISSION TIME STAMP
 .K ^TMP("AMER TEMP",$J)
 .F  S AMERINDX=$O(^AMERADM(AMERINDX)) Q:AMERINDX="B"  D
 ..I $D(AMERTRG),$P(^AMERADM(AMERINDX,0),U,19)?1N.N Q   ;IHS/OIT/SCR 10/14/09 patch 2 beta1
 ..S AMERTIME=$P($G(^AMERADM(AMERINDX,0)),"^",2)
 ..Q:AMERTIME=""
 ..I $G(AMERARRY(AMERTIME))'="" D
 ...S AMERARRY(AMERTIME,AMERIDX2)=AMERINDX
 ...S AMERIDX2=AMERIDX2+1
 ...Q
 ..I $G(AMERARRY(AMERTIME))="" D
 ...S AMERIDX2=0
 ...S AMERARRY(AMERTIME)=AMERINDX
 ..Q
 .S AMERINDX=""
 .S AMERCNT=0
 .Q:'$D(AMERARRY)  ;IHS/OIT/SCR 10/14/09 patch 2 beta1
 .W !!
 .W !,?3,"NAME",?18,"DOB",?31,"CHART",?40,"ADMISSION",?59,"PRESENTING COMPLAINT",!
 .F  S AMERINDX=$O(AMERARRY(AMERINDX)) Q:AMERINDX=""  D
 ..S AMERCNT=AMERCNT+1
 ..S AMERTIME=AMERINDX
 ..S AMERDPT=$G(AMERARRY(AMERTIME))
 ..S ^TMP("AMER TEMP",$J,AMERCNT,AMERDPT)=""
 ..S AMERNAME=$P($G(^DPT(AMERDPT,0)),"^",1)
 ..S AMERNAME=$E(AMERNAME,1,13)
 ..S AMERDOB=$P($G(^AMERADM(AMERDPT,0)),"^",8)
 ..S Y=AMERDOB X ^DD("DD") S AMERDOB=Y  ;FORMAT DATE
 ..S AMERCHRT=$P($G(^AMERADM(AMERDPT,0)),"^",9)
 ..S Y=AMERTIME X ^DD("DD") S AMERTIMF=Y
 ..;AMER*3.0*9;Switched to field 23
 ..;S AMERCOMP=$P($G(^AMERADM(AMERDPT,0)),"^",10)
 ..S AMERCOMP=$P($G(^AMERADM(AMERDPT,23)),"^",1)
 ..S AMERCOMP=$E(AMERCOMP,1,21)
 ..W !,AMERCNT_")",?3,AMERNAME,?18,AMERDOB,?31,AMERCHRT,?40,AMERTIMF,?59,AMERCOMP
 ..S AMERIDX2=""
 ..F  S AMERIDX2=$O(AMERARRY(AMERTIME,AMERIDX2)) Q:AMERIDX2=""  D
 ...S AMERCNT=AMERCNT+1
 ...S AMERTIME=AMERINDX
 ...S AMERDPT=$G(AMERARRY(AMERINDX,AMERIDX2))
 ...S ^TMP("AMER TEMP",$J,AMERCNT,AMERDPT)=""
 ...S AMERNAME=$P($G(^DPT(AMERDPT,0)),"^",1)
 ...S AMERNAME=$E(AMERNAME,1,13)
 ...S AMERDOB=$P($G(^AMERADM(AMERDPT,0)),"^",8)
 ...S Y=AMERDOB X ^DD("DD") S AMERDOB=Y  ;FORMAT DATE
 ...S AMERCHRT=$P($G(^AMERADM(AMERDPT,0)),"^",9)
 ...S Y=AMERTIME X ^DD("DD") S AMERTIMF=Y
 ...;AMER*3.0*9;Switched to field 23
 ...;S AMERCOMP=$P($G(^AMERADM(AMERDPT,0)),"^",10)
 ...S AMERCOMP=$P($G(^AMERADM(AMERDPT,23)),"^",1)
 ...S AMERCOMP=$E(AMERCOMP,1,21)
 ...W !,AMERCNT_")",?3,AMERNAME,?18,AMERDOB,?31,AMERCHRT,?40,AMERTIMF,?59,AMERCOMP
 ...Q
 ..Q
 .Q
 Q AMERCNT