Last active
July 19, 2023 14:30
-
-
Save aclud/f31ce0d1844ad7ec1a37 to your computer and use it in GitHub Desktop.
DICOM QC repair javascript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Reading Site = IACH | |
// Default QC Repair Script for GLWACH Modality Origins on QC Workstations | |
<empty> | |
// Rule::Evaluate | |
function Rule::Evaluate() | |
{ | |
log.info("***************** Repair Script Start ******************"); | |
var strDefault_DOB = "19000101"; // Default DOB - set to "" to disable | |
var iAccNumLength = 8; // number of digits in the Accno e.g. "03972309" = 8 | |
var iPadTo = iAccNumLength; // Set to 0 to disable padding Accno with zeros | |
var strAccNumPrefix = "0057/"; // Prefix for Accno | |
var strSiteID = "IACH"; // Site ID | |
var strReadingLoc = "IACH"; | |
var strArchiveLoc = strSiteID; | |
var strInstitution = strSiteID; | |
var strAccNum; | |
var strStatus = dcmsetImage.GetValue(0x0032000A); | |
var strManufacture = dcmsetImage.GetValue(0x00080070); | |
var strModel = dcmsetImage.GetValue(0x00081090); | |
var strSerial = dcmsetImage.GetValue(0x00181000); | |
var strStationName = dcmsetImage.GetValue(0x00081010); | |
var strOrigDOB = dcmsetImage.GetValue(0x00100030); | |
var strOrigDate = dcmsetImage.GetValue(0x00080020); | |
dcmsetRepair.SetValue(0x00104000, strReadingLoc); | |
dcmsetRepair.SetValue(0x00200010, strReadingLoc); | |
dcmsetRepair.SetValue(0x00102160, strArchiveLoc); | |
dcmsetRepair.SetValue(0x00080080, strInstitution); | |
log.info("\tStatus:" + strStatus + ":"); | |
strAccNum = dcmsetImage.GetValue(0x00080050); | |
log.info("Original Accession Number: " + strAccNum); | |
var re = /\^|/g; | |
// Pad Accno with zeros | |
strAccNum = strAccNum.replace(re,""); | |
strTemp = strAccNum; | |
if(strAccNum.length < iPadTo) | |
{ | |
log.info("Padding Accession Number"); | |
for(cnt=0; cnt < (iPadTo - strAccNum.length); cnt++) | |
strTemp = "0" + strTemp; | |
} | |
// Add Accno prefix if needed | |
strAccNum = strAccNum.length <= iAccNumLength ? strAccNumPrefix + strAccNum : strAccNum; | |
log.info("Accesion Number used for match: " + strAccNum); | |
dcmsetRepair.SetValue(0x00080050,strAccNum); | |
// Insert/Correct DOB | |
if((strOrigDOB <= "") && (strDefault_DOB > "")) | |
{ | |
dcmsetRepair.SetValue(0x00100030, strDefault_DOB); | |
log.info("\tBlank DOB field set to " + strDefault_DOB); | |
} | |
var d = new Date(); | |
var month = (d.getMonth() + 1); | |
var strMonth = (month < 10) ? "0" + month : "" + month; | |
var day = d.getDate(); | |
var strDay = (day < 10) ? "0" + day : "" + day; | |
strDefault_Dt = d.getFullYear(); | |
strDefault_Dt += strMonth; | |
strDefault_Dt += strDay; | |
if(strOrigDate <= "") | |
{ | |
dcmsetRepair.SetValue(0x00080020, strDefault_Dt); | |
log.info("\tBlank Study date field set to " + strDefault_Dt); | |
} | |
log.info("***************** Repair Script End ******************"); | |
return true; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment