diff --git a/zymoTransmit.py b/zymoTransmit.py index 2b3ceff..97ade59 100644 --- a/zymoTransmit.py +++ b/zymoTransmit.py @@ -119,6 +119,7 @@ def getTestResults(testResultPath:str="results.txt", cdphCSV:bool=False): def makeHL7Codes(resultList:typing.List[zymoTransmitSupport.inputOutput.resultReader.TestResult]): hl7Sets = {} + skippedData = [] for result in resultList: patientID = result.patientID specimenID = result.specimenID @@ -138,7 +139,8 @@ def makeHL7Codes(resultList:typing.List[zymoTransmitSupport.inputOutput.resultRe for reason in result.reasonsNotToTransmit: print("\t%s" %reason) del hl7Sets[(patientID, specimenID)] - return hl7Sets + skippedData.append((patientID, specimenID)) + return hl7Sets, skippedData def makeHL7Blocks(hl7Sets:typing.Dict[typing.Tuple[str, str], typing.List[zymoTransmitSupport.hl7Encoder.generics.Hl7Line]]): @@ -173,6 +175,7 @@ def prepareAndSendResults(args:CheckArgs): convertPFX(args.input, pfxPassword=password) input("Press enter to quit.") quit() + skippedData = [] certificateFilePath = os.path.join(contentRoot, config.Connection.certificateFolder, config.Connection.certificateFileName) client, session = zymoTransmitSupport.inputOutput.connection.getSOAPClient( config.Connection.wsdlURL, certificateFilePath, dumpClientInfo=False) @@ -186,13 +189,17 @@ def prepareAndSendResults(args:CheckArgs): hl7TextBlocks = zymoTransmitSupport.inputOutput.rawHL7.textBlocksFromRawHL7(args.input) else: resultList = getTestResults(args.input, args.cdph) - hl7Sets = makeHL7Codes(resultList) + hl7Sets, skippedData = makeHL7Codes(resultList) hl7TextBlocks = makeHL7Blocks(hl7Sets) hl7TextRecord = makeHL7TextRecord(hl7TextBlocks) if not args.noTransmit: transmissionResults = zymoTransmitSupport.inputOutput.soapAPI.transmitBlocks(client, hl7TextBlocks) resultText = zymoTransmitSupport.inputOutput.logger.writeLogFile(config.Configuration.logFolder, transmissionResults, hl7TextRecord) print(resultText) + if skippedData: + print("WARNING: Some results were skipped for reasons listed above:") + for patientID, specimenID in skippedData: + print("%s:%s was skipped" %(patientID, specimenID)) else: print("Results not transmitted due to argument noTransmit being set to true.") diff --git a/zymoTransmitSupport/hl7Encoder/encoders.py b/zymoTransmitSupport/hl7Encoder/encoders.py index 8e2a347..6c2c6e2 100644 --- a/zymoTransmitSupport/hl7Encoder/encoders.py +++ b/zymoTransmitSupport/hl7Encoder/encoders.py @@ -24,8 +24,14 @@ def makeSFTLine(passThruMode:bool=False): def makePIDLine(result:inputOutput.resultReader.TestResult): - idAssigner = patient.IDAssignerSubfield.fromObject(config.Configuration.PID.IDAssigner) - facility = patient.FacilitySubfield.fromObject(config.Configuration.PID.Facility) + 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") + idAssigner = patient.IDAssignerSubfield(result.auxiliaryData["labName"], result.auxiliaryData["labCLIA"], "CLIA") + facility = patient.FacilitySubfield(result.auxiliaryData["labName"], result.auxiliaryData["labCLIA"], "CLIA") + else: + idAssigner = patient.IDAssignerSubfield.fromObject(config.Configuration.PID.IDAssigner) + facility = patient.FacilitySubfield.fromObject(config.Configuration.PID.Facility) patientIdentifierList = patient.PatientIdentifierList( result.patientID, idAssigner,