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

AMER.m

Go to the documentation of this file.
AMER ; IHS/ANMC/GIS - PRIMARY ROUTINE FOR ER ADMISSION ;
 ;;3.0;ER VISIT SYSTEM;**4,5,6**;MAR 03, 2009;Build 30
 ;
 N AMERLINE,AMERPCC,AMERTIME,AMERNEW
 I $D(AMERBFLG) K AMERBFLG S AMERSTRT=10,AMERFIN=14,AMERQSEQ=$G(AMERSSEQ) G RUN
VAR D EXIT1 S AMERSTRT=1,AMERFIN=19
VAR1 S %="",$P(%,"~",80)="",AMERLINE=%
 S AMERVER=$$VERSION^XPDUTL("AMER")
 S AMERSVER=$$VERSION^XPDUTL("PIMS")
 S IOP=0 D ^%ZIS W @IOF,"ER SYSTEM Ver ",AMERVER,": ",$S('$D(AMERDOA):"ADMISSION TO EMERGENCY ROOM",1:"   DOA ADMISSION"),"      ^ = back up     ^^ = quit",!,"Questions preceded by a '*' are MANDATORY.  Enter '??' to see choices."
EDIT ; ENTRY POINT FROM AMER4
 I '$D(AMERTFLG) S AMERQSEQ=""
RUN F AMERRUN=AMERSTRT:1 Q:AMERRUN>AMERFIN  Q:$D(AMERQUIT)  D
 . I '$D(^AMER(2.3,"B",("QA"_AMERRUN))) Q
 . S AMERQNO=AMERRUN
 . I '$D(AMERMAND) W $$LINE("QA"_AMERRUN)
 . D OPT("QA"_AMERRUN)
 . D @("QA"_AMERRUN_"^AMER"_$S(AMERRUN<6:"1",AMERRUN<10:"1B",1:"1"))
 . D SET
 . ;
 . ;AMER*3.0*5;Log activity
 . D
 .. NEW ERIEN,AFIELD,ADMFLD
 .. S AFIELD=""
 .. S ERIEN=$O(^AMER(2.3,"B","QA"_AMERRUN,"")) Q:ERIEN=""
 .. S ADMFLD=$$GET1^DIQ(9009082.3,ERIEN,.04,"I")
 .. I ADMFLD]"" S AFIELD=$P($G(^DD(9009081,ADMFLD,0)),U)
 .. I AFIELD="" D
 ... S ADMFLD=$$GET1^DIQ(9009082.3,ERIEN,.05,"I")
 ... I ADMFLD]"" S AFIELD=$P($G(^DD(9009080,ADMFLD,0)),U)
 .. Q:AFIELD=""
 .. ;
 .. ;Now log the activity
 .. I $G(AMERDFN)]"" D LOG^AMERBUSA("P","E","AMER","AMER: Entered Patient ER visit information - "_AFIELD_" ("_AMERDFN_")",AMERDFN)
 . Q
 ;
 ;AMER*3*5;Added auditing call
 I $G(AMERDFN)]"",'$D(^AMERADM(AMERDFN)) D LOG^AMERBUSA("P","A","AMER","AMER: Admitted Patient to the ER",AMERDFN) S AMERNEW=1
 ;
 I $D(AMEREFLG) S AMERNOHS=""
 ;
 ;AMER*3*6;Change batch handling, comment out line, add next line
 ;I $D(AMERBCH) Q  ;NO TEMP FILES SO NO "SAVE" FROM TEMP FILES
 ;
 I $D(AMERBCH),$D(AMERQUIT) Q
 ;
 I $D(AMEREFLG) D  Q
 .S AMERNOHS=""
 .S AMERPCC=$$EXISTING^AMERPCC(AMERDFN)
 .D:AMERPCC>0 VISITIN^AMERPCC(AMERDFN,AMERPCC) ;update VISIT file if it exists
 .Q
 I $D(AMERQUIT) G EXIT
 I '$D(AMERNOHS) D PRINT I $D(AMERQUIT) G EXIT
 D ^AMER0 I $D(AMERQUIT) G EXIT
 ;
 ;AMER*3.0*4
 ;Supply information to BEDD application if loaded
 ;
 ;First see if RPMS patch has been loaded
 I $$VERSION^XPDUTL("BEDD") D
 . ;
 . ;Check if XML portion has been loaded
 . N X
 . S X="BEDDUTW" X ^%ZOSF("TEST") Q:'$T
 . ;
 . ;Check for needed fields
 . I $G(DFN)="" Q
 . S:$G(D0)="" D0=$$GET1^DIQ(9009081,DFN_",",1.1,"I")
 . S:$G(D1)="" D1=$$GET1^DIQ(9009081,DFN_",",1,"I")
 . ;
 . ;Call routine to pass info to BEDD
 . D NEW^BEDDUTIL($G(D),AMERDFN,$G(D0),$G(D1),DFN)
 . ;
 . ;AMER*3*5;Added auditing call
 . I $G(AMERNEW)=1 D LOG^AMERBUSA("P","A","AMER","AMER: Admitted patient to the ED Dashboard",AMERDFN)
 ;
 ;AMER*3*6;Quit if batch
 I $D(AMERBCH) Q
 ;
 W *7,!!,"ER admission data collection is now complete.  Thank you.",!!
