diff --git a/CDPH.bat b/CDPH.bat new file mode 100644 index 0000000..d51f1f0 --- /dev/null +++ b/CDPH.bat @@ -0,0 +1 @@ +python zymoTransmit.py --cdph \ No newline at end of file diff --git a/raceEthnicityCodes.txt b/raceEthnicityCodes.txt index ed15caf..2fd0848 100644 --- a/raceEthnicityCodes.txt +++ b/raceEthnicityCodes.txt @@ -9,4 +9,4 @@ PHC1369 not obtainable PHC1367 refused ASKU asked but unknown -UNK unknown +UNK unknown u diff --git a/zymoTransmit.py b/zymoTransmit.py index 44865fa..809c4ba 100644 --- a/zymoTransmit.py +++ b/zymoTransmit.py @@ -29,7 +29,7 @@ class CheckArgs(object): - __slots__ = ["input", "noTransmit", "hl7Directory", "cdph"] + __slots__ = ["input", "noTransmit", "hl7Directory", "cdph", "debug"] def __init__(self): parser = argparse.ArgumentParser() @@ -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 @@ -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: @@ -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") diff --git a/zymoTransmitSupport/config.py b/zymoTransmitSupport/config.py index 6403524..db28617 100644 --- a/zymoTransmitSupport/config.py +++ b/zymoTransmitSupport/config.py @@ -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"] \ No newline at end of file diff --git a/zymoTransmitSupport/hl7Encoder/patient.py b/zymoTransmitSupport/hl7Encoder/patient.py index ccf8034..0679bef 100644 --- a/zymoTransmitSupport/hl7Encoder/patient.py +++ b/zymoTransmitSupport/hl7Encoder/patient.py @@ -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 = "" diff --git a/zymoTransmitSupport/inputOutput/caResultReader.py b/zymoTransmitSupport/inputOutput/caResultReader.py index 6e86862..f46b3b5 100644 --- a/zymoTransmitSupport/inputOutput/caResultReader.py +++ b/zymoTransmitSupport/inputOutput/caResultReader.py @@ -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") @@ -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) diff --git a/zymoTransmitSupport/inputOutput/resultReader.py b/zymoTransmitSupport/inputOutput/resultReader.py index a29b7c5..52c311c 100644 --- a/zymoTransmitSupport/inputOutput/resultReader.py +++ b/zymoTransmitSupport/inputOutput/resultReader.py @@ -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")