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

MCORMN0.m

Go to the documentation of this file.
MCORMN0 ;WISC/DCB-HL7 MESSAGE BUILDER ;7/23/99  09:08
 ;;1.0;CLINICAL PROCEDURES;**5**;Apr 01, 2004;Build 1
 W !,"This is not a valid entry point" Q
BUILD(RAP,MCDFN,SAP,SNF,RNF,MST,PCI,VID,MCLINE,MSTR,MCDEST,MCPROC,MCFILE,MCREC,SDATE,ATYPE) ; Build the message
 K ^TMP("MCORMN",$J)
 N MCERR,MCOR,MCOR1,MCOR2,MCOR3,MCOR4,MSE,OBR,HLECH
 N LOOP,MCDS,ST,MSE,MCHOLD,MCHOLD
 S MSE=0,HLECH=$E(MSTR,2,4) D SLIP(MSTR)
 S MCHOLD=+$O(^MCAR(697.2,"B",MCPROC,""))
 S MCHOLD=$P($G(^MCAR(697.2,MCHOLD,0)),U,8)
 S MCERR=$$GETDATA^MCORMN1(MCPROC,MCREC,"^TMP(""MCORMN"",$J)",MCFILE,ATYPE) Q:MCERR=0 1
 S MCHOLD=$S(MCHOLD="":MCPROC,1:MCHOLD)
 D SETNODE(MCDEST,$$MSH^MCORMN01(MCHOLD,SAP,SNF,RAP,RNF,MST,PCI,VID))
 D SETNODE(MCDEST,$$PID^MCORMN01(MCDFN))
 D SETNODE(MCDEST,$$OBR1^MCORMN01(SDATE,MCPROC,MCREC,MCFILE)) S OBR=MCLINE
 S MCOR1=""
 F  S MCOR1=$O(^TMP("MCORMN",$J,"E",MCOR1)) Q:MCOR1=""  D
 .S MCOR2=""
 .F  S MCOR2=$O(^TMP("MCORMN",$J,"E",MCOR1,MCOR2)) Q:MCOR2=""  D
 ..S MCOR3=""
 ..F  S MCOR3=$O(^TMP("MCORMN",$J,"E",MCOR1,MCOR2,MCOR3)) Q:MCOR3=""  D
 ...D GETDATA(RAP,MCDEST,OBR,MCOR1,MCOR2,MCOR3)
 I +$P($G(^MCAR(MCFILE,MCREC,2005,0)),U,4)>0 D
 .N OBI,OBR,OSI,VTI,UNT,RNG
 .S OBI=MCFILE_ST(3)_"2005"_ST(3)_"P"_ST(2)_"IMAGES?"_ST(2)_"DD"
 .S OBR="Images are associated with this procedure"
 .S OSI="",VTI="",FILETYPE="P",UNT="",RNG=""
 .D SETOBX1(FILETYPE,VTI,OBI,OSI,OBR),SETOBX2(UNT,RNG)
 Q 0
GETDATA(RAP,MCDEST,OBR,MCOR1,MCOR2,MCOR3) ; Process the Data
 N TMP1,TMP,HL7,TYPE
 S TMP=$G(^TMP("MCORMN",$J,"F",MCOR1,MCOR3,0))
 S HL7=$G(^TMP("MCORMN",$J,"F",MCOR1,MCOR3,1))
 S TYPE=$P(HL7,U,7)
 I (TYPE'="OBR"),(TYPE'="INFO"),(RAP="Health Summary") S TYPE="DD"
 Q:(TYPE="INFO")!(TYPE="MISC")!(TYPE="")
 S TMP1="D "_TYPE_"(TMP,HL7,OBR,MCOR1,MCOR2,MCOR3)" X TMP1
 Q
ICD9(TMP,HL7,OBX,MCOR1,MCOR2,MCOR3) ; This is the ICD9 message builder for OBX
 N OID,VT1,UNT,OSI,OBI,RNG,RST,DA,DIC,DR,DIQ,XTMP,CONT
 S OBI="ICD9",OSI="",MST=$G(MST)+1,OSI=MST,CONT=""
 S VTI=$P(HL7,U,2) S:VTI="" VTI="CE"
 S UNT="",RNG="",RST=$G(^TMP("MCORMN",$J,"E",MCOR1,MCOR2,MCOR3,1)) Q:RST=""
 ;S DA=$O(^ICD9("B",RST,"")) Q:DA=""
 Q
 S DIC="^ICD9(",DR=".01;3",DIQ="XTMP(" D EN^DIQ1
 S RST=XTMP(80,DA,.01)_ST(2)_XTMP(80,DA,3)_ST(2)_"ICD9"
 D SETOBX1("",VTI,OBI,OSI,RST)
 Q