EXIT ; ENTRY POINT FROM AMERD
 H 2 I $D(IOF) W @IOF
EXIT1 ; ENTRY POINT FROM AMERD
 K AMERPRV,L,AGMVDF,AMERDA,AMERSSEQ
 K AMERDR,AGE,DFN,DOB,SEX,SSN,AMERNEW
 K AMERQUIT,AMERRUN,AMERLINE,AMERDFN,AMERQNO,AMERQSEQ,AMERSTG,X,Y,Z,F,I,A,%,AUPNPAT,AUPNDOD,AUPNDOB,AUPNSEX,AMERI,AMERNOHS,DIROUT,DH,AMQQSSEQ
 K D,D0,DA,DD,DI,DIADD,DIC,DICR,DIG,DIH,DIK,DISYS,DIU,DIV,DIW,DO,DQ,DIE,DR,DX,%T,S,DUOUT,DTOUT,DPP,DINUM,DIPGM
 K AUPNDAYS,DIRUT,AMERSTRT,AMERFIN,AMEREFLG,AMER,AMERNV,AMERRV,AMERDEST,AMERTAB,B,C,E,G,H,J,K,N,POP,Q,T,V,SDSEX,%Y,%DT
 K ^TMP("AMER",$J,1),^(2),^(3)
 Q
 ;
SET K AMERMAND I $D(AMERQUIT) Q
 I AMERRUN=98 Q
 I AMERRUN="REG" D REG Q
 I AMERRUN="PRINT" D PRINT S AMERRUN=98 Q
 I AMERRUN="EDIT" S AMERNOHS="" D RESTORE Q
 I X?2."^" W !,*7,"Session terminated..." S AMERQUIT="" Q
 I $E(X)=U S X=U
 I X=U,$D(AMEREFLG),(AMERRUN>AMERFIN) Q
 I X=U,AMERQNO<3 W !,"Session terminated...",*7 S AMERQUIT="" Q
 I Y=""!(Y=-1),'$D(AMEROPT),AMERQNO>2,X'=U D MAND Q
 K AMEROPT
 S AMERQSEQ=AMERQSEQ_AMERQNO_";"
 I X=U S X="^B" D BACK Q
 I Y=""!(Y=-1) Q
 S ^TMP("AMER",$J,1,AMERQNO)=Y
 Q
 ;
OUT ; ENTRY POINT FROM MULTIPLE ROUTINES
 I '$D(POP) S POP=0
 I ($D(DTOUT))!($D(DUOUT))!(POP)!($D(DIROUT)) K DTOUT,DUOUT,POP,DIRUT S AMERQUIT=""
 I $G(X)=U K AMERQUIT
 I $G(X)?2."^" S AMERQUIT=""
 I $D(AMERQUIT) W *7,!,"Session terminated.  No data has been entered!"
 Q
 ;
BACK ; ENTRY POINT FROM AMERD
 S A=$L(AMERQSEQ,";"),AMERRUN=$P(AMERQSEQ,";",A-2)-1,AMERQSEQ=$P(AMERQSEQ,";",1,A-3)_";"
 I AMERRUN=-1 S AMERRUN=999
 Q
 ;
RESTORE ;
 S AMERDFN=+Y,AMERRUN=1
 W *7,!!,"This patient is currently admitted to the ER....",!,"Want to edit his/her ER admission data"
 S %=1 D YN^DICN D OUT I $D(AMERQUIT) Q
 I "Yy"'[$E(%Y) S AMERRUN=0 Q
 D UTL^AMER0(AMERDFN)
 Q
 ;
