Search in sources :

Example 1 with Tag

use of org.hl7.cql_annotations.r1.Tag in project kindling by HL7.

the class BookMaker method fixReferences.

private void fixReferences(XhtmlNode parent, XhtmlNode node, String name) throws Exception {
    List<XhtmlNode> wantDelete = new ArrayList<XhtmlNode>();
    for (XhtmlNode child : node.getChildNodes()) {
        if (child.getNodeType() == NodeType.Element) {
            if ("index-only-no-book".equals(child.getAttribute("class")))
                wantDelete.add(child);
            else
                fixReferences(node, child, name);
        }
    }
    for (XhtmlNode c : wantDelete) node.getChildNodes().remove(c);
    if (node.getName().equals("a")) {
        if (node.getAttributes().containsKey("name")) {
            String lname = node.getAttributes().get("name");
            node.getAttributes().put("name", name + "." + lname);
        // System.out.println("found anchor "+name+"."+lname);
        } else if (node.getAttribute("href") != null || node.getAttributes().get("xlink:href") != null) {
            String s = node.getAttributes().get("href");
            if (s == null || s.length() == 0)
                s = node.getAttributes().get("xlink:href");
            if (s == null || s.length() == 0)
                throw new Error("empty \"href\" element in \"a\" tag around " + parent.allText());
            if (s.startsWith("#")) {
                s = "#" + name + "." + s.substring(1);
            } else if (s.startsWith("http:") || s.startsWith("https:") || s.startsWith("ftp:") || s.startsWith("mailto:")) {
            // s = s;
            } else {
                int i = s.indexOf('.');
                if (i == -1)
                    throw new Error("unable to understand ref: '" + s + "' on '" + node.allText() + "'");
                if (s.contains("#")) {
                    int j = s.indexOf('#');
                    s = "#" + s.substring(0, i) + "." + s.substring(j + 1);
                } else if (s.endsWith(".html")) {
                    s = "#" + s.substring(0, i);
                } else {
                    if (!s.endsWith(".zip") && !s.endsWith(".xsd") && !s.endsWith(".xml") && !s.endsWith(".json") && !s.endsWith(".png") && !s.endsWith(".xml") && !s.endsWith(".eap") && !s.endsWith(".xmi")) {
                        System.out.println("odd ref: " + s + " in " + node.allText());
                    // s = s;
                    } else {
                    // actually, what we want to do is do what?
                    // System.out.println("ref to remove: "+s+" in "+node.allText());
                    // Utilities.copyFile(new File(page.getFolders().dstDir+s), new File(targetBin+File.separatorChar+s));
                    // s = "http://hl7.org/documentcenter/public/standards/FHIR"+DSTU_PATH_PORTION+"/v"+page.getVersion()+"/"+s;
                    }
                }
            }
            node.getAttributes().put("href", s);
            if (s.startsWith("http") && parent != null && !node.allText().equals(s)) {
                node.addText(" (" + s + ") ");
            }
        // System.out.println("reference to "+s);
        }
    }
}
Also used : ArrayList(java.util.ArrayList) XhtmlNode(org.hl7.fhir.utilities.xhtml.XhtmlNode)

Example 2 with Tag

use of org.hl7.cql_annotations.r1.Tag in project quality-measure-and-cohort-service by Alvearie.

the class DefaultVT method testMeasureEvaluationByMeasureIdentifier.

// to tag a specific test to be part of DVT (deployment verification test)
@Category(DVT.class)
@Test
public /**
 * Test a successful measure evaluation using identifier and version as the lookup key
 */
