Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix up WHO ANC tests #503

Merged
merged 1 commit into from
Dec 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package org.opencds.cqf.tooling.acceleratorkit;

import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertTrue;

import java.io.IOException;
Expand All @@ -13,24 +12,22 @@
public class ANCMiniContentTest extends BaseContentTest {

public ANCMiniContentTest() {
super(new Spreadsheet() {
{
path = "acceleratorkit/ANC Test Cases-mini.xlsx";
scope = "ANCM";
dataElementPages = "ANC.A. Registration,ANC.B5 Quick check,ANC.End End";
}
});
super(new Spreadsheet()
.path("acceleratorkit/WHO-ANC-mini.xlsx")
.testCases("acceleratorkit/ANC Test Cases-mini.xlsx")
.scope("ANCM")
.dataElementPages("ANC.A. Registration,ANC.B5 Quick check,ANC.End End"));
}

@Test
public void validateContentCount() {
assertFalse(profilesPath().toFile().exists());
assertEquals(profilesPath().toFile().listFiles().length, 12);
assertEquals(cqlPath().toFile().listFiles().length, 4);
assertFalse(examplesPath().toFile().exists());
assertFalse(extensionsPath().toFile().exists());
assertFalse(resourcesPath().toFile().exists());
assertFalse(testsPath().toFile().exists());
assertEquals(vocabularyPath().resolve("codesystem").toFile().listFiles().length, 1);
assertEquals(examplesPath().toFile().listFiles().length, 12);
assertEquals(extensionsPath().toFile().listFiles().length, 2);
assertEquals(resourcesPath().resolve("questionnaire").toFile().listFiles().length, 3);
assertEquals(testsPath().toFile().listFiles().length, 14);
assertEquals(vocabularyPath().resolve("codesystem").toFile().listFiles().length, 2);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
package org.opencds.cqf.tooling.acceleratorkit;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.Objects;

import org.hl7.fhir.instance.model.api.IBaseResource;
Expand Down Expand Up @@ -53,7 +55,17 @@ protected void init() throws IOException {
Files.createDirectories(p);
}

var f = Files.createTempDirectory(p, "content-test-");
var testPath = p.resolve("content-test-" + scope());

// Clean out any existing tests.
if (testPath.toFile().exists()) {
Files.walk(testPath)
.sorted(Comparator.reverseOrder())
.map(Path::toFile)
.forEach(File::delete);
}

var f = Files.createDirectory(testPath);
outputPath = f.toAbsolutePath();
processor = new Processor();
processor.execute(args());
Expand All @@ -67,11 +79,55 @@ protected String command() {
* Add new fields to this class to support additional command line arguments.
*/
protected static class Spreadsheet {
String path;
String encoding;
String scope;
String dataElementPages;
String testCases;
private String path;
public String path() {
return path;
}

public Spreadsheet path(String path) {
this.path = path;
return this;
}

private String encoding;
public String encoding() {
return encoding;
}

public Spreadsheet encoding(String encoding) {
this.encoding = encoding;
return this;
}

private String scope;
private String scope() {
return scope;
}

public Spreadsheet scope(String scope) {
this.scope = scope;
return this;
}

private String dataElementPages;
public String dataElementPages() {
return dataElementPages;
}

public Spreadsheet dataElementPages(String dataElementPages) {
this.dataElementPages = dataElementPages;
return this;
}

private String testCases;
public String testCases() {
return testCases;
}

public Spreadsheet testCases(String testCases) {
this.testCases = testCases;
return this;
}
}

protected String[] params() {
Expand All @@ -81,7 +137,8 @@ protected String[] params() {
"-dep", dataElementPages(),
"-op", outputPath().toAbsolutePath().toString(),
"-e", encoding(),
"-tc", testCases()};
"-tc", testCasesPath() != null ? testCasesPath().toAbsolutePath().toString() : null
};
};

protected String[] args() {
Expand All @@ -106,25 +163,28 @@ protected String[] args() {
}

// Input params accessors
protected Path spreadsheetPath() {
return Path.of(resourcesPath, spreadsheet.path());
}

protected Path testCasesPath() {
if (spreadsheet.testCases() == null) {
return null;
}

protected String testCases() {
return spreadsheet.testCases;
return Path.of(resourcesPath, spreadsheet.testCases());
}

protected String encoding() {
return spreadsheet.encoding;
return spreadsheet.encoding();
}

protected String scope() {
return spreadsheet.scope;
}

protected Path spreadsheetPath() {
return Path.of(resourcesPath, spreadsheet.path);
return spreadsheet.scope();
}

protected String dataElementPages() {
return spreadsheet.dataElementPages;
return spreadsheet.dataElementPages();
}

// FHIR context accessors
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,10 @@
public class DTRContentTest extends BaseContentTest {

public DTRContentTest() {
super(new Spreadsheet() {
{
path = "acceleratorkit/DTR.xlsx";
scope = "ASLP";
dataElementPages = "ASLP.A1 Adult Sleep Studies";
}
});
super(new Spreadsheet()
.path("acceleratorkit/DTR.xlsx")
.scope("ASLP")
.dataElementPages("ASLP.A1 Adult Sleep Studies"));;
}

@Test
Expand Down
Binary file not shown.