[613] | 1 | VAQPST50 ;ALB/JRP - CREATE DATA SEGMENT FROM H.S. COMPONENT;28-APR-94
|
---|
| 2 | ;;1.5;PATIENT DATA EXCHANGE;**4**;NOV 17, 1993
|
---|
| 3 | ADDSEG(HSPTR,MAXTIME,MAXOCCUR) ;ADD NEW DATA SEGMENT USING H.S. COMPONENT
|
---|
| 4 | ;INPUT : HSPTR - Pointer to HEALTH SUMMARY COMPONENT file (#142.1)
|
---|
| 5 | ; MAXTIME - Max time limit allowed for auto processing
|
---|
| 6 | ; MAXOCCUR - Max occurrence limit allowed for auto processing
|
---|
| 7 | ;OUTPUT : X - Pointer to VAQ - DATA SEGMENT file (#394.71) that
|
---|
| 8 | ; was created
|
---|
| 9 | ; -1^ErrorText - Entry not created
|
---|
| 10 | ;NOTES : If time and/or occurrence limits do not apply to the
|
---|
| 11 | ; component, MAXTIME and/or MAXOCCUR are not required.
|
---|
| 12 | ; : If time and/or occurrence limits apply to the component,
|
---|
| 13 | ; default values will be taken from the VAQ - PARAMETER
|
---|
| 14 | ; file (#394.81). If parameter file does not contain these
|
---|
| 15 | ; values, a default of 1 year and 10 occurrences will be used.
|
---|
| 16 | ; : If a maximum limit is not valid, the default limit will
|
---|
| 17 | ; be used.
|
---|
| 18 | ;
|
---|
| 19 | ;CHECK INPUT
|
---|
| 20 | S HSPTR=+$G(HSPTR)
|
---|
| 21 | Q:('HSPTR) "-1^Did not pass pointer to HEALTH SUMMARY COMPONENT file"
|
---|
| 22 | Q:('$D(^GMT(142.1,HSPTR,0))) "-1^Did not pass valid pointer to HEALTH SUMMARY COMPONENT file"
|
---|
| 23 | S MAXTIME=$G(MAXTIME)
|
---|
| 24 | S MAXOCCUR=$G(MAXOCCUR)
|
---|
| 25 | ;DECLARE VARIABLES
|
---|
| 26 | N NAME,ABB,TIME,OCCUR,TMP,DEFTIME,DEFOCCUR
|
---|
| 27 | N X,Y,DIC,DINUM,DA,DIE,DR
|
---|
| 28 | ;GET COMPONENT NAME & ABBREVIATION
|
---|
| 29 | S TMP=$G(^GMT(142.1,HSPTR,0))
|
---|
| 30 | S NAME=$P(TMP,"^",1)
|
---|
| 31 | Q:(NAME="") "-1^Entry in HEALTH SUMMARY COMPONENT file did not contain a name"
|
---|
| 32 | S ABB=$P(TMP,"^",4)
|
---|
| 33 | Q:(ABB="") "-1^Entry in HEALTH SUMMARY COMPONENT file did not contain an abbreviation"
|
---|
| 34 | ;CONVERT NAME SO ONLY FIRST CHARACTER OF EVERY WORD IS IN UPPERCASE
|
---|
| 35 | S NAME=$$FIRSTUP(NAME)
|
---|
| 36 | ;SEE IF NAME OR ABBREVIATION ALREADY EXIST IN DATA SEGMENT FILE
|
---|
| 37 | Q:($D(^VAT(394.71,"B",NAME))) "-1^"_NAME_" already exists in VAQ - DATA SEGMENT file"
|
---|
| 38 | Q:($D(^VAT(394.71,"CAPS",NAME))) "-1^"_NAME_" already exists in VAQ - DATA SEGMENT file"
|
---|
| 39 | Q:($D(^VAT(394.71,"C",ABB))) "-1^Abbreviation of "_ABB_" already used in VAQ - DATA SEGMENT file"
|
---|
| 40 | ;GET DEFAULT TIME AND OCCURRENCE LIMITS
|
---|
| 41 | S X=+$O(^VAT(394.81,0))
|
---|
| 42 | S TMP=$G(^VAT(394.81,X,"LIMITS"))
|
---|
| 43 | S DEFTIME=$P(TMP,"^",1)
|
---|
| 44 | S:(DEFTIME="") DEFTIME="1Y"
|
---|
| 45 | S DEFOCCUR=$P(TMP,"^",2)
|
---|
| 46 | S:(DEFOCCUR="") DEFOCCUR=10
|
---|
| 47 | ;DETERMINE IF TIME AND/OR OCCURRENCE LIMITS APPLY
|
---|
| 48 | S TMP=$$LIMITS^VAQDBIH3(HSPTR)
|
---|
| 49 | S TIME=+TMP
|
---|
| 50 | S OCCUR=+$P(TMP,"^",2)
|
---|
| 51 | ;SET MAX LIMITS
|
---|
| 52 | I (TIME) S:($$VALOCC^VAQDBIH2(MAXTIME,0)<0) MAXTIME=DEFTIME
|
---|
| 53 | I ('TIME) S MAXTIME=""
|
---|
| 54 | I (OCCUR) S:($$VALOCC^VAQDBIH2(MAXOCCUR,1)<0) MAXOCCUR=DEFOCCUR
|
---|
| 55 | I ('OCCUR) S MAXOCCUR=""
|
---|
| 56 | ;SET UP CALL TO FILEMAN & CREATE STUB
|
---|
| 57 | K DD,DO
|
---|
| 58 | S DIC="^VAT(394.71,"
|
---|
| 59 | S DIC(0)="L"
|
---|
| 60 | S X=NAME
|
---|
| 61 | D FILE^DICN
|
---|
| 62 | S DA=+Y
|
---|
| 63 | Q:(DA<0) "-1^Unable to create entry in VAQ - DATA SEGMENT file"
|
---|
| 64 | ;SET UP CALL TO FILEMAN & FINISH ENTRY
|
---|
| 65 | S DIE="^VAT(394.71,"
|
---|
| 66 | S DR=".02///^S X=ABB"
|
---|
| 67 | S DR(1,394.71,.03)=".03///YES"
|
---|
| 68 | S DR(1,394.71,.04)=".04////"_HSPTR
|
---|
| 69 | S DR(1,394.71,.05)=".05///^S X=MAXTIME"
|
---|
| 70 | S DR(1,394.71,.06)=".06///^S X=MAXOCCUR"
|
---|
| 71 | S DR(1,394.71,10)="10///$$GET^GMTSPDX(TRAN,DFN,SEGPTR,ROOT,(OFFSET-1),TIMLIM,OCCLIM)"
|
---|
| 72 | S DR(1,394.71,20)="20///@"
|
---|
| 73 | D ^DIE
|
---|
| 74 | Q 0
|
---|
| 75 | LOWER(STRING) ;CONVERT UPPERCASE TO LOWERCASE
|
---|
| 76 | ;INPUT : STRING - Text string to convert
|
---|
| 77 | ;OUTPUT : string - Same text string in all lowercase
|
---|
| 78 | ;
|
---|
| 79 | Q $TR($G(STRING),"ABCDEFGHIJKLMNOPQRSTUVWXYZ","abcdefghijklmnopqrstuvwxyz")
|
---|
| 80 | FIRSTUP(TEXT) ;FIRST CHARACTER EVERY WORD UPPER
|
---|
| 81 | ;INPUT : TEXT - Text string to convert
|
---|
| 82 | ;OUTPUT : Text - Same text string with beginning of every word
|
---|
| 83 | ; in uppercase and all other characters in lowercase
|
---|
| 84 | ;
|
---|
| 85 | ;CHECK INPUT
|
---|
| 86 | Q:($G(TEXT)="") ""
|
---|
| 87 | ;DECLARE VARIABLES
|
---|
| 88 | N OUTTEXT,SPOT,UPCHAR,X,Y,LEN
|
---|
| 89 | ;CONVERT TO LOWERCASE
|
---|
| 90 | S OUTTEXT=$$LOWER(TEXT)
|
---|
| 91 | ;CAPITALIZE FIRST WORD
|
---|
| 92 | S X=$E(OUTTEXT,1)
|
---|
| 93 | X ^%ZOSF("UPPERCASE")
|
---|
| 94 | S OUTTEXT=Y_$E(OUTTEXT,2,$L(OUTTEXT))
|
---|
| 95 | ;CAPITALIZE REST OF WORDS
|
---|
| 96 | S SPOT=1
|
---|
| 97 | S LEN=$L(OUTTEXT)
|
---|
| 98 | F S SPOT=$F(OUTTEXT," ",SPOT) Q:('SPOT) D
|
---|
| 99 | .S X=$E(OUTTEXT,SPOT)
|
---|
| 100 | .X ^%ZOSF("UPPERCASE")
|
---|
| 101 | .S OUTTEXT=$E(OUTTEXT,1,(SPOT-1))_Y_$E(OUTTEXT,(SPOT+1),LEN)
|
---|
| 102 | Q OUTTEXT
|
---|