Search in sources :

Example 86 with Use

use of org.hl7.fhir.r4.model.ExplanationOfBenefit.Use in project ab2d by CMSgov.

the class EndToEndBfdTests method disableContractWeDontNeed.

/**
 * For all but the contract we want to use, disable them
 */
private void disableContractWeDontNeed() {
    List<PdpClient> clients = pdpClientRepository.findAllByEnabledTrue().stream().filter(client -> client.getContract().getAttestedOn() != null).collect(toList());
    for (PdpClient pdp : clients) {
        if (!pdp.getContract().getContractNumber().equals(CONTRACT_TO_USE)) {
            pdp.setEnabled(false);
            pdpClientRepository.save(pdp);
        }
    }
}
Also used : BeforeEach(org.junit.jupiter.api.BeforeEach) JobPreProcessor(gov.cms.ab2d.worker.processor.JobPreProcessor) Autowired(org.springframework.beans.factory.annotation.Autowired) STU3(gov.cms.ab2d.fhir.FhirVersion.STU3) JobProgressService(gov.cms.ab2d.worker.processor.JobProgressService) Constants(gov.cms.ab2d.common.util.Constants) R4(gov.cms.ab2d.fhir.FhirVersion.R4) ContractRepository(gov.cms.ab2d.common.repository.ContractRepository) PdpClientRepository(gov.cms.ab2d.common.repository.PdpClientRepository) JobProcessor(gov.cms.ab2d.worker.processor.JobProcessor) ExtendWith(org.junit.jupiter.api.extension.ExtendWith) LoggerEventSummary(gov.cms.ab2d.eventlogger.reports.sql.LoggerEventSummary) PropertiesDTO(gov.cms.ab2d.common.dto.PropertiesDTO) EOB(gov.cms.ab2d.fhir.BundleUtils.EOB) JobOutput(gov.cms.ab2d.common.model.JobOutput) Path(java.nio.file.Path) MethodSource(org.junit.jupiter.params.provider.MethodSource) Resource(org.springframework.core.io.Resource) CoverageProcessorImpl(gov.cms.ab2d.worker.processor.coverage.CoverageProcessorImpl) MockitoExtension(org.mockito.junit.jupiter.MockitoExtension) JobChannelService(gov.cms.ab2d.worker.service.JobChannelService) CoverageDriver(gov.cms.ab2d.worker.processor.coverage.CoverageDriver) Contract(gov.cms.ab2d.common.model.Contract) CoverageSearchRepository(gov.cms.ab2d.coverage.repository.CoverageSearchRepository) BlockingQueue(java.util.concurrent.BlockingQueue) ContractProcessor(gov.cms.ab2d.worker.processor.ContractProcessor) UUID(java.util.UUID) IdentifierUtils(gov.cms.ab2d.fhir.IdentifierUtils) Arguments(org.junit.jupiter.params.provider.Arguments) FhirVersion(gov.cms.ab2d.fhir.FhirVersion) Collectors(java.util.stream.Collectors) CoverageService(gov.cms.ab2d.coverage.service.CoverageService) Test(org.junit.jupiter.api.Test) JobOutputService(gov.cms.ab2d.common.service.JobOutputService) Slf4j(lombok.extern.slf4j.Slf4j) List(java.util.List) IDomainResource(org.hl7.fhir.instance.model.api.IDomainResource) OffsetDateTime(java.time.OffsetDateTime) Stream(java.util.stream.Stream) PatientIdentifier(gov.cms.ab2d.fhir.PatientIdentifier) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) TempDir(org.junit.jupiter.api.io.TempDir) JobPreProcessorImpl(gov.cms.ab2d.worker.processor.JobPreProcessorImpl) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) PropertiesService(gov.cms.ab2d.common.service.PropertiesService) CoverageMapping(gov.cms.ab2d.coverage.model.CoverageMapping) PdpClientService(gov.cms.ab2d.common.service.PdpClientService) Optional(java.util.Optional) CoverageSearch(gov.cms.ab2d.coverage.model.CoverageSearch) BFDClient(gov.cms.ab2d.bfd.client.BFDClient) CoverageDriverImpl(gov.cms.ab2d.worker.processor.coverage.CoverageDriverImpl) FileServiceImpl(gov.cms.ab2d.worker.service.FileServiceImpl) Assertions.assertNotNull(org.junit.jupiter.api.Assertions.assertNotNull) PdpClient(gov.cms.ab2d.common.model.PdpClient) UrlResource(org.springframework.core.io.UrlResource) Mock(org.mockito.Mock) AB2DPostgresqlContainer(gov.cms.ab2d.common.util.AB2DPostgresqlContainer) Assertions.assertNull(org.junit.jupiter.api.Assertions.assertNull) PostgreSQLContainer(org.testcontainers.containers.PostgreSQLContainer) JobRepository(gov.cms.ab2d.common.repository.JobRepository) IBaseBundle(org.hl7.fhir.instance.model.api.IBaseBundle) InvalidContractException(gov.cms.ab2d.common.service.InvalidContractException) ArrayList(java.util.ArrayList) CoverageLockWrapper(gov.cms.ab2d.worker.processor.coverage.CoverageLockWrapper) ContractToContractCoverageMapping(gov.cms.ab2d.worker.config.ContractToContractCoverageMapping) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) Arguments.arguments(org.junit.jupiter.params.provider.Arguments.arguments) SinceSource(gov.cms.ab2d.common.model.SinceSource) Container(org.testcontainers.junit.jupiter.Container) JobService(gov.cms.ab2d.common.service.JobService) JobProgressUpdateService(gov.cms.ab2d.worker.processor.JobProgressUpdateService) ContractWorkerClient(gov.cms.ab2d.worker.service.ContractWorkerClient) LogManager(gov.cms.ab2d.eventlogger.LogManager) JobProcessorImpl(gov.cms.ab2d.worker.processor.JobProcessorImpl) Testcontainers(org.testcontainers.junit.jupiter.Testcontainers) Job(gov.cms.ab2d.common.model.Job) BundleUtils(gov.cms.ab2d.fhir.BundleUtils) ReflectionTestUtils(org.springframework.test.util.ReflectionTestUtils) CoverageProcessor(gov.cms.ab2d.worker.processor.coverage.CoverageProcessor) File(java.io.File) JobStatus(gov.cms.ab2d.common.model.JobStatus) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) Collectors.toList(java.util.stream.Collectors.toList) JobOutputRepository(gov.cms.ab2d.common.repository.JobOutputRepository) Paths(java.nio.file.Paths) Assertions(org.junit.jupiter.api.Assertions) JobServiceImpl(gov.cms.ab2d.common.service.JobServiceImpl) PdpClient(gov.cms.ab2d.common.model.PdpClient)

Example 87 with Use

use of org.hl7.fhir.r4.model.ExplanationOfBenefit.Use in project org.hl7.fhir.core by hapifhir.

the class ICD11Generator method buildValueSet.

private String buildValueSet(CodeSystem cs, String code, String name, JsonObject o, String dest) throws IOException {
    String id = code + "-" + name;
    String url = "http://id.who.int/icd11/ValueSet/" + id;
    ValueSet vs = new ValueSet();
    vs.setId(id);
    vs.setUrl(url);
    vs.setName("VS" + name + "4" + code);
    vs.setTitle("Value Set for " + name + " on " + code);
    vs.setStatus(PublicationStatus.ACTIVE);
    vs.setExperimental(false);
    vs.setDate(cs.getDate());
    vs.setPublisher("WHO");
    vs.setCopyright("Consult WHO For terms of use");
    vs.setVersion(cs.getVersion());
    vs.setStatus(cs.getStatus());
    ConceptSetComponent inc = vs.getCompose().addInclude();
    inc.setSystem(cs.getUrl());
    for (JsonElement e : o.getAsJsonArray("scaleEntity")) {
        inc.addFilter().setProperty("concept").setOp(FilterOperator.ISA).setValue(tail(e.getAsString()));
    }
    new XmlParser(XmlVersion.V1_1).setOutputStyle(OutputStyle.PRETTY).compose(new FileOutputStream(Utilities.path(dest, "vs-" + id + ".xml")), vs);
    return url;
}
Also used : ConceptSetComponent(org.hl7.fhir.r4.model.ValueSet.ConceptSetComponent) XmlParser(org.hl7.fhir.r4.formats.XmlParser) JsonElement(com.google.gson.JsonElement) FileOutputStream(java.io.FileOutputStream)

Example 88 with Use

use of org.hl7.fhir.r4.model.ExplanationOfBenefit.Use in project org.hl7.fhir.core by hapifhir.

the class IEEE11073Convertor method generateLoincMdcMap.

private static ConceptMap generateLoincMdcMap(CodeSystem mdc, String dst, String src) throws IOException, FHIRException {
    ConceptMap cm = new ConceptMap();
    cm.setId("loinc-mdc");
    cm.setUrl("http:/???/fhir/ConceptMap/loinc-mdc");
    cm.setVersion("[todo]");
    cm.setName("LoincMdcCrossMap");
    cm.setTitle("Cross Map between LOINC and MDC");
    cm.setStatus(PublicationStatus.DRAFT);
    cm.setExperimental(true);
    cm.setDateElement(new DateTimeType());
    cm.setPublisher("HL7, Inc");
    ContactDetail cd = cm.addContact();
    cd.setName("LOINC + IEEE");
    ContactPoint cp = cd.addTelecom();
    cp.setSystem(ContactPointSystem.URL);
    cp.setValue("http://loinc.org");
    cm.setDescription("A Cross Map between the LOINC and MDC Code systems");
    cm.setPurpose("To implementers map between medical device codes and LOINC codes");
    cm.setCopyright("This content LOINC \u00ae is copyright \u00a9 1995 Regenstrief Institute, Inc. and the LOINC Committee, and available at no cost under the license at http://loinc.org/terms-of-use");
    cm.setSource(new UriType("http://loinc.org/vs"));
    cm.setTarget(new UriType(MDC_ALL_VALUES));
    ConceptMapGroupComponent g = cm.addGroup();
    g.setSource("urn:iso:std:iso:11073:10101");
    g.setTarget("http://loinc.org");
    CSVReader csv = new CSVReader(new FileInputStream(src));
    csv.readHeaders();
    while (csv.line()) {
        SourceElementComponent e = g.addElement();
        e.setCode(csv.cell("IEEE_CF_CODE10"));
        e.setDisplay(csv.cell("IEEE_DESCRIPTION"));
        TargetElementComponent t = e.addTarget();
        t.setEquivalence(ConceptMapEquivalence.EQUIVALENT);
        t.setCode(csv.cell("LOINC_NUM"));
        t.setDisplay(csv.cell("LOINC_LONG_COMMON_NAME"));
    }
    new XmlParser().setOutputStyle(OutputStyle.PRETTY).compose(new FileOutputStream(Utilities.path(dst, "conceptmap-" + cm.getId() + ".xml")), cm);
    System.out.println("Done");
    return cm;
}
Also used : XmlParser(org.hl7.fhir.dstu3.formats.XmlParser) CSVReader(org.hl7.fhir.utilities.CSVReader) FileOutputStream(java.io.FileOutputStream) TargetElementComponent(org.hl7.fhir.dstu3.model.ConceptMap.TargetElementComponent) ConceptMapGroupComponent(org.hl7.fhir.dstu3.model.ConceptMap.ConceptMapGroupComponent) FileInputStream(java.io.FileInputStream) SourceElementComponent(org.hl7.fhir.dstu3.model.ConceptMap.SourceElementComponent)

Example 89 with Use

use of org.hl7.fhir.r4.model.ExplanationOfBenefit.Use in project org.hl7.fhir.core by hapifhir.

the class IEEE11073Convertor method generateMDC.

public static CodeSystem generateMDC(String src, String dst, UcumService ucum) throws IOException, FHIRException {
    CSVReader csv = new CSVReader(new FileInputStream(src));
    csv.readHeaders();
    CodeSystem cs = new CodeSystem();
    Map<String, String> ucumIssues = new HashMap<String, String>();
    int errorCount = 0;
    cs.setId("MDC");
    cs.setUrl("urn:iso:std:iso:11073:10101");
    cs.setVersion("[todo]");
    cs.setName("11073:10101 codes for the FHIR community");
    cs.setStatus(PublicationStatus.ACTIVE);
    cs.setExperimental(false);
    cs.setDateElement(new DateTimeType());
    cs.setPublisher("HL7 (FHIR Project)");
    ContactDetail cd = cs.addContact();
    ContactPoint cp = cd.addTelecom();
    cp.setSystem(ContactPointSystem.URL);
    cp.setValue("http://ieee?");
    cs.setDescription("1073 Codes for the FHIR community (generated from the Rosetta data");
    Identifier i = new Identifier();
    cs.setIdentifier(i);
    i.setSystem("urn:ietf:rfc:3986");
    i.setValue("urn:oid:2.16.840.1.113883.6.24");
    cs.setCaseSensitive(false);
    cs.setContent(CodeSystemContentMode.COMPLETE);
    cs.addProperty().setCode("ucum").setDescription("UCUM units associated with Concept").setType(PropertyType.STRING);
    cs.addProperty().setCode("unit").setDescription("MDC units associated with Concept").setType(PropertyType.STRING);
    cs.addProperty().setCode("refid").setDescription("MDC Reference Id for Concept").setType(PropertyType.CODE);
    Set<String> codes = new HashSet<String>();
    while (csv.line()) {
        if (csv.has("CF_CODE10")) {
            String code = csv.cell("CF_CODE10");
            if (codes.contains(code))
                System.out.println("Duplicate Code " + code);
            else {
                codes.add(code);
                ConceptDefinitionComponent c = cs.addConcept();
                c.setCode(code);
                c.setDisplay(csv.cell("Common Term"));
                c.setDefinition(csv.cell("Term Description"));
                String vd = csv.cell("Vendor_Description");
                if (!c.hasDefinition())
                    c.setDefinition(vd);
                if (!c.hasDisplay())
                    c.setDisplay(vd);
                String refid = csv.cell("REFID");
                c.addProperty().setCode("refid").setValue(new CodeType().setValue(refid));
                if (csv.has("Synonym"))
                    c.addDesignation().setValue(csv.cell("Synonym")).setUse(new Coding().setSystem("http://hl7.org/fhir/designation-use").setCode("synonym"));
                if (csv.has("Acronym"))
                    c.addDesignation().setValue(csv.cell("Acronym")).setUse(new Coding().setSystem("http://hl7.org/fhir/designation-use").setDisplay("acronym"));
                if (csv.has("Systematic Name")) {
                    String sysName = csv.cell("Systematic Name");
                    if (!c.hasDefinition())
                        c.setDefinition(sysName);
                    c.addDesignation().setValue(sysName).setUse(new Coding().setSystem("http://hl7.org/fhir/designation-use").setCode("structured-name"));
                }
                if (csv.has("UOM_MDC"))
                    c.addProperty().setCode("unit").setValue(new StringType().setValue(csv.cell("UOM_MDC")));
                if (csv.has("UOM_UCUM")) {
                    CommaSeparatedStringBuilder ul = new CommaSeparatedStringBuilder();
                    for (String u : csv.cell("UOM_UCUM").split(" ")) {
                        String msg = ucum.validate(u);
                        if (msg != null) {
                            errorCount++;
                            ucumIssues.put(u, msg);
                        } else
                            ul.append(u);
                    }
                    if (ul.length() > 0)
                        c.addProperty().setCode("ucum").setValue(new StringType().setValue(ul.toString()));
                }
            }
        }
    }
    csv.close();
    new XmlParser().setOutputStyle(OutputStyle.PRETTY).compose(new FileOutputStream(Utilities.path(dst, "codesystem-" + cs.getId() + ".xml")), cs);
    System.out.println(errorCount + "UCUM errors");
    for (String u : sorted(ucumIssues.keySet())) System.out.println("Invalid UCUM code: " + u + " because " + ucumIssues.get(u));
    return cs;
}
Also used : XmlParser(org.hl7.fhir.dstu3.formats.XmlParser) CSVReader(org.hl7.fhir.utilities.CSVReader) CommaSeparatedStringBuilder(org.hl7.fhir.utilities.CommaSeparatedStringBuilder) FileInputStream(java.io.FileInputStream) ConceptDefinitionComponent(org.hl7.fhir.dstu3.model.CodeSystem.ConceptDefinitionComponent) FileOutputStream(java.io.FileOutputStream)

Example 90 with Use

use of org.hl7.fhir.r4.model.ExplanationOfBenefit.Use in project org.hl7.fhir.core by hapifhir.

the class CCDAConverter method processSocialObservation.

protected void processSocialObservation(ListResource list, Element so, SocialHistoryType type) throws Exception {
    Observation obs = new Observation();
    addItemToList(list, obs);
    switch(type) {
        case SocialHistory:
            cda.checkTemplateId(so, "2.16.840.1.113883.10.20.22.4.38");
            // SHALL contain exactly one [1..1] code (CONF:8558/).
            obs.setCode(convert.makeCodeableConceptFromCD(cda.getChild(so, "code")));
            break;
        case Pregnancy:
            cda.checkTemplateId(so, "2.16.840.1.113883.10.20.15.3.8");
            // SHALL contain exactly one [1..1] code (CONF:8558/), which SHALL be an assertion
            obs.setCode(Factory.newCodeableConcept("11449-6", "http://loinc.org", "Pregnancy Status"));
            break;
        case SmokingStatus:
            cda.checkTemplateId(so, "2.16.840.1.113883.10.20.22.4.78");
            // SHALL contain exactly one [1..1] code (CONF:8558/), which SHALL be an assertion
            obs.setCode(Factory.newCodeableConcept("72166-2", "http://loinc.org", "Tobacco Smoking Status"));
            break;
        case TobaccoUse:
            cda.checkTemplateId(so, "2.16.840.1.113883.10.20.22.4.12");
            // SHALL contain exactly one [1..1] code (CONF:8558/), which SHALL be an assertion
            obs.setCode(Factory.newCodeableConcept("11367-0", "http://loinc.org", "History of Tobacco Use"));
    }
    // SHALL contain at least one [1..*] id (8551).
    for (Element e : cda.getChildren(so, "id")) obs.getIdentifier().add(convert.makeIdentifierFromII(e));
    // SHALL contain exactly one [1..1] statusCode (CONF:8553/455/14809).
    // a.	This statusCode SHALL contain exactly one [1..1] @code="completed" Completed (CodeSystem: ActStatus 2.16.840.1.113883.5.14 STATIC) (CONF:19117).
    obs.setStatus(ObservationStatus.FINAL);
    // SHOULD contain zero or one [0..1] effectiveTime (CONF:2018/14814).
    // for smoking status/tobacco: low only. in R2, this is just value. So we treat low only as just a value
    Element et = cda.getChild(so, "effectiveTime");
    if (et != null) {
        if (cda.getChild(et, "low") != null)
            obs.setEffective(convert.makeDateTimeFromTS(cda.getChild(et, "low")));
        else
            obs.setEffective(convert.makeDateTimeFromIVL(et));
    }
    // a.	Observation/value can be any data type.
    for (Element e : cda.getChildren(so, "value")) if (obs.getValue() == null) {
        // special case for pregnancy:
        if (type == SocialHistoryType.Pregnancy && "true".equals(e.getAttribute("negationInd"))) {
            obs.setValue(Factory.newCodeableConcept("60001007", "http://snomed.info/sct", "Not pregnant"));
        } else {
            // negationInd is not described. but it might well be used. For now, we blow up
            checkNoNegation(so, "Social Observation (" + type + ")");
            if (so.hasAttribute("nullFlavor"))
                obs.setValue(convert.makeCodeableConceptFromNullFlavor(so.getAttribute("nullFlavor")));
            else if (e.hasAttribute("nullFlavor") && !"OTH".equals(e.getAttribute("nullFlavor")))
                obs.setValue(convert.makeCodeableConceptFromNullFlavor(e.getAttribute("nullFlavor")));
            else
                obs.setValue(convert.makeTypeFromANY(e));
        }
    } else
        throw new Exception("too many values on Social Observation");
    if (type == SocialHistoryType.Pregnancy) {
        for (Element e : cda.getChildren(so, "entyRelationship")) {
            Element dd = cda.getChild(e, "observation");
            checkNoNegationOrNullFlavor(dd, "Estimated Date of Delivery");
            // MAY contain zero or one [0..1] entryRelationship (CONF:458) such that it
            // SHALL contain exactly one [1..1] @typeCode="REFR" Refers to (CodeSystem: HL7ActRelationshipType 2.16.840.1.113883.5.1002 STATIC) (CONF:459).
            // SHALL contain exactly one [1..1] Estimated Date of Delivery (templateId:2.16.840.1.113883.10.20.15.3.1) (CONF:15584).
            Observation co = new Observation();
            String id = nextRef();
            co.setId(id);
            obs.getContained().add(co);
            ObservationRelatedComponent or = new ObservationRelatedComponent();
            obs.getRelated().add(or);
            or.setType(ObservationRelationshipType.HASMEMBER);
            or.setTarget(Factory.makeReference("#" + id));
            co.setCode(Factory.newCodeableConcept("11778-8", "http://loinc.org", "Delivery date Estimated"));
            // not legal, see gForge http://gforge.hl7.org/gf/project/fhir/tracker/?action=TrackerItemEdit&tracker_item_id=3125&start=0
            co.setValue(convert.makeDateTimeFromTS(cda.getChild(dd, "value")));
        }
    }
}
Also used : Element(org.w3c.dom.Element) ObservationRelatedComponent(org.hl7.fhir.dstu3.model.Observation.ObservationRelatedComponent)

Aggregations

ArrayList (java.util.ArrayList)82 BundleEntryComponent (org.hl7.fhir.r4.model.Bundle.BundleEntryComponent)43 List (java.util.List)41 FHIRException (org.hl7.fhir.exceptions.FHIRException)40 Date (java.util.Date)39 IOException (java.io.IOException)38 CodeableConcept (org.hl7.fhir.r4.model.CodeableConcept)35 Test (org.junit.jupiter.api.Test)35 Resource (org.hl7.fhir.r4.model.Resource)34 Collectors (java.util.stream.Collectors)29 Coding (org.hl7.fhir.r4.model.Coding)27 Reference (org.hl7.fhir.r4.model.Reference)27 Timer (com.codahale.metrics.Timer)26 HashMap (java.util.HashMap)25 Bundle (org.hl7.fhir.r4.model.Bundle)25 Reference (org.hl7.fhir.dstu3.model.Reference)24 XhtmlNode (org.hl7.fhir.utilities.xhtml.XhtmlNode)23 CodeableConcept (org.hl7.fhir.dstu3.model.CodeableConcept)21 DefinitionException (org.hl7.fhir.exceptions.DefinitionException)21 JsonObject (com.google.gson.JsonObject)20