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

AMEREDTA.m

Go to the documentation of this file.
AMEREDTA ; IHS/OIT/SCR - SUB-ROUTINE FOR ER VISIT EDIT of ADMIT information
 ;;3.0;ER VISIT SYSTEM;**2,10**;MAR 3, 2009;Build 23
 ;
 ;GDIT/HS/BEE 05/10/2018;CR#10213 - AMER*3.0*10 - Save updated clinic and hospital location
 ;
 ; VARIABLES: The following variables are passed to multiple editing routines
 ; AMERDA  : the IEN of the ER VISIT that is selected for editing
 ;  AMERAIEN: The IEN of the ER AUDIT that is created when user begins editing a record
 ;  AMEREDNO: An integer representing the number of multiple fields that have been edited
 ;            for uniqueness in multiple field number in audit file
 ;            
 ; Edit Auditing VARIABLES newed and used throughout edit routines:
 ;      AMEROLD : original value of edited field
 ;      AMERNEW : new value of edited field
 ;      AMERSTRG : A ";" deliminated string of edit information for a field   
 ;              
EDADMIT(AMERDA,AMERAIEN)   ;EP - CALLED BY AMEREDIT when "ADMIT" is selected for editing
 N AMERCHRT,AMERDOB,AMERSEX,AMERDR,DIR,Y,AMERNEW,AMEROLD,AMEREDTS,AMERSTRG
 N AMERQUIT,AMERISNW,AMERONAM,AMERNNAM,AMERANS,AMEROTIM,AMERNTIM,X
 S (AMERCHRT,AMERDOB,AMERSEX,AMERDR,AMEROLD,AMERNEW,AMEREDTS,AMERSTRG,AMERQUIT,AMERTIM)=""
 Q:'$D(^XUSEC("AMERZ9999",DUZ)) $$ERSEDTA(AMERDA,AMERAIEN)
 D EN^DDIOL("**Changing the PATIENT will change chart number, age and other fields**","","!!?3")
 D EN^DDIOL("*** AND will also cause a new PCC VISIT to be created ***","","!?10")
 S DIR(0)="Y",DIR("A")="Change Patient",DIR("B")="NO"
 D ^DIR K DIR
 I $D(DUOUT)!$D(DTOUT)!(Y<0) K DUOUT,DTOUT Q 0
 I Y=1 D
 .S (AMERDFN,AMEROLD)=$P($G(^AMERVSIT(AMERDA,0)),U,2)
 .S AMERISNW=$$NEWREG^AMERVSIT(AMERDFN,AMERDA)
 .I AMERISNW  D  ;THIS PATIENT WAS CREATED THE SAME DAY AS THIS VISIT
 ..D EN^DDIOL("The patient record was created on the same day as the ER VISIT being edited","","!")
 ..S DIR(0)="SO^1:UPDATE NEW PATIENT RECORD;2:REPLACE WITH AN EXISITING PATIENT"
 ..S DIR("A")="Which would you like to do"
 ..D ^DIR K DIR
 ..Q:Y=""!(Y="^")
 ..S AMERANS=Y
 ..I AMERANS=1 D   ;PATIENT DFN DOES NOT CHANGE, BUT INFORMATION IN IT DOES
 ...S AMERONAM=$P($G(^DPT(AMERDFN,0)),U,1)
 ...S AMERCHNG=$$UPDATPAT^AMERVSIT(AMERDFN)  ;CALLS PATIENT REG PEPs TO UPDATE FIELDS ORIGINALLY ENTERED
 ...Q:AMERCHNG=0
 ...S AMERCHRT=$P($G(^AUPNPAT(AMERDFN,41,DUZ(2),0)),U,2)
 ...S AMERSEX=$P($G(^DPT(AMERDFN,0)),U,2)
 ...S AMERDOB=$P($G(^DPT(AMERDFN,0)),U,3)
 ...S AMERNNAM=$P($G(^DPT(AMERDFN,0)),U,1)
 ...;S AMERDR=".12///"_AMERDOB_";.18///"_AMERSEX_";.19///"_$G(DUZ)
 ...S AMERDR=".12///"_AMERDOB_";.18///"_AMERSEX_";.19////"_$G(DUZ)  ;IHS/OIT/SCR 071509 patch 2
 ...S AMERSTRG=$$EDAUDIT^AMEREDAU(".02",AMERONAM,AMERNNAM,"PATIENT")
 ...I AMERSTRG="^" S AMERQUIT=1 Q
 ...D DIE^AMEREDIT(AMERDA,AMERDR)
 ...D DIEREC^AMEREDAU(AMERAIEN,AMERSTRG)
 ...Q
 ..I AMERANS=2 D
 ...S AMERDFN=$$CHANGPAT^AMERVSIT(AMEROLD,AMERDA,AMERISNW) ;THIS ROUTINE REMOVES V POV AND V PROVIDER ENTRIES FOR THE VISIT ASSOCIATED TO THE OLD DFN
 ..Q
 .I 'AMERISNW S AMERDFN=$$CHANGPAT^AMERVSIT(AMEROLD,AMERDA,AMERISNW)
 .I AMERDFN=0 Q  ;$$CHANGPAT RETURNS 0 IF USER HAS TIMED OR UPPED OUT
 .I AMEROLD'=AMERDFN D
 ..S AMERCHRT=$P($G(^AUPNPAT(AMERDFN,41,DUZ(2),0)),U,2)
 ..S AMERSEX=$P($G(^DPT(AMERDFN,0)),U,2)
 ..;S AMERDOB=$P($G(^DPT(AMERDFN,0)),U,3)
 ..S AMERDOB=$$DOB^AUPNPAT(AMERDFN)  ;IHS/OIT/SCR 071509 patch 2
 ..;S AMERDR=".02////"_AMERDFN_";.13////"_AMERCHRT_";.12///"_AMERDOB_";.18///"_AMERSEX_";.19///"_$G(DUZ)
 ..S AMERDR=".02////"_AMERDFN_";.13////"_AMERCHRT_";.12///"_AMERDOB_";.18///"_AMERSEX_";.19////"_$G(DUZ)  ;IHS/OIT/SCR 071509 patch 2
 ..S AMERNEW=$$EDDISPL^AMEREDAU(AMERDFN,"P")
 ..S AMEROLD=$$EDDISPL^AMEREDAU(AMEROLD,"P")
 ..S AMERSTRG=$$EDAUDIT^AMEREDAU(".02",AMEROLD,AMERNEW,"PATIENT")
 ..I AMERSTRG="^" S AMERQUIT=1 Q
 ..D DIE^AMEREDIT(AMERDA,AMERDR)
 ..D DIEREC^AMEREDAU(AMERAIEN,AMERSTRG)
 ..D SYNCHPCC^AMERPCC(AMERDA)  ;THIS ROUTINE ADDS THE V PROVIDER AND V POV ENTRIES TO THE NEW VISIT CREATED FOR THIS PATIENT
 ..Q
 .Q
 Q:AMERQUIT 0
 S AMERDR=""
 D EN^DDIOL("**Changing the ADMISSION TIME can cause other time related data to be deleted**","","!!")
 S DIR(0)="Y",DIR("A")="Change Admission Time",DIR("B")="NO"
 D ^DIR
 I $D(DUOUT)!$D(DTOUT)!(Y<0) K DIR,DUOUT,DTOUT,Y Q 0
 I Y=1 D
 .S DIR(0)="D^::ER",DIR("A")="Date and time of admission to ER"
 .S (Y,AMEROTIM)=$P($G(^AMERVSIT(AMERDA,0)),U,1)
 .D DD^%DT
 .S DIR("B")=Y
 .S DIR("?")="Enter date and time in the usual Fileman format (e.g. 1/1/2000@1PM)"
 .D ^DIR K DIR
 .I $D(DUOUT)!$D(DTOUT) K DUOUT,DTOUT S AMERQUIT=1 Q
 .I Y>0 D
 ..S AMERDR=".01///"_Y,AMERNTIM=Y
 ..I AMERNTIM'=AMEROTIM D
 ...S AMERNEW=$$EDDISPL^AMEREDAU(AMERNTIM,"D")  ;tranforms fileman date into user friendly date
 ...S AMEROLD=$$EDDISPL^AMEREDAU(AMEROTIM,"D")
 ...S AMERSTRG=$$EDAUDIT^AMEREDAU(".01",AMEROLD,AMERNEW,"ADMISSION TIMESTAMP")
 ...I AMERSTRG="^" Q
 ...D DIEREC^AMEREDAU(AMERAIEN,AMERSTRG)
 ...D DIE^AMEREDIT(AMERDA,AMERDR)  ;Updates the AMERVSIT with correct time
 ...D UPDTVTIM^AMERVSIT(AMERDA,AMEROTIM,AMERNTIM)  ;looks up PCC VISIT with old time and updates it with new time
 ...D CHKTIME^AMERTIME(AMERNTIM,AMERAIEN)
 ...Q
 ..I AMERSTRG="^" S AMERQUIT=1 Q
 ..S AMERDR=""
 ..Q
 .Q
 Q:AMERQUIT 0
 ;
 ;GDIT/HS/BEE 05/10/2018;CR#10213 - AMER*3.0*10 - Save updated clinic and hospital location
 ;Reworked entire section to save custom clinics and differing hospital locations
 ;
 ;allow user to update "clinic type"
 D EN^DDIOL("","","!")
 ;S AMEROLD=$P($G(^AMERVSIT(AMERDA,0)),U,4)
 ;S:AMEROLD'="" DIC("B")=$P($G(^AMER(3,AMEROLD,0)),U,1)
 ;S DIC("A")="Clinic type (EMERGENCY or URGENT): "
 ;S DIC="^AMER(3,",DIC("S")="I $P(^(0),U,2)="_$$CAT^AMER0("CLINIC TYPE"),DIC(0)="AEQ"
 ;D ^DIC K DIC
 ;I $D(DUOUT)!$D(DTOUT) K DIC,DUOUT,DTOUT Q 0
 ;S AMERNEW=$P(Y,U,1)
 ;I AMEROLD'=AMERNEW D
 ;.S AMEROLD=$$EDDISPL^AMEREDAU(AMEROLD,"L")
 ;.S AMERNEW=$$EDDISPL^AMEREDAU(AMERNEW,"L")
 ;.S AMERSTRG=$$EDAUDIT^AMEREDAU(".05",AMEROLD,AMERNEW,"CLINIC TYPE")
 ;.I AMERSTRG="^" S AMERQUIT=1 Q
 ;.S AMERDR=$S(AMERDR'="":AMERDR_";",1:""),AMERDR=AMERDR_".04///"_AMERNEW
 ;.D DIEREC^AMEREDAU(AMERAIEN,AMERSTRG)
 ;.D DIE^AMEREDIT(AMERDA,AMERDR)
 ;.S (AMERDR,Y,AMERNEW,AMEROLD)=""
 ;.Q
 N VIEN,NCLN,OCLN
 ;
 ;Get visit
 S VIEN=$$GET1^DIQ(9009080,AMERDA_",",.03,"I") I VIEN="" Q 0
 ;
 ;Update clinic
 S (NCLN,OCLN,AMERQUIT)=""
 I VIEN>0 D
 .NEW DIC,X,Y,AMERCLN,AMERTYP,AMERDR
 .S DIC("B")=""
 .S AMERCLN=$$GETCLN^AMER2A(VIEN) ;Pull Hospital Location
 .I AMERCLN]"" S OCLN=AMERCLN,DIC("B")=$$GET1^DIQ(9009083,AMERCLN,.01,"E")  ;Get AMER clinic text
 .S DIC="^AMER(3,"
 .S DIC("S")="I '$P(^(0),U,5),$P(^(0),U,2)="_$$CAT^AMER0("CLINIC TYPE")
 .S DIC(0)="AEQ"
 .S DIC("A")="*Clinic type: "
 .D ^DIC I '+Y S AMERQUIT=1 Q
 .S NCLN=+Y
 .S AMERDR=".04///"_NCLN
 .D DIE^AMEREDIT(AMERDA,AMERDR)
 ;
 ;Need to update clinic and hospital location if overrides on file
 I OCLN'=NCLN,VIEN>0,'AMERQUIT D
 . NEW ERR,AMEROLD,AMERNEW
 . ;
 . ;GDIT/HS/BEE 05/10/2018;CR#10213/10423 - AMER*3.0*10 - Save updated clinic and hospital location
 . ;Need to update clinic and hospital location if overrides on file
 . S ERR=$$CKHLOC^AMERBSD(VIEN,NCLN)
 . ;
 . S AMEROLD=$$EDDISPL^AMEREDAU(OCLN,"L")
 . S AMERNEW=$$EDDISPL^AMEREDAU(NCLN,"L")
 . S AMERSTRG=$$EDAUDIT^AMEREDAU(".05",AMEROLD,AMERNEW,"CLINIC TYPE")
 . D DIEREC^AMEREDAU(AMERAIEN,AMERSTRG)
 ;
 Q:AMERQUIT 0
PQ  ;NOW allow user to update "presenting complaint'
 S Y=$G(^AMERVSIT(AMERDA,1))
 S AMEROLD=Y
 S:AMEROLD'="" DIR("B")=AMEROLD
 S DIR(0)="FOr^1:80",DIR("A")="Presenting complaint",DIR("?")="Enter free text chief complaint (80 characters max.)"
 D ^DIR K DIR
 I $D(DUOUT)!$D(DTOUT)!(Y<0) K DUOUT,DTOUT,Y Q 0
 ;IHS/OIT/SCR 071509 patch 2 START CHANGES
 ;D CKSC^AMER1 I $D(AMERCKSC) S Y=DIR("B") K AMERCKSC Q
 D CKSC^AMER1
 I $D(AMERCKSC) D  G PQ
 .S Y=$G(DIR("B"))
 .K AMERCKSC
 .Q
 ;IHS/OIT/SCR 071509 patch 2 END CHANGES
 S AMERNEW=Y
 I AMEROLD'=AMERNEW D
 .S AMERSTRG=$$EDAUDIT^AMEREDAU("1",AMEROLD,AMERNEW,"PRESENTING COMPLAINT")
 .I AMERSTRG="^" S AMERQUIT=1 Q
 .S AMERDR=$S(AMERDR'="":AMERDR_";",1:""),AMERDR=AMERDR_"1////"_AMERNEW
 .D DIEREC^AMEREDAU(AMERAIEN,AMERSTRG)
 .D DIE^AMEREDIT(AMERDA,AMERDR)
 .S (AMERDR,Y,AMERNEW,AMEROLD)=""
 .Q
 Q:AMERQUIT 0
 D EN^DDIOL("","","!")
 K DIC,AMERDR,DIR,AMEREDTS
 D EN^DDIOL("ERS PCC Data Entry is complete for this option","","!!")
 S DIR("A")="Edit more admission data"
 S DIR(0)="Y",DIR("B")="NO"
 D ^DIR K DIR
 I Y=1 Q $$ERSEDTA(AMERDA,AMERAIEN)  ;Return with value that subroutine returns
 Q 1
 ;
ERSEDTA(AMERDA,AMERAIEN)  ;SUBROUTINE TO ISOLATE FIELDS THAT DO NOT GO TO PCC THAT DO NOT REQUIRE A LOCK
 ;NOW allow user to update "visit type"
 N AMERTRAN
 S (AMERDR,AMEROLD,AMERNEW,AMEREDTS,AMERSTRG,AMERQUIT,AMERTRAN)=""
 D EN^DDIOL("","","!")
 S Y=$P($G(^AMERVSIT(AMERDA,0)),U,5)
 S AMEROLD=Y
 S:AMEROLD'="" DIC("B")=AMEROLD
 S DIC="^AMER(3,"
 S DIC("S")="I $P(^(0),U,2)="_$$CAT^AMER0("VISIT TYPE")
 S DIC(0)="AEQ"
 S DIC("A")="Visit Type: "
 D ^DIC K DIC
 I $D(DUOUT)!$D(DTOUT) K DIC,DUOUT,DTOUT Q 0
 S AMERNEW=$P(Y,U,1)
 I AMEROLD'=AMERNEW D
 .S AMERSTRG=$$EDAUDIT^AMEREDAU(".05",$$EDDISPL^AMEREDAU(AMEROLD,"V"),$$EDDISPL^AMEREDAU(AMERNEW,"V"),"VISIT TYPE")
 .I AMERSTRG="^" S AMERQUIT=1 Q
 .S AMERDR=$S(AMERDR'="":AMERDR_";",1:""),AMERDR=AMERDR_".05///"_AMERNEW
 .D DIEREC^AMEREDAU(AMERAIEN,AMERSTRG)
 .D DIE^AMEREDIT(AMERDA,AMERDR)
 .;IHS/OIT/SCR 12/15/08 - update ER VISIT FILE with DATE LAST UPDATED (NOW)
 .D TIMESTMP^AMERSAV1(AMERDA)
 .S (AMERDR,Y,AMERNEW,AMEROLD)=""
 .Q
 Q:AMERQUIT 0
 ;TRANSFER
 S AMEROLD=""
 S (DIR("B"),AMEROLD)="NO"
 I $P($G(^AMERVSIT(AMERDA,17)),U,1)=1 S (DIR("B"),AMEROLD)="YES"
 S DIR(0)="YO",DIR("A")="*Was this patient transferred from another facility"
 D ^DIR K DIR
 I $D(DUOUT)!$D(DTOUT) K DUOUT,DTOUT Q 0
 S AMERNEW=$$EDDISPL^AMEREDAU(Y,"B") ; "BOOLEAN" translates from 0 to NO
 I AMERNEW'=AMEROLD D
 .S AMERDR=$S(AMERDR'="":AMERDR_";",1:""),AMERDR=AMERDR_"17.1///"_AMERNEW
 .;REMOVE all "MODE OF TRANSPORT" and all ambulance and related info if
 .;MODE OF TRANSPORT is a different type from "TRANSFERED BY" and we just changed
 .S:AMERNEW="YES" AMERDR=$S($D(AMERDR):AMERDR_";",1:""),AMERDR=AMERDR_".25////@;.14////@;.15////@;.21////@"
 .S AMERSTRG=$$EDAUDIT^AMEREDAU("17.1",AMEROLD,AMERNEW,"TRANSFERED")
 .I AMERSTRG="^" S AMERQUIT=1 Q
 .I AMERNEW="NO" D
 ..;if the original transfered value was "yes" and it is being changed to "no"
 ..;then we have to remove the HER Transfer facility stuff and medical attendant
 ..S AMERDR=$S($D(AMERDR):AMERDR_";",1:""),AMERDR=AMERDR_"17.1////0;17.2////@;17.3////@;17.4////@"
 ..S AMERHERN=0
 ..F  S AMERHERN=$O(^AMERVSIT(AMERDA,18,AMERHERN)) Q:AMERHERN="B"!(AMERHERN="")  I $P($G(^AMERVSIT(AMERDA,18,AMERHERN,0)),U,2)="A" D
 ...S DA=AMERHERN
 ...S DA(1)=AMERDA,DIK="^AMERVSIT(DA(1),18,"
 ...D ^DIK,EN^DIK K DIK  ;Kill the sub-record and Re-index
 ...K DIK,DA(1),DA
 ...Q
 ..Q
 .D DIEREC^AMEREDAU(AMERAIEN,AMERSTRG)
 .D DIE^AMEREDIT(AMERDA,AMERDR)
 .S (AMERDR,Y)=""
 .Q
 I AMERNEW="YES" D TRANSFER^AMEREDTU(AMERDA)
 I AMERNEW="NO" D
 .D EN^DDIOL("**Changing the MODE of TRANSPORT can cause ambulance data to be deleted**","","!!?3")
 .S DIC("A")="Mode of transport to the ER: "
 .S AMEROLD=$P($G(^AMERVSIT(AMERDA,0)),U,25)
 .I AMEROLD="" K DIC("B")
 .I AMEROLD'="" S DIC("B")=$P($G(^AMER(3,AMEROLD,0)),U,1)
 .S (Y,AMEROLD)=$P($G(^AMERVSIT(AMERDA,0)),U,25)
 .S DIC="^AMER(3,",DIC("S")="I $P(^(0),U,2)="_$$CAT^AMER0("MODE OF TRANSPORT")
 .S DIC(0)="AEQ"
 .D ^DIC K DIC
 .I $D(DUOUT)!$D(DTOUT) K DUOUT,DTOUT,DIC S AMERQUIT=1 Q
 .S AMERNEW=$P(Y,U,1),AMERTRAN=$P(Y,U,2)
 .I AMEROLD'=AMERNEW D
 ..S AMERDR=$S(AMERDR'="":AMERDR_";",1:""),AMERDR=AMERDR_".25////"_AMERNEW
 ..S AMEROLD=$$EDDISPL^AMEREDAU(AMEROLD,"M") ;TRANSLATE number to MODE OF TRANSPORT description
 ..I AMEROLD["AMBULANCE" S AMERDR=$S(AMERDR'="":AMERDR_";",1:""),AMERDR=AMERDR_".14////@;.15////@;.21////@"
 ..S AMERSTRG=$$EDAUDIT^AMEREDAU(".25",AMEROLD,AMERTRAN,"MODE OF TRANSPORT")
 ..I AMERSTRG="^" S AMERQUIT=1 Q
 ..S AMEREDTS=$S(AMEREDTS="":AMERSTRG,1:AMEREDTS_"^"_AMERSTRG)  ;concactonate edit strings
 ..D DIEREC^AMEREDAU(AMERAIEN,AMERSTRG)
 ..D DIE^AMEREDIT(AMERDA,AMERDR)
 ..S (AMERDR,Y)=""
 ..Q
 .I AMERTRAN["AMBULANCE" D AMBULNCE^AMEREDTU
 .Q
 Q:AMERQUIT 0
 I $D(DUOUT)!$D(DTOUT) K DUOUT,DTOUT Q 0
 Q 1