List of usage examples for org.joda.time DateTime getMillis
public long getMillis()
From source file:com.marand.thinkmed.medications.pharmacist.impl.PreparePerfusionSyringeProcessHandlerImpl.java
License:Open Source License
@Override public void handlePreparationRequest(@Nonnull final String patientId, @Nonnull final String therapyCompositionUid, @Nonnull final String ehrOrderName, final int numberOfSyringes, final boolean urgent, @Nonnull final DateTime dueTime, @Nonnull final String userName, final boolean printSystemLabel) { StringUtils.checkNotBlank(patientId, "patientId"); StringUtils.checkNotBlank(therapyCompositionUid, "therapyCompositionUid"); StringUtils.checkNotBlank(ehrOrderName, "ehrOrderName"); Preconditions.checkNotNull(dueTime, "dueTime"); StringUtils.checkNotBlank(userName, "userName"); final String originalTherapyId = medicationsBo.getOriginalTherapyId(patientId, therapyCompositionUid); Preconditions.checkArgument(//from w w w . j a va 2s. co m !bpmService.isProcessInExecution(originalTherapyId, PreparePerfusionSyringeProcess.class), "Only one active prepare perfusion syringe request allowed for therapy!"); bpmService.startProcess(originalTherapyId, PreparePerfusionSyringeProcess.class, Pair.of(PreparePerfusionSyringeProcess.patientId, patientId), Pair.of(PreparePerfusionSyringeProcess.originalTherapyId, originalTherapyId), Pair.of(PreparePerfusionSyringeProcess.numberOfSyringes, numberOfSyringes), Pair.of(PreparePerfusionSyringeProcess.isUrgent, urgent), Pair.of(PreparePerfusionSyringeProcess.undoState, false), Pair.of(PreparePerfusionSyringeProcess.cancelPreparation, false), Pair.of(PreparePerfusionSyringeProcess.orderCanceled, false), Pair.of(PreparePerfusionSyringeProcess.therapyCanceled, false), Pair.of(PreparePerfusionSyringeProcess.dueDateTimeMillis, dueTime.getMillis()), Pair.of(PreparePerfusionSyringeProcess.orderer, RequestContextHolder.getContext().getUserId()), Pair.of(PreparePerfusionSyringeProcess.ordererFullName, userName), Pair.of(PreparePerfusionSyringeProcess.printSystemLabel, printSystemLabel)); }
From source file:com.marand.thinkmed.medications.process.impl.MedicationsProcessServiceImpl.java
License:Open Source License
@Override public void startTherapyProcess(final long patientId, final MedicationOrderComposition composition, final Long sessionId, final Named knownOrganizationalEntity, final DateTime when) { for (final MedicationInstructionInstruction instruction : composition.getMedicationDetail() .getMedicationInstruction()) { final String therapyId = InstructionTranslator.translate(instruction, composition); final String knownOrganizationalEntityName = knownOrganizationalEntity != null ? knownOrganizationalEntity.name() : null;// w w w. j a va 2 s . co m bpmService.startProcess(therapyId, TherapyProcess.class, Pair.<TherapyProcess, Object>of(TherapyProcess.therapyId, therapyId), Pair.<TherapyProcess, Object>of(TherapyProcess.patientId, patientId), Pair.<TherapyProcess, Object>of(TherapyProcess.originalTherapyId, therapyId), Pair.<TherapyProcess, Object>of(TherapyProcess.sessionId, sessionId), Pair.<TherapyProcess, Object>of(TherapyProcess.knownOrganizationalEntity, knownOrganizationalEntityName), Pair.<TherapyProcess, Object>of(TherapyProcess.when, when.getMillis())); } }
From source file:com.marand.thinkmed.medications.process.impl.MedicationsProcessServiceImpl.java
License:Open Source License
@Override public void sendAbortTherapyRequest(final long patientId, final String compositionUid, final String ehrOrderName, final boolean therapySuspended, final DateTime abortTimestamp) { final String therapyId = getTherapyId(ehrOrderName, compositionUid); final Pair<MedicationOrderComposition, MedicationInstructionInstruction> originalTherapy = medicationsBo .getOriginalTherapy(patientId, compositionUid, ehrOrderName); final String originalTherapyId = InstructionTranslator.translate(originalTherapy.getSecond(), originalTherapy.getFirst()); bpmService.messageEventReceived(//from w w w . j a v a 2 s. c om therapySuspended ? TherapyProcess.receiveAbortSuspendedTherapyRequest : TherapyProcess.receiveAbortTherapyRequest, originalTherapyId, TherapyProcess.class, Pair.<TherapyProcess, Object>of(TherapyProcess.therapyId, therapyId), Pair.<TherapyProcess, Object>of(TherapyProcess.userId, RequestContextHolder.getContext().getUserId()), Pair.<TherapyProcess, Object>of(TherapyProcess.when, abortTimestamp.getMillis())); }
From source file:com.marand.thinkmed.medications.process.impl.MedicationsProcessServiceImpl.java
License:Open Source License
@Override public void sendSuspendTherapyRequest(final long patientId, final String compositionUid, final String ehrOrderName, final DateTime suspendTimestamp) { final String therapyId = getTherapyId(ehrOrderName, compositionUid); final Pair<MedicationOrderComposition, MedicationInstructionInstruction> originalTherapy = medicationsBo .getOriginalTherapy(patientId, compositionUid, ehrOrderName); final String originalTherapyId = InstructionTranslator.translate(originalTherapy.getSecond(), originalTherapy.getFirst()); bpmService.messageEventReceived(TherapyProcess.receiveSuspendTherapyRequest, originalTherapyId, TherapyProcess.class, Pair.<TherapyProcess, Object>of(TherapyProcess.therapyId, therapyId), Pair.<TherapyProcess, Object>of(TherapyProcess.userId, RequestContextHolder.getContext().getUserId()), Pair.<TherapyProcess, Object>of(TherapyProcess.when, suspendTimestamp.getMillis())); }
From source file:com.marand.thinkmed.medications.process.impl.MedicationsProcessServiceImpl.java
License:Open Source License
@Override public void sendModifyTherapyRequest(final long patientId, final TherapyDto modifiedTherapy, final boolean therapySuspended, final Long centralCaseId, final Long careProviderId, final Long sessionId, final Named knownOrganizationalEntity, final NamedIdentity prescriber, final DateTime when, final Locale locale) { final String therapyId = getTherapyId(modifiedTherapy.getEhrOrderName(), modifiedTherapy.getCompositionUid()); final Pair<MedicationOrderComposition, MedicationInstructionInstruction> originalTherapy = medicationsBo .getOriginalTherapy(patientId, modifiedTherapy.getCompositionUid(), modifiedTherapy.getEhrOrderName()); final String originalTherapyId = InstructionTranslator.translate(originalTherapy.getSecond(), originalTherapy.getFirst()); final String knownOrganizationalEntityName = knownOrganizationalEntity != null ? knownOrganizationalEntity.name() : null;/*from ww w . j a v a 2 s . c om*/ try { bpmService.messageEventReceived( therapySuspended ? TherapyProcess.receiveModifySuspendedTherapyRequest : TherapyProcess.receiveModifyTherapyRequest, originalTherapyId, TherapyProcess.class, Pair.<TherapyProcess, Object>of(TherapyProcess.therapyId, therapyId), Pair.<TherapyProcess, Object>of(TherapyProcess.userId, RequestContextHolder.getContext().getUserId()), Pair.<TherapyProcess, Object>of(TherapyProcess.prescriber, prescriber), Pair.<TherapyProcess, Object>of(TherapyProcess.when, when.getMillis()), Pair.<TherapyProcess, Object>of(TherapyProcess.language, locale), Pair.<TherapyProcess, Object>of(TherapyProcess.modifiedTherapy, modifiedTherapy), Pair.<TherapyProcess, Object>of(TherapyProcess.sessionId, sessionId), Pair.<TherapyProcess, Object>of(TherapyProcess.centralCaseId, centralCaseId), Pair.<TherapyProcess, Object>of(TherapyProcess.careProviderId, careProviderId), Pair.<TherapyProcess, Object>of(TherapyProcess.knownOrganizationalEntity, knownOrganizationalEntityName)); } catch (ProcessNotExistsBpmException e) { // no process no problem ;-) } }
From source file:com.marand.thinkmed.medications.process.impl.TherapyTaskProviderImpl.java
License:Open Source License
@Override public void rescheduleTasks(final String taskId, final DateTime fromTime, final long moveTimeInMillis, final boolean rescheduleSingleTask, final String therapyId) { if (!rescheduleSingleTask) { final PartialList<TaskDto> therapyTasks = processService.findTasks(null, MedicationTaskDef.INSTANCE.getGroupName(), MedicationTaskDef.INSTANCE.getTaskExecutionId(), false, fromTime, null, Pair.of(MedicationTaskDef.THERAPY_ID, therapyId)); for (final TaskDto therapyTask : therapyTasks) { final long newTimeInMillis = therapyTask.getDueTime().getMillis() + moveTimeInMillis; processService.setDueDate(therapyTask.getId(), new DateTime(newTimeInMillis)); }/*from w w w.ja v a 2 s . c o m*/ } processService.setDueDate(taskId, new DateTime(fromTime.getMillis() + moveTimeInMillis)); }
From source file:com.marand.thinkmed.medications.therapy.impl.TherapyUpdaterImpl.java
License:Open Source License
private void moveTherapyInterval(final String patientId, final MedicationOrderComposition composition, final MedicationInstructionInstruction instruction, final DateTime startTimestamp, final boolean save) { DateTime endDate = null;//from w w w. j a v a 2 s . c o m for (final MedicationInstructionInstruction.OrderActivity orderActivity : instruction.getOrder()) { final MedicationInstructionInstruction.OrderActivity.MedicationTimingCluster medicationTiming = orderActivity .getMedicationTiming(); if (medicationTiming.getStopDate() != null) { final DateTime start = DataValueUtils.getDateTime(medicationTiming.getStartDate()); final DateTime end = DataValueUtils.getDateTime(medicationTiming.getStopDate()); final long durationInMillis = end.getMillis() - start.getMillis(); final DateTime newEnd = new DateTime(startTimestamp.getMillis() + durationInMillis); medicationTiming.setStopDate(DataValueUtils.getDateTime(newEnd)); endDate = newEnd; } medicationTiming.setStartDate(DataValueUtils.getDateTime(startTimestamp)); } if (save) { medicationsOpenEhrDao.modifyMedicationOrderComposition(patientId, composition); } if (endDate != null) { final List<Pair<MedicationOrderComposition, MedicationInstructionInstruction>> linkedTherapies = medicationsOpenEhrDao .getLinkedTherapies(patientId, composition.getUid().getValue(), instruction.getName().getValue(), EhrLinkType.FOLLOW); Preconditions.checkArgument(linkedTherapies.size() < 2, "not more than 1 follow therapy should exist"); if (!linkedTherapies.isEmpty()) { final Pair<MedicationOrderComposition, MedicationInstructionInstruction> linkedTherapy = linkedTherapies .get(0); moveTherapyInterval(patientId, linkedTherapy.getFirst(), linkedTherapy.getSecond(), endDate, true); } } }
From source file:com.mastfrog.acteur.CheckIfUnmodifiedSinceHeader.java
@Inject CheckIfUnmodifiedSinceHeader(HttpEvent event, Page page) { DateTime dt = event.getHeader(Headers.IF_UNMODIFIED_SINCE); if (dt != null) { DateTime pageLastModified = page.getResponseHeaders().getLastModified(); if (pageLastModified != null) { boolean modSince = pageLastModified.getMillis() > dt.getMillis(); if (modSince) { setState(new RespondWith(HttpResponseStatus.PRECONDITION_FAILED)); return; }//from ww w . jav a 2s. c o m } } setState(new ConsumedState()); }
From source file:com.mastfrog.acteur.headers.Headers.java
License:Open Source License
public static String toISO2822Date(DateTime dt) { dt = new DateTime(dt.getMillis(), DateTimeZone.UTC); return dt.toDateTime(DateTimeZone.UTC).toDateTimeISO().toString(ISO2822DateFormat); }
From source file:com.mastfrog.acteur.ResponseHeaders.java
License:Open Source License
protected DateTime getLastModified() { DateTime dt = lastModified; if (dt != null) { dt = new DateTime(dt.getMillis(), DateTimeZone.UTC).withMillisOfSecond(0); }//from w w w . jav a 2 s . c om return dt; }