本文整理汇总了Java中org.oscarehr.common.model.Drug.setId方法的典型用法代码示例。如果您正苦于以下问题:Java Drug.setId方法的具体用法?Java Drug.setId怎么用?Java Drug.setId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.oscarehr.common.model.Drug
的用法示例。
在下文中一共展示了Drug.setId方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getPrescriptDrug
import org.oscarehr.common.model.Drug; //导入方法依赖的package包/类
private Drug getPrescriptDrug(LoggedInInfo loggedInInfo,CachedDemographicDrug cachedDrug) throws MalformedURLException {
Drug pd = new Drug();
pd.setBrandName(cachedDrug.getBrandName());
pd.setCustomName(cachedDrug.getCustomName());
pd.setRxDate(DateUtils.toDate(cachedDrug.getRxDate()));
pd.setArchived(cachedDrug.isArchived());
pd.setSpecial(cachedDrug.getSpecial());
pd.setEndDate(DateUtils.toDate(cachedDrug.getEndDate()));
pd.setRegionalIdentifier(cachedDrug.getRegionalIdentifier());
pd.setCreateDate(DateUtils.toDate(cachedDrug.getCreateDate()));
pd.setId(cachedDrug.getFacilityIdIntegerCompositePk().getCaisiItemId());
int remoteFacilityId = cachedDrug.getFacilityIdIntegerCompositePk().getIntegratorFacilityId();
pd.setRemoteFacilityId(remoteFacilityId);
CachedFacility cachedFacility = CaisiIntegratorManager.getRemoteFacility(loggedInInfo, loggedInInfo.getCurrentFacility(),remoteFacilityId);
pd.setRemoteFacilityName(cachedFacility.getName());
return (pd);
}
示例2: testUpdateDrugWithValidInput
import org.oscarehr.common.model.Drug; //导入方法依赖的package包/类
@Test
public void testUpdateDrugWithValidInput() {
LoggedInInfo info = new LoggedInInfo();
Drug d = new Drug();
d.setDemographicId(1);
d.setId(1);
d.setGenericName("ASA");
Drug result = this.updateDrug(info, d);
assertNotNull(result);
assertEquals(1, (int) d.getId()); //should take on id assigned by dao.addNewDrug
assertEquals("ASA", d.getGenericName()); //should not change other fields.
// merge() should have adjusted the this.old variable
// to have archived status
assertTrue(MockDrugDao.old.isArchived());
assertEquals("represcribed", MockDrugDao.old.getArchivedReason());
}
示例3: testShouldAttemptToAddDrugIfDoesNotExist
import org.oscarehr.common.model.Drug; //导入方法依赖的package包/类
@Test
public void testShouldAttemptToAddDrugIfDoesNotExist(){
List<Drug> drugs = new ArrayList<Drug>();
Drug d = MockDrugDao.getTestDrug();
d.setId(3); //result in MockDrugDao.find() failing.
d.setGenericName("ASA"); // allowed to add in test MockDrugDao.addNewDrug
drugs.add(d);
LoggedInInfo info = new LoggedInInfo();
PrescriptionDrugs pd = prescribe(info, drugs, 1);
assertNotNull(pd);
assertEquals(MockDrugDao.daoAddNewDrugCalled, 1);
assertEquals(pd.drugs.get(0).getGenericName(), "ASA");
}
示例4: getTestDrug
import org.oscarehr.common.model.Drug; //导入方法依赖的package包/类
public Drug getTestDrug() {
Date startDate = new Date();
Date endDate = new Date();
Date archivedDate = new Date();
Drug d = new Drug();
d.setId(1);
d.setDemographicId(1);
d.setProviderNo("1");
d.setBrandName("Foobar");
d.setGenericName("Barbang");
d.setRegionalIdentifier("12345");
d.setAtc("abcde");
d.setTakeMax(2);
d.setTakeMin(1);
d.setRxDate((Date) startDate.clone());
d.setEndDate((Date) endDate.clone());
d.setFreqCode("BID");
d.setDuration("28");
d.setDurUnit("D");
d.setRoute("PO");
d.setDrugForm("TAB");
d.setPrn(true);
d.setMethod("Take");
d.setRepeat(5);
d.setSpecial("some string");
d.setArchived(false);
d.setArchivedDate((Date) archivedDate.clone());
d.setArchivedReason("reason");
return d;
}
示例5: testShouldReturnNullIfAddingANewDrugFails
import org.oscarehr.common.model.Drug; //导入方法依赖的package包/类
@Test
public void testShouldReturnNullIfAddingANewDrugFails(){
List<Drug> drugs = new ArrayList<Drug>();
Drug d = MockDrugDao.getTestDrug();
d.setId(3); //result in MockDrugDao.find() failing.
d.setGenericName("NOT ASA"); // fail to add in test MockDrugDao.addNewDrug
drugs.add(d);
LoggedInInfo info = new LoggedInInfo();
PrescriptionDrugs pd = prescribe(info, drugs, 1);
assertNull(pd);
assertEquals(MockDrugDao.daoAddNewDrugCalled, 1);
}
示例6: testInvalidDurationNumberStrings
import org.oscarehr.common.model.Drug; //导入方法依赖的package包/类
@Test(expected = NumberFormatException.class)
public void testInvalidDurationNumberStrings() {
Drug d = new Drug();
LoggedInInfo info = new LoggedInInfo();
Date startDate = new Date();
Date endDate = new Date();
Date archivedDate = new Date();
// SHOULD CAUSE THE EXCEPTION
d.setDuration("NOT A NUMBER");
// Other fields
d.setId(1);
d.setDemographicId(1);
d.setProviderNo("1");
d.setBrandName("Foobar");
d.setGenericName("Barbang");
d.setRegionalIdentifier("12345");
d.setAtc("abcde");
d.setTakeMax(2);
d.setTakeMin(1);
d.setRxDate((Date) startDate.clone());
d.setEndDate((Date) endDate.clone());
d.setFreqCode("BID");
d.setDurUnit("D");
d.setRoute("PO");
d.setDrugForm("TAB");
d.setPrn(true);
d.setMethod("Take");
d.setRepeat(5);
d.setSpecial("some string");
d.setArchived(false);
d.setArchivedDate((Date) archivedDate.clone());
d.setArchivedReason("reason");
DrugTo1 t = this.getAsTransferObject(info, d);
}
示例7: testInvalidProviderNumberString
import org.oscarehr.common.model.Drug; //导入方法依赖的package包/类
@Test(expected = NumberFormatException.class)
public void testInvalidProviderNumberString() {
Drug d = new Drug();
LoggedInInfo info = new LoggedInInfo();
Date startDate = new Date();
Date endDate = new Date();
Date archivedDate = new Date();
// SHOULD CAUSE THE EXCEPTION
d.setProviderNo("NOT A NUMBER");
// Other fields
d.setId(1);
d.setDemographicId(1);
d.setBrandName("Foobar");
d.setGenericName("Barbang");
d.setRegionalIdentifier("12345");
d.setAtc("abcde");
d.setTakeMax(2);
d.setTakeMin(1);
d.setRxDate((Date) startDate.clone());
d.setEndDate((Date) endDate.clone());
d.setFreqCode("BID");
d.setDuration("28");
d.setDurUnit("D");
d.setRoute("PO");
d.setDrugForm("TAB");
d.setPrn(true);
d.setMethod("Take");
d.setRepeat(5);
d.setSpecial("some string");
d.setArchived(false);
d.setArchivedDate((Date) archivedDate.clone());
d.setArchivedReason("reason");
DrugTo1 t = this.getAsTransferObject(info, d);
}
示例8: findByDemographicIdAndDrugId
import org.oscarehr.common.model.Drug; //导入方法依赖的package包/类
public List<Drug> findByDemographicIdAndDrugId(int demographicNo, Integer drugId) {
if(drugId > 5) {
return new ArrayList<Drug>();
} else{
List<Drug> drugs = new ArrayList<Drug>();
Drug d = getTestDrug();
d.setId(drugId);
d.setDemographicId(demographicNo);
drugs.add(d);
return drugs;
}
}
示例9: getTestDrug
import org.oscarehr.common.model.Drug; //导入方法依赖的package包/类
public static Drug getTestDrug() {
Date startDate = new Date();
Date endDate = new Date();
Date archivedDate = new Date();
Drug d = new Drug();
d.setId(1);
d.setDemographicId(1);
d.setProviderNo("1");
d.setBrandName("Aspirin");
d.setGenericName("ASA");
d.setRegionalIdentifier("12345");
d.setAtc("abcde");
d.setTakeMax(2);
d.setTakeMin(1);
d.setRxDate((Date) startDate.clone());
d.setEndDate((Date) endDate.clone());
d.setFreqCode("BID");
d.setDuration("28");
d.setDurUnit("D");
d.setRoute("PO");
d.setDrugForm("TAB");
d.setPrn(true);
d.setMethod("Take");
d.setRepeat(5);
d.setSpecial("some string");
d.setArchived(false);
d.setArchivedDate((Date) archivedDate.clone());
d.setArchivedReason("reason");
return d;
}
示例10: getAsDomainObject
import org.oscarehr.common.model.Drug; //导入方法依赖的package包/类
/**
* Converts from a transfer object to a Drug domain object.
*
* @param loggedInInfo information regarding the current logged in user.
* @param t the transfer object to copy the data from
* @return a Drug domain object representing this data.
* @throws ConversionException if conversion did not complete properly.
*/
@Override
public Drug getAsDomainObject(LoggedInInfo loggedInInfo, DrugTo1 t) throws ConversionException {
Drug d = new Drug();
// Copy fields from DrugTo1 object
// over to the new Drug object.
// This is not quite a one-to-one copy, some transformation
// is done on types.
try {
d.setId(t.getDrugId());
d.setBrandName(t.getBrandName());
d.setGenericName(t.getGenericName());
d.setDemographicId(t.getDemographicNo());
d.setProviderNo(t.getProviderNo().toString()); // Cast to string.
d.setAtc(t.getAtc());
d.setRegionalIdentifier(t.getRegionalIdentifier());
d.setDosage(t.getStrength() + t.getStrengthUnit());
d.setTakeMax(t.getTakeMax());
d.setTakeMin(t.getTakeMin());
d.setRxDate(t.getRxDate());
d.setEndDate(t.getEndDate());
d.setFreqCode(t.getFrequency());
d.setDuration(t.getDuration().toString()); // Cast to string.
d.setDurUnit(t.getDurationUnit());
d.setRepeat(t.getRepeats());
d.setSpecial(t.getInstructions());
d.setArchived(t.isArchived());
d.setArchivedReason(t.getArchivedReason());
d.setArchivedDate(t.getArchivedDate());
d.setRoute(t.getRoute());
d.setDrugForm(t.getForm());
d.setMethod(t.getMethod());
d.setPrn(t.isPrn());
d.setLongTerm(t.getLongTerm());
d.setNoSubs(t.getNoSubstitutions());
d.setPosition(1);
d.setOutsideProviderName(t.getExternalProvider());
d.setSpecialInstruction(t.getAdditionalInstructions());
if(t.getQuantity() != null){
d.setQuantity(t.getQuantity().toString());
}
populateDrugStrength(d, t);
}catch(RuntimeException re){
throw new ConversionException();
}
return d;
}
示例11: testUpdateDrugWithFailedAddNewDrug
import org.oscarehr.common.model.Drug; //导入方法依赖的package包/类
@Test
public void testUpdateDrugWithFailedAddNewDrug() {
LoggedInInfo info = new LoggedInInfo();
Drug d = new Drug();
d.setDemographicId(1);
d.setId(1);
d.setGenericName("foobar"); // will fail in MockDrugDao
Drug result = this.updateDrug(info, d);
assertNull(result);
// should not have created a new "old" drug.
assertNull(MockDrugDao.old);
}
示例12: testValidDomainToTransfer
import org.oscarehr.common.model.Drug; //导入方法依赖的package包/类
@Test
public void testValidDomainToTransfer() throws Exception {
Drug d = new Drug();
LoggedInInfo info = new LoggedInInfo();
Date startDate = new Date();
Date endDate = new Date();
Date archivedDate = new Date();
d.setId(1);
d.setDemographicId(1);
d.setProviderNo("1");
d.setBrandName("Foobar");
d.setGenericName("Barbang");
d.setRegionalIdentifier("12345");
d.setAtc("abcde");
d.setTakeMax(2);
d.setTakeMin(1);
d.setRxDate((Date) startDate.clone());
d.setEndDate((Date) endDate.clone());
d.setFreqCode("BID");
d.setDuration("28");
d.setDurUnit("D");
d.setRoute("PO");
d.setDrugForm("TAB");
d.setPrn(true);
d.setMethod("Take");
d.setRepeat(5);
d.setSpecial("some string");
d.setArchived(false);
d.setArchivedDate((Date) archivedDate.clone());
d.setArchivedReason("reason");
DrugTo1 t = this.getAsTransferObject(info, d);
assertEquals(1, (int)t.getDrugId());
assertEquals(1, (int) t.getDemographicNo());
assertEquals(1, (int) t.getProviderNo());
assertEquals("Foobar", t.getBrandName());
assertEquals("Barbang", t.getGenericName());
assertEquals("12345", t.getRegionalIdentifier());
assertEquals("abcde", t.getAtc());
assertEquals(1.0, t.getTakeMin(), 0.01);
assertEquals(2.0, t.getTakeMax(), 0.01);
assertEquals(startDate.toString(), t.getRxDate().toString());
assertEquals(endDate.toString(), t.getEndDate().toString());
assertEquals("BID", t.getFrequency());
assertEquals(28, (int) t.getDuration());
assertEquals("D", t.getDurationUnit());
assertEquals("PO", t.getRoute());
assertEquals("TAB", t.getForm());
assertTrue(t.isPrn());
assertEquals("Take", t.getMethod());
assertEquals(5, (int) t.getRepeats());
assertEquals("some string", t.getInstructions());
assertEquals(archivedDate.toString(), t.getArchivedDate().toString());
assertEquals("reason", t.getArchivedReason());
assertFalse(t.isArchived());
}
示例13: addNewDrug
import org.oscarehr.common.model.Drug; //导入方法依赖的package包/类
public boolean addNewDrug(Drug d) {
// For testing purposes we only return
// a drug if the drug matches out ASA drug in the test data.
// Write tests to take advantage of this fact...
daoAddNewDrugCalled++;
if (d.getGenericName().equals("ASA")) {
d.setId(1);
return true;
}
return false;
}
示例14: addDrug
import org.oscarehr.common.model.Drug; //导入方法依赖的package包/类
/**
* Adds a new drug to the database.
*
* @param info information regarding the logged in user.
* @param d the drug object to add to the database.
*
* @return the drug object that was added.
*/
public Drug addDrug( LoggedInInfo info, Drug d) {
LogAction.addLogSynchronous(info, "RxManager.addDrug", "providerNo=" +
info.getLoggedInProviderNo()
+ " drug.brandName="+d.getBrandName()
+ " demographicNo="+d.getDemographicId());
// Will throw an exception if access is denied.
this.writeCheck(info, d.getDemographicId());
// Have to set ID to null so that database
// can auto-generate one for this drug.
d.setId(null);
if (this.drugDao.addNewDrug(d)) {
// If the addNewDrug(d) call succeeds d will
// contain the ID that was auto-generated by the
// database.
return d;
} else {
return null;
}
}