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

Invalid boundary reference range for lower limit #516

Open
quake1997 opened this issue Jan 2, 2024 · 0 comments
Open

Invalid boundary reference range for lower limit #516

quake1997 opened this issue Jan 2, 2024 · 0 comments

Comments

@quake1997
Copy link

quake1997 commented Jan 2, 2024

Describe the bug
Generated reference range for low boundary is incorrect

To Reproduce
For Cholesterol (2093-3) value >5 should determine lower limit but it's higher:

 "referenceRange" : [
          {
            "high" : {
              "value" : 5
            },
            "text" : ">5"
          }
        ]

    @Test
    void shouldCreateBundleResourceWithCorrectLowBoundaryReferenceRange() {
        //given
        var ftv = new HL7ToFHIRConverter();
        var hl7message = "MSH|^~\\&|SendingApp|SendingFac|ReceivingApp|ReceivingFac|20220101120000||ORU^R01|MSGID123456789012345|P|2.6\r" +
                "PID|1||123456||Doe^John^A^III||19700101|M|||123 Main St^^Anytown^CA^12345^USA||(555)555-5555\r" +
                "OBR|1|123456|78901234|Lipid Panel^L|||20220101110000|||||||555-44-3333^Smith^Bob^Dr.^MD^NPI987654321\r" +
                "OBX|1|NM|2093-3^Cholesterol^L|1.1|mmol/L||>5||F|||20220101113000\r";

        //when
        var res = (Bundle) context.getParser().parseResource(ftv.convert(hl7message));

        //then
        var referenceRange = res.getEntry().stream()
                                .map(Bundle.BundleEntryComponent::getResource)
                                .filter(r -> r instanceof Observation)
                                .map(Observation.class::cast)
                                .filter(o -> o.getCode().getCoding()
                                              .stream()
                                              .map(Coding::getCode)
                                              .anyMatch("2093-3"::equals))
                                .flatMap(o -> o.getReferenceRange().stream())
                                .findFirst()
                                .orElseThrow();

        assertEquals(new BigDecimal("5"), referenceRange.getLow().getValue());
    }

Expected behavior
The value 5 should be lower limit not higher

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant