Skip to content

Commit

Permalink
Take in and properly handle accession numbers as primary sample ident…
Browse files Browse the repository at this point in the history
…ifiers.
  • Loading branch information
michael-weinstein committed Jul 21, 2020
1 parent d47fb61 commit aa17529
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 16 deletions.
4 changes: 2 additions & 2 deletions templateSubmission.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#PatientID Patient Last Name Patient First Name Patient Middle Name Patient Date of Birth Patient Sex Patient Street Address Patient City Patient State Patient Zip Patient Phone Provider Last Name Provider First Name Provider Middle Name Provider Street Provider City Provider State Provider Zip Provider Phone Specimen ID Collection Date Collection Time Received Date Received Time Specimen SNOMED Code Test LOINC Code Analysis Date Analysis Time Result Reported Date Reported Time Notes Race Ethnicity
#1K94U Weinstein Andrew P 8/15/2017 M 17062 Murphy Ave. #1 Irvine CA 92614 888-882-9682 Rain Leo 13842 Tustin East Drive Tustin CA 92780 (818) 344-3434 1234567 6/8/2020 0:00 6/8/2020 13:00 258529004 94306-8 6/9/2020 11:00 Negative 6/10/2020 14:00 "Phone is pretty flexible for formatting, just be reasonable. Email address is also an acceptable entry there, if needed. Please stick to mm/dd/yyyy formatting for dates. Having a # at the start of a line will cause that line to be ignored as a comment or header." unknown unk
#PatientID Patient Last Name Patient First Name Patient Middle Name Patient Date of Birth Patient Sex Patient Street Address Patient City Patient State Patient Zip Patient Phone Provider Last Name Provider First Name Provider Middle Name Provider Street Provider City Provider State Provider Zip Provider Phone Specimen ID Collection Date Collection Time Received Date Received Time Specimen SNOMED Code Test LOINC Code Analysis Date Analysis Time Result Reported Date Reported Time Notes Race Ethnicity Accession ID
#1K94U Weinstein Andrew P 8/15/2017 M 17062 Murphy Ave. #1 Irvine CA 92614 888-882-9682 Rain Leo 13842 Tustin East Drive Tustin CA 92780 (818) 344-3434 1234567 6/8/2020 0:00 6/8/2020 13:00 258529004 94306-8 6/9/2020 11:00 Negative 6/10/2020 14:00 "Phone is pretty flexible for formatting, just be reasonable. Email address is also an acceptable entry there, if needed. Please stick to mm/dd/yyyy formatting for dates. Having a # at the start of a line will cause that line to be ignored as a comment or header." unknown unk 1A2B3C4D5E
24 changes: 18 additions & 6 deletions zymoTransmitSupport/hl7Encoder/encoders.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,18 +67,22 @@ def makePIDLine(result:inputOutput.resultReader.TestResult):


