Search in sources :

Example 1 with FINISHED

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);
    }
}
Also used : ValidationMessage(org.hl7.fhir.utilities.validation.ValidationMessage) IniFile(org.hl7.fhir.utilities.IniFile) CommaSeparatedStringBuilder(org.hl7.fhir.utilities.CommaSeparatedStringBuilder) ImplementationGuideDefn(org.hl7.fhir.definitions.model.ImplementationGuideDefn) TransformerException(javax.xml.transform.TransformerException) IOException(java.io.IOException) FHIRException(org.hl7.fhir.exceptions.FHIRException) FileNotFoundException(java.io.FileNotFoundException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) EValidationFailed(org.hl7.fhir.tools.publisher.ExampleInspector.EValidationFailed) IniFile(org.hl7.fhir.utilities.IniFile) File(java.io.File) CSFile(org.hl7.fhir.utilities.CSFile) TextFile(org.hl7.fhir.utilities.TextFile)

Example 2 with FINISHED

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");
}
Also used : InputStreamReader(java.io.InputStreamReader) OperationOutcomeIssueComponent(org.hl7.fhir.dstu3.model.OperationOutcome.OperationOutcomeIssueComponent) OperationOutcome(org.hl7.fhir.dstu3.model.OperationOutcome) BufferedReader(java.io.BufferedReader) File(java.io.File) FileInputStream(java.io.FileInputStream) Order(org.junit.jupiter.api.Order) TestMethodOrder(org.junit.jupiter.api.TestMethodOrder) RestIntegrationTest(org.opencds.cqf.ruler.test.RestIntegrationTest) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 3 with FINISHED

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");
}
Also used : InputStreamReader(java.io.InputStreamReader) OperationOutcomeIssueComponent(org.hl7.fhir.r4.model.OperationOutcome.OperationOutcomeIssueComponent) OperationOutcome(org.hl7.fhir.r4.model.OperationOutcome) BufferedReader(java.io.BufferedReader) ValueSet(org.hl7.fhir.r4.model.ValueSet) Order(org.junit.jupiter.api.Order) TestMethodOrder(org.junit.jupiter.api.TestMethodOrder) RestIntegrationTest(org.opencds.cqf.ruler.test.RestIntegrationTest) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 4 with FINISHED

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");
}
Also used : OperationOutcomeIssueComponent(org.hl7.fhir.r4.model.OperationOutcome.OperationOutcomeIssueComponent) OperationOutcome(org.hl7.fhir.r4.model.OperationOutcome) ValueSet(org.hl7.fhir.r4.model.ValueSet) Order(org.junit.jupiter.api.Order) TestMethodOrder(org.junit.jupiter.api.TestMethodOrder) RestIntegrationTest(org.opencds.cqf.ruler.test.RestIntegrationTest) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 5 with FINISHED

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.");
}
Also used : Task(org.hl7.fhir.r4.model.Task) TasksPollingInfo(org.hl7.gravity.refimpl.sdohexchange.fhir.extract.TasksPollingBundleExtractor.TasksPollingInfo) TasksPollingBundleExtractor(org.hl7.gravity.refimpl.sdohexchange.fhir.extract.TasksPollingBundleExtractor) CpClientException(org.hl7.gravity.refimpl.sdohexchange.service.CpService.CpClientException) Organization(org.hl7.fhir.r4.model.Organization) TokenClientParam(ca.uhn.fhir.rest.gclient.TokenClientParam) Endpoint(org.hl7.fhir.r4.model.Endpoint) Bundle(org.hl7.fhir.r4.model.Bundle) TaskPollingUpdateException(org.hl7.gravity.refimpl.sdohexchange.fhir.extract.TasksPollingBundleExtractor.TaskPollingUpdateException) ServiceRequest(org.hl7.fhir.r4.model.ServiceRequest)

Aggregations

Test (org.junit.jupiter.api.Test)8 RestIntegrationTest (org.opencds.cqf.ruler.test.RestIntegrationTest)8 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)8 Bundle (org.hl7.fhir.r4.model.Bundle)7 File (java.io.File)6 Date (java.util.Date)6 Order (org.junit.jupiter.api.Order)6 TestMethodOrder (org.junit.jupiter.api.TestMethodOrder)6 FileInputStream (java.io.FileInputStream)5 BufferedReader (java.io.BufferedReader)4 InputStreamReader (java.io.InputStreamReader)4 Reference (org.hl7.fhir.r4.model.Reference)4 TokenClientParam (ca.uhn.fhir.rest.gclient.TokenClientParam)3 HashSet (java.util.HashSet)3 BundleEntryComponent (org.hl7.fhir.r4.model.Bundle.BundleEntryComponent)3 Coding (org.hl7.fhir.r4.model.Coding)3 Task (org.hl7.fhir.r4.model.Task)3 ValueSet (org.hl7.fhir.r4.model.ValueSet)3 Provider (org.mitre.synthea.world.agents.Provider)3 Code (org.mitre.synthea.world.concepts.HealthRecord.Code)3