void testMeasureEvaluationByMeasureIdentifier() throws Exception {
    // You want -Denabled.dark.features=all in your Liberty jvm.options
    Assume.assumeTrue(isServiceDarkFeatureEnabled(CohortEngineRestConstants.DARK_LAUNCHED_MEASURE_EVALUATION));
    final String RESOURCE = getUrlBase() + CohortServiceAPISpec.CREATE_DELETE_EVALUATION_PATH;
    FhirContext fhirContext = FhirContext.forR4();
    IParser parser = fhirContext.newJsonParser().setPrettyPrint(true);
    Library library = TestHelper.getTemplateLibrary();
    Identifier identifier = new Identifier().setValue("measure-identifier").setSystem("http://ibm.com/health/test");
    Measure measure = TestHelper.getTemplateMeasure(library);
    measure.setIdentifier(Arrays.asList(identifier));
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    TestHelper.createMeasureArtifact(baos, parser, measure, library);
    // Files.write( baos.toByteArray(), new File("target/test_measure_v1_0_0.zip"));
    Map<String, Parameter> parameterOverrides = new HashMap<>();
    parameterOverrides.put("Measurement Period", new IntervalParameter(new DateParameter("2019-07-04"), true, new DateParameter("2020-07-04"), true));
    MeasureEvaluation requestData = new MeasureEvaluation();
    requestData.setDataServerConfig(dataServerConfig);
    requestData.setTerminologyServerConfig(termServerConfig);
    // This is a patient ID that is assumed to exist in the target FHIR server
    requestData.setPatientId(VALID_PATIENT_ID);
    requestData.setMeasureContext(new MeasureContext(null, parameterOverrides, new com.ibm.cohort.engine.measure.Identifier(identifier.getSystem(), identifier.getValue()), measure.getVersion()));
    requestData.setEvidenceOptions(new MeasureEvidenceOptions(false, MeasureEvidenceOptions.DefineReturnOptions.NONE));
    ObjectMapper om = new ObjectMapper();
    System.out.println(om.writeValueAsString(requestData));
    RequestSpecification request = buildBaseRequest(new Headers()).queryParam(CohortEngineRestHandler.VERSION, ServiceBuildConstants.DATE).multiPart(CohortEngineRestHandler.REQUEST_DATA_PART, requestData, "application/json").multiPart(CohortEngineRestHandler.MEASURE_PART, "test_measure_v1_0_0.zip", new ByteArrayInputStream(baos.toByteArray()));
    ValidatableResponse response = request.post(RESOURCE, getServiceVersion()).then();
    ValidatableResponse vr = runSuccessValidation(response, ContentType.JSON, HttpStatus.SC_OK);
    String expected = getJsonFromFile(ServiceAPIGlobalSpec.EXP_FOLDER_TYPE, "measure_evaluation_exp.json");
    String actual = vr.extract().asString();
    assertMeasureReportEquals(parser, expected, actual, false);
}
Also used : FhirContext(ca.uhn.fhir.context.FhirContext) ValidatableResponse(com.jayway.restassured.response.ValidatableResponse) HashMap(java.util.HashMap) MeasureEvaluation(com.ibm.cohort.engine.api.service.model.MeasureEvaluation) PatientListMeasureEvaluation(com.ibm.cohort.engine.api.service.model.PatientListMeasureEvaluation) Headers(com.jayway.restassured.response.Headers) RequestSpecification(com.jayway.restassured.specification.RequestSpecification) ByteArrayOutputStream(java.io.ByteArrayOutputStream) MeasureEvidenceOptions(com.ibm.cohort.engine.measure.evidence.MeasureEvidenceOptions) MeasureContext(com.ibm.cohort.engine.measure.MeasureContext) Identifier(org.hl7.fhir.r4.model.Identifier) DateParameter(com.ibm.cohort.cql.evaluation.parameters.DateParameter) ByteArrayInputStream(java.io.ByteArrayInputStream) Measure(org.hl7.fhir.r4.model.Measure) DateParameter(com.ibm.cohort.cql.evaluation.parameters.DateParameter) Parameter(com.ibm.cohort.cql.evaluation.parameters.Parameter) IntervalParameter(com.ibm.cohort.cql.evaluation.parameters.IntervalParameter) Library(org.hl7.fhir.r4.model.Library) IntervalParameter(com.ibm.cohort.cql.evaluation.parameters.IntervalParameter) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) IParser(ca.uhn.fhir.parser.IParser) Category(org.junit.experimental.categories.Category) Test(org.junit.Test)

Example 3 with Tag

use of org.hl7.cql_annotations.r1.Tag in project openmrs-module-fhir2 by openmrs.

the class LocationTagTranslatorImplTest method toOpenmrsType_shouldReturnExistingTagIfTagExists.

@Test
public void toOpenmrsType_shouldReturnExistingTagIfTagExists() {
    LocationTag omrsTag = new LocationTag(LAB_TAG_NAME, LAB_TAG_DESCRIPTION);
    Coding tag = new Coding();
    tag.setCode(LAB_TAG_NAME);
    tag.setDisplay(LAB_TAG_DESCRIPTION);
    when(fhirLocationDao.getLocationTagByName(tag.getCode())).thenReturn(omrsTag);
    LocationTag existingLocationTag = locationTagTranslatorImpl.toOpenmrsType(tag);
    assertThat(existingLocationTag, notNullValue());
    assertThat(existingLocationTag.getName(), is(LAB_TAG_NAME));
}
Also used : LocationTag(org.openmrs.LocationTag) Coding(org.hl7.fhir.r4.model.Coding) Test(org.junit.Test)

Example 4 with Tag

use of org.hl7.cql_annotations.r1.Tag in project openmrs-module-fhir2 by openmrs.

the class LocationTranslatorImplTest method toOpenmrsType_shouldTranslateFhirTagsToOpenmrsLocationTags.

