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

EDPLOGA.m

Go to the documentation of this file.
  1. EDPLOGA ;SLC/KCM - Add Entry to ED Log ;2/28/12 08:33am
  1. ;;2.0;EMERGENCY DEPARTMENT;**6**;Feb 24, 2012;Build 200
  1. ;
  1. ;TODO: add transaction processing
  1. ;
  1. ADD(NEWPT,AREA,TIME,CHOICES) ; Create a new ED Log record for a patient
  1. ; add the new record to the returned XML
  1. ; NEWPT = dfn \T name \T dob \T ssn
  1. N DFN,NAME,SSN,STATUS,BED,ARR,REC,AMB,CLINIC,EDPLOG,EDPFAIL
  1. S EDPFAIL=0
  1. S AMB="(ambulance en route)"
  1. ;
  1. ; Set up the patient fields that were passed in
  1. D NVPARSE^EDPX(.REC,NEWPT)
  1. S DFN=REC("dfn"),NAME=REC("name"),SSN="",CLINIC=$G(REC("clinic"))
  1. I DFN S REC("name")=$P(^DPT(DFN,0),U),REC("ssn")=$P(^DPT(DFN,0),U,9)
  1. ;S SSN=REC("ssn") S:SSN="*SENSITIVE*" SSN="" --NtoL
  1. I 'DFN,(NAME="") S EDPFAIL=$$FAIL^EDPLOG("add",2300014) Q EDPFAIL
  1. ;
  1. ; Add default values to stub entry (should be based on config for area)
  1. S BED=$P(^EDPB(231.9,AREA,1),U,12) I 'BED S BED=$O(^EDPB(231.8,"B","EDIS_DEFAULT",0)) I 'BED S EDPFAIL=$$FAIL^EDPLOG("add",2300019) Q EDPFAIL
  1. I $G(REC("name"))=AMB D
  1. . S ARR=$O(^EDPB(233.1,"B","edp.arrival.ambulance",0))
  1. . S BED=$P(^EDPB(231.9,AREA,1),U,11)
  1. S STATUS="" I BED S STATUS=$P(^EDPB(231.8,BED,0),U,8)
  1. ;
  1. I +DFN,$D(^EDP(230,"AP",EDPSITE,AREA,DFN)) S EDPFAIL=$$FAIL^EDPLOG("add",2300002) Q EDPFAIL
  1. I 'DFN,(NAME'=AMB),$D(^EDP(230,"AN",EDPSITE,AREA,NAME)) S EDPFAIL=$$FAIL^EDPLOG("add",2300002) Q EDPFAIL
  1. N ERR S ERR=$$VALID^EDPLOG1(.REC) I $L(ERR) S EDPFAIL=$$FAIL^EDPLOG("add",ERR) Q EDPFAIL
  1. S ^EDPB(231.9,AREA,230)=$H ; last update timestamp
  1. ;
  1. ; Create a current log record
  1. N FDA,FDAIEN,DIERR,HIST,HISTIEN,LOGIEN
  1. S FDA(230,"+1,",.01)=TIME
  1. S FDA(230,"+1,",.02)=EDPSITE
  1. S FDA(230,"+1,",.03)=AREA
  1. S FDA(230,"+1,",.04)=NAME
  1. ;S FDA(230,"+1,",.05)=SSN --NtoL
  1. S FDA(230,"+1,",.06)=DFN
  1. S FDA(230,"+1,",3.2)=STATUS
  1. S FDA(230,"+1,",3.4)=BED
  1. I $L(SSN) S FDA(230,"+1,",.11)=$E(NAME)_$E(SSN,6,9)
  1. I NAME=AMB S FDA(230,"+1,",.11)="(amb)"
  1. I NAME'=AMB S FDA(230,"+1,",.08)=TIME
  1. I $G(ARR) S FDA(230,"+1,",.1)=ARR
  1. I CLINIC S FDA(230,"+1,",.14)=CLINIC
  1. I $G(REC("create")) S FDA(230,"+1,",.13)=REC("create")
  1. M HIST(230.1)=FDA(230)
  1. D UPDATE^DIE("","FDA","FDAIEN","ERR")
  1. I $D(DIERR) S EDPFAIL=$$FAIL^EDPLOG("add",2300004) Q EDPFAIL
  1. S LOGIEN=FDAIEN(1)
  1. ;
  1. ; Post new patient event
  1. I DFN,TIME D EVT(LOGIEN)
  1. ;
  1. ; Create the first history entry
  1. S HIST(230.1,"+1,",.01)=LOGIEN
  1. S HIST(230.1,"+1,",.02)=TIME
  1. S HIST(230.1,"+1,",.03)=EDPUSER
  1. K HIST(230.1,"+1,",.11) ; don't need last4
  1. K HIST(230.1,"+1,",.13) ; don't need creation source
  1. D UPDATE^DIE("","HIST","HISTIEN","ERR")
  1. I $D(DIERR) S EDPFAIL=$$FAIL^EDPLOG("add",2300004) Q EDPFAIL
  1. ;
  1. D XML^EDPX("<add status='ok' id='"_FDAIEN(1)_"' />")
  1. D GET^EDPQLE(FDAIEN(1),CHOICES)
  1. Q EDPFAIL
  1. ;
  1. DEL(AREA,LOGID) ; Delete Stub Log Entry
  1. N I,CNT,DIK,DA
  1. S I=0,CNT=0 F S I=$O(^EDP(230.1,"B",LOGID,I)) Q:'I S CNT=CNT+1
  1. I $L($P($G(^EDP(230,LOGID,1)),U))!(CNT>1) D Q
  1. . D FAIL^EDPLOG("upd","Does not appear to be a stub entry")
  1. ;
  1. ; Delete initial history entry
  1. S DIK="^EDP(230.1,",DA=$O(^EDP(230.1,"B",LOGID,0))
  1. I DA D ^DIK
  1. ; Delete stub log entry
  1. S DIK="^EDP(230,",DA=LOGID
  1. D ^DIK
  1. ;
  1. D XML^EDPX("<upd status='ok' />")
  1. Q
  1. ;
  1. EVT(LOG) ; -- post new patient event [expects EDPSITE]
  1. N X0,DFN,SDT,SDCL,SDATA,SDAMEVT,X
  1. S X0=$G(^EDP(230,+$G(LOG),0)),DFN=+$P(X0,U,6),SDT=+$P(X0,U,8)
  1. I 'DFN!'SDT Q ;missing data
  1. S SDCL=$$DFLTLOC^EDPLPCE(DFN) Q:'SDCL
  1. ; have patient, time, hosp loc -> post event
  1. S SDATA=U_DFN_U_SDT_U_SDCL,SDAMEVT=1
  1. S EDPDATA=LOG_SDATA
  1. S X=+$O(^ORD(101,"B","EDP NEW PATIENT",0))_";ORD(101,"
  1. D EN^XQOR
  1. K EDPDATA
  1. Q