@Test
  public void testEstimatedBirthDate() {

    visitLocation.setName("Hôpital Universitaire de Mirebalais");

    Patient patient = new Patient();
    patient.setGender("M");
    patient.setBirthdate(new DateTime(1940, 7, 7, 5, 5, 5).toDate());
    patient.setBirthdateEstimated(true);

    PatientIdentifier primaryIdentifier = new PatientIdentifier();
    primaryIdentifier.setIdentifier("ZL1234");
    primaryIdentifier.setIdentifierType(primaryIdentifierType);
    primaryIdentifier.setVoided(false);
    patient.addIdentifier(primaryIdentifier);

    PatientIdentifier paperRecordIdentifier = new PatientIdentifier();
    paperRecordIdentifier.setIdentifier("A00005");
    paperRecordIdentifier.setIdentifierType(paperRecordIdentifierType);
    paperRecordIdentifier.setVoided(false);
    patient.addIdentifier(paperRecordIdentifier);

    PersonName name = new PersonName();
    name.setGivenName("Ringo");
    name.setFamilyName("Starr");
    patient.addName(name);

    String output = wristbandTemplate.generateWristband(patient, new Location());

    assertThat(output, containsString("^FO160,200^FB2150,1,0,L,0^AU^FD1940^FS"));
  }
Пример #2
0
 /** Gets a Location entity by its exact name. */
 public static Location getLocationByName(String locationName, Location parent) {
   LocationService locationService = Context.getLocationService();
   Location location = locationService.getLocation(locationName);
   if (location == null) {
     location = new Location();
     location.setName(locationName);
     location.setDescription(locationName);
     if (parent != null) {
       location.setParentLocation(parent);
     }
     locationService.saveLocation(location);
   }
   return location;
 }
  @Test
  public void testParsingDispositionWithTransferLocation() throws Exception {
    Concept admit =
        new ConceptBuilder(
                null,
                conceptService.getConceptDatatypeByName("N/A"),
                conceptService.getConceptClassByName("Misc"))
            .addName("Transfer")
            .get();
    when(emrConceptService.getConcept("test:transfer")).thenReturn(admit);

    Obs dispositionObs =
        dispositionDescriptor.buildObsGroup(
            new Disposition(
                "emrapi.transfer",
                "Transfer",
                "test:transfer",
                Collections.<String>emptyList(),
                Collections.<DispositionObs>emptyList()),
            emrConceptService);

    Obs transferLocationObs = new Obs();
    transferLocationObs.setObsId(100);
    transferLocationObs.setConcept(dispositionDescriptor.getInternalTransferLocationConcept());
    transferLocationObs.setValueText("3");
    dispositionObs.addGroupMember(transferLocationObs);

    Location transferLocation = new Location();
    transferLocation.setName("Outpatient clinic");
    when(locationService.getLocation(3)).thenReturn(transferLocation);

    encounter.addObs(doNotGoToServiceToFormatMembers(dispositionObs));
    ParsedObs parsed = parser.parseObservations(Locale.ENGLISH);

    SimpleObject expectedTransferLocationObject =
        SimpleObject.create("obsId", transferLocationObs.getObsId());
    expectedTransferLocationObject.put("question", "Transfer location");
    expectedTransferLocationObject.put("answer", "Outpatient clinic");

    List<SimpleObject> expectedAdditionalObsList = new ArrayList<SimpleObject>();
    expectedAdditionalObsList.add(expectedTransferLocationObject);

    assertThat(parsed.getDiagnoses().size(), is(0));
    assertThat(parsed.getDispositions().size(), is(1));
    assertThat(parsed.getObs().size(), is(0));
    assertThat(path(parsed.getDispositions(), 0, "disposition"), is((Object) "Transfer"));
    assertThat(
        path(parsed.getDispositions(), 0, "additionalObs"), is((Object) expectedAdditionalObsList));
  }
  @Test
  public void testParsingObsWithLocationAnswer() throws Exception {
    ConceptDatatype textDatatype = conceptService.getConceptDatatypeByName("Text");
    ConceptClass misc = conceptService.getConceptClassByName("Misc");

    Location xanadu = new Location();
    xanadu.setName("Xanadu");
    when(locationService.getLocation(2)).thenReturn(xanadu);

    Concept someLocation =
        new ConceptBuilder(conceptService, textDatatype, misc).addName("Some location").get();

    encounter.addObs(
        new ObsBuilder()
            .setConcept(someLocation)
            .setValue("2")
            .setComment("org.openmrs.Location")
            .get());
    ParsedObs parsed = parser.parseObservations(Locale.ENGLISH);
    ;
    assertThat(parsed.getObs().size(), is(1));
    assertThat(path(parsed.getObs(), 0, "question"), is((Object) "Some location"));
    assertThat(path(parsed.getObs(), 0, "answer"), is((Object) "Xanadu"));
  }