PRINT ; PRINT HEALTH SUMMARY
 Q
 ;
 W ! S DIC="^APCHSCTL(",DIC(0)="AEQ"
 S DIC("B")="ADULT REGULAR"
 D ^DIC K DIC D OUT I $D(AMERQUIT) Q
 S APCHSTYP=+Y,APCHSPAT=AMERDFN
 D HSOUT^APCHS
 Q
 ;
REG ;
 I $D(AMERDEMO) W !!,"Patient registration not available in demo mode",!! H 2 W *7 Q
 S DOG="" K DFN D ^AGVAR,DOG^AG0
 I '$D(DFN) S AMERQUIT="" G REGEXIT
 ;
 ;AMER*3.0*5;Now log the activity
 D LOG^AMERBUSA("P","A","AMER","AMER: Performed Patient Mini-Registration",DFN)
 S ^TMP("AMER",$J,1,1)=DFN,AMERDFN=DFN,AMERRUN=1
REGEXIT K XY,XYER,AG,AUPDIC,AUPDICW,DIC,DIE,DO,D0,DIU,DIV,DIG,DA,D1,DFN,DIPGM,BS,F,FF,RM,SL,SUB,D,DI,DIH,DOG,DQ,%W,%Y,%,AGOPT,AUPL,AUPQF,AUPX,DIW,DR,%DT
 Q
 ;
MAND ; ENTRY POINT FROM AMERD ; MANDATORY ANSWER
 W *7,!,"This answer is mandatory. If you need help, type '??'."
 S AMERRUN=AMERRUN-1,AMERMAND=""
 Q
 ;
BATCH ; ENTRY POINT FOR BATCH MODE
 S AMERBCH=""
B1 D AMER I $D(AMERQUIT) D EXIT1 K AMERBCH Q
 S AMERSSEQ=$P(AMERQSEQ,";",1,$L(AMERQSEQ,";")-2)_";"
 D VAR^AMERD I $D(AMERQUIT) D EXIT1 K AMERBCH,AMERSSEQ Q
 I $D(AMERDOA) K AMERDOA
 I '$D(AMERBCH) D EXIT1
 G B1
 ;
DOA ; ENTRY POINT FOR DOA
 S AMERDOA=""
 D BATCH,EXIT1 K AMERDOA
 Q
 ;
SCAN ; ENTRY POINT FROM SCAN PT NAME OPTION ;SCAN PT NAMES
 D MSG^AMER1A
SC1 W !!
 ;
 ;Call to patient lookup
 D ^AMERLKP
 I $D(IOF) W @IOF
 D EXIT1^AMER K DIRUT
 Q
 ;
EN1 ; ENTRY POINT FOR MINI REGISTRATION
 D REG
 K A1BETAG,AGDOG,AGDTS
 D EXIT1 I $D(IOF) W @IOF
 Q
 ;
TRG ; ENTRY POINT FOR EDITING TRIAGE NURSE'S FIELDS
 N AMERLINE
 D EXIT1
 S %="",$P(%,"~",80)="",AMERLINE=% K %
 ;S AMERSTRT=1,AMERFIN=27,AMERQSEQ=""   ;IHS/OIT/SCR 01/06/09
 S AMERSTRT=1,AMERFIN=25,AMERQSEQ=""
 S AMERTRG=1
 D EDIT^AMERD
 K AMERTRG,AMERLINE
 Q
 ;
LINE(X) ; QUERY SEPERATOR LINE
 N Y,AMERLINE
 S %="",$P(%,"~",80)="",AMERLINE=% K %
 I $G(X)="" S X="Q"
 S Y=$O(^AMER(2.3,"B",X,"")),Y=$P($G(^AMER(2.3,+Y,0)),U,11)
 I 'Y Q ($C(10)_$C(13)_$C(10)_$C(13)_AMERLINE_$C(10)_$C(13))
 Q ""
 ;
DEMO ; ENTRY POINT FOR DEMO MODE.  NO VISIT CREATED
 S AMERDEMO=1
 D AMER
 K AMERDEMO
 Q
 ;
OPT(X) ; ENTRY POINT FROM AMERD ;OPTIONAL
 K AMEROPT
 N %,Y,Z
 S Y=$O(^AMER(2.3,"B",X,"")) I 'Y Q
 S %=$P($G(^AMER(2.3,Y,0)),U,12)
 I % S AMEROPT=""
 Q
 ;
R1 ;
 Q