- BLRMERGD ;IHS/ISD/EDE - LAB MERGE DOCUMENTATION [ 12/21/1998 3:55 PM ]
- ;;5.2;BLR;**1005**;DEC 14, 1998
- ;
- ;LAB PATIENT MERGE
- ;
- ;GENERAL INFO
- ;
- ;The Lab package files are not FileMan compatible, nor are the
- ;routines that manipulate data stored in those files. Data is
- ;inserted into files using direct sets and xrefs are generated
- ;in the same manner. Some fields have xrefs defined but they are
- ;never fired because the data is not added using ^DIE. I do not
- ;know for sure but it is possible that some fields are valued using
- ;FileMan calls, but others certainly are not. Where possible
- ;the BLRMERG* routines modify data using ^DIE. Because this will
- ;trigger xrefs defined in the dictionary there may be xrefs set
- ;that were not set by the hard code that originally valued the
- ;fields. Furthermore, there is no assurance that the xrefs defined
- ;in the dictionary are exactly the same as the xrefs generated by
- ;hard code. Because of these inconsistencies, after the field
- ;values are changed using ^DIE I modify various xrefs using hard
- ;sets and kills.
- ;
- ;After the two lab patients are merged a bulletin, named PCC
- ;LAB PATIENT MERGEIs sent to the mail group named PCC LAB PATIENT
- ;MERGE.
- ;
- ;AFFECTED FILES
- ;
- ;--------------------
- ;VA Patient 2, ^DPT(
- ;
- ;The "LR" node for a patient entry points to that patient's lab
- ;data in the Lab Data file 63,
- ;^LR(, (e.g. ^DPT(222,"LR")=2).
- ;
- ;--------------------
- ;Lab Data file 63, ^LR(
- ;
- ;Field .02, D0,0 is the parent file. The VA Patient file 2 for
- ;this purpose.
- ;Field .03, D0,0 is the ien of the patient.
- ;
- ;There is one entry in this file for each Lab patient. Within one
- ;patient's entry lab tests are stored by accession area (e.g. BB,
- ;CH, CY, SP). Within these subscripts data is stored by inverse
- ;date. The 1st piece of the 0th node is the date/time the specimen
- ;was taken. The 6th piece of the 0th node provides access to the
- ;associated entry in the Accession file 68, ^LRO(68,. The format
- ;of the 6th piece varies depending on the accession area. For CY,
- ;SP, EM, and AU the 6th piece is a number which is the ien in the
- ;Accession Number multiple 68.02 in the Accession file 68. For CH,
- ;BB, and MI the 6th piece is freetext in the form `aa xxxx n' where
- ;aa=the type (e.g. HE for Hematology), and n=the ien in the 68.02
- ;multiple. The xxxx represents a transformation of the date the
- ;specimen was taken. The transformation is based on the type and
- ;may be daily, monthly, quarterly, or annually.
- ;
- ;^LR(8,"CY" 7019487,0)="2980512^607^^^CLAYTON CURTIS MD^1^17^IM etc"
- ;^LR(9,"BB",7019492.869244,0)="2980506.130756^^2980506.1325^^70^BB 0506 1^
- ;etc"
- ;--------------------
- ;Accession file 68, ^LRO(68,
- ;
- ;Data is stored in this file by accession area, and within accession
- ;area by date, and within that by entry within that date. The 1st
- ;piece of the 0th node of each entry is the LRDFN which is a pointer
- ;to the patient's entry in the Lab Data file 63, ^LR(.
- ;
- ;--------------------
- ;Lab Order Entry file 69, ^LRO(69,
- ;
- ;Data is stored in this file by date ordered, and within date ordered
- ;by sequence number. The 1st piece of the 0th node is the LRDFN
- ;which is a pointer to the patient's entry in the Lab Data file 63,
- ;^LR(
- ;
- ;
- ;MERGE LOGIC/NAVIGATION
- ;
- ;General:
- ;
- ;All entries in the Lab Order Entry file 69 that point to the Lab
- ;Data file 63 entry for the `from' patient are repointed to the
- ;`to' patient. All entries in the Accession file 68 that point
- ;to the Lab Data file 63 entry for the `from' patient are repointed
- ;to the `to' patient. The `from' patient's entry in the Lab Data
- ;file 63 is copied into the `to' patient's entry in the Lab Data
- ;file 63 and the `from' patient's entry is deleted.
- ;
- ;Detail:
- ;
- ;When two patients are merged in the VA PATIENT file, # 2, ^DPT(
- ;the "LR" node for each patient is checked to see if they have an
- ;entry in the lab system. The "LR" node contains a pointer to that
- ;patient's entry in the LAB DATA file, # 63, ^LR(. I will
- ;subsequently refer to this pointer as LRDFN. All lab data for
- ;that patient is stored in ^LR(LRDFN,. Data is stored in file 63
- ;by accession area within LRDFN, and generally by inverse date
- ;within accession area. E.g., ^LR(LRDFN,"CH",7019479.895049, etc.
- ;The exception to that is autopsy which is stored by subscripts
- ;".1", "AU", "AV", "AW", and "AWI".
- ;
- ;If the `to' patient has data in file 63 but the `from' patient
- ;does not, then no action is necessary.
- ;
- ;If the `from' patient has data in file 63 but the `to' patient
- ;does not, then all that is needed is to set the "LR" node for the
- ;`to' patient to the LRDFN of the `from' patient, change the
- ;patient pointer in the ^LR(LRDFN entry to point to the `to'
- ;patient instead of the `from' patient, and kill the "LR" node
- ;on the `from' patient.
- ;
- ;When both the `from' and `to' patients have data in file 63 then
- ;the `from' patient's data must be merged with the `to' patient's
- ;data. This will result in the `from' patient's ^LR entry being
- ;deleted. There are other lab files that point to this ^LR entry,
- ;therefore, the fields in those files must be repointed prior to
- ;the file 63 merge.
- ;
- ;This is accomplished in two different ways. The first approach
- ;is to follow a link field in file 63 to an entry in the ACCESSION
- ;file, # 68, ^LRO(68,. The link field is stored in the 6th piece
- ;of the 0th node of each accession area in file 63, e.g.
- ;^LR(LRDFN,"CH",inverse date,0) or ^LR(LRDFN, "AU") for autposy.
- ;
- ;The format of the link field varies depending on the accession
- ;area. For CY, SP, EM, and AU the link field is a number which
- ;is the ien in the Accession Number multiple 68.02 in the Accession
- ;file 68. For CH, BB, and MI the link field is freetext in the form
- ;`aa xxxx n' where aa=the type (e.g. HE for Hematology), and n=the
- ;ien in the 68.02 multiple. The xxxx is a transformation of the
- ;date and not used by the merge software.
- ;
- ;Data is stored in the ACCESSION file, # 68, by date within
- ;accession area. That means that all BLOOD BANK entries are stored
- ;under the ien for BLOOD BANK, and within that by accession date,
- ;and within that by accession number for that area/date, e.g.
- ;^LRO(68,4,1,2980519,1,2,0) which would be the 2nd accession number
- ;for 2980519 for accession area ien 4, which happens to be BLOOD
- ;BANK. The .01 field of the 68.02 multiple is a pointer to file 63,
- ;^LR(LRDFN which corresponds to a particular patient.
- ;This field is changed to point to the `to' patient's ^LR( entry
- ;instead of the `from' patient's ^LR( entry.
- ;
- ;In the ACCESSIONS file, # 68 BB, CH, etc. entries are stored by
- ;a transformation of the
- ;date, based on whether the accession numbers roll over daily,
- ;monthly, quarterly, etc., for the D1 subscript but CY, SP, etc.
- ;are stored by cyy0000 instead. The "C" xref in the Lab Order file
- ;69 is by the normal date for CY, SP etc.
- ;
- ;For some accession areas there is a link in file 68 to the LAB
- ;ORDER ENTRY file, # 69, ^LRO(69,. When it exists this link pointer
- ;is stored as the .1 node in file 63. E.g.,
- ;^LRO(68,4,1,2980519,1,2,.1)=4.
- ;
- ;Data is stored in the LAB ORDER ENTRY file, # 69, by date ordered,
- ;and within that by sequence #. These entries are located via the
- ;"C" xref which is in the following form:
- ;^LRO(69,"C",order #,date ordered,sequence #)="". The .01 field
- ;of the 69.01 multiple is a pointer to file 63, ^LR(LRDFN which
- ;corresponds to a particular patient. This field is changed to
- ;point to the `to' patient's ^LR( entry instead of the `from'
- ;patient's ^LR( entry.
- ;
- ;Prior to repointing the 69.01 .01 field the kill side of the
- ;xrefs on 69.01 21 and 69.03 .01 are executed and then the set
- ;side of the xrefs are executed after the repointing of 69.01 .01.
- ;
- ;Also after the 69.01 .01 field is repointed the "AN" xrefs are
- ;modified. One "AN" xref is at the file level, ^LRO(69,"AN", and
- ;the other is at a multiple level, ^LRO(69,date,1,"AN".
- ;
- ;Because following the link fields does not find all relevant
- ;entries the second approach is to find associated entries in file
- ;69 using the "D" xref which is in the form
- ;^LRO(69,"D",'from' patient's LRDFN,date,specimen #)="". The same
- ;action as discussed above for file 69 is executed for entries found
- ;via the "D" xref.
- ;
- ;Additionally, the "AC" xref and the "MI" xref are reset to use the
- ;`to' patient's LRDFN. They are in the form
- ;^LRO(68,"AC",'from' patient's LRDFN,date,accession #)="" and
- ;the same form for "MI". The xrefs are fixed using hard sets.
- ;
- ;After fields in files 68 and 69 are repointed the `from' patient's
- ;^LR entry is merged into the `to' patient's ^LR entry. ^LR
- ;entries are stored by inverse date within accession area so no
- ;`from' patient entry can have the same inverse date as any `to'
- ;patient entry within the same accession area. To resolve this
- ;problem each `from' patient entry is checked to see if the `to'
- ;patient has the same entry. If the `to' patient does have the
- ;same entry then the date/time of the `from' patient's entry is
- ;incremented by one second and checked again. This process
- ;continues until an unused inverse date slot is found. Then the
- ;date/time is changed in files 68 and 69 and in the ^LR entry, the
- ;changed ^LR entry is copied to the new inverse date slot in the
- ;`from' patients ^LR entry, and the old inverse date entry is
- ;deleted. After all `from' and `to' patient inverse date entries
- ;are unique the `from' patient's ^LR entry is copied to the `to'
- ;patient's ^LR entry and then the `from' patient's ^LR entry is
- ;deleted. After the copy the `to' patient's ^LR entry in re-indexed.
- BLRMERGD ;IHS/ISD/EDE - LAB MERGE DOCUMENTATION [ 12/21/1998 3:55 PM ]
- +1 ;;5.2;BLR;**1005**;DEC 14, 1998
- +2 ;
- +3 ;LAB PATIENT MERGE
- +4 ;
- +5 ;GENERAL INFO
- +6 ;
- +7 ;The Lab package files are not FileMan compatible, nor are the
- +8 ;routines that manipulate data stored in those files. Data is
- +9 ;inserted into files using direct sets and xrefs are generated
- +10 ;in the same manner. Some fields have xrefs defined but they are
- +11 ;never fired because the data is not added using ^DIE. I do not
- +12 ;know for sure but it is possible that some fields are valued using
- +13 ;FileMan calls, but others certainly are not. Where possible
- +14 ;the BLRMERG* routines modify data using ^DIE. Because this will
- +15 ;trigger xrefs defined in the dictionary there may be xrefs set
- +16 ;that were not set by the hard code that originally valued the
- +17 ;fields. Furthermore, there is no assurance that the xrefs defined
- +18 ;in the dictionary are exactly the same as the xrefs generated by
- +19 ;hard code. Because of these inconsistencies, after the field
- +20 ;values are changed using ^DIE I modify various xrefs using hard
- +21 ;sets and kills.
- +22 ;
- +23 ;After the two lab patients are merged a bulletin, named PCC
- +24 ;LAB PATIENT MERGEIs sent to the mail group named PCC LAB PATIENT
- +25 ;MERGE.
- +26 ;
- +27 ;AFFECTED FILES
- +28 ;
- +29 ;--------------------
- +30 ;VA Patient 2, ^DPT(
- +31 ;
- +32 ;The "LR" node for a patient entry points to that patient's lab
- +33 ;data in the Lab Data file 63,
- +34 ;^LR(, (e.g. ^DPT(222,"LR")=2).
- +35 ;
- +36 ;--------------------
- +37 ;Lab Data file 63, ^LR(
- +38 ;
- +39 ;Field .02, D0,0 is the parent file. The VA Patient file 2 for
- +40 ;this purpose.
- +41 ;Field .03, D0,0 is the ien of the patient.
- +42 ;
- +43 ;There is one entry in this file for each Lab patient. Within one
- +44 ;patient's entry lab tests are stored by accession area (e.g. BB,
- +45 ;CH, CY, SP). Within these subscripts data is stored by inverse
- +46 ;date. The 1st piece of the 0th node is the date/time the specimen
- +47 ;was taken. The 6th piece of the 0th node provides access to the
- +48 ;associated entry in the Accession file 68, ^LRO(68,. The format
- +49 ;of the 6th piece varies depending on the accession area. For CY,
- +50 ;SP, EM, and AU the 6th piece is a number which is the ien in the
- +51 ;Accession Number multiple 68.02 in the Accession file 68. For CH,
- +52 ;BB, and MI the 6th piece is freetext in the form `aa xxxx n' where
- +53 ;aa=the type (e.g. HE for Hematology), and n=the ien in the 68.02
- +54 ;multiple. The xxxx represents a transformation of the date the
- +55 ;specimen was taken. The transformation is based on the type and
- +56 ;may be daily, monthly, quarterly, or annually.
- +57 ;
- +58 ;^LR(8,"CY" 7019487,0)="2980512^607^^^CLAYTON CURTIS MD^1^17^IM etc"
- +59 ;^LR(9,"BB",7019492.869244,0)="2980506.130756^^2980506.1325^^70^BB 0506 1^
- +60 ;etc"
- +61 ;--------------------
- +62 ;Accession file 68, ^LRO(68,
- +63 ;
- +64 ;Data is stored in this file by accession area, and within accession
- +65 ;area by date, and within that by entry within that date. The 1st
- +66 ;piece of the 0th node of each entry is the LRDFN which is a pointer
- +67 ;to the patient's entry in the Lab Data file 63, ^LR(.
- +68 ;
- +69 ;--------------------
- +70 ;Lab Order Entry file 69, ^LRO(69,
- +71 ;
- +72 ;Data is stored in this file by date ordered, and within date ordered
- +73 ;by sequence number. The 1st piece of the 0th node is the LRDFN
- +74 ;which is a pointer to the patient's entry in the Lab Data file 63,
- +75 ;^LR(
- +76 ;
- +77 ;
- +78 ;MERGE LOGIC/NAVIGATION
- +79 ;
- +80 ;General:
- +81 ;
- +82 ;All entries in the Lab Order Entry file 69 that point to the Lab
- +83 ;Data file 63 entry for the `from' patient are repointed to the
- +84 ;`to' patient. All entries in the Accession file 68 that point
- +85 ;to the Lab Data file 63 entry for the `from' patient are repointed
- +86 ;to the `to' patient. The `from' patient's entry in the Lab Data
- +87 ;file 63 is copied into the `to' patient's entry in the Lab Data
- +88 ;file 63 and the `from' patient's entry is deleted.
- +89 ;
- +90 ;Detail:
- +91 ;
- +92 ;When two patients are merged in the VA PATIENT file, # 2, ^DPT(
- +93 ;the "LR" node for each patient is checked to see if they have an
- +94 ;entry in the lab system. The "LR" node contains a pointer to that
- +95 ;patient's entry in the LAB DATA file, # 63, ^LR(. I will
- +96 ;subsequently refer to this pointer as LRDFN. All lab data for
- +97 ;that patient is stored in ^LR(LRDFN,. Data is stored in file 63
- +98 ;by accession area within LRDFN, and generally by inverse date
- +99 ;within accession area. E.g., ^LR(LRDFN,"CH",7019479.895049, etc.
- +100 ;The exception to that is autopsy which is stored by subscripts
- +101 ;".1", "AU", "AV", "AW", and "AWI".
- +102 ;
- +103 ;If the `to' patient has data in file 63 but the `from' patient
- +104 ;does not, then no action is necessary.
- +105 ;
- +106 ;If the `from' patient has data in file 63 but the `to' patient
- +107 ;does not, then all that is needed is to set the "LR" node for the
- +108 ;`to' patient to the LRDFN of the `from' patient, change the
- +109 ;patient pointer in the ^LR(LRDFN entry to point to the `to'
- +110 ;patient instead of the `from' patient, and kill the "LR" node
- +111 ;on the `from' patient.
- +112 ;
- +113 ;When both the `from' and `to' patients have data in file 63 then
- +114 ;the `from' patient's data must be merged with the `to' patient's
- +115 ;data. This will result in the `from' patient's ^LR entry being
- +116 ;deleted. There are other lab files that point to this ^LR entry,
- +117 ;therefore, the fields in those files must be repointed prior to
- +118 ;the file 63 merge.
- +119 ;
- +120 ;This is accomplished in two different ways. The first approach
- +121 ;is to follow a link field in file 63 to an entry in the ACCESSION
- +122 ;file, # 68, ^LRO(68,. The link field is stored in the 6th piece
- +123 ;of the 0th node of each accession area in file 63, e.g.
- +124 ;^LR(LRDFN,"CH",inverse date,0) or ^LR(LRDFN, "AU") for autposy.
- +125 ;
- +126 ;The format of the link field varies depending on the accession
- +127 ;area. For CY, SP, EM, and AU the link field is a number which
- +128 ;is the ien in the Accession Number multiple 68.02 in the Accession
- +129 ;file 68. For CH, BB, and MI the link field is freetext in the form
- +130 ;`aa xxxx n' where aa=the type (e.g. HE for Hematology), and n=the
- +131 ;ien in the 68.02 multiple. The xxxx is a transformation of the
- +132 ;date and not used by the merge software.
- +133 ;
- +134 ;Data is stored in the ACCESSION file, # 68, by date within
- +135 ;accession area. That means that all BLOOD BANK entries are stored
- +136 ;under the ien for BLOOD BANK, and within that by accession date,
- +137 ;and within that by accession number for that area/date, e.g.
- +138 ;^LRO(68,4,1,2980519,1,2,0) which would be the 2nd accession number
- +139 ;for 2980519 for accession area ien 4, which happens to be BLOOD
- +140 ;BANK. The .01 field of the 68.02 multiple is a pointer to file 63,
- +141 ;^LR(LRDFN which corresponds to a particular patient.
- +142 ;This field is changed to point to the `to' patient's ^LR( entry
- +143 ;instead of the `from' patient's ^LR( entry.
- +144 ;
- +145 ;In the ACCESSIONS file, # 68 BB, CH, etc. entries are stored by
- +146 ;a transformation of the
- +147 ;date, based on whether the accession numbers roll over daily,
- +148 ;monthly, quarterly, etc., for the D1 subscript but CY, SP, etc.
- +149 ;are stored by cyy0000 instead. The "C" xref in the Lab Order file
- +150 ;69 is by the normal date for CY, SP etc.
- +151 ;
- +152 ;For some accession areas there is a link in file 68 to the LAB
- +153 ;ORDER ENTRY file, # 69, ^LRO(69,. When it exists this link pointer
- +154 ;is stored as the .1 node in file 63. E.g.,
- +155 ;^LRO(68,4,1,2980519,1,2,.1)=4.
- +156 ;
- +157 ;Data is stored in the LAB ORDER ENTRY file, # 69, by date ordered,
- +158 ;and within that by sequence #. These entries are located via the
- +159 ;"C" xref which is in the following form:
- +160 ;^LRO(69,"C",order #,date ordered,sequence #)="". The .01 field
- +161 ;of the 69.01 multiple is a pointer to file 63, ^LR(LRDFN which
- +162 ;corresponds to a particular patient. This field is changed to
- +163 ;point to the `to' patient's ^LR( entry instead of the `from'
- +164 ;patient's ^LR( entry.
- +165 ;
- +166 ;Prior to repointing the 69.01 .01 field the kill side of the
- +167 ;xrefs on 69.01 21 and 69.03 .01 are executed and then the set
- +168 ;side of the xrefs are executed after the repointing of 69.01 .01.
- +169 ;
- +170 ;Also after the 69.01 .01 field is repointed the "AN" xrefs are
- +171 ;modified. One "AN" xref is at the file level, ^LRO(69,"AN", and
- +172 ;the other is at a multiple level, ^LRO(69,date,1,"AN".
- +173 ;
- +174 ;Because following the link fields does not find all relevant
- +175 ;entries the second approach is to find associated entries in file
- +176 ;69 using the "D" xref which is in the form
- +177 ;^LRO(69,"D",'from' patient's LRDFN,date,specimen #)="". The same
- +178 ;action as discussed above for file 69 is executed for entries found
- +179 ;via the "D" xref.
- +180 ;
- +181 ;Additionally, the "AC" xref and the "MI" xref are reset to use the
- +182 ;`to' patient's LRDFN. They are in the form
- +183 ;^LRO(68,"AC",'from' patient's LRDFN,date,accession #)="" and
- +184 ;the same form for "MI". The xrefs are fixed using hard sets.
- +185 ;
- +186 ;After fields in files 68 and 69 are repointed the `from' patient's
- +187 ;^LR entry is merged into the `to' patient's ^LR entry. ^LR
- +188 ;entries are stored by inverse date within accession area so no
- +189 ;`from' patient entry can have the same inverse date as any `to'
- +190 ;patient entry within the same accession area. To resolve this
- +191 ;problem each `from' patient entry is checked to see if the `to'
- +192 ;patient has the same entry. If the `to' patient does have the
- +193 ;same entry then the date/time of the `from' patient's entry is
- +194 ;incremented by one second and checked again. This process
- +195 ;continues until an unused inverse date slot is found. Then the
- +196 ;date/time is changed in files 68 and 69 and in the ^LR entry, the
- +197 ;changed ^LR entry is copied to the new inverse date slot in the
- +198 ;`from' patients ^LR entry, and the old inverse date entry is
- +199 ;deleted. After all `from' and `to' patient inverse date entries
- +200 ;are unique the `from' patient's ^LR entry is copied to the `to'
- +201 ;patient's ^LR entry and then the `from' patient's ^LR entry is
- +202 ;deleted. After the copy the `to' patient's ^LR entry in re-indexed.