Skip to content

Commit

Permalink
Imahara edition able to submit results.
Browse files Browse the repository at this point in the history
  • Loading branch information
michael-weinstein committed Jul 17, 2020
1 parent d2bdf20 commit cf6806a
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 18 deletions.
1 change: 1 addition & 0 deletions CDPH.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
python zymoTransmit.py --cdph
2 changes: 1 addition & 1 deletion raceEthnicityCodes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@
PHC1369 not obtainable
PHC1367 refused
ASKU asked but unknown
UNK unknown
UNK unknown u
14 changes: 12 additions & 2 deletions zymoTransmit.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

class CheckArgs(object):

__slots__ = ["input", "noTransmit", "hl7Directory", "cdph"]
__slots__ = ["input", "noTransmit", "hl7Directory", "cdph", "debug"]

def __init__(self):
parser = argparse.ArgumentParser()
Expand All @@ -41,6 +41,7 @@ def __init__(self):
parser.add_argument("-n", "--noTransmit", help = "Do not attempt to transmit data", action = 'store_true')
parser.add_argument("-d", "--hl7Directory", help = "Upload a directory of HL7 files", action = 'store_true')
parser.add_argument("--cdph", help = "Read CDPH format with header line", action = 'store_true')
parser.add_argument("--debug", help="Running in debugging mode", action='store_true')
parser.add_argument("input", help = "Input file", type = str, nargs='?')
rawArgs = parser.parse_args()
testConnection = rawArgs.testConnection
Expand All @@ -52,6 +53,7 @@ def __init__(self):
self.noTransmit = rawArgs.noTransmit
self.hl7Directory = rawArgs.hl7Directory
self.cdph = rawArgs.cdph
self.debug = rawArgs.debug
if self.hl7Directory and convertCertificate:
raise RuntimeError("Error: Program cannot be set to both process a certificate AND take in a directory for upload")
if testConnection or loinc or snomed:
Expand Down Expand Up @@ -197,12 +199,20 @@ def makeDirectoriesIfNeeded():
os.mkdir(os.path.join(contentRoot, config.Configuration.logFolder))


class PlaceHolderException(Exception):
pass


def main():
if "--debug" in sys.argv:
allOrNothingException = PlaceHolderException
else:
allOrNothingException = Exception
try:
makeDirectoriesIfNeeded()
args = CheckArgs()
prepareAndSendResults(args)
except Exception as err:
except allOrNothingException as err:
print("Encountered an unhandled error as follows:")
traceback.print_exc()
input("Run was not successful. Press enter to quit")
Expand Down
2 changes: 1 addition & 1 deletion zymoTransmitSupport/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,6 @@ class Facility:

class ResultTerms:
positiveResultTerms = ["POSITIVE", "DETECTED", "POS"]
indeterminateResultTerms = ["INDETERMINATE", "N/A", "UNKNOWN"]
indeterminateResultTerms = ["INDETERMINATE", "N/A", "UNKNOWN", "INCONCLUSIVE", "INVALID"]
negativeResultTerms = ["ND", "NEG", "NEGATIVE", "NOT DETECTED"]
unsatisfactorySpecimenResultTerms = ["UNSATISFACTORY SPECIMEN", "SPECIMEN UNSATISFACTORY", "UNSATISFACTORY"]
4 changes: 3 additions & 1 deletion zymoTransmitSupport/hl7Encoder/patient.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,9 @@ def __init__(self, sex:str=None):
"M": "M",
"F": "F",
"MALE": "M",
"FEMALE": "F"
"FEMALE": "F",
"U": "",
"UNKNOWN": ""
}
if not sex:
sexString = ""
Expand Down
23 changes: 13 additions & 10 deletions zymoTransmitSupport/inputOutput/caResultReader.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,29 +129,30 @@ def processDateAndTime(self, dateString: str, timeString: str, possibleDateDelim
break
if not dateDelimiter:
if len(dateString) == 8:
month = dateString[:4]
day = dateString[4:6]
year = dateString[6:]
year = dateString[:4]
month = dateString[4:6]
day = dateString[6:]
elif len(dateString) == 14:
month = dateString[:4]
day = dateString[4:6]
year = dateString[6:8]
year = dateString[:4]
month = dateString[4:6]
day = dateString[6:8]
hour = dateString[8:10]
minute = dateString[10:12]
second = dateString[12:14]
timeString = ":".join([hour, minute, second])
elif len(dateString) == 19 and "-" in dateString:
month = dateString[:4]
day = dateString[4:6]
year = dateString[6:8]
year = dateString[:4]
month = dateString[4:6]
day = dateString[6:8]
hour = dateString[8:10]
minute = dateString[10:12]
second = dateString[12:14]
timeString = ":".join([hour, minute, second])
offset = timeString.split("-")[1]
offset = dateString.split("-")[1]
offset = offset[:2]
offset = int(offset)
tzInfo = datetime.timedelta(hours=offset)
tzInfo = datetime.timezone(tzInfo)
else:
errorMessageLines = []
errorMessageLines.append("Unable to process date value")
Expand Down Expand Up @@ -235,6 +236,8 @@ def revertDateTimeObject(self, revertant:[datetime.datetime, datetime.date, date
dateString = ""
timeString = "%s:%s:%s" %(revertant.hour, revertant.minute, revertant.second)
else:
if type(revertant) == tuple:
return revertant[0], revertant[1]
raise ValueError("Got an invalid value trying to revert a datetime object to a string: %s of type %s" %(revertant, type(revertant)))
return (dateString, timeString)

Expand Down
6 changes: 3 additions & 3 deletions zymoTransmitSupport/inputOutput/resultReader.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,9 @@ def processDateAndTime(self, dateString: str, timeString: str, possibleDateDelim
break
if not dateDelimiter:
if len(dateString) == 8:
month = dateString[:2]
day = dateString[2:4]
year = dateString[4:]
year = dateString[:4]
month = dateString[4:6]
day = dateString[6:]
else:
errorMessageLines = []
errorMessageLines.append("Unable to process date value")
Expand Down

0 comments on commit cf6806a

Please sign in to comment.