Skip to content

Commit

Permalink
Fixed Imahara edition issue with reverting to config for PID field fa…
Browse files Browse the repository at this point in the history
…cility values. Better warning and handling when a bad result string is detected.
  • Loading branch information
michael-weinstein committed Jul 17, 2020
1 parent 688ddab commit 0ee6382
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
11 changes: 9 additions & 2 deletions zymoTransmit.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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]]):
Expand Down Expand Up @@ -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)
Expand All @@ -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.")

Expand Down
10 changes: 8 additions & 2 deletions zymoTransmitSupport/hl7Encoder/encoders.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 0ee6382

Please sign in to comment.