def makeORCLine(result:inputOutput.resultReader.TestResult):
if result.accession:
orderID = result.accession
else:
orderID = "%s.%s" % (result.patientID, result.specimenID)
if "labName" in result.auxiliaryData or "labCLIA" in result.auxiliaryData:
if not ("labName" in result.auxiliaryData and "labCLIA" in result.auxiliaryData):
raise ValueError("Lab name and lab CLIA must both be either present or absent in auxiliary data")
fillerOrderNumber = orderHeader.FillerOrderNumber(
"%s.%s" % (result.patientID, result.specimenID),
orderID,
result.auxiliaryData["labName"],
result.auxiliaryData["labCLIA"],
"CLIA"
)
else:
fillerOrderNumber = orderHeader.FillerOrderNumber(
"%s.%s" % (result.patientID, result.specimenID),
orderID,
config.LabInfo.name,
config.LabInfo.clia,
"CLIA"
Expand Down Expand Up @@ -147,18 +151,22 @@ def makeORCLine(result:inputOutput.resultReader.TestResult):


def makeOBRLine(result:inputOutput.resultReader.TestResult):
if result.accession:
orderID = result.accession
else:
orderID = "%s.%s" % (result.patientID, result.specimenID)
if "labName" in result.auxiliaryData or "labCLIA" in result.auxiliaryData:
if not ("labName" in result.auxiliaryData and "labCLIA" in result.auxiliaryData):
raise ValueError("Lab name and lab CLIA must both be either present or absent in auxiliary data")
fillerOrderNumber = orderRequest.FillerOrderNumber(
"%s.%s" % (result.patientID, result.specimenID),
orderID,
result.auxiliaryData["labName"],
result.auxiliaryData["labCLIA"],
"CLIA"
)
else:
fillerOrderNumber = orderRequest.FillerOrderNumber(
"%s.%s" % (result.patientID, result.specimenID),
orderID,
config.LabInfo.name,
config.LabInfo.clia,
"CLIA"
Expand Down Expand Up @@ -305,6 +313,10 @@ def makeObservationValueAndAbnormalityObjects(resultString:str):

def makeSPMLine(result:inputOutput.resultReader.TestResult):
specimenData = snomed.snomedTable[result.specimenSNOMED]
if result.accession:
orderID = result.accession
else:
orderID = "%s.%s" % (result.patientID, result.specimenID)
if "labName" in result.auxiliaryData:
assignerName = result.auxiliaryData["labName"]
else:
Expand All @@ -317,14 +329,14 @@ def makeSPMLine(result:inputOutput.resultReader.TestResult):
if not ("labName" in result.auxiliaryData and "labCLIA" in result.auxiliaryData):
raise ValueError("Lab name and lab CLIA must both be either present or absent in auxiliary data")
fillerAssignedIdentifier = specimen.FillerAssignedIdentifier(
"%s.%s" % (result.patientID, result.specimenID),
orderID,
result.auxiliaryData["labName"],
result.auxiliaryData["labCLIA"],
"CLIA"
)
else:
fillerAssignedIdentifier = specimen.FillerAssignedIdentifier(
"%s.%s" % (result.patientID, result.specimenID),
orderID,
config.LabInfo.name,
config.LabInfo.clia,
"CLIA"
Expand Down
8 changes: 1 addition & 7 deletions zymoTransmitSupport/inputOutput/caResultReader.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,6 @@ def __init__(self, rawLine: [str, collections.Iterable], delimiter: str = "\t"):
self.resultCode,
self.unused
) = self.elementArray
if self.accession:
if self.specimenID:
holder = self.specimenID
self.specimenID = self.accession
self.accession = holder
else:
self.specimenID = self.accession
self.patientDateOfBirth = self.processDateAndTime(patientDateOfBirth, "")
self.collectionDateTime = self.processDateAndTime(collectionDate, "")
self.reportedDateTime = self.processDateAndTime(reportedDateAndTime, "")
Expand Down Expand Up @@ -348,6 +341,7 @@ def convertToStandardResultObject(self):
self.note,
self.race,
self.ethnicity,
self.accession
]
resultObject = resultReader.TestResult(resultArray)
auxiliaryData = {
Expand Down
3 changes: 2 additions & 1 deletion zymoTransmitSupport/inputOutput/resultReader.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@


class TestResult(object):
expectedElements = 34
expectedElements = 35

def __init__(self, rawLine: [str, collections.Iterable], delimiter: str = "\t"):
self.rawLine = rawLine
Expand Down Expand Up @@ -52,6 +52,7 @@ def __init__(self, rawLine: [str, collections.Iterable], delimiter: str = "\t"):
self.note,
self.race,
self.ethnicity,
self.accession
) = self.elementArray
self.patientDateOfBirth = self.processDateAndTime(patientDateOfBirth, "")
self.collectionDateTime = self.processDateAndTime(collectionDate, collectionTime)
Expand Down

0 comments on commit aa17529

Please sign in to comment.