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

HLEMP.m

Go to the documentation of this file.
  1. HLEMP ;ALB/CJM-HL7 - APIs for Monitor Events Log Profiles ;07/10/2003
  1. ;;1.6;HEALTH LEVEL SEVEN;**109**;Oct 13,1995
  1. ;
  1. FDEFAULT(DUZ) ;
  1. ;Description: Given a DUZ, returns the default profile, or "" on failure
  1. ;
  1. Q:'$G(DUZ) 0
  1. Q $O(^HLEV(776.5,"AC",DUZ,0))
  1. ;
  1. Q $S(Y=-1:0,1:+Y)
  1. ;
  1. GET(IEN,PROFILE) ;
  1. ;Description - given the ien, it returns an array containing the profile
  1. ;Input:
  1. ; IEN - ien of the profile
  1. ;Output:
  1. ; function returns 0 on failure, 1 on success
  1. ; PROFILE( **pass by reference**
  1. ; "ALL APPS" - 1 if all sending applications should be included, 0 otherwise
  1. ; "ALL SITES" - 1 if all sites should be included, 0 otherwise
  1. ; "ALL STATUSES" 1 if all review statuses should be included, 0 otherwise
  1. ; "ALL TYPES" - 1 if all event types should be included, 0 otherwise
  1. ; "APPS",<HL7 APPLICATION PARAMETER>) -list of sending applications to include - NOT the iens, but the names of the HL7 Application Parameter
  1. ; "DUZ" - the duz of the profile's owner
  1. ; "DEFAULT" - 1 if this is the default profile, 0 if it isn't
  1. ; "IEN" - ien of the profile
  1. ; "NAME" - name of the profile
  1. ; "SITES",<institution ien>) - list of institution numbers to include
  1. ; "START" - starting date/time for selecting events for display, in FM format
  1. ; "STATUSES",<review status code>) - list of review status codes to include
  1. ; "TYPES",<HL7 MONITOR EVENT TYPE>) - list of event type iens
  1. ; "URGENT" - 1 means urgent only, 0 means disregard urgency
  1. ;
  1. ;
  1. Q:'$G(IEN) 0
  1. N NODE,SITE,TYPE,APP,STATUS,APPNAME,I
  1. K PROFILE S PROFILE=IEN
  1. S NODE=$G(^HLEV(776.5,IEN,0))
  1. Q:'$L(NODE) 0
  1. S PROFILE("IEN")=IEN
  1. S PROFILE("DUZ")=+NODE
  1. S PROFILE("NAME")=$P(NODE,"^",2)
  1. S PROFILE("DEFAULT")=$P(NODE,"^",3)
  1. S PROFILE("ALL SITES")=$P(NODE,"^",4)
  1. S PROFILE("ALL TYPES")=$P(NODE,"^",5)
  1. S PROFILE("ALL APPS")=$P(NODE,"^",6)
  1. S PROFILE("ALL STATUSES")=$P(NODE,"^",7)
  1. S START=+$P(NODE,"^",8) D
  1. .N NOW
  1. .S NOW=$$NOW^XLFDT
  1. .S PROFILE("START")=0
  1. .I START=1 S PROFILE("START")=$$FMADD^XLFDT(NOW,,-1) Q
  1. .I START=2 S PROFILE("START")=$$FMADD^XLFDT(NOW,,-2) Q
  1. .I START=3 S PROFILE("START")=$$FMADD^XLFDT(NOW,,-6) Q
  1. .I START=4 S PROFILE("START")=+NOW Q
  1. .I START=5 S PROFILE("START")=$$FMADD^XLFDT(NOW,-1) Q
  1. .I START=6 S PROFILE("START")=$$FMADD^XLFDT(+NOW,-1) Q
  1. .I START=7 S PROFILE("START")=$$FMADD^XLFDT(NOW,-2) Q
  1. .I START=8 S PROFILE("START")=$$FMADD^XLFDT(NOW,-3) Q
  1. .I START=9 S PROFILE("START")=$$FMADD^XLFDT(NOW,-7) Q
  1. S PROFILE("URGENT")=$P(NODE,"^",9)
  1. S SITE=0
  1. F I="APPS","SITES","TYPES","STATUSES" S PROFILE(I)=""
  1. F S SITE=$O(^HLEV(776.5,IEN,1,SITE)) Q:'SITE S PROFILE("SITES",+$G(^HLEV(776.5,IEN,1,SITE,0)))=""
  1. S TYPE=0
  1. F S TYPE=$O(^HLEV(776.5,IEN,2,TYPE)) Q:'TYPE S PROFILE("TYPES",+$G(^HLEV(776.5,IEN,2,TYPE,0)))=""
  1. S APP=0
  1. F S APP=$O(^HLEV(776.5,IEN,3,APP)) Q:'APP S PROFILE("APPS",$$APPNAME^HLEMU(+$G(^HLEV(776.5,IEN,3,APP,0))))=""
  1. S STATUS=0
  1. F S STATUS=$O(^HLEV(776.5,IEN,4,STATUS)) Q:'STATUS S APPNAME=$$APPNAME^HLEMU(+$G(^HLEV(776.5,IEN,4,STATUS,0))) I $L(APPNAME) S PROFILE("APPS",APPNAME)=""
  1. Q 1
  1. ;
  1. CREATE(DUZ,NAME,ERROR) ;
  1. ;Given the DUZ and a name, creates a new profile of that name.
  1. ;Output-
  1. ; function value - returns the new profile ien on success, 0 on failure
  1. ; ERROR **optional, pass by reference** an array of errors
  1. ;
  1. Q:'$G(DUZ) 0
  1. Q:'$L(NAME) 0
  1. ;
  1. N DATA
  1. S DATA(.01)=DUZ
  1. S DATA(.02)=NAME
  1. Q $$ADD^HLEMU(776.5,,.DATA,.ERROR)
  1. ;
  1. EDIT(PROFILE) ;
  1. ;Given the ien of a profile, allows a user to edit it.
  1. ;Input: PROFILE - ien of a profile
  1. ;Output: function returns 1 on success, 0 on failure, or on indication that the user did not complete the edit
  1. ;
  1. Q:'$G(PROFILE) 0
  1. Q:'$G(^HLEV(776.5,PROFILE,0)) 0
  1. K DA,DIE,DR
  1. S DA=PROFILE
  1. S DIE=776.5
  1. S DR=".02:.09"
  1. S DIE("NO^")="OUTOK"
  1. D ^DIE
  1. I '$D(Y),'$D(DTOUT),$$GET(PROFILE,.PROFILE) D
  1. .S DR=""
  1. .S DIE("NO^")="OUTOK"
  1. .I 'PROFILE("ALL SITES") S DR="1;"
  1. .I 'PROFILE("ALL TYPES") S DR=DR_"2;"
  1. .I 'PROFILE("ALL APPS") S DR=DR_"3;"
  1. .I 'PROFILE("ALL STATUSES") S DR=DR_4
  1. .D ^DIE
  1. Q $S($D(Y)!$D(DTOUT):0,1:1)
  1. ;
  1. DELETE(PROFILE) ;
  1. ;Given the ien, deletes the profile
  1. Q $$DELETE^HLEMU(776.5,.PROFILE)