@Test
public void toOpenmrsType_shouldTranslateFhirTagsToOpenmrsLocationTags() {
    LocationTag omrsTag = new LocationTag(LAB_TAG_NAME, LAB_TAG_DESCRIPTION);
    List<Coding> tags = new ArrayList<>();
    Coding tag = new Coding();
    tag.setCode(LAB_TAG_NAME);
    tag.setDisplay(LAB_TAG_DESCRIPTION);
    tags.add(tag);
    org.hl7.fhir.r4.model.Location fhirLocation = new org.hl7.fhir.r4.model.Location();
    fhirLocation.getMeta().setTag(tags);
    when(locationTagTranslator.toOpenmrsType(tag)).thenReturn(omrsTag);
    omrsLocation = locationTranslator.toOpenmrsType(fhirLocation);
    assertThat(omrsLocation.getTags(), notNullValue());
    assertThat(omrsLocation.getTags(), hasSize(greaterThanOrEqualTo(1)));
    assertThat(omrsLocation.getTags().iterator().next().getName(), is(LAB_TAG_NAME));
}
Also used : LocationTag(org.openmrs.LocationTag) Coding(org.hl7.fhir.r4.model.Coding) ArrayList(java.util.ArrayList) Location(org.openmrs.Location) Test(org.junit.Test)

Example 5 with Tag

use of org.hl7.cql_annotations.r1.Tag in project openmrs-module-fhir2 by openmrs.

the class LocationTranslatorImpl method toFhirResource.

/**
 * @see org.openmrs.module.fhir2.api.translators.LocationTranslator#toFhirResource(org.openmrs.Location)
 */
@Override
public Location toFhirResource(@Nonnull org.openmrs.Location openmrsLocation) {
    if (openmrsLocation == null) {
        return null;
    }
    Location fhirLocation = new Location();
    Location.LocationPositionComponent position = new Location.LocationPositionComponent();
    fhirLocation.setId(openmrsLocation.getUuid());
    fhirLocation.setName(getMetadataTranslation(openmrsLocation));
    fhirLocation.setDescription(openmrsLocation.getDescription());
    fhirLocation.setAddress(locationAddressTranslator.toFhirResource(openmrsLocation));
    double latitude = NumberUtils.toDouble(openmrsLocation.getLatitude(), -1.0d);
    if (latitude >= 0.0d) {
        position.setLatitude(latitude);
    }
    double longitude = NumberUtils.toDouble(openmrsLocation.getLongitude(), -1.0d);
    if (longitude >= 0.0d) {
        position.setLongitude(longitude);
    }
    fhirLocation.setPosition(position);
    if (!openmrsLocation.getRetired()) {
        fhirLocation.setStatus(Location.LocationStatus.ACTIVE);
    }
    if (openmrsLocation.getRetired()) {
        fhirLocation.setStatus(Location.LocationStatus.INACTIVE);
    }
    fhirLocation.setTelecom(getLocationContactDetails(openmrsLocation));
    if (openmrsLocation.getTags() != null) {
        for (LocationTag tag : openmrsLocation.getTags()) {
            fhirLocation.getMeta().addTag(FhirConstants.OPENMRS_FHIR_EXT_LOCATION_TAG, tag.getName(), tag.getDescription());
        }
    }
    if (openmrsLocation.getParentLocation() != null) {
        fhirLocation.setPartOf(createLocationReference(openmrsLocation.getParentLocation()));
    }
    fhirLocation.getMeta().setLastUpdated(openmrsLocation.getDateChanged());
    fhirLocation.addContained(provenanceTranslator.getCreateProvenance(openmrsLocation));
    fhirLocation.addContained(provenanceTranslator.getUpdateProvenance(openmrsLocation));
    return fhirLocation;
}
Also used : LocationTag(org.openmrs.LocationTag) Location(org.hl7.fhir.r4.model.Location)

Aggregations

Tag (org.openstreetmap.osmosis.core.domain.v0_6.Tag)66 Test (org.junit.Test)26 CommonEntityData (org.openstreetmap.osmosis.core.domain.v0_6.CommonEntityData)23 WayNode (org.openstreetmap.osmosis.core.domain.v0_6.WayNode)17 IOException (java.io.IOException)16 ArrayList (java.util.ArrayList)16 Node (org.openstreetmap.osmosis.core.domain.v0_6.Node)16 OsmUser (org.openstreetmap.osmosis.core.domain.v0_6.OsmUser)16 Date (java.util.Date)12 Way (org.openstreetmap.osmosis.core.domain.v0_6.Way)12 Coding (org.hl7.fhir.r4.model.Coding)10 RelationMember (org.openstreetmap.osmosis.core.domain.v0_6.RelationMember)10 OsmosisRuntimeException (org.openstreetmap.osmosis.core.OsmosisRuntimeException)9 Relation (org.openstreetmap.osmosis.core.domain.v0_6.Relation)9 Test (org.junit.jupiter.api.Test)7 SQLException (java.sql.SQLException)6 UUID (java.util.UUID)6 LocationTag (org.openmrs.LocationTag)6 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)5 Osmformat (crosby.binary.Osmformat)5