Search in sources :

Example 1 with LOINC_URI

use of org.mitre.synthea.TestHelper.LOINC_URI in project synthea by synthetichealth.

the class CodeResolveAndExportTest method verifyEncounterCodeStu3.

private void verifyEncounterCodeStu3() throws IOException {
    InputStream inputStream = new FileInputStream(stu3OutputPath.toFile().getAbsolutePath());
    Bundle bundle = (Bundle) FhirStu3.getContext().newJsonParser().parseResource(inputStream);
    // Find encounter reason code.
    Optional<BundleEntryComponent> maybeEncounterEntry = bundle.getEntry().stream().filter(entry -> entry.getResource().getResourceType().equals(ResourceType.Encounter)).findFirst();
    assertTrue(maybeEncounterEntry.isPresent());
    org.hl7.fhir.dstu3.model.Encounter encounterResource = (org.hl7.fhir.dstu3.model.Encounter) maybeEncounterEntry.get().getResource();
    assertEquals(encounterResource.getReason().size(), 1);
    CodeableConcept encounterReason = encounterResource.getReason().get(0);
    assertEquals(encounterReason.getCoding().size(), 1);
    Coding reasonCoding = encounterReason.getCoding().get(0);
    // Check encounter reason code.
    assertEquals(SNOMED_URI, reasonCoding.getSystem());
    assertEquals(EXPECTED_REASON_CODE, reasonCoding.getCode());
    assertEquals(EXPECTED_REASON_DISPLAY, reasonCoding.getDisplay());
    Optional<BundleEntryComponent> maybeObservationEntry = bundle.getEntry().stream().filter(entry -> entry.getResource().getResourceType().equals(ResourceType.Observation)).findFirst();
    assertTrue(maybeObservationEntry.isPresent());
    // Find observation type code.
    org.hl7.fhir.dstu3.model.Observation observationResource = (org.hl7.fhir.dstu3.model.Observation) maybeObservationEntry.get().getResource();
    CodeableConcept observationType = observationResource.getCode();
    assertNotNull(observationType);
    assertEquals(observationType.getCoding().size(), 1);
    Coding observationTypeCoding = observationType.getCoding().get(0);
    // Check observation type code.
    assertEquals(LOINC_URI, observationTypeCoding.getSystem());
    assertEquals(OBSERVATION_CODE, observationTypeCoding.getCode());
    assertEquals(OBSERVATION_DISPLAY, observationTypeCoding.getDisplay());
    // Find observation value code.
    CodeableConcept observationValue = observationResource.getValueCodeableConcept();
    assertNotNull(observationValue);
    assertEquals(observationValue.getCoding().size(), 1);
    Coding observationValueCoding = observationValue.getCoding().get(0);
    // Check observation value code.
    assertEquals(LOINC_URI, observationValueCoding.getSystem());
    assertEquals(EXPECTED_VALUE_CODE, observationValueCoding.getCode());
    assertEquals(EXPECTED_VALUE_DISPLAY, observationValueCoding.getDisplay());
    inputStream.close();
}
Also used : TestHelper.years(org.mitre.synthea.TestHelper.years) Arrays(java.util.Arrays) XPathExpressionException(javax.xml.xpath.XPathExpressionException) Location(org.mitre.synthea.world.geography.Location) Bundle(org.hl7.fhir.dstu3.model.Bundle) BundleEntryComponent(org.hl7.fhir.dstu3.model.Bundle.BundleEntryComponent) Coding(org.hl7.fhir.dstu3.model.Coding) CodeableConcept(org.hl7.fhir.dstu3.model.CodeableConcept) Person(org.mitre.synthea.world.agents.Person) Document(org.w3c.dom.Document) After(org.junit.After) Path(java.nio.file.Path) Encounter(org.mitre.synthea.world.concepts.HealthRecord.Encounter) RestTemplate(org.springframework.web.client.RestTemplate) RandomCodeGenerator(org.mitre.synthea.helpers.RandomCodeGenerator) List(java.util.List) SAXException(org.xml.sax.SAXException) LOINC_URI(org.mitre.synthea.TestHelper.LOINC_URI) Optional(java.util.Optional) TestHelper(org.mitre.synthea.TestHelper) DocumentBuilderFactory(javax.xml.parsers.DocumentBuilderFactory) EncounterType(org.mitre.synthea.world.concepts.HealthRecord.EncounterType) XPath(javax.xml.xpath.XPath) XPathConstants(javax.xml.xpath.XPathConstants) SimpleDateFormat(java.text.SimpleDateFormat) TestHelper.isHttpRecordingEnabled(org.mitre.synthea.TestHelper.isHttpRecordingEnabled) XPathExpression(javax.xml.xpath.XPathExpression) Generator(org.mitre.synthea.engine.Generator) CodingDt(ca.uhn.fhir.model.dstu2.composite.CodingDt) WireMock(com.github.tomakehurst.wiremock.client.WireMock) CodeableConceptDt(ca.uhn.fhir.model.dstu2.composite.CodeableConceptDt) WireMockRule(com.github.tomakehurst.wiremock.junit.WireMockRule) ResourceType(org.hl7.fhir.dstu3.model.ResourceType) Node(org.w3c.dom.Node) Code(org.mitre.synthea.world.concepts.HealthRecord.Code) LOINC_OID(org.mitre.synthea.TestHelper.LOINC_OID) Before(org.junit.Before) TestHelper.wiremockOptions(org.mitre.synthea.TestHelper.wiremockOptions) Config(org.mitre.synthea.helpers.Config) NodeList(org.w3c.dom.NodeList) Assert.assertNotNull(org.junit.Assert.assertNotNull) Assert.assertTrue(org.junit.Assert.assertTrue) IOException(java.io.IOException) Test(org.junit.Test) FileInputStream(java.io.FileInputStream) Payer(org.mitre.synthea.world.agents.Payer) File(java.io.File) Provider(org.mitre.synthea.world.agents.Provider) SNOMED_URI(org.mitre.synthea.TestHelper.SNOMED_URI) XPathFactory(javax.xml.xpath.XPathFactory) Rule(org.junit.Rule) Entry(ca.uhn.fhir.model.dstu2.resource.Bundle.Entry) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException) DocumentBuilder(javax.xml.parsers.DocumentBuilder) ProviderTest(org.mitre.synthea.world.agents.ProviderTest) Assert.assertEquals(org.junit.Assert.assertEquals) TestHelper.getTxRecordingSource(org.mitre.synthea.TestHelper.getTxRecordingSource) InputStream(java.io.InputStream) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) Bundle(org.hl7.fhir.dstu3.model.Bundle) FileInputStream(java.io.FileInputStream) BundleEntryComponent(org.hl7.fhir.dstu3.model.Bundle.BundleEntryComponent) Coding(org.hl7.fhir.dstu3.model.Coding) Encounter(org.mitre.synthea.world.concepts.HealthRecord.Encounter) CodeableConcept(org.hl7.fhir.dstu3.model.CodeableConcept)

Example 2 with LOINC_URI

use of org.mitre.synthea.TestHelper.LOINC_URI in project synthea by synthetichealth.

the class CodeResolveAndExportTest method verifyEncounterCodeR4.

private void verifyEncounterCodeR4() throws IOException {
    InputStream inputStream = new FileInputStream(r4OutputPath.toFile().getAbsolutePath());
    org.hl7.fhir.r4.model.Bundle bundle = (org.hl7.fhir.r4.model.Bundle) FhirR4.getContext().newJsonParser().parseResource(inputStream);
    // Find encounter reason code.
    Optional<org.hl7.fhir.r4.model.Bundle.BundleEntryComponent> maybeEncounterEntry = bundle.getEntry().stream().filter(entry -> entry.getResource().getResourceType().equals(org.hl7.fhir.r4.model.ResourceType.Encounter)).findFirst();
    assertTrue(maybeEncounterEntry.isPresent());
    org.hl7.fhir.r4.model.Encounter encounterResource = (org.hl7.fhir.r4.model.Encounter) maybeEncounterEntry.get().getResource();
    assertEquals(encounterResource.getReasonCode().size(), 1);
    org.hl7.fhir.r4.model.CodeableConcept encounterReason = encounterResource.getReasonCode().get(0);
    assertEquals(encounterReason.getCoding().size(), 1);
    org.hl7.fhir.r4.model.Coding reasonCoding = encounterReason.getCoding().get(0);
    // Check encounter reason code.
    assertEquals(SNOMED_URI, reasonCoding.getSystem());
    assertEquals(EXPECTED_REASON_CODE, reasonCoding.getCode());
    assertEquals(EXPECTED_REASON_DISPLAY, reasonCoding.getDisplay());
    Optional<org.hl7.fhir.r4.model.Bundle.BundleEntryComponent> maybeObservationEntry = bundle.getEntry().stream().filter(entry -> entry.getResource().getResourceType().equals(org.hl7.fhir.r4.model.ResourceType.Observation)).findFirst();
    assertTrue(maybeObservationEntry.isPresent());
    // Find observation type code.
    org.hl7.fhir.r4.model.Observation observationResource = (org.hl7.fhir.r4.model.Observation) maybeObservationEntry.get().getResource();
    org.hl7.fhir.r4.model.CodeableConcept observationType = observationResource.getCode();
    assertNotNull(observationType);
    assertEquals(observationType.getCoding().size(), 1);
    org.hl7.fhir.r4.model.Coding observationTypeCoding = observationType.getCoding().get(0);
    // Check observation type code.
    assertEquals(LOINC_URI, observationTypeCoding.getSystem());
    assertEquals(OBSERVATION_CODE, observationTypeCoding.getCode());
    assertEquals(OBSERVATION_DISPLAY, observationTypeCoding.getDisplay());
    // Find observation value code.
    org.hl7.fhir.r4.model.CodeableConcept observationValue = observationResource.getValueCodeableConcept();
    assertNotNull(observationValue);
    assertEquals(observationValue.getCoding().size(), 1);
    org.hl7.fhir.r4.model.Coding observationValueCoding = observationValue.getCoding().get(0);
    // Check observation value code.
    assertEquals(LOINC_URI, observationValueCoding.getSystem());
    assertEquals(EXPECTED_VALUE_CODE, observationValueCoding.getCode());
    assertEquals(EXPECTED_VALUE_DISPLAY, observationValueCoding.getDisplay());
    inputStream.close();
}
Also used : TestHelper.years(org.mitre.synthea.TestHelper.years) Arrays(java.util.Arrays) XPathExpressionException(javax.xml.xpath.XPathExpressionException) Location(org.mitre.synthea.world.geography.Location) Bundle(org.hl7.fhir.dstu3.model.Bundle) BundleEntryComponent(org.hl7.fhir.dstu3.model.Bundle.BundleEntryComponent) Coding(org.hl7.fhir.dstu3.model.Coding) CodeableConcept(org.hl7.fhir.dstu3.model.CodeableConcept) Person(org.mitre.synthea.world.agents.Person) Document(org.w3c.dom.Document) After(org.junit.After) Path(java.nio.file.Path) Encounter(org.mitre.synthea.world.concepts.HealthRecord.Encounter) RestTemplate(org.springframework.web.client.RestTemplate) RandomCodeGenerator(org.mitre.synthea.helpers.RandomCodeGenerator) List(java.util.List) SAXException(org.xml.sax.SAXException) LOINC_URI(org.mitre.synthea.TestHelper.LOINC_URI) Optional(java.util.Optional) TestHelper(org.mitre.synthea.TestHelper) DocumentBuilderFactory(javax.xml.parsers.DocumentBuilderFactory) EncounterType(org.mitre.synthea.world.concepts.HealthRecord.EncounterType) XPath(javax.xml.xpath.XPath) XPathConstants(javax.xml.xpath.XPathConstants) SimpleDateFormat(java.text.SimpleDateFormat) TestHelper.isHttpRecordingEnabled(org.mitre.synthea.TestHelper.isHttpRecordingEnabled) XPathExpression(javax.xml.xpath.XPathExpression) Generator(org.mitre.synthea.engine.Generator) CodingDt(ca.uhn.fhir.model.dstu2.composite.CodingDt) WireMock(com.github.tomakehurst.wiremock.client.WireMock) CodeableConceptDt(ca.uhn.fhir.model.dstu2.composite.CodeableConceptDt) WireMockRule(com.github.tomakehurst.wiremock.junit.WireMockRule) ResourceType(org.hl7.fhir.dstu3.model.ResourceType) Node(org.w3c.dom.Node) Code(org.mitre.synthea.world.concepts.HealthRecord.Code) LOINC_OID(org.mitre.synthea.TestHelper.LOINC_OID) Before(org.junit.Before) TestHelper.wiremockOptions(org.mitre.synthea.TestHelper.wiremockOptions) Config(org.mitre.synthea.helpers.Config) NodeList(org.w3c.dom.NodeList) Assert.assertNotNull(org.junit.Assert.assertNotNull) Assert.assertTrue(org.junit.Assert.assertTrue) IOException(java.io.IOException) Test(org.junit.Test) FileInputStream(java.io.FileInputStream) Payer(org.mitre.synthea.world.agents.Payer) File(java.io.File) Provider(org.mitre.synthea.world.agents.Provider) SNOMED_URI(org.mitre.synthea.TestHelper.SNOMED_URI) XPathFactory(javax.xml.xpath.XPathFactory) Rule(org.junit.Rule) Entry(ca.uhn.fhir.model.dstu2.resource.Bundle.Entry) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException) DocumentBuilder(javax.xml.parsers.DocumentBuilder) ProviderTest(org.mitre.synthea.world.agents.ProviderTest) Assert.assertEquals(org.junit.Assert.assertEquals) TestHelper.getTxRecordingSource(org.mitre.synthea.TestHelper.getTxRecordingSource) InputStream(java.io.InputStream) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) Bundle(org.hl7.fhir.dstu3.model.Bundle) FileInputStream(java.io.FileInputStream) BundleEntryComponent(org.hl7.fhir.dstu3.model.Bundle.BundleEntryComponent) Encounter(org.mitre.synthea.world.concepts.HealthRecord.Encounter)

Example 3 with LOINC_URI

use of org.mitre.synthea.TestHelper.LOINC_URI in project synthea by synthetichealth.

the class CodeResolveAndExportTest method verifyEncounterCodeDstu2.

private void verifyEncounterCodeDstu2() throws IOException {
    InputStream inputStream = new FileInputStream(dstu2OutputPath.toFile().getAbsolutePath());
    ca.uhn.fhir.model.dstu2.resource.Bundle bundle = (ca.uhn.fhir.model.dstu2.resource.Bundle) FhirDstu2.getContext().newJsonParser().parseResource(inputStream);
    // Find encounter reason code.
    Optional<Entry> maybeEncounterEntry = bundle.getEntry().stream().filter(entry -> entry.getResource().getResourceName().equals(org.hl7.fhir.dstu2.model.ResourceType.Encounter.name())).findFirst();
    assertTrue(maybeEncounterEntry.isPresent());
    ca.uhn.fhir.model.dstu2.resource.Encounter encounterResource = (ca.uhn.fhir.model.dstu2.resource.Encounter) maybeEncounterEntry.get().getResource();
    assertEquals(encounterResource.getReason().size(), 1);
    CodeableConceptDt encounterReason = encounterResource.getReason().get(0);
    assertEquals(encounterReason.getCoding().size(), 1);
    CodingDt reasonCoding = encounterReason.getCoding().get(0);
    // Check encounter reason code.
    assertEquals(SNOMED_URI, reasonCoding.getSystem());
    assertEquals(EXPECTED_REASON_CODE, reasonCoding.getCode());
    assertEquals(EXPECTED_REASON_DISPLAY, reasonCoding.getDisplay());
    Optional<Entry> maybeObservationEntry = bundle.getEntry().stream().filter(entry -> entry.getResource().getResourceName().equals(org.hl7.fhir.dstu2.model.ResourceType.Observation.name())).findFirst();
    assertTrue(maybeObservationEntry.isPresent());
    // Find observation type code.
    ca.uhn.fhir.model.dstu2.resource.Observation observationResource = (ca.uhn.fhir.model.dstu2.resource.Observation) maybeObservationEntry.get().getResource();
    CodeableConceptDt observationType = observationResource.getCode();
    assertNotNull(observationType);
    assertEquals(observationType.getCoding().size(), 1);
    CodingDt observationTypeCoding = observationType.getCoding().get(0);
    // Check observation type code.
    assertEquals(LOINC_URI, observationTypeCoding.getSystem());
    assertEquals(OBSERVATION_CODE, observationTypeCoding.getCode());
    assertEquals(OBSERVATION_DISPLAY, observationTypeCoding.getDisplay());
    // Find observation value code.
    CodeableConceptDt observationValue = (CodeableConceptDt) observationResource.getValue();
    assertNotNull(observationValue);
    assertEquals(observationValue.getCoding().size(), 1);
    CodingDt observationValueCoding = observationValue.getCoding().get(0);
    // Check observation value code.
    assertEquals(LOINC_URI, observationValueCoding.getSystem());
    assertEquals(EXPECTED_VALUE_CODE, observationValueCoding.getCode());
    assertEquals(EXPECTED_VALUE_DISPLAY, observationValueCoding.getDisplay());
    inputStream.close();
}
Also used : TestHelper.years(org.mitre.synthea.TestHelper.years) Arrays(java.util.Arrays) XPathExpressionException(javax.xml.xpath.XPathExpressionException) Location(org.mitre.synthea.world.geography.Location) Bundle(org.hl7.fhir.dstu3.model.Bundle) BundleEntryComponent(org.hl7.fhir.dstu3.model.Bundle.BundleEntryComponent) Coding(org.hl7.fhir.dstu3.model.Coding) CodeableConcept(org.hl7.fhir.dstu3.model.CodeableConcept) Person(org.mitre.synthea.world.agents.Person) Document(org.w3c.dom.Document) After(org.junit.After) Path(java.nio.file.Path) Encounter(org.mitre.synthea.world.concepts.HealthRecord.Encounter) RestTemplate(org.springframework.web.client.RestTemplate) RandomCodeGenerator(org.mitre.synthea.helpers.RandomCodeGenerator) List(java.util.List) SAXException(org.xml.sax.SAXException) LOINC_URI(org.mitre.synthea.TestHelper.LOINC_URI) Optional(java.util.Optional) TestHelper(org.mitre.synthea.TestHelper) DocumentBuilderFactory(javax.xml.parsers.DocumentBuilderFactory) EncounterType(org.mitre.synthea.world.concepts.HealthRecord.EncounterType) XPath(javax.xml.xpath.XPath) XPathConstants(javax.xml.xpath.XPathConstants) SimpleDateFormat(java.text.SimpleDateFormat) TestHelper.isHttpRecordingEnabled(org.mitre.synthea.TestHelper.isHttpRecordingEnabled) XPathExpression(javax.xml.xpath.XPathExpression) Generator(org.mitre.synthea.engine.Generator) CodingDt(ca.uhn.fhir.model.dstu2.composite.CodingDt) WireMock(com.github.tomakehurst.wiremock.client.WireMock) CodeableConceptDt(ca.uhn.fhir.model.dstu2.composite.CodeableConceptDt) WireMockRule(com.github.tomakehurst.wiremock.junit.WireMockRule) ResourceType(org.hl7.fhir.dstu3.model.ResourceType) Node(org.w3c.dom.Node) Code(org.mitre.synthea.world.concepts.HealthRecord.Code) LOINC_OID(org.mitre.synthea.TestHelper.LOINC_OID) Before(org.junit.Before) TestHelper.wiremockOptions(org.mitre.synthea.TestHelper.wiremockOptions) Config(org.mitre.synthea.helpers.Config) NodeList(org.w3c.dom.NodeList) Assert.assertNotNull(org.junit.Assert.assertNotNull) Assert.assertTrue(org.junit.Assert.assertTrue) IOException(java.io.IOException) Test(org.junit.Test) FileInputStream(java.io.FileInputStream) Payer(org.mitre.synthea.world.agents.Payer) File(java.io.File) Provider(org.mitre.synthea.world.agents.Provider) SNOMED_URI(org.mitre.synthea.TestHelper.SNOMED_URI) XPathFactory(javax.xml.xpath.XPathFactory) Rule(org.junit.Rule) Entry(ca.uhn.fhir.model.dstu2.resource.Bundle.Entry) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException) DocumentBuilder(javax.xml.parsers.DocumentBuilder) ProviderTest(org.mitre.synthea.world.agents.ProviderTest) Assert.assertEquals(org.junit.Assert.assertEquals) TestHelper.getTxRecordingSource(org.mitre.synthea.TestHelper.getTxRecordingSource) InputStream(java.io.InputStream) CodeableConceptDt(ca.uhn.fhir.model.dstu2.composite.CodeableConceptDt) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) Bundle(org.hl7.fhir.dstu3.model.Bundle) FileInputStream(java.io.FileInputStream) Entry(ca.uhn.fhir.model.dstu2.resource.Bundle.Entry) CodingDt(ca.uhn.fhir.model.dstu2.composite.CodingDt) Encounter(org.mitre.synthea.world.concepts.HealthRecord.Encounter)

Aggregations

CodeableConceptDt (ca.uhn.fhir.model.dstu2.composite.CodeableConceptDt)3 CodingDt (ca.uhn.fhir.model.dstu2.composite.CodingDt)3 Entry (ca.uhn.fhir.model.dstu2.resource.Bundle.Entry)3 WireMock (com.github.tomakehurst.wiremock.client.WireMock)3 WireMockRule (com.github.tomakehurst.wiremock.junit.WireMockRule)3 File (java.io.File)3 FileInputStream (java.io.FileInputStream)3 IOException (java.io.IOException)3 InputStream (java.io.InputStream)3 Path (java.nio.file.Path)3 SimpleDateFormat (java.text.SimpleDateFormat)3 Arrays (java.util.Arrays)3 List (java.util.List)3 Optional (java.util.Optional)3 DocumentBuilder (javax.xml.parsers.DocumentBuilder)3 DocumentBuilderFactory (javax.xml.parsers.DocumentBuilderFactory)3 ParserConfigurationException (javax.xml.parsers.ParserConfigurationException)3 XPath (javax.xml.xpath.XPath)3 XPathConstants (javax.xml.xpath.XPathConstants)3 XPathExpression (javax.xml.xpath.XPathExpression)3