Skip to content

Commit

Permalink
Engagement/jessica/15405 cleanup deidentification enrichment (#15821)
Browse files Browse the repository at this point in the history
* Changed where the files used and produced by the remove pii test live as well as delete the output file after the test runs
  • Loading branch information
JessicaWNava authored Sep 11, 2024
1 parent bc4cd62 commit 372c5fb
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions prime-router/src/main/kotlin/cli/tests/RemovePIITest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ import org.hl7.fhir.r4.model.ServiceRequest
import org.hl7.fhir.r4.model.Specimen
import java.io.File
import java.nio.file.Paths
import kotlin.io.path.Path
import kotlin.io.path.deleteIfExists

class RemovePIITest : CoolTest() {
/**
Expand All @@ -41,9 +43,10 @@ class RemovePIITest : CoolTest() {
*/
override suspend fun run(environment: Environment, options: CoolTestOptions): Boolean {
ugly("Starting remove PII test")
val inputFilePath = Paths.get("").toAbsolutePath().toString() + "/src/main/kotlin/cli/tests/fakePII.fhir"
val inputFilePath = Paths.get("").toAbsolutePath().toString() +
"/src/main/resources/clitests/compare-test-files/fakePII.fhir"
val outputFilePath = Paths.get("").toAbsolutePath().toString() +
"/src/main/kotlin/cli/tests/piiRemoved.fhir"
"/src/main/resources/clitests/compare-test-files/piiRemoved.fhir"

PIIRemovalCommands().test(
"-i $inputFilePath -o $outputFilePath"
Expand All @@ -56,40 +59,48 @@ class RemovePIITest : CoolTest() {

if (!testIdsRemoved(inputBundle, outputContent)) {
ugly("Not all IDs removed. Test failed.")
Path(outputFilePath).deleteIfExists()
return false
}

if (!testPatientPIIRemoved(inputBundle, outputBundle)) {
ugly("Not all patient PII removed. Test failed.")
Path(outputFilePath).deleteIfExists()
return false
}

if (!testOrganizationPIIRemoved(inputBundle, outputBundle)) {
ugly("Not all organization PII removed. Test failed.")
Path(outputFilePath).deleteIfExists()
return false
}

if (!testPractitionerPIIRemoved(inputBundle, outputBundle)) {
ugly("Not all practitioner PII removed. Test failed.")
Path(outputFilePath).deleteIfExists()
return false
}

if (!testServiceRequestPIIRemoved(inputBundle, outputBundle)) {
ugly("Not all service request PII removed. Test failed.")
Path(outputFilePath).deleteIfExists()
return false
}

if (!testObservationPIIRemoved(inputBundle, outputBundle)) {
ugly("Not all observation PII removed. Test failed.")
Path(outputFilePath).deleteIfExists()
return false
}

if (!testSpecimenPIIRemoved(inputBundle, outputBundle)) {
ugly("Not all specimen PII removed. Test failed.")
Path(outputFilePath).deleteIfExists()
return false
}

ugly("PII removal test passed")
Path(outputFilePath).deleteIfExists()
return true
}

Expand Down

0 comments on commit 372c5fb

Please sign in to comment.