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

AMER0.m

Go to the documentation of this file.
AMER0 ; IHS/ANMC/GIS - AMER SUBROUTINE ;  
 ;;3.0;ER VISIT SYSTEM;**1,2,5,8**;MAR 03, 2009;Build 23
 ;
 ;AMER*3.0*8;Moved presenting complaint from field 8 to field 23
SAVE N AMERPCMP S %=$$STG^AMER0(.AMERPCMP)
 ;N AMERADM,AMERPCC S AMERADM=U_"AMERADM"
 N AMERADM,AMERPCC,AMERDA,AMERTIME ;IHS/OIT/SCR 05/19/09
 S AMERADM=U_"AMERADM"
 I $D(AMERDR("VISIT")) S $P(%,U,12)=AMERDR("VISIT") K AMERDR("VISIT")
 S AMERDFN=^TMP("AMER",$J,1,1),Y=$G(^AUPNPAT(AMERDFN,41,DUZ(2),0)),$P(%,U,9)=$P(Y,U,2)
 S $P(%,U,5)=$P(^DPT(AMERDFN,0),U,2)
 S $P(%,U,11)=DUZ,$P(%,U,8)=$P(^DPT(AMERDFN,0),U,3),AMERSTG=%
 I $D(^AMERADM(AMERDFN)) D SETADM(AMERSTG,AMERPCMP) D TRF(AMERDFN) Q
 S DIC="^AMERADM(",DIC(0)="L",X=AMERDFN,DINUM=X
 K DD,DO
 D FILE^DICN K DIC I Y=-1 Q
 S @AMERADM@(+Y,0)=AMERSTG
 ;
 ;AMER*3.0*8;Save new presenting complaint
 S @AMERADM@(+Y,23)=$G(AMERPCMP)
 ;
 I $G(^TMP("AMER",$J,1,6)) D TRF(+Y) ; TRANSFER SEQUENCE
 S AMERDA=+Y ;IHS/OIT/SCRT 05/19/09 patch 1
 S AMERTIME=$G(^TMP("AMER",$J,1,2))
 I AMERTIME'="" D
 .;if the LOCATION is not set up for scheduling create create a PCC VISIT through ERS PCC interface $$VISIT^AMPERPCC(AMERDFN,AMERTIME)
 .;IHS/OIT/SCR 05/19/09 no scheduling, no visit - commented out next line
 .;I $G(^AMER(2.5,DUZ(2),"SD"))="" S AMERPCC=$$VISIT^AMERPCC(AMERDFN,AMERTIME)
 .; if the LOCATION is set up for scheduling create a PCC VISIT through ERS interface CHECKIN^AMERBSDU(AMERDFN,AMERTIME)
 .I $G(^AMER(2.5,DUZ(2),"SD"))'="" S AMERPCC=$$ERCHCKIN^AMERBSDU(AMERDFN,AMERTIME)
 .I AMERPCC>0 D
 ..D SAVPCCA^AMERPCC(AMERPCC,AMERDFN)
 ..D VISITIN^AMERPCC(AMERDFN,AMERPCC) ;update VISIT file if it exists
 ..;SAVE THE PCC VISIT IEN TO A NEW NODE IN THE TEMP FILE SO IT CAN BE TRANSFERED TO ER VISIT FILE later
 ..S ^TMP("AMER",$J,4)=AMERPCC
 ..;AMER*3.0*8;Create V EMERGENCY VISIT RECORD entry
 .. D VER^AMERVER(AMERDFN,AMERPCC)
 ..Q
 .;IHS/OIT/SCR 051909 patch 1 Don't save info if no PCC visit has been located
 .;I AMERPCC<0 D  ;IHS/OIT/SCR patch 2 replaced by next line
 .I AMERPCC<=0 D
 ..S DIK="^AMERADM(",DA=AMERDA
 ..D ^DIK
 ..D EN^DDIOL("Please re-enter data with a unique appointment time","","!")
 ..D EN^DDIOL("DATA NOT SAVED!!","","!!")
 ..S AMERQUIT=1
 ..Q
 .Q
 Q
 ;
PAT ; ENTRY POINT TO VIEW A SINGLE ENTRY FROM THE ER LOG
 N AMERDA,AMERPCC
 S DIC="^DPT(",DIC(0)="AEQM",DIC("A")="Enter name, DOB or chart number: "
 D ^DIC K DIC
 I $D(DUOUT)!($D(DTOUT)) K DTOUT,DUOUT S AMERQUIT="" G PEXIT
 I Y=-1 G PEXIT
 W !! S DIC="^AMERVSIT(",DIC(0)="EQ",D="AC",X=+Y
 D IX^DIC K DIC
 I $D(DUOUT)!($D(DTOUT)) K DTOUT,DUOUT S AMERQUIT="" G PEXIT
 I Y=-1 G PEXIT
 ;IHS/OIT/SCR 01/09/09 SYNCH THIS VISIT WITH WHAT IS IN PCC
 S AMERDA=+Y
 S AMERPCC=$$FINDVSIT^AMERPCC(AMERDA)
 ;
 ;AMER*3.0*5
 D LOG^AMERBUSA("P","Q","AMER0","AMER: Printed ER Visit","^"_AMERPCC)
 ; 
 I (AMERPCC>0) D
 .D SYNCHERA^AMERERS(AMERDA,AMERPCC)   ;SYNCH ADMISSION IFO
 .D SYNCHERX^AMERERS(AMERDA,AMERPCC)   ;SYNCH DIAG INFO
 .D SYNCHERD^AMERERS(AMERDA,AMERPCC)   ;SYNCH PRIMARY PROVIDER INFO
 .D TIMESTMP^AMERSAV1(AMERDA)
 .W !,"FINISHED SYNCHING ERS WITH CURRENT PCC DATA"  ;IHS/OIT/SCR 05/29/09 patch 1
 .Q
 S AMERPAT=$P($G(^AMERVSIT(AMERDA,0)),U,2)
 D:AMERPAT>0 SYNCHERP^AMERERS(AMERPAT,AMERDA)
 ;IHS/OIT/SCR 01/09/09 END SYNCH THIS VISIT WITH WHAT IS IN PCC
 ;S DIC="^AMERVSIT(",BY="NUMBER",(FR,TO)=+Y,FLDS="[AMER DETAIL"
 S DIC="^AMERVSIT(",BY="NUMBER",(FR,TO)=AMERDA,FLDS="[AMER DETAIL"
 S DHD=$$AMERDHD^AMERREPT("ER LOG ENTRY FOR SINGLE PATIENT","","")
 D EN1^DIP
 I $G(IOST)["C-" S DIR(0)="E" D ^DIR
PEXIT K Y,X,AUPNDAYS,AUPNPAT,AUPNDOB,AUPNDOD,DA,DIC,DIJ,DISYS,DK,DP,AUPNSEX
 K AGE,SSN,SEX,DO,POP
 Q
 ;
CAT(X) ; EP FROM MULTIPLE AMER ROUTINES
 ; GIVEN AN ER CATEGORY, RETURN ITS IEN
 N DIC,Y
 S DIC(0)="",DIC="^AMER(2," D ^DIC
 Q +Y
 ;
OPT(X,C) ; ENTRY POINT FROM AMER1
 ; GIVEN A CATEGORY AND OPTION NAME, RETURN OPTION IEN
 N DIC,Y
 S DIC(0)="",DIC="^AMER(3,",DIC("S")="I $P(^(0),U,2)="_$$CAT^AMER0(C)
 D ^DIC
 Q +Y
 ;
 ;AMER*3.0*8;Moved presenting complaint into 23 (leave in field 8 for compatibility)
STG(AMERPCMP) ; EP FROM SAVE^AMER0
 S AMERPCMP=$G(^TMP("AMER",$J,1,3))  ;AMER*3.0*8
 ;
 ; CONVERT ^TMP VALUES TO A '^' DELIMITED STRING
 N X,Y,Z,%,I,N,A S A=""
 S X="QA" F  S X=$O(^AMER(2.3,"B",X)) Q:$E(X,1,2)'="QA"  S %=$P(X,"QA",2) D
 . I (%<6!(%>9)) S Y=^AMER(2.3,$O(^AMER(2.3,"B",X,0)),0) D
 .. S Z=$P(Y,U,4),N=$P(Y,U,3) I Z=""!(N="") Q
 .. S %=$G(^DD(9009081,Z,0)),I=$P(%,U,4),I=$P(I,";",2) I 'I Q
 .. S %=$G(^TMP("AMER",$J,1,N)) Q:%=""  I %?1.N1"^"1.E S %=+%
 .. ;
 .. ;AMER*3.0*8;Backwards compatible for BEDD until BEDD*2.0*1 gets installed
 .. ;Need to keep saving in original field until BEDD code to use new field is loaded
 .. I $P(X,"QA",2)=3 D  Q
 ... I $T(NEW^BEDDUTW)="" Q  ;Not using BEDD
 ... I $T(XML^BEDD2X01)]"" Q  ;Already installed, don't save
 ... S $P(A,U,10)=%
 .. S $P(A,U,I)=%
 Q A
 ;
TEST W $$STG Q
 ;
UTL(E) ; ENTRY POINT FROM AMER
 ; CONVERT ADMISSION FILE ENTRY BACK TO TMP GLOBALS
 N X,Y,Z,%,I,N,S
 S X="QA" F  S X=$O(^AMER(2.3,"B",X)) Q:$E(X,1,2)'="QA"  S Y=$G(^AMER(2.3,$O(^(X,0)),0)) D
 . S Z=$P(Y,U,4),N=$P(Y,U,3)
 . S %=$G(^DD(9009081,+$G(Z),0)),%=$P(%,U,4)
 . S S=+%
 . S I=$P(%,";",2) I 'I,I'["E1," Q
 . I I S %=$P($G(^AMERADM(E,S)),U,I)
 . I 'I S %=$G(^AMERADM(E,S))
 . I %="" Q
 . S ^TMP("AMER",$J,1,N)=%
 . Q
 ;
 ;AMER*3.0*8;Switched complaint fields
 I $G(^AMERADM(E,23))]"" S ^TMP("AMER",$J,3,1)=$G(^AMERADM(E,23))
 ;
 Q
 ;
TRF(DA) ; DR STRINGS RELATED TO TRANSFER
 S A=""
 F I=1:1:4 S %=+$G(^TMP("AMER",$J,1,(I+5))) S $P(A,U,I)=%
 S @AMERADM@(DA,2)=A
 Q
 ;
 N X,Y,Z,N,A,%,DIE,DIC,DR,D0,D,DI,DQ,DTOUT,D1,DQ,DO,DTO
 S DIE="^AMERADM("
 S Z=20 F  S Z=$O(^TMP("AMER",$J,1,Z)) Q:'Z  S V=^(Z) I V]"" S X=$O(^AMER(2.3,"B",("QA"_Z),0)) Q:'X  S A=$G(^AMER(2.3,X,0)) I A]"" D
 . S %=$P(A,U,4) I %="" Q
 . S DR=%_"////"_V
 . D ^DIE
 . Q
 Q
 ;
SETADM(AMERSTG,AMERPCMP)  ;
 N DIE,AMERDFN,AMERDOB,AMERCHRT,AMERSEX,AMERPCC,AMERVTYP,AMERTRNS,AMERCMPL
 N AMERTRGN,AMERTRGP,AMERTRTM,AMERPRTM,AMERDUZ,AMERAMBN,AMERAMBB,AMERTRAN
 N AMERAMBC,AMERACTY,AMERDR,AMERMOD
 ;
 ;AMER*3.0*8;Fixed entries to save in correct location
 S AMERDFN=$P(AMERSTG,U,1)
 Q:AMERDFN<0
 I $D(^AMERADM(AMERDFN)) S AMERDR=""
 E  S AMERDR=".01///"_AMERDFN
 S AMERDOB=$P(AMERSTG,U,8)
 I AMERDR="" S AMERDR=AMERDR_".02////"_AMERDOB
 E  S AMERDR=AMERDR_";.02////"_AMERDOB
 S AMERCHRT=$P(AMERSTG,U,9)
 S AMERDR=AMERDR_";.03////"_AMERCHRT
 S AMERTIME=$P(AMERSTG,U,2)
 S AMERDR=AMERDR_";1////"_AMERTIME
 S AMERSEX=$P(AMERSTG,U,5)
 S AMERDR=AMERDR_";.05////"_AMERSEX
 S AMERVTYP=$P(AMERSTG,U,4)
 S AMERDR=AMERDR_";3////"_AMERVTYP
 ;
 ;S AMERTRNS=$P(AMERSTG,U,6)
 ;S AMERDR=AMERDR_";14////"_AMERTRNS
 S AMERMOD=$P(AMERSTG,U,6)
 S AMERDR=AMERDR_";6////"_AMERMOD
 ;
 ;AMER*3.0*8;Moved complaint from field 8 to field 23
 ;S AMERCMPL=$P(AMERSTG,U,10)
 ;S AMERDR=AMERDR_";8////"_AMERCMPL
 S AMERDR=AMERDR_";23////"_AMERPCMP
 D
 . ;If using BEDD and no patch 1, save in original field
 . I $T(NEW^BEDDUTW)="" Q  ;Not using BEDD
 . I $T(XML^BEDD2X01)]"" Q  ;Already installed, don't save
 . S AMERDR=AMERDR_";8////"_AMERPCMP
 ;
 S AMERTRGN=$P(AMERSTG,U,19)
 S AMERDR=AMERDR_";19////"_AMERTRGN
 S AMERTRGP=$P(AMERSTG,U,19)
 S AMERDR=AMERDR_";20////"_AMERTRGP
 S AMERTRTM=$P(AMERSTG,U,21)
 S AMERDR=AMERDR_";21////"_AMERTRTM
 S AMERPRTM=$P(AMERSTG,U,22)
 S AMERDR=AMERDR_";22////"_AMERPRTM
 S AMERDUZ=$P(AMERSTG,U,11)
 S AMERDR=AMERDR_";10////"_AMERDUZ
 S AMERAMBN=$P(AMERSTG,U,14)
 S AMERDR=AMERDR_";12////"_AMERAMBN
 S AMERAMBB=$P(AMERSTG,U,15)
 S AMERDR=AMERDR_";13////"_AMERAMBB
 S AMERTRAN=$P(AMERSTG,U,16)
 S AMERDR=AMERDR_";14////"_AMERTRAN
 S AMERAMBC=$P(AMERSTG,U,17)
 S AMERDR=AMERDR_";15////"_AMERAMBC
 S AMERACTY=$P(AMERSTG,U,20)
 S AMERDR=AMERDR_";20////"_AMERACTY
 S AMERPCC=$$EXISTING^AMERPCC(AMERDFN)
 S AMERDR=AMERDR_";1.1////"_AMERPCC
 S DIE="^AMERADM(",DA=AMERDFN,DR=AMERDR
 L +^FILE(9009081):2
 I $T D
 .D ^DIE
 .L -^FILE(9009081)
 .Q
 ;
 ;AMER*3.0*8;Update V EMERGENCY VISIT RECORD entry
 D VER^AMERVER(AMERDFN,AMERPCC)
 ;
 Q