Пример #5
0
 /**
  * Get locations
  *
  * @param limit
  * @return
  */
 public List<Location> getLocations(String limit) {
   String query = "location?" + "limit=" + limit;
   ObjectMapper m = new ObjectMapper();
   List<Location> locations = new ArrayList<Location>();
   Location location;
   try {
     JsonNode rootNode = m.readTree(RestCall.getRequestGet(query));
     JsonNode results = rootNode.get("results");
     for (JsonNode result : results) {
       String uuid = result.path("uuid").textValue();
       String name = result.path("display").textValue();
       location = new Location();
       location.setName(name);
       location.setUuid(uuid);
       locations.add(location);
     }
     return locations;
   } catch (Exception ex) {
     logger.info("Some Error occured while getting locations.");
     logger.error("\n ERROR Caused by\n", ex);
     ex.printStackTrace();
     return locations;
   }
 }
  @Test
  public void shouldEvaluateOBRORUR01TemplateForOBSGroup() throws Exception {
    // given
    Encounter encounter = new Encounter();

    Date date = new Date();
    encounter.setEncounterDatetime(date);
    encounter.setUuid("ENCOUNTER UUID");

    EncounterType encounterType = new EncounterType();
    encounterType.setName("ENCOUNTER TYPE NAME");
    encounter.setEncounterType(encounterType);

    Location location = new Location(1);
    location.setUuid("LOCATION UUID");
    location.setName("LOCATION NAME");
    encounter.setLocation(location);

    Person provider = new Person(1);
    provider.setUuid("PROVIDER UUID");
    provider.addName(
        new PersonName("PROVIDER GIVENNAME", "PROVIDER MIDDLENAME", "PROVIDER FAMILYNAME"));
    encounter.setProvider(provider);

    ConceptSource source = new ConceptSource();
    source.setName("AMPATH");

    ConceptMap map = new ConceptMap();
    map.setSourceCode("200");
    map.setSource(source);

    ConceptDatatype datatype = new ConceptDatatype();
    datatype.setUuid(ConceptDatatype.NUMERIC_UUID);
    datatype.setHl7Abbreviation(ConceptDatatype.NUMERIC);

    ConceptNumeric concept = new ConceptNumeric();
    concept.setDatatype(datatype);
    concept.addConceptMapping(map);
    concept.addName(new ConceptName("NumericConcept", Locale.ENGLISH));
    concept.setUnits("mg");

    Date dateCreated = new Date(213231421890234L);

    Obs obs = new Obs(2);
    obs.setConcept(concept);
    obs.setDateCreated(dateCreated);
    obs.setValueNumeric(10d);

    obs.setObsGroup(getObsGroup());
    obs.getObsGroup().addGroupMember(obs);

    encounter.addObs(obs);

    obs = new Obs(3);
    obs.setConcept(concept);
    obs.setDateCreated(dateCreated);
    obs.setValueNumeric(23d);
    encounter.addObs(obs);

    Map<String, Object> bindings = new HashMap<String, Object>();
    bindings.put("encounter", encounter);
    bindings.put("implementationId", "MVP");

    // when
    HL7Template hl7Template = hl7QueryService.getHL7TemplateByName("Generic Obs Group");
    String evaluatedTemplate = hl7QueryService.evaluateTemplate(hl7Template, bindings);

    // then
    evaluatedTemplate = StringUtils.deleteWhitespace(evaluatedTemplate);
    Assert.assertEquals(
        "<ORU_R01.ORDER_OBSERVATION><OBR><OBR.1>0</OBR.1><OBR.4><CE.1>100</CE.1>"
            + "<CE.2>MEDICALRECORDOBSERVATIONS</CE.2><CE.3>LOCAL</CE.3></OBR.4><OBR.18>0</OBR.18>"
            + "<OBR.29><EIP.2><EI.3>ENCOUNTERUUID</EI.3></EIP.2></OBR.29></OBR><ORU_R01.OBSERVATION>"
            + "<OBX><OBX.1>1</OBX.1><OBX.2>NM</OBX.2><OBX.3><CE.1>200</CE.1><CE.2>NumericConcept</CE.2>"
            + "<CE.3>AMPATH</CE.3></OBX.3><OBX.5>23.0</OBX.5><OBX.6><CE.1>mg</CE.1><CE.3>UCUM</CE.3></OBX.6>"
            + "<OBX.14><TS.1>"
            + new HL7TemplateFunctions().formatDate(dateCreated, null)
            + "</TS.1>"
            + "</OBX.14></OBX></ORU_R01.OBSERVATION></ORU_R01.ORDER_OBSERVATION>"
            + "<ORU_R01.ORDER_OBSERVATION><OBR><OBR.1>2</OBR.1><OBR.4><CE.1>100</CE.1><CE.2>MedSet</CE.2>"
            + "<CE.3>LOCAL</CE.3></OBR.4><OBR.18>0</OBR.18><OBR.29><EIP.2><EI.3>ENCOUNTERUUID</EI.3></EIP.2></OBR.29"
            + "></OBR><ORU_R01.OBSERVATION><OBX><OBX.1>2</OBX.1><OBX.2>NM</OBX.2><OBX.3><CE.1>200</CE.1>"
            + "<CE.2>NumericConcept</CE.2><CE.3>AMPATH</CE.3></OBX.3><OBX.5>10.0</OBX.5><OBX.6><CE.1>mg</CE.1>"
            + "<CE.3>UCUM</CE.3></OBX.6><OBX.14><TS.1>"
            + new HL7TemplateFunctions().formatDate(dateCreated, null)
            + "</TS.1></OBX.14></OBX></ORU_R01.OBSERVATION></ORU_R01.ORDER_OBSERVATION>",
        evaluatedTemplate);
  }
  @Test
  public void testWristBandTemplate() {

    Date today = new Date();

    visitLocation.setName("Hôpital Universitaire de Mirebalais");

    Patient patient = new Patient();
    patient.setGender("M");
    patient.setBirthdate(new DateTime(1940, 7, 7, 5, 5, 5).toDate());

    PatientIdentifier primaryIdentifier = new PatientIdentifier();
    primaryIdentifier.setIdentifier("ZL1234");
    primaryIdentifier.setIdentifierType(primaryIdentifierType);
    primaryIdentifier.setVoided(false);
    patient.addIdentifier(primaryIdentifier);

    PatientIdentifier paperRecordIdentifier = new PatientIdentifier();
    paperRecordIdentifier.setIdentifier("A000005");
    paperRecordIdentifier.setIdentifierType(paperRecordIdentifierType);
    paperRecordIdentifier.setVoided(false);
    paperRecordIdentifier.setLocation(visitLocation);
    patient.addIdentifier(paperRecordIdentifier);

    PersonAddress address = new PersonAddress();
    address.setAddress2("Avant Eglise Chretienne des perlerlerin de la siant tete de moliere");
    address.setAddress1("Saut D'Eau");
    address.setAddress3("1ere Riviere Canot");
    address.setCityVillage("Saut d'Eau");
    address.setStateProvince("Centre");
    patient.addAddress(address);

    PersonName name = new PersonName();
    name.setGivenName("Ringo");
    name.setFamilyName("Starr");
    patient.addName(name);

    when(messageSourceService.getMessage(
            "coreapps.ageYears", Collections.singletonList(patient.getAge()).toArray(), locale))
        .thenReturn("75 an(s)");

    String output = wristbandTemplate.generateWristband(patient, visitLocation);

    assertThat(output, containsString("^XA^CI28^MTD^FWB"));
    assertThat(
        output,
        containsString(
            "^FO050,200^FB2150,1,0,L,0^AS^FDHôpital Universitaire de Mirebalais "
                + df.format(today)
                + "^FS"));
    assertThat(output, containsString("^FO100,200^FB2150,1,0,L,0^AU^FDRingo Starr^FS"));
    assertThat(output, containsString("^FO160,200^FB2150,1,0,L,0^AU^FD07 juil. 1940^FS"));
    assertThat(
        output, containsString("^FO160,200^FB1850,1,0,L,0^AT^FD" + patient.getAge() + " an(s)^FS"));
    assertThat(output, containsString("^FO160,200^FB1650,1,0,L,0^AU^FDMasculin  A 000005^FS"));
    assertThat(
        output,
        containsString(
            "^FO220,200^FB2150,1,0,L,0^AS^FDAvant Eglise Chretienne des perlerlerin de la siant tete de moliere^FS"));
    assertThat(
        output,
        containsString(
            "^FO270,200^FB2150,1,0,L,0^AS^FDSaut D'Eau, 1ere Riviere Canot, Saut d'Eau, Centre^FS"));
    assertThat(output, containsString("^FO100,2400^AT^BY4^BC,150,N^FDZL1234^XZ"));
  }