ASTM(TMP,HL7,OBX,MCOR1,MCOR2,MCOR3) ; This is the ASTM message builder for OBX
 N ASTM,ASTME,VTI,UNT,RNG,RST,OSI,OBI,FILETYPE
 S FILETYPE=$P(TMP,U,2),OSI=""
 S ASTM=$P(HL7,U,1),ASTME=$G(^MCAR(690.5,ASTM,0))
 S ASTM=$P(ASTME,U,1)_$P(ASTME,U,2),VTI=$P(HL7,U,2)
 S OBI=ASTM_ST(2)_$P(ASTME,U,3)_ST(2)_"CPT4"
 S UNT=$P(HL7,U,3),RNG=$P(HL7,U,4)
 D RDATA(VTI,OBI,OSI,UNT,RNG,FILETYPE,MCOR1,MCOR2,MCOR3)
 Q
SUM(TMP,HL7,OBX,MCOR1,MCOR2,MCOR3) ; This is the miss. message builder for OBX
 N FILETYPE,VTI,UNT,RNG,RST,OSI,OBI
 S FILETYPE=$P(TMP,U,2),OSI=""
 S OBI="SST",(UNT,RNG)="",OSI=""
 S VTI="TX"
 D RDATA(VTI,OBI,OSI,UNT,RNG,FILETYPE,MCOR1,MCOR2,MCOR3)
 Q
DD(TMP,HL7,OBX,MCOR1,MCOR2,MCOR3) ; This is the DD mesage builder for OBX
 N FLDNAME,VTI,OBI,OSI,UNT,RNG,FILETYPE,FLDNAME
 S FILETYPE=$P(TMP,U,2),FLDNAME=$P(TMP,"^",1),OSI=""
 S VTI=$P(HL7,U,2),OBI=MCOR1_ST(3)_MCOR3_ST(3)_FILETYPE_ST(2)_FLDNAME_ST(2)_"DD"
 S UNT=$P(HL7,U,3),RNG=$P(HL7,U,4)
 D RDATA(VTI,OBI,OSI,UNT,RNG,FILETYPE,MCOR1,MCOR2,MCOR3)
 Q
OBR(TMP,HL7,OBX,MCOR1,MCOR2,MCOR3) ; This is the OBR add on message
 N RST,PIECE,FILETYPE
 S FILETYPE=$P(TMP,U,2),RST=$G(^TMP("MCORMN",$J,"E",MCOR1,MCOR2,MCOR3,1))
 S RST=$$CONVERT^MCORMN01(FILETYPE,RST),PIECE=$P(HL7,U,6)+1
 S $P(@MCDEST@(OBX),ST(1),PIECE)=RST
 Q
RDATA(VTI,OBI,OSI,UNT,RNG,FILETYPE,MCOR1,MCOR2,MCOR3) ;
 N MCOR4,CONT,LEN,RSTT,TEMP,COUNT,END,RST,CNT,LOOP,LOOP2,X,DIWL,DIWR,DIWF
 S MCOR4=""
 F LOOP=1:1 S MCOR4=$O(^TMP("MCORMN",$J,"E",MCOR1,MCOR2,MCOR3,MCOR4)) Q:MCOR4=""  D
 .S X=^TMP("MCORMN",$J,"E",MCOR1,MCOR2,MCOR3,MCOR4)
 .;I $L(X)>80 D WP
 .I $L(X)>80 D
 ..D WP
 .E  D
 ..D:LOOP=1 SETOBX1(FILETYPE,VTI,OBI,OSI,X)
 ..D:LOOP'=1 SETNODE(MCDEST,X)
 D SETOBX2(UNT,RNG)
 Q
WP ;
 K ^UTILITY($J,"W") S DIWL=0,DIWR=80,DIWF="" D ^DIWP
 S CNT=^UTILITY($J,"W",0)
 F LOOP2=1:1:CNT S RST=^UTILITY($J,"W",0,LOOP2,0) D
 .I (LOOP2>1)!(LOOP>1) D SETNODE(MCDEST,RST)
 .E  D SETOBX1(FILETYPE,VTI,OBI,OSI,RST)
 K ^UTILITY($J,"W")
 Q
SETOBX1(FILETYPE,VTI,OBI,OSI,OBR) ; Sets the first part of QBX line
 S:VTI="" VTI="ST"
 S:OSI="" (MSE,OSI)=$G(MSE)+1
 D SETNODE(MCDEST,$$OBX1^MCORMN01(FILETYPE,VTI,OBI,OSI,OBR))
 Q
SETOBX2(RNG,UNT) ;Sets the second part of OBX line
 S @MCDEST@(MCLINE,0)=@MCDEST@(MCLINE,0)_$$OBX2^MCORMN01(RNG,UNT)
 Q
SETNODE(NODE,VALUE) ;Set the node with the HL7 message string
 S MCLINE=MCLINE+1,@NODE@(MCLINE,0)=VALUE
 Q
SLIP(MSTR) ;Seperate the delimiters
 F LOOP=1:1:5 S ST(LOOP)=$E(MSTR,LOOP,LOOP)
 Q