- HDISVS02 ;BPFO/JRP - PROCESS RECEIVED XML DATA;12/20/2004
- ;;1.0;HEALTH DATA & INFORMATICS;;Feb 22, 2005
- ;
- TERM(DATA,EINDX,AINDX,SYSPTR,FFPTR,ERRARR) ;Process 'Term' portion of XML document
- ; Input : DATA - Array reference from which the 'File' element
- ; begins (closed root)
- ; EINDX - Element index array (closed root)
- ; AINDX - Attribute index array (closed root)
- ; SYSPTR - Pointer to HDIS SYSTEM file (#7118.21)
- ; FFPTR - Pointer to HDIS FILE/FIELD file (#7115.6)
- ; Derived from 'FileNumber' & 'FieldNumber' element
- ; ERRARR - Error array (closed root)
- ;Output : None
- ; @ERRARR@(x) = Error text (if applicable)
- ; Notes : Existance/validity of input assumed (internal call)
- N INDX,REP,TERM,IREF,VUID,TMP,OOPS,TERMPTR,FILEARR,X
- S INDX=@EINDX@("Term")
- S REP=0
- F S REP=+$O(@DATA@(INDX,REP)) Q:'REP D
- .S OOPS=0
- .S TERMPTR=0
- .;Get elements
- .S TERM=$G(@DATA@(INDX,REP,@EINDX@("TermName"),1,"V"))
- .S IREF=$G(@DATA@(INDX,REP,@EINDX@("FacilityInternalReference"),1,"V"))
- .S VUID=$G(@DATA@(INDX,REP,@EINDX@("VUID"),1,"V"))
- .;Validate elements
- .;VUID allowed to be null (in most cases they are)
- .F TMP="TERM","IREF" I $G(@TMP)="" D
- ..S Y="TermName"
- ..I TMP="IREF" S Y="FacilityInternalReference"
- ..S X="XML element '"_Y_"' for repetition number "_REP_" of 'Term' "
- ..I TMP="TERM" S X="Repetition number "_REP_" of XML element 'Term' "
- ..I TMP'="TERM" S X=X_"("_TERM_") "
- ..S X=X_"did not have a value"
- ..D ADDERR^HDISVC00(X,ERRARR)
- ..S OOPS=1
- .;Problem found - quit
- .I OOPS Q
- .;VUID passed - ignore
- .I VUID'="" Q
- .;Convert term to upper case
- .S TERM=$$UP^XLFSTR(TERM)
- .;Known term/concept
- .K FILEARR
- .S FILEARR(FFPTR)=""
- .K TERMPTR
- .I $$GETTERM^HDISVF04(TERM,.FILEARR,.TERMPTR) D
- ..;Get VUID
- ..S VUID=""
- ..S X=$$GETVUID^HDISVF04(TERMPTR,.VUID)
- ..;Make sure VUID has a value
- ..I VUID="" D
- ...S X="Entry number "_TERMPTR_" in HDIS TERM/CONCEPT VUID "
- ...S X=X_"ASSOCIATION file (#7118.11) does not have a VUID."
- ...S X=X_" Repetition "_REP_" of 'Term' ("_TERM_")."
- ...D ADDERR^HDISVC00(X,ERRARR)
- ...S OOPS=1
- .;Problem found - quit
- .I OOPS Q
- .;Assign non-standard VUID
- .I VUID="" D
- ..;Calculate non-standard VUID
- ..S VUID=$$CALCNSV^HDISVF03()
- ..I VUID="" D Q
- ...S TMP="Unable to calculate non-standard VUID for repetition number "
- ...S TMP=TMP_REP_" of 'Term' ("_TERM_")"
- ...D ADDERR^HDISVC00(TMP,ERRARR)
- ...S OOPS=1
- ..;Create entry in Term/Concept file
- ..K FILEARR
- ..S FILEARR(FFPTR)=""
- ..K TERMPTR
- ..I '$$ADDTERM^HDISVF04(TERM,VUID,.FILEARR,0,1,$$NOW^XLFDT(),0,.TERMPTR) D
- ...S TMP="Unable to create entry in HDIS TERM/CONCEPT VUID "
- ...S TMP=TMP_"ASSOCIATION file (#7118.11) for repetition number "
- ...S TMP=TMP_REP_" of 'Term' ("_TERM_"). VUID was "_VUID_"."
- ...D ADDERR^HDISVC00(TMP,ERRARR)
- ...S OOPS=1
- ..;Wait 1 second - resolve global cache problem
- ..H 1
- .;Problem found - quit
- .I OOPS Q
- .;Create entry in Facility Term/Concept file
- .I '$$FINDFAC^HDISVF08(SYSPTR,FFPTR,TERMPTR,IREF,1) D
- ..S TMP="Unable to create entry in HDIS FACILITY TERM/CONCEPT "
- ..S TMP="ASSOCIATION file (#7118.22) for repetition number "_REP
- ..S TMP=TMP_" of 'Term' ("_TERM_"). VUID was "_VUID_"."
- ..D ADDERR^HDISVC00(TMP,ERRARR)
- ..S OOPS=1
- .;Problem found - quit
- .I OOPS Q
- Q
- --- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HHDISVS02 3412 printed Feb 18, 2025@23:23:24 Page 2
- HDISVS02 ;BPFO/JRP - PROCESS RECEIVED XML DATA;12/20/2004
- +1 ;;1.0;HEALTH DATA & INFORMATICS;;Feb 22, 2005
- +2 ;
- TERM(DATA,EINDX,AINDX,SYSPTR,FFPTR,ERRARR) ;Process 'Term' portion of XML document
- +1 ; Input : DATA - Array reference from which the 'File' element
- +2 ; begins (closed root)
- +3 ; EINDX - Element index array (closed root)
- +4 ; AINDX - Attribute index array (closed root)
- +5 ; SYSPTR - Pointer to HDIS SYSTEM file (#7118.21)
- +6 ; FFPTR - Pointer to HDIS FILE/FIELD file (#7115.6)
- +7 ; Derived from 'FileNumber' & 'FieldNumber' element
- +8 ; ERRARR - Error array (closed root)
- +9 ;Output : None
- +10 ; @ERRARR@(x) = Error text (if applicable)
- +11 ; Notes : Existance/validity of input assumed (internal call)
- +12 NEW INDX,REP,TERM,IREF,VUID,TMP,OOPS,TERMPTR,FILEARR,X
- +13 SET INDX=@EINDX@("Term")
- +14 SET REP=0
- +15 FOR
- SET REP=+$ORDER(@DATA@(INDX,REP))
- if 'REP
- QUIT
- Begin DoDot:1
- +16 SET OOPS=0
- +17 SET TERMPTR=0
- +18 ;Get elements
- +19 SET TERM=$GET(@DATA@(INDX,REP,@EINDX@("TermName"),1,"V"))
- +20 SET IREF=$GET(@DATA@(INDX,REP,@EINDX@("FacilityInternalReference"),1,"V"))
- +21 SET VUID=$GET(@DATA@(INDX,REP,@EINDX@("VUID"),1,"V"))
- +22 ;Validate elements
- +23 ;VUID allowed to be null (in most cases they are)
- +24 FOR TMP="TERM","IREF"
- IF $GET(@TMP)=""
- Begin DoDot:2
- +25 SET Y="TermName"
- +26 IF TMP="IREF"
- SET Y="FacilityInternalReference"
- +27 SET X="XML element '"_Y_"' for repetition number "_REP_" of 'Term' "
- +28 IF TMP="TERM"
- SET X="Repetition number "_REP_" of XML element 'Term' "
- +29 IF TMP'="TERM"
- SET X=X_"("_TERM_") "
- +30 SET X=X_"did not have a value"
- +31 DO ADDERR^HDISVC00(X,ERRARR)
- +32 SET OOPS=1
- End DoDot:2
- +33 ;Problem found - quit
- +34 IF OOPS
- QUIT
- +35 ;VUID passed - ignore
- +36 IF VUID'=""
- QUIT
- +37 ;Convert term to upper case
- +38 SET TERM=$$UP^XLFSTR(TERM)
- +39 ;Known term/concept
- +40 KILL FILEARR
- +41 SET FILEARR(FFPTR)=""
- +42 KILL TERMPTR
- +43 IF $$GETTERM^HDISVF04(TERM,.FILEARR,.TERMPTR)
- Begin DoDot:2
- +44 ;Get VUID
- +45 SET VUID=""
- +46 SET X=$$GETVUID^HDISVF04(TERMPTR,.VUID)
- +47 ;Make sure VUID has a value
- +48 IF VUID=""
- Begin DoDot:3
- +49 SET X="Entry number "_TERMPTR_" in HDIS TERM/CONCEPT VUID "
- +50 SET X=X_"ASSOCIATION file (#7118.11) does not have a VUID."
- +51 SET X=X_" Repetition "_REP_" of 'Term' ("_TERM_")."
- +52 DO ADDERR^HDISVC00(X,ERRARR)
- +53 SET OOPS=1
- End DoDot:3
- End DoDot:2
- +54 ;Problem found - quit
- +55 IF OOPS
- QUIT
- +56 ;Assign non-standard VUID
- +57 IF VUID=""
- Begin DoDot:2
- +58 ;Calculate non-standard VUID
- +59 SET VUID=$$CALCNSV^HDISVF03()
- +60 IF VUID=""
- Begin DoDot:3
- +61 SET TMP="Unable to calculate non-standard VUID for repetition number "
- +62 SET TMP=TMP_REP_" of 'Term' ("_TERM_")"
- +63 DO ADDERR^HDISVC00(TMP,ERRARR)
- +64 SET OOPS=1
- End DoDot:3
- QUIT
- +65 ;Create entry in Term/Concept file
- +66 KILL FILEARR
- +67 SET FILEARR(FFPTR)=""
- +68 KILL TERMPTR
- +69 IF '$$ADDTERM^HDISVF04(TERM,VUID,.FILEARR,0,1,$$NOW^XLFDT(),0,.TERMPTR)
- Begin DoDot:3
- +70 SET TMP="Unable to create entry in HDIS TERM/CONCEPT VUID "
- +71 SET TMP=TMP_"ASSOCIATION file (#7118.11) for repetition number "
- +72 SET TMP=TMP_REP_" of 'Term' ("_TERM_"). VUID was "_VUID_"."
- +73 DO ADDERR^HDISVC00(TMP,ERRARR)
- +74 SET OOPS=1
- End DoDot:3
- +75 ;Wait 1 second - resolve global cache problem
- +76 HANG 1
- End DoDot:2
- +77 ;Problem found - quit
- +78 IF OOPS
- QUIT
- +79 ;Create entry in Facility Term/Concept file
- +80 IF '$$FINDFAC^HDISVF08(SYSPTR,FFPTR,TERMPTR,IREF,1)
- Begin DoDot:2
- +81 SET TMP="Unable to create entry in HDIS FACILITY TERM/CONCEPT "
- +82 SET TMP="ASSOCIATION file (#7118.22) for repetition number "_REP
- +83 SET TMP=TMP_" of 'Term' ("_TERM_"). VUID was "_VUID_"."
- +84 DO ADDERR^HDISVC00(TMP,ERRARR)
- +85 SET OOPS=1
- End DoDot:2
- +86 ;Problem found - quit
- +87 IF OOPS
- QUIT
- End DoDot:1
- +88 QUIT