From bbfec8187527d74233e8a80c041647022a19b44d Mon Sep 17 00:00:00 2001 From: Michael Weinstein Date: Mon, 20 Jul 2020 16:21:32 -0700 Subject: [PATCH] Now checks for valid SNOMED code in CDPH CSV fields before trying anything else and uses that if present. --- zymoTransmitSupport/hl7Encoder/snomed.py | 8 +++---- .../inputOutput/caResultReader.py | 21 +++++++++++++++++++ zymoTransmitSupport/supportData.py | 2 +- 3 files changed, 25 insertions(+), 6 deletions(-) diff --git a/zymoTransmitSupport/hl7Encoder/snomed.py b/zymoTransmitSupport/hl7Encoder/snomed.py index b97ae37..a44b2bb 100644 --- a/zymoTransmitSupport/hl7Encoder/snomed.py +++ b/zymoTransmitSupport/hl7Encoder/snomed.py @@ -39,18 +39,16 @@ def loadRawDataTable(): dataTable = [] for line in data: line = [element.strip() for element in line] - if len(line) == 7: - line.append("") dataTable.append(line) return dataTable def makeSnomedTable(data:list): - loincTable = {} + snomedTable = {} for line in data: code, fullName, preferredName = line - loincTable[code] = SNOMED(code, fullName, preferredName) - return loincTable + snomedTable[code] = SNOMED(code, fullName, preferredName) + return snomedTable def makeLookupTables(loincTable:typing.Dict[str, SNOMED]): diff --git a/zymoTransmitSupport/inputOutput/caResultReader.py b/zymoTransmitSupport/inputOutput/caResultReader.py index f46b3b5..210eabd 100644 --- a/zymoTransmitSupport/inputOutput/caResultReader.py +++ b/zymoTransmitSupport/inputOutput/caResultReader.py @@ -19,6 +19,24 @@ def makeSpecimenRegexes(): swabRegex = re.compile("SWAB", re.IGNORECASE) +def getSnomedList(): # Doing this to avoid circular references and because SNOMED format is not specific enough + inputFileDirectory = os.path.split(os.path.abspath(__file__))[0] + inputFileDirectory = os.path.split(inputFileDirectory)[0] + inputFileDirectory = os.path.split(inputFileDirectory)[0] + inputFile = "snomedSpecimens.txt" + inputPath = os.path.join(inputFileDirectory, inputFile) + data = open(inputPath, 'r').readlines() + data = [line.strip() for line in data if line and not line.startswith("#")] + data = [line.split("\t") for line in data if line] + codeTable = [] + for line in data: + line = [element.strip() for element in line] + codeTable.append(line[0]) + return codeTable + +snomedList = getSnomedList() + + class CATestResult(object): expectedElements = 40 @@ -263,6 +281,9 @@ def checkFields(regexList:list): bloodSNOMED = "788707000" swabNotOtherwiseSpecifiedSNOMED = "257261003" fields = [self.specimenType, self.specimenSite] + for field in fields: + if field in snomedList: + return field nasal = checkFields(nasalRegexList) swab = checkFields([swabRegex]) oral = checkFields(oralRegexList) diff --git a/zymoTransmitSupport/supportData.py b/zymoTransmitSupport/supportData.py index 8db4a7b..49e74cb 100644 --- a/zymoTransmitSupport/supportData.py +++ b/zymoTransmitSupport/supportData.py @@ -1,4 +1,4 @@ -softwareVersion = "1.0.0" +softwareVersion = "1.0.1" softwareDate = "20200719" \ No newline at end of file