use of org.hl7.fhir.dstu3.model.Encounter.EncounterStatus.FINISHED in project kindling by HL7.
the class Publisher method execute.
/**
* Entry point to the publisher. This classes Java Main() calls this function
* to actually produce the specification
*
* @param folder
* @throws IOException
*/
public void execute(String folder) throws IOException {
tester = new PublisherTestSuites();
page.log("Publish FHIR in folder " + folder + " @ " + Config.DATE_FORMAT().format(page.getGenDate().getTime()), LogMessageType.Process);
if (web)
page.log("Build final copy for HL7 web site", LogMessageType.Process);
else
page.log("Build local copy", LogMessageType.Process);
if (outputdir != null) {
page.log("Create output in " + outputdir, LogMessageType.Process);
}
page.log("Detected Java version: " + System.getProperty("java.version") + " from " + System.getProperty("java.home") + " on " + System.getProperty("os.arch"), LogMessageType.Process);
try {
tester.initialTests();
page.setFolders(new FolderManager(folder, outputdir));
if (!initialize(folder))
throw new Exception("Unable to publish as preconditions aren't met");
cache = new IniFile(page.getFolders().rootDir + "temp" + File.separator + "build.cache");
loadSuppressedMessages(page.getFolders().rootDir);
boolean doAny = false;
for (String n : dates.keySet()) {
Long d = cache.getLongProperty("dates", n);
boolean b = d == null || (dates.get(n) > d);
cache.setLongProperty("dates", n, dates.get(n).longValue(), null);
buildFlags.put(n.toLowerCase(), b);
doAny = doAny || b;
}
cache.save();
if (noPartialBuild || !doAny || !(new File(page.getFolders().dstDir + "qa.html").exists()))
// nothing - build all
buildFlags.put("all", true);
if (singlePage != null) {
for (String n : buildFlags.keySet()) buildFlags.put(n, false);
buildFlags.put("page-" + singlePage.toLowerCase(), true);
} else if (singleResource != null) {
for (String n : buildFlags.keySet()) buildFlags.put(n, false);
buildFlags.put(singleResource.toLowerCase(), true);
}
if (!buildFlags.get("all")) {
if (!noSound) {
AudioUtilities.tone(1000, 10);
AudioUtilities.tone(1400, 10);
AudioUtilities.tone(1800, 10);
AudioUtilities.tone(1000, 10);
AudioUtilities.tone(1400, 10);
AudioUtilities.tone(1800, 10);
}
page.log("Partial Build (if you want a full build, just run the build again)", LogMessageType.Process);
CommaSeparatedStringBuilder b = new CommaSeparatedStringBuilder();
for (String n : buildFlags.keySet()) if (buildFlags.get(n))
b.append(n);
page.log(" Build: " + b.toString(), LogMessageType.Process);
} else {
if (!noSound)
AudioUtilities.tone(1200, 30);
page.log("Full Build", LogMessageType.Process);
}
if (isGenerate && page.getBuildId() == null)
page.setBuildId(getGitBuildId());
page.log("Version " + page.getVersion() + "-" + page.getBuildId(), LogMessageType.Hint);
Utilities.createDirectory(page.getFolders().dstDir);
Utilities.deleteTempFiles();
page.getBreadCrumbManager().parse(page.getFolders().srcDir + "hierarchy.xml");
page.loadSnomed();
page.loadLoinc();
page.loadUcum();
buildFeedsAndMaps();
prsr.setExternals(externals);
prsr.parse(page.getGenDate(), page.getValidationErrors());
for (String n : page.getDefinitions().sortedResourceNames()) if (!page.getBreadCrumbManager().knowsResource(n))
page.getValidationErrors().add(new ValidationMessage(Source.Publisher, IssueType.INVALID, -1, -1, "hierarchy.xml", "Resource not found: " + n, IssueSeverity.ERROR));
for (String n : prsr.getErrors()) page.getValidationErrors().add(new ValidationMessage(Source.Publisher, IssueType.INVALID, -1, -1, "source spreadsheets", n, IssueSeverity.ERROR));
if (web) {
page.log("Clear Directory", LogMessageType.Process);
Utilities.clearDirectory(page.getFolders().dstDir);
}
if (web || (isGenerate && buildFlags.get("all"))) {
Utilities.createDirectory(page.getFolders().dstDir + "html");
Utilities.createDirectory(page.getFolders().dstDir + "examples");
}
for (ImplementationGuideDefn ig : page.getDefinitions().getSortedIgs()) if (!ig.isCore())
Utilities.createDirectory(page.getFolders().dstDir + ig.getCode());
if (buildFlags.get("all")) {
copyStaticContent();
}
page.makeRenderingContext();
loadValueSets1();
prsr.getRegistry().commit();
generateSCMaps();
validate();
processProfiles();
checkAllOk();
if (isGenerate) {
produceSpecification();
checkAllOk();
}
if (doValidate)
validationProcess();
page.saveSnomed();
page.getWorkerContext().saveCache();
processWarnings(false);
if (isGenerate && buildFlags.get("all"))
produceQA();
if (!buildFlags.get("all")) {
page.log("This was a Partial Build", LogMessageType.Process);
CommaSeparatedStringBuilder b = new CommaSeparatedStringBuilder();
for (String n : buildFlags.keySet()) if (buildFlags.get(n))
b.append(n);
page.log(" Build: " + b.toString(), LogMessageType.Process);
} else
page.log("This was a Full Build", LogMessageType.Process);
if (!noSound) {
AudioUtilities.tone(800, 10);
AudioUtilities.tone(1000, 10);
AudioUtilities.tone(1200, 10);
AudioUtilities.tone(1000, 10);
AudioUtilities.tone(800, 10);
}
page.log("Finished publishing FHIR @ " + Config.DATE_FORMAT().format(Calendar.getInstance().getTime()), LogMessageType.Process);
} catch (Exception e) {
if (!(e instanceof NullPointerException)) {
// because NullPointerException is unexpected...
try {
processWarnings(e instanceof EValidationFailed);
} catch (Exception e2) {
page.log(" ERROR: Unable to process warnings: " + e2.getMessage(), LogMessageType.Error);
e2.printStackTrace();
}
}
if (buildFlags.containsKey("all") && !buildFlags.get("all")) {
page.log("This was a Partial Build", LogMessageType.Process);
CommaSeparatedStringBuilder b = new CommaSeparatedStringBuilder();
for (String n : buildFlags.keySet()) if (buildFlags.get(n))
b.append(n);
page.log(" Build: " + b.toString(), LogMessageType.Process);
} else
page.log("This was a Full Build", LogMessageType.Process);
if (!noSound) {
AudioUtilities.tone(800, 20);
AudioUtilities.tone(1000, 20);
AudioUtilities.tone(1200, 20);
}
try {
Thread.sleep(50);
} catch (InterruptedException e1) {
}
if (!noSound) {
AudioUtilities.tone(800, 20);
AudioUtilities.tone(1000, 20);
AudioUtilities.tone(1200, 20);
}
try {
Thread.sleep(50);
} catch (InterruptedException e1) {
}
if (!noSound) {
AudioUtilities.tone(800, 20);
AudioUtilities.tone(1000, 20);
AudioUtilities.tone(1200, 20);
}
page.log("FHIR build failure @ " + Config.DATE_FORMAT().format(Calendar.getInstance().getTime()), LogMessageType.Process);
System.out.println("Error: " + e.getMessage());
e.printStackTrace();
TextFile.stringToFile(StringUtils.defaultString(e.getMessage()), Utilities.path(folder, "publish", "simple-error.txt"));
System.exit(1);
}
}
use of org.hl7.fhir.dstu3.model.Encounter.EncounterStatus.FINISHED in project cqf-ruler by DBCG.
the class CodeSystemProviderIT method testDSTU3UpdateCodeSystems.
@Test
@Order(5)
public void testDSTU3UpdateCodeSystems() throws IOException {
log.info("Beginning Test DSTU3 Update Code Systems");
assertEquals(0, performCodeSystemSearchByUrl(cptUrl).size());
File[] valuesets = new File(CodeSystemProviderIT.class.getResource("valueset").getPath()).listFiles();
for (File file : valuesets) {
if (file.isFile() && FilenameUtils.getExtension(file.getPath()).equals("json")) {
BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(file)));
String resourceString = reader.lines().collect(Collectors.joining(System.lineSeparator()));
reader.close();
loadResource("json", resourceString);
} else if (file.isFile() && FilenameUtils.getExtension(file.getPath()).equals("xml")) {
BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(file)));
String resourceString = reader.lines().collect(Collectors.joining(System.lineSeparator()));
reader.close();
loadResource("xml", resourceString);
}
}
OperationOutcome outcome = codeSystemUpdateProvider.updateCodeSystems();
for (OperationOutcomeIssueComponent issue : outcome.getIssue()) {
assertEquals(OperationOutcome.IssueSeverity.INFORMATION, issue.getSeverity());
assertTrue(issue.getDetails().getText().startsWith("Successfully updated the following CodeSystems: "));
assertTrue(issue.getDetails().getText().contains("cpt"));
assertTrue(issue.getDetails().getText().contains("icd-10"));
assertTrue(issue.getDetails().getText().contains("sct"));
assertTrue(issue.getDetails().getText().contains("rxnorm"));
}
assertEquals(1, performCodeSystemSearchByUrl(icd10).size());
assertEquals(1, performCodeSystemSearchByUrl(rxNormUrl).size());
assertEquals(1, performCodeSystemSearchByUrl(snomedSctUrl).size());
assertEquals(1, performCodeSystemSearchByUrl(cptUrl).size());
log.info("Finished Test DSTU3 Update Code Systems");
}
use of org.hl7.fhir.dstu3.model.Encounter.EncounterStatus.FINISHED in project cqf-ruler by DBCG.
the class CodeSystemProviderIT method testR4ICD10PerformCodeSystemUpdateByList.
@Test
@Order(4)
public void testR4ICD10PerformCodeSystemUpdateByList() throws IOException {
log.info("Beginning Test R4 SNOMED CodeSystemUpdate");
BufferedReader reader = new BufferedReader(new InputStreamReader(CodeSystemProviderIT.class.getResourceAsStream("valueset" + "/" + "valueset-pdmp-review-procedure.json")));
String resourceString = reader.lines().collect(Collectors.joining(System.lineSeparator()));
reader.close();
ValueSet vs = (ValueSet) loadResource("json", resourceString);
assertEquals(0, performCodeSystemSearchByUrl(snomedSctUrl).size());
codeSystemUpdateProvider.performCodeSystemUpdate(Arrays.asList(vs));
OperationOutcome outcome = codeSystemUpdateProvider.updateCodeSystems(vs.getIdElement());
for (OperationOutcomeIssueComponent issue : outcome.getIssue()) {
assertEquals(OperationOutcome.IssueSeverity.INFORMATION, issue.getSeverity());
assertTrue(issue.getDetails().getText().startsWith("Successfully updated the following CodeSystems: "));
assertTrue(issue.getDetails().getText().contains("sct"));
}
assertEquals(1, performCodeSystemSearchByUrl(snomedSctUrl).size());
log.info("Finished Test R4 SNOMED CodeSystemUpdate");
}
use of org.hl7.fhir.dstu3.model.Encounter.EncounterStatus.FINISHED in project cqf-ruler by DBCG.
the class CodeSystemProviderIT method testR4RxNormCodeSystemUpdateById.
@Test
@Order(3)
public void testR4RxNormCodeSystemUpdateById() throws IOException {
log.info("Beginning Test R4 LOINC CodeSystemUpdate");
ValueSet vs = (ValueSet) loadResource("org/opencds/cqf/ruler/devtools/r4/valueset/valueset-pain-treatment-plan.json");
assertEquals(0, performCodeSystemSearchByUrl(loincUrl).size());
OperationOutcome outcome = codeSystemUpdateProvider.updateCodeSystems(vs.getIdElement());
for (OperationOutcomeIssueComponent issue : outcome.getIssue()) {
assertEquals(OperationOutcome.IssueSeverity.INFORMATION, issue.getSeverity());
assertTrue(issue.getDetails().getText().startsWith("Successfully updated the following CodeSystems: "));
assertTrue(issue.getDetails().getText().contains("loinc"));
}
assertEquals(1, performCodeSystemSearchByUrl(loincUrl).size());
log.info("Finished Test R4 LOINC CodeSystemUpdate");
}
use of org.hl7.fhir.dstu3.model.Encounter.EncounterStatus.FINISHED in project Gravity-SDOH-Exchange-RI by FHIR.
the class TaskPollingService method updateTasks.
public void updateTasks() {
log.info("Updating tasks from CP Organizations...");
Bundle tasksBundle = openEhrClient.search().forResource(Task.class).include(Task.INCLUDE_FOCUS).include(Task.INCLUDE_OWNER).include(Organization.INCLUDE_ENDPOINT.setRecurse(true)).where(new TokenClientParam("owner:Organization.type").exactly().systemAndCode(OrganizationTypeCode.CP.getSystem(), OrganizationTypeCode.CP.toCode())).where(new TokenClientParam(Task.SP_STATUS + ":" + SearchModifierCode.NOT.toCode()).exactly().code(Task.TaskStatus.FAILED.toCode())).where(new TokenClientParam(Task.SP_STATUS + ":" + SearchModifierCode.NOT.toCode()).exactly().code(Task.TaskStatus.REJECTED.toCode())).where(new TokenClientParam(Task.SP_STATUS + ":" + SearchModifierCode.NOT.toCode()).exactly().code(Task.TaskStatus.COMPLETED.toCode())).where(new TokenClientParam(Task.SP_STATUS + ":" + SearchModifierCode.NOT.toCode()).exactly().code(Task.TaskStatus.CANCELLED.toCode())).where(Task.AUTHORED_ON.before().millis(Date.from(LocalDateTime.now().minusSeconds(10).atZone(ZoneId.systemDefault()).toInstant()))).returnBundle(Bundle.class).execute();
TasksPollingInfo tasksPollingInfo = new TasksPollingBundleExtractor().extract(tasksBundle);
// Collect all entries from every Task bundle for performance considerations.
Bundle updateBundle = new Bundle();
updateBundle.setType(Bundle.BundleType.TRANSACTION);
for (Task task : tasksPollingInfo.getTasks()) {
ServiceRequest serviceRequest = tasksPollingInfo.getServiceRequest(task);
Organization organization = tasksPollingInfo.getOrganization(task);
try {
Endpoint endpoint = tasksPollingInfo.getEndpoint(organization);
combineResult(updateBundle, getUpdateBundle(task, serviceRequest, endpoint));
} catch (TaskPollingUpdateException | CpClientException exc) {
combineResult(updateBundle, failTask(task, serviceRequest, exc.getMessage()));
}
}
// If there is at least one bundle entry - execute a transaction request.
if (updateBundle.getEntry().size() != 0) {
log.info("One or more tasks were changed. Storing updates to EHR...");
openEhrClient.transaction().withBundle(updateBundle).execute();
}
log.info("Task update process finished.");
}
Aggregations