/** * Turn the given drug into a string acceptable for hl7 and forms * * @param drug Drug to convert to a string * @return String representation of the given drug */ public static String drugToString(Drug drug) { return drug.getDrugId() + "^" + drug.getName() + "^" + HL7Constants.HL7_LOCAL_DRUG; } }
/** * Gets the entries concept drug name in the form of CONCEPTNAME (Drug: DRUGNAME) * * @param locale * @return full drug name (with concept name appended) */ public String getFullName(Locale locale) { if (concept == null) { return getName(); } else { return getName() + " (" + concept.getName(locale).getName() + ")"; } }
/** * Compare drug names ignoring numericals and other characters. Using compareToIgnoreCase() * method to prevent a capital letter getting precedence over a simple letter which comes before * it in the alphabet. * * @param d1 the first Drug to be compared * @param d2 the second Drug to be compared * @return the int * @should return negative if name for drug1 comes before that of drug2 * @should return zero if name for drug1 comes before that of drug2 * @should return positive if name for drug1 comes before that of drug2 ignoring dashes * @should return positive if name for drug1 comes before that of drug2 ignoring numerics */ private int compareDrugNamesIgnoringNumericals(Drug d1, Drug d2) { String firstDrugName = remove(d1.getName()); String secondDrugName = remove(d2.getName()); return firstDrugName.compareToIgnoreCase(secondDrugName); }
/** * Convenience method that returns a display name for the drug, defaults to drug.name * * @return the display name * @since 1.8.5, 1.9.4, 1.10 */ public String getDisplayName() { if (StringUtils.isNotBlank(getName())) { return getName(); } if (getConcept() != null) { return getConcept().getName().getName(); } return ""; }
/** * Ensures that unique drugs are returned in situations where more than one searched fields * match e.g drug name and linked concept name match the search phrase * * @see ConceptService#getDrugs(String, java.util.Locale, boolean, boolean) */ @Test public void getDrugs_shouldReturnUniqueDrugs() { //sanity check that drug.name and drug.concept.name will both match the search phrase Drug drug = conceptService.getDrug("ASPIRIN"); assertEquals(drug.getName().toLowerCase(), drug.getConcept().getName().getName().toLowerCase()); List<Drug> drugs = conceptService.getDrugs("Asp", null, false, false); assertEquals(1, drugs.size()); assertEquals(3, drugs.get(0).getDrugId().intValue()); }
@Override public String toString() { String prefix = DISCONTINUE == getAction() ? "DC " : ""; return prefix + "DrugOrder(" + getDose() + getDoseUnits() + " of " + (isNonCodedDrug() ? getDrugNonCoded() : (getDrug() != null ? getDrug().getName() : "[no drug]")) + " from " + getDateActivated() + " to " + (isDiscontinuedRightNow() ? getDateStopped() : getAutoExpireDate()) + ")"; }
/** * Gets a user-friendly display representation of the delegate * * @param o * @return */ @PropertyGetter("display") public static String getDisplay(DrugOrder delegate) { StringBuilder ret = new StringBuilder(); ret.append(delegate.getDrug() != null ? delegate.getDrug().getName() : "[no drug]"); ret.append(": "); ret.append(delegate.getDose()).append(" ").append(delegate.getUnits()); // TODO dates, etc return ret.toString(); } }
@Override public List<Map<String, Object>> simplify(List<Drug> drugs) { List<Map<String, Object>> simplified = new ArrayList<Map<String, Object>>(); Locale locale = Context.getLocale(); for (Drug drug : drugs) { Map<String, Object> item = new LinkedHashMap<String, Object>(); item.put("id", drug.getId()); item.put("name", drug.getName()); if (drug.getDosageForm() != null) { item.put("dosageForm", drug.getDosageForm().getName(locale).getName()); } item.put("combination", drug.getCombination()); if (drug.getConcept() != null) { item.put("concept", drug.getConcept().getName(locale).getName()); } simplified.add(item); } return simplified; } }
public void CRUDOperation(DBHandler db){ // Inserting Contacts Log.d("Insert: ", "Inserting .."); db.addDrug(new Drug("Chloroquine", "The bitter drug that is not slimy")); db.addDrug(new Drug("Artesunate", "The big drug..PS: I hate it so much")); // Reading all contacts Log.d("Reading: ", "Reading all contacts.."); drug = db.getAllDrugs(); for (Drug dg : drug) { String log = "Id: "+dg.getID()+" , Name: " + dg.getName() + " , Desc: " + dg.get_desc(); Log.d("Name: ", log); } }
@Override public void setInitialValue(Object initialValue) { if (initialValue instanceof Drug) { Drug asDrug = (Drug) initialValue; this.initialValue = new Option(asDrug.getName(), "Drug:" + asDrug.getId(), true); } else if (initialValue instanceof Concept) { Concept asConcept = (Concept) initialValue; this.initialValue = new Option((asConcept.getName().getName()), asConcept.getConceptId().toString(), true); } else { this.initialValue = (Option) initialValue; } }
/** * @see OrderResource1_10#getDisplayString(org.openmrs.Order) */ @PropertyGetter("display") public static String getDisplay(DrugOrder delegate) { StringBuilder ret = new StringBuilder(); ret.append("(" + delegate.getAction() + ") "); if (delegate.getDrug() != null) { ret.append(delegate.getDrug().getName()); } else { ret.append(delegate.getConcept().getDisplayString()); } if (Order.Action.DISCONTINUE != delegate.getAction() && delegate.getDosingType() != null && delegate.getDosingInstructionsInstance() != null) { String dosingInstructionsAsString = delegate.getDosingInstructionsInstance().getDosingInstructionsAsString( Context.getLocale()); ret.append(": "); ret.append(dosingInstructionsAsString); } return ret.toString(); } }
@Override public List<Map<String, Object>> simplify(List<Drug> drugs) { List<Map<String, Object>> simplified = new ArrayList<Map<String, Object>>(); Locale locale = Context.getLocale(); for (Drug drug : drugs) { Map<String, Object> item = new LinkedHashMap<String, Object>(); item.put("id", drug.getId()); item.put("name", drug.getName()); if (drug.getDosageForm() != null) { item.put("dosageForm", drug.getDosageForm().getName(locale).getName()); } if (drug.getRoute() != null) { item.put("route", drug.getRoute().getName(locale).getName()); } item.put("doseStrength", drug.getDoseStrength()); item.put("units", drug.getUnits()); item.put("combination", drug.getCombination()); if (drug.getConcept() != null) { item.put("concept", drug.getConcept().getName(locale).getName()); } simplified.add(item); } return simplified; } }
displayText = drug.getName(); if (drugLabels != null) { displayText = drugLabels.get(drugListIndexPos);
widget.setInitialValue(new Option(existingObs.getValueDrug().getName(), existingObs.getValueDrug().getDrugId().toString(), true));
@Test public void shouldGetADrugByUuid() throws Exception { MockHttpServletRequest req = request(RequestMethod.GET, getURI() + "/" + getUuid()); SimpleObject result = deserialize(handle(req)); Drug drug = service.getDrugByUuid(getUuid()); Assert.assertNotNull(result); Assert.assertEquals(drug.getUuid(), PropertyUtils.getProperty(result, "uuid")); Assert.assertEquals(drug.getName(), PropertyUtils.getProperty(result, "name")); }
@Test public void shouldEditADrug() throws Exception { final String editedName = "Aspirin Edited"; String json = "{ \"name\":\"" + editedName + "\" }"; MockHttpServletRequest req = request(RequestMethod.POST, getURI() + "/" + getUuid()); req.setContent(json.getBytes()); handle(req); Drug editedDrug = service.getDrugByUuid(getUuid()); Assert.assertNotNull(editedDrug); Assert.assertEquals(editedName, editedDrug.getName()); }
@Override public void validateDefaultRepresentation() throws Exception { super.validateDefaultRepresentation(); assertPropEquals("name", getObject().getName()); assertPropEquals("description", getObject().getDescription()); assertPropEquals("retired", getObject().isRetired()); assertPropEquals("doseStrength", getObject().getDoseStrength()); assertPropEquals("maximumDailyDose", getObject().getMaximumDailyDose()); assertPropEquals("minimumDailyDose", getObject().getMinimumDailyDose()); assertPropEquals("units", getObject().getUnits()); assertPropEquals("combination", getObject().getCombination()); assertPropPresent("concept"); assertPropPresent("route"); assertPropPresent("dosageForm"); }
@Override public void validateFullRepresentation() throws Exception { super.validateFullRepresentation(); assertPropEquals("name", getObject().getName()); assertPropEquals("description", getObject().getDescription()); assertPropEquals("retired", getObject().isRetired()); assertPropEquals("doseStrength", getObject().getDoseStrength()); assertPropEquals("maximumDailyDose", getObject().getMaximumDailyDose()); assertPropEquals("minimumDailyDose", getObject().getMinimumDailyDose()); assertPropEquals("units", getObject().getUnits()); assertPropEquals("combination", getObject().getCombination()); assertPropPresent("concept"); assertPropPresent("route"); assertPropPresent("dosageForm"); assertPropPresent("auditInfo"); }