List of usage examples for org.joda.time DateTime getSecondOfMinute
public int getSecondOfMinute()
From source file:org.hawkular.metrics.core.impl.DateTimeService.java
License:Apache License
public DateTime getTimeSlice(DateTime dt, Duration duration) { Period p = duration.toPeriod(); if (p.getYears() != 0) { return dt.yearOfEra().roundFloorCopy().minusYears(dt.getYearOfEra() % p.getYears()); } else if (p.getMonths() != 0) { return dt.monthOfYear().roundFloorCopy().minusMonths((dt.getMonthOfYear() - 1) % p.getMonths()); } else if (p.getWeeks() != 0) { return dt.weekOfWeekyear().roundFloorCopy().minusWeeks((dt.getWeekOfWeekyear() - 1) % p.getWeeks()); } else if (p.getDays() != 0) { return dt.dayOfMonth().roundFloorCopy().minusDays((dt.getDayOfMonth() - 1) % p.getDays()); } else if (p.getHours() != 0) { return dt.hourOfDay().roundFloorCopy().minusHours(dt.getHourOfDay() % p.getHours()); } else if (p.getMinutes() != 0) { return dt.minuteOfHour().roundFloorCopy().minusMinutes(dt.getMinuteOfHour() % p.getMinutes()); } else if (p.getSeconds() != 0) { return dt.secondOfMinute().roundFloorCopy().minusSeconds(dt.getSecondOfMinute() % p.getSeconds()); }/*www.j a va 2 s . c o m*/ return dt.millisOfSecond().roundCeilingCopy().minusMillis(dt.getMillisOfSecond() % p.getMillis()); }
From source file:org.hawkular.metrics.datetime.DateTimeService.java
License:Apache License
public static DateTime getTimeSlice(DateTime dt, Duration duration) { Period p = duration.toPeriod(); if (p.getYears() != 0) { return dt.yearOfEra().roundFloorCopy().minusYears(dt.getYearOfEra() % p.getYears()); } else if (p.getMonths() != 0) { return dt.monthOfYear().roundFloorCopy().minusMonths((dt.getMonthOfYear() - 1) % p.getMonths()); } else if (p.getWeeks() != 0) { return dt.weekOfWeekyear().roundFloorCopy().minusWeeks((dt.getWeekOfWeekyear() - 1) % p.getWeeks()); } else if (p.getDays() != 0) { return dt.dayOfMonth().roundFloorCopy().minusDays((dt.getDayOfMonth() - 1) % p.getDays()); } else if (p.getHours() != 0) { return dt.hourOfDay().roundFloorCopy().minusHours(dt.getHourOfDay() % p.getHours()); } else if (p.getMinutes() != 0) { return dt.minuteOfHour().roundFloorCopy().minusMinutes(dt.getMinuteOfHour() % p.getMinutes()); } else if (p.getSeconds() != 0) { return dt.secondOfMinute().roundFloorCopy().minusSeconds(dt.getSecondOfMinute() % p.getSeconds()); }//from w w w .j a v a 2 s .c o m return dt.millisOfSecond().roundCeilingCopy().minusMillis(dt.getMillisOfSecond() % p.getMillis()); }
From source file:org.hawkular.metrics.tasks.api.AbstractTrigger.java
License:Apache License
protected DateTime getExecutionTime(long time, Duration duration) { DateTime dt = new DateTime(time); Period p = duration.toPeriod(); if (p.getYears() != 0) { return dt.yearOfEra().roundFloorCopy().minusYears(dt.getYearOfEra() % p.getYears()); } else if (p.getMonths() != 0) { return dt.monthOfYear().roundFloorCopy().minusMonths((dt.getMonthOfYear() - 1) % p.getMonths()); } else if (p.getWeeks() != 0) { return dt.weekOfWeekyear().roundFloorCopy().minusWeeks((dt.getWeekOfWeekyear() - 1) % p.getWeeks()); } else if (p.getDays() != 0) { return dt.dayOfMonth().roundFloorCopy().minusDays((dt.getDayOfMonth() - 1) % p.getDays()); } else if (p.getHours() != 0) { return dt.hourOfDay().roundFloorCopy().minusHours(dt.getHourOfDay() % p.getHours()); } else if (p.getMinutes() != 0) { return dt.minuteOfHour().roundFloorCopy().minusMinutes(dt.getMinuteOfHour() % p.getMinutes()); } else if (p.getSeconds() != 0) { return dt.secondOfMinute().roundFloorCopy().minusSeconds(dt.getSecondOfMinute() % p.getSeconds()); }//w w w .j a v a 2 s .c o m return dt.millisOfSecond().roundCeilingCopy().minusMillis(dt.getMillisOfSecond() % p.getMillis()); }
From source file:org.hortonmachine.gvsig.epanet.core.ChartHelper.java
License:Open Source License
/** * Constructor./*from w w w . ja v a 2 s .c o m*/ * * @param valuesMapList the list of ordered maps containing x,y pairs. * @param title the title of the chart. * @param xLabel the x label. * @param yLabel the y label. */ @SuppressWarnings("deprecation") public static void chart(List<LinkedHashMap<DateTime, float[]>> valuesMapList, String title, String xLabel, String yLabel) { List<TimeSeries> seriesList = new ArrayList<TimeSeries>(); for (LinkedHashMap<DateTime, float[]> valuesMap : valuesMapList) { TimeSeries[] series = new TimeSeries[0]; Set<Entry<DateTime, float[]>> entrySet = valuesMap.entrySet(); for (Entry<DateTime, float[]> entry : entrySet) { DateTime date = entry.getKey(); float[] values = entry.getValue(); if (series.length == 0) { series = new TimeSeries[values.length]; for (int i = 0; i < values.length; i++) { series[i] = new TimeSeries(i + 1); } } for (int i = 0; i < values.length; i++) { int sec = date.getSecondOfMinute(); int min = date.getMinuteOfHour(); int hour = date.getHourOfDay(); int day = date.getDayOfMonth(); int month = date.getMonthOfYear(); int year = date.getYear(); series[i].add(new Second(sec, min, hour, day, month, year), values[i]); } } for (TimeSeries timeSeries : series) { seriesList.add(timeSeries); } } TimeSeriesCollection lineDataset = new TimeSeriesCollection(); for (TimeSeries timeSeries : seriesList) { lineDataset.addSeries(timeSeries); } lineDataset.setXPosition(TimePeriodAnchor.MIDDLE); lineDataset.setDomainIsPointsInTime(true); JFreeChart theChart = ChartFactory.createTimeSeriesChart(null, xLabel, yLabel, lineDataset, seriesList.size() > 1, true, true); XYPlot thePlot = theChart.getXYPlot(); ((XYPlot) thePlot).setRenderer(new XYLineAndShapeRenderer()); XYItemRenderer renderer = ((XYPlot) thePlot).getRenderer(); DateAxis axis = (DateAxis) ((XYPlot) thePlot).getDomainAxis(); axis.setDateFormatOverride(dateFormatter); // axis.setAutoRangeMinimumSize(5.0); ValueAxis rangeAxis = ((XYPlot) thePlot).getRangeAxis(); rangeAxis.setAutoRangeMinimumSize(5.0); for (int i = 0; i < seriesList.size(); i++) { ((XYLineAndShapeRenderer) renderer).setSeriesLinesVisible(i, true); ((XYLineAndShapeRenderer) renderer).setSeriesShapesVisible(i, true); } ChartPanel chartPanel = new ChartPanel(theChart, false); chartPanel.setPreferredSize(new Dimension(600, 500)); chartPanel.setHorizontalAxisTrace(false); chartPanel.setVerticalAxisTrace(false); WindowManager windowManager = ToolsSwingLocator.getWindowManager(); windowManager.showWindow(chartPanel, title, MODE.WINDOW); }
From source file:org.iexhub.connectors.PDQQueryManager.java
License:Apache License
/** * @param qUQIIN000003UV01/*from w w w. j a v a2s.c o m*/ */ private void setCreationTime(QUQIIN000003UV01Type qUQIIN000003UV01) { DateTime dt = new DateTime(DateTimeZone.UTC); TS creationTime = new TS(); StringBuilder timeBuilder = new StringBuilder(); timeBuilder.append(dt.getYear()); timeBuilder.append((dt.getMonthOfYear() < 10) ? ("0" + dt.getMonthOfYear()) : dt.getMonthOfYear()); timeBuilder.append((dt.getDayOfMonth() < 10) ? ("0" + dt.getDayOfMonth()) : dt.getDayOfMonth()); timeBuilder.append((dt.getHourOfDay() < 10) ? ("0" + dt.getHourOfDay()) : dt.getHourOfDay()); timeBuilder.append((dt.getMinuteOfHour() < 10) ? ("0" + dt.getMinuteOfHour()) : dt.getMinuteOfHour()); timeBuilder.append((dt.getSecondOfMinute() < 10) ? ("0" + dt.getSecondOfMinute()) : dt.getSecondOfMinute()); creationTime.setValue(timeBuilder.toString()); qUQIIN000003UV01.setCreationTime(creationTime); }
From source file:org.iexhub.connectors.PDQQueryManager.java
License:Apache License
/** * @param pRPA_IN201305UV02/*from w ww . j a v a2s .c o m*/ */ private void setCreationTime(PRPAIN201305UV02 pRPA_IN201305UV02) { DateTime dt = new DateTime(DateTimeZone.UTC); TS creationTime = new TS(); StringBuilder timeBuilder = new StringBuilder(); timeBuilder.append(dt.getYear()); timeBuilder.append((dt.getMonthOfYear() < 10) ? ("0" + dt.getMonthOfYear()) : dt.getMonthOfYear()); timeBuilder.append((dt.getDayOfMonth() < 10) ? ("0" + dt.getDayOfMonth()) : dt.getDayOfMonth()); timeBuilder.append((dt.getHourOfDay() < 10) ? ("0" + dt.getHourOfDay()) : dt.getHourOfDay()); timeBuilder.append((dt.getMinuteOfHour() < 10) ? ("0" + dt.getMinuteOfHour()) : dt.getMinuteOfHour()); timeBuilder.append((dt.getSecondOfMinute() < 10) ? ("0" + dt.getSecondOfMinute()) : dt.getSecondOfMinute()); creationTime.setValue(timeBuilder.toString()); pRPA_IN201305UV02.setCreationTime(creationTime); }
From source file:org.iexhub.connectors.PIXManager.java
License:Apache License
/** * @param patientId/*from ww w. java 2 s .c om*/ * @param domainOID * @param populateDataSource * @return * @throws IOException */ public PRPAIN201310UV02 patientRegistryGetIdentifiers(String patientId, String domainOID, boolean populateDataSource) throws IOException { if ((patientId == null) || (patientId.length() == 0)) { throw new PatientIdParamMissingException("PatientId parameter is required"); } PRPAIN201309UV02 pRPA_IN201309UV02 = new PRPAIN201309UV02(); // ITS version... pRPA_IN201309UV02.setITSVersion("XML_1.0"); // ID... II messageId = new II(); messageId.setRoot(iExHubDomainOid); messageId.setExtension(UUID.randomUUID().toString()); pRPA_IN201309UV02.setId(messageId); // Creation time... DateTime dt = new DateTime(DateTimeZone.UTC); TS creationTime = new TS(); StringBuilder creationTimeBuilder = new StringBuilder(); creationTimeBuilder.append(dt.getYear()); creationTimeBuilder.append((dt.getMonthOfYear() < 10) ? ("0" + dt.getMonthOfYear()) : dt.getMonthOfYear()); creationTimeBuilder.append((dt.getDayOfMonth() < 10) ? ("0" + dt.getDayOfMonth()) : dt.getDayOfMonth()); creationTimeBuilder.append((dt.getHourOfDay() < 10) ? ("0" + dt.getHourOfDay()) : dt.getHourOfDay()); creationTimeBuilder .append((dt.getMinuteOfHour() < 10) ? ("0" + dt.getMinuteOfHour()) : dt.getMinuteOfHour()); creationTimeBuilder .append((dt.getSecondOfMinute() < 10) ? ("0" + dt.getSecondOfMinute()) : dt.getSecondOfMinute()); creationTime.setValue(creationTimeBuilder.toString()); pRPA_IN201309UV02.setCreationTime(creationTime); // Interaction ID... II interactionId = new II(); interactionId.setRoot("2.16.840.1.113883.1.6"); interactionId.setExtension("PRPA_IN201309UV02"); pRPA_IN201309UV02.setInteractionId(interactionId); // Processing code... CS processingCode = new CS(); processingCode.setCode("P"); pRPA_IN201309UV02.setProcessingCode(processingCode); // Processing mode code... CS processingModeCode = new CS(); processingModeCode.setCode("T"); pRPA_IN201309UV02.setProcessingModeCode(processingModeCode); // Accept ack code... CS acceptAckCode = new CS(); acceptAckCode.setCode("AL"); pRPA_IN201309UV02.setAcceptAckCode(acceptAckCode); // Create receiver... MCCIMT000100UV01Receiver receiver = new MCCIMT000100UV01Receiver(); receiver.setTypeCode(CommunicationFunctionType.RCV); MCCIMT000100UV01Device receiverDevice = new MCCIMT000100UV01Device(); receiverDevice.setClassCode(EntityClassDevice.DEV); receiverDevice.setDeterminerCode("INSTANCE"); II receiverDeviceId = new II(); receiverDeviceId.setRoot(receiverApplicationName); receiverDevice.getId().add(receiverDeviceId); receiver.setDevice(receiverDevice); pRPA_IN201309UV02.getReceiver().add(receiver); // Create sender... MCCIMT000100UV01Sender sender = new MCCIMT000100UV01Sender(); sender.setTypeCode(CommunicationFunctionType.SND); MCCIMT000100UV01Device senderDevice = new MCCIMT000100UV01Device(); senderDevice.setClassCode(EntityClassDevice.DEV); senderDevice.setDeterminerCode("INSTANCE"); II senderDeviceId = new II(); senderDeviceId.setRoot(PIXManager.iExHubSenderDeviceId); senderDevice.getId().add(senderDeviceId); sender.setDevice(senderDevice); pRPA_IN201309UV02.setSender(sender); // Create AuthorOrPerformer... QUQIMT021001UV01AuthorOrPerformer authorOrPerformer = new QUQIMT021001UV01AuthorOrPerformer(); authorOrPerformer.setTypeCode(XParticipationAuthorPerformer.fromValue("AUT")); COCTMT090100UV01AssignedPerson assignedPerson = new COCTMT090100UV01AssignedPerson(); assignedPerson.setClassCode("ASSIGNED"); II assignedPersonId = new II(); assignedPersonId.setRoot(PIXManager.iExHubDomainOid); assignedPersonId.setExtension("IExHub"); assignedPerson.getId().add(assignedPersonId); authorOrPerformer.setAssignedPerson( objectFactory.createQUQIMT021001UV01AuthorOrPerformerAssignedPerson(assignedPerson)); // Create QueryByParameter... PRPAMT201307UV02QueryByParameter queryByParam = new PRPAMT201307UV02QueryByParameter(); II queryId = new II(); queryId.setRoot(queryIdOid); queryId.setExtension(UUID.randomUUID().toString()); queryByParam.setQueryId(queryId); CS responsePriorityCode = new CS(); responsePriorityCode.setCode("I"); queryByParam.setResponsePriorityCode(responsePriorityCode); CS statusCode = new CS(); statusCode.setCode("new"); queryByParam.setStatusCode(statusCode); // Create ParameterList... PRPAMT201307UV02ParameterList paramList = new PRPAMT201307UV02ParameterList(); if (populateDataSource) { // Create DataSource... PRPAMT201307UV02DataSource dataSource = new PRPAMT201307UV02DataSource(); II dataSourceId = new II(); dataSourceId.setRoot(dataSourceOid); dataSource.getValue().add(dataSourceId); ST dataSourceSemanticsText = new ST(); dataSourceSemanticsText.getContent().add("DataSource.id"); dataSource.setSemanticsText(dataSourceSemanticsText); paramList.getDataSource().add(dataSource); } // Create PatientIdentifier... PRPAMT201307UV02PatientIdentifier patientIdentifier = new PRPAMT201307UV02PatientIdentifier(); II patientIdentifierId = new II(); patientIdentifierId.setRoot(domainOID); patientIdentifierId.setExtension(patientId); patientIdentifier.getValue().add(patientIdentifierId); ST patientIdentifierSemanticsText = new ST(); patientIdentifierSemanticsText.getContent().add("Patient.Id"); patientIdentifier.setSemanticsText(patientIdentifierSemanticsText); paramList.getPatientIdentifier().add(patientIdentifier); queryByParam.setParameterList(paramList); // Create ControlActProcess... PRPAIN201309UV02QUQIMT021001UV01ControlActProcess controlAct = new PRPAIN201309UV02QUQIMT021001UV01ControlActProcess(); CD controlActProcessCode = new CD(); controlActProcessCode.setCode("PRPA_TE201309UV02"); controlActProcessCode.setCodeSystem("2.16.840.1.113883.1.6"); controlAct.setCode(controlActProcessCode); controlAct.setClassCode(ActClassControlAct.CACT); controlAct.setMoodCode(XActMoodIntentEvent.EVN); controlAct.getAuthorOrPerformer().add(authorOrPerformer); controlAct.setQueryByParameter(objectFactory .createPRPAIN201309UV02QUQIMT021001UV01ControlActProcessQueryByParameter(queryByParam)); pRPA_IN201309UV02.setControlActProcess(controlAct); OMElement requestElement = pixManagerStub.toOM(pRPA_IN201309UV02, pixManagerStub .optimizeContent(new javax.xml.namespace.QName("urn:hl7-org:v3", "PRPA_IN201301UV02")), new javax.xml.namespace.QName("urn:hl7-org:v3", "PRPA_IN201309UV02")); String queryText = requestElement.toString(); UUID logMsgId = null; if (logPixRequestMessages) { logMsgId = UUID.randomUUID(); Files.write(Paths.get(logOutputPath + logMsgId.toString() + "_PIXGetIdentifiersRequest.xml"), requestElement.toString().getBytes()); } logIti45AuditMsg(queryText, patientId + "^^^&" + domainOID + "&ISO"); PRPAIN201310UV02 response = pixManagerStub.pIXManager_PRPA_IN201309UV02(pRPA_IN201309UV02); if (logPixResponseMessages) { OMElement responseElement = pixManagerStub.toOM(response, pixManagerStub .optimizeContent(new javax.xml.namespace.QName("urn:hl7-org:v3", "PRPA_IN201310UV02")), new javax.xml.namespace.QName("urn:hl7-org:v3", "PRPA_IN201310UV02")); Files.write(Paths .get(logOutputPath + ((logMsgId == null) ? UUID.randomUUID().toString() : logMsgId.toString()) + "_PIXGetIdentifiersResponse.xml"), responseElement.toString().getBytes()); } return response; }
From source file:org.iexhub.connectors.PIXManager.java
License:Apache License
/** * @param fhirPatientResource/*from w w w . j a va2s . c o m*/ * @return * @throws IOException */ public MCCIIN000002UV01 registerPatient(Patient fhirPatientResource) throws IOException { String dateOfBirth = (fhirPatientResource.getBirthDate() != null) ? fhirPatientResource.getBirthDateElement().getValueAsString() : null; String gender = (fhirPatientResource.getGender() == null) ? "" : (fhirPatientResource.getGender() .compareToIgnoreCase(AdministrativeGenderEnum.MALE.getCode()) == 0) ? "M" : ((fhirPatientResource.getGender() .compareToIgnoreCase(AdministrativeGenderEnum.FEMALE.getCode()) == 0) ? "F" : ((fhirPatientResource.getGender().compareToIgnoreCase( AdministrativeGenderEnum.OTHER.getCode()) == 0) ? "UN" : "")); if ((fhirPatientResource.getName().get(0).getFamilyAsSingleString() == null) || (fhirPatientResource.getName().get(0).getFamilyAsSingleString().length() == 0)) { throw new FamilyNameParamMissingException("FamilyName parameter is required"); } PRPAIN201301UV02 pRPA_IN201301UV02 = new PRPAIN201301UV02(); // ITS version... pRPA_IN201301UV02.setITSVersion("XML_1.0"); // ID... II messageId = new II(); messageId.setRoot(iExHubDomainOid); messageId.setExtension(UUID.randomUUID().toString()); pRPA_IN201301UV02.setId(messageId); // Creation time... DateTime dt = new DateTime(DateTimeZone.UTC); TS creationTime = new TS(); StringBuilder creationTimeBuilder = new StringBuilder(); creationTimeBuilder.append(dt.getYear()); creationTimeBuilder.append((dt.getMonthOfYear() < 10) ? ("0" + dt.getMonthOfYear()) : dt.getMonthOfYear()); creationTimeBuilder.append((dt.getDayOfMonth() < 10) ? ("0" + dt.getDayOfMonth()) : dt.getDayOfMonth()); creationTimeBuilder.append((dt.getHourOfDay() < 10) ? ("0" + dt.getHourOfDay()) : dt.getHourOfDay()); creationTimeBuilder .append((dt.getMinuteOfHour() < 10) ? ("0" + dt.getMinuteOfHour()) : dt.getMinuteOfHour()); creationTimeBuilder .append((dt.getSecondOfMinute() < 10) ? ("0" + dt.getSecondOfMinute()) : dt.getSecondOfMinute()); creationTime.setValue(creationTimeBuilder.toString()); pRPA_IN201301UV02.setCreationTime(creationTime); // Interaction ID... II interactionId = new II(); interactionId.setRoot("2.16.840.1.113883.1.6"); interactionId.setExtension("PRPA_IN201301UV02"); pRPA_IN201301UV02.setInteractionId(interactionId); // Processing code... CS processingCode = new CS(); processingCode.setCode("P"); pRPA_IN201301UV02.setProcessingCode(processingCode); // Processing mode code... CS processingModeCode = new CS(); processingModeCode.setCode("T"); pRPA_IN201301UV02.setProcessingModeCode(processingModeCode); // Accept ack code... CS acceptAckCode = new CS(); acceptAckCode.setCode("AL"); pRPA_IN201301UV02.setAcceptAckCode(acceptAckCode); // Create receiver... MCCIMT000100UV01Receiver receiver = new MCCIMT000100UV01Receiver(); receiver.setTypeCode(CommunicationFunctionType.RCV); MCCIMT000100UV01Device receiverDevice = new MCCIMT000100UV01Device(); receiverDevice.setClassCode(EntityClassDevice.DEV); receiverDevice.setDeterminerCode("INSTANCE"); II receiverDeviceId = new II(); receiverDeviceId.setRoot(receiverApplicationName); receiverDevice.getId().add(receiverDeviceId); MCCIMT000100UV01Agent asAgent = new MCCIMT000100UV01Agent(); asAgent.getClassCode().add("AGNT"); MCCIMT000100UV01Organization representedOrganization = new MCCIMT000100UV01Organization(); representedOrganization.setDeterminerCode("INSTANCE"); representedOrganization.setClassCode("ORG"); II representedOrganizationId = new II(); representedOrganizationId.setRoot(PIXManager.receiverApplicationRepresentedOrganization); representedOrganization.getId().add(representedOrganizationId); asAgent.setRepresentedOrganization( objectFactory.createMCCIMT000100UV01AgentRepresentedOrganization(representedOrganization)); receiverDevice.setAsAgent(objectFactory.createMCCIMT000100UV01DeviceAsAgent(asAgent)); receiver.setDevice(receiverDevice); pRPA_IN201301UV02.getReceiver().add(receiver); // Create sender... MCCIMT000100UV01Sender sender = new MCCIMT000100UV01Sender(); sender.setTypeCode(CommunicationFunctionType.SND); MCCIMT000100UV01Device senderDevice = new MCCIMT000100UV01Device(); senderDevice.setClassCode(EntityClassDevice.DEV); senderDevice.setDeterminerCode("INSTANCE"); II senderDeviceId = new II(); senderDeviceId.setRoot(PIXManager.iExHubSenderDeviceId); senderDevice.getId().add(senderDeviceId); MCCIMT000100UV01Agent senderAsAgent = new MCCIMT000100UV01Agent(); senderAsAgent.getClassCode().add("AGNT"); MCCIMT000100UV01Organization senderRepresentedOrganization = new MCCIMT000100UV01Organization(); senderRepresentedOrganization.setDeterminerCode("INSTANCE"); senderRepresentedOrganization.setClassCode("ORG"); II senderRepresentedOrganizationId = new II(); senderRepresentedOrganizationId.setRoot(PIXManager.iExHubDomainOid); senderRepresentedOrganization.getId().add(senderRepresentedOrganizationId); senderAsAgent.setRepresentedOrganization( objectFactory.createMCCIMT000100UV01AgentRepresentedOrganization(senderRepresentedOrganization)); senderDevice.setAsAgent(objectFactory.createMCCIMT000100UV01DeviceAsAgent(senderAsAgent)); sender.setDevice(senderDevice); pRPA_IN201301UV02.setSender(sender); PRPAIN201301UV02MFMIMT700701UV01Subject1 subject = new PRPAIN201301UV02MFMIMT700701UV01Subject1(); // Create Registration Event... PRPAIN201301UV02MFMIMT700701UV01RegistrationEvent registrationEvent = new PRPAIN201301UV02MFMIMT700701UV01RegistrationEvent(); registrationEvent.getClassCode().add("REG"); registrationEvent.getMoodCode().add("EVN"); registrationEvent.getNullFlavor().add("NA"); CS statusCode = new CS(); statusCode.setCode("active"); registrationEvent.setStatusCode(statusCode); PRPAIN201301UV02MFMIMT700701UV01Subject2 subject1 = new PRPAIN201301UV02MFMIMT700701UV01Subject2(); subject1.setTypeCode(ParticipationTargetSubject.SBJ); // Create Patient... PRPAMT201301UV02Patient patient = new PRPAMT201301UV02Patient(); patient.getClassCode().add("PAT"); CS patientStatusCode = new CS(); patientStatusCode.setCode("active"); patient.setStatusCode(patientStatusCode); // Create PatientPerson... PRPAMT201301UV02Person patientPerson = new PRPAMT201301UV02Person(); // Other ID's specified... II constructedPatientId = null; if (fhirPatientResource.getIdentifier() != null) { for (IdentifierDt fhirId : fhirPatientResource.getIdentifier()) { if ((fhirId.getUse() != null) && (fhirId.getUse().equals(IdentifierUseEnum.OFFICIAL.getCode()))) { // This is the official identifier constructedPatientId = new II(); if ((fhirId.getSystem() == null) || (fhirId.getSystem().length() == 0)) { throw new PatientIdParamMissingException("Patient ID system missing"); } constructedPatientId.setRoot((fhirId.getSystem().toLowerCase().startsWith(uriPrefix)) ? fhirId.getSystem().replace(uriPrefix, "") : fhirId.getSystem()); constructedPatientId.setExtension(fhirId.getValue()); constructedPatientId.setAssigningAuthorityName(PIXManager.iExHubAssigningAuthority); patient.getId().add(constructedPatientId); } else { PRPAMT201301UV02OtherIDs asOtherId = new PRPAMT201301UV02OtherIDs(); asOtherId.getClassCode().add("SD"); II otherId = new II(); otherId.setRoot(fhirId.getSystemElement().getValueAsString()); otherId.setExtension(fhirId.getValue()); asOtherId.getId().add(otherId); COCTMT150002UV01Organization scopingOrg = new COCTMT150002UV01Organization(); scopingOrg.setClassCode("ORG"); scopingOrg.setDeterminerCode("INSTANCE"); II scopingOrgId = new II(); scopingOrgId.setRoot(fhirId.getSystemElement().getValueAsString()); scopingOrg.getId().add(scopingOrgId); asOtherId.setScopingOrganization(scopingOrg); patientPerson.getAsOtherIDs().add(asOtherId); } } } patientPerson.getName().add(populatePersonName(fhirPatientResource.getName().get(0))); if ((gender != null) && (gender.length() > 0)) { CE adminGenderCode = new CE(); adminGenderCode.setCode(gender); adminGenderCode.setCodeSystem("2.16.840.1.113883.5.1"); patientPerson.setAdministrativeGenderCode(adminGenderCode); } else { CE adminGenderCode = new CE(); adminGenderCode.getNullFlavor().add("UNK"); adminGenderCode.setCodeSystem("2.16.840.1.113883.5.1"); patientPerson.setAdministrativeGenderCode(adminGenderCode); } patientPerson.getClassCode().add("PSN"); patientPerson.setDeterminerCode("INSTANCE"); if ((fhirPatientResource.getTelecom() != null) && (!fhirPatientResource.getTelecom().isEmpty())) { for (ContactPointDt contactPoint : fhirPatientResource.getTelecom()) { // Add if telecom value is present only if (contactPoint.getValue() != null && !contactPoint.getValue().isEmpty()) { TEL contactPartyTelecom = new TEL(); contactPartyTelecom.setValue(contactPoint.getValue()); patientPerson.getTelecom().add(contactPartyTelecom); } } } if (dateOfBirth != null) { // Try several formats for date parsing... DateTimeFormatter formatter = null; DateTime birthDateTime = null; try { formatter = DateTimeFormat.forPattern("MM/dd/yyyy"); birthDateTime = formatter.parseDateTime(dateOfBirth); } catch (Exception e) { try { formatter = DateTimeFormat.forPattern("yyyy-MM-dd"); birthDateTime = formatter.parseDateTime(dateOfBirth); } catch (Exception e2) { throw e2; } } StringBuilder birthDateBuilder = new StringBuilder(); birthDateBuilder.append(birthDateTime.getYear()); birthDateBuilder.append((birthDateTime.getMonthOfYear() < 10) ? ("0" + birthDateTime.getMonthOfYear()) : birthDateTime.getMonthOfYear()); birthDateBuilder.append((birthDateTime.getDayOfMonth() < 10) ? ("0" + birthDateTime.getDayOfMonth()) : birthDateTime.getDayOfMonth()); TS birthTime = new TS(); birthTime.setValue(birthDateBuilder.toString()); patientPerson.setBirthTime(birthTime); } JAXBElement<PRPAMT201301UV02Person> patientPersonElement = objectFactory .createPRPAMT201301UV02PatientPatientPerson(patientPerson); patient.setPatientPerson(patientPersonElement); // Create ProviderOrganization - set IExHub as provider if no careProvider specified in FHIR patient resource parameter... COCTMT150003UV03Organization providerOrganization = new COCTMT150003UV03Organization(); providerOrganization.setDeterminerCode("INSTANCE"); providerOrganization.setClassCode("ORG"); if ((fhirPatientResource.getCareProvider() != null) && (!fhirPatientResource.getCareProvider().isEmpty())) { for (ResourceReferenceDt resourceRef : fhirPatientResource.getCareProvider()) { if (resourceRef.getResource().getClass() == Organization.class) { Organization careProvider = (Organization) resourceRef.getResource(); // Provider ID II providerId = new II(); providerId.setRoot((careProvider.getId().getValueAsString().startsWith("#")) ? careProvider.getId().getValueAsString().substring(1) : careProvider.getId().getValueAsString()); providerOrganization.getId().add(providerId); // Provider name if ((careProvider.getName() != null) && (careProvider.getName().length() > 0)) { ON providerName = new ON(); providerName.getContent().add(careProvider.getName()); providerOrganization.getName().add(providerName); } // Create Contact Party if FHIR organization contacts are present... for (Contact fhirOrganizationContact : careProvider.getContact()) { COCTMT150003UV03ContactParty contactParty = new COCTMT150003UV03ContactParty(); contactParty.setClassCode(RoleClassContact.CON); // Contact telecom(s) if ((fhirOrganizationContact.getTelecom() != null) && (!fhirOrganizationContact.getTelecom().isEmpty())) { for (ContactPointDt contactPoint : fhirOrganizationContact.getTelecom()) { TEL contactPartyTelecom = new TEL(); contactPartyTelecom.setValue(contactPoint.getValue()); contactParty.getTelecom().add(contactPartyTelecom); } } // Contact name if ((fhirOrganizationContact.getName() != null) && (!fhirOrganizationContact.getName().isEmpty())) { COCTMT150003UV03Person contactPerson = new COCTMT150003UV03Person(); contactPerson.getName().add(populatePersonName(fhirOrganizationContact.getName())); contactParty.setContactPerson( objectFactory.createCOCTMT150003UV03ContactPartyContactPerson(contactPerson)); } // Contact address(es) if ((careProvider.getAddress() != null) && (!careProvider.getAddress().isEmpty())) { for (AddressDt fhirAddr : careProvider.getAddress()) { contactParty.getAddr().add(populatePatientAddress(fhirAddr)); } } providerOrganization.getContactParty().add(contactParty); } } } } else { II providerId = new II(); providerId.setRoot(providerOrganizationOid); providerOrganization.getId().add(providerId); ON providerName = new ON(); providerName.getContent().add(providerOrganizationName); providerOrganization.getName().add(providerName); COCTMT150003UV03ContactParty contactParty = new COCTMT150003UV03ContactParty(); contactParty.setClassCode(RoleClassContact.CON); TEL contactPartyTelecom = new TEL(); contactPartyTelecom.setValue(providerOrganizationContactTelecom); contactParty.getTelecom().add(contactPartyTelecom); providerOrganization.getContactParty().add(contactParty); } patient.setProviderOrganization(providerOrganization); subject1.setPatient(patient); registrationEvent.setSubject1(subject1); // Create Custodian info... MFMIMT700701UV01Custodian custodian = new MFMIMT700701UV01Custodian(); custodian.getTypeCode().add("CST"); COCTMT090003UV01AssignedEntity assignedEntity = new COCTMT090003UV01AssignedEntity(); assignedEntity.setClassCode("ASSIGNED"); II assignedEntityId = new II(); assignedEntityId.setRoot(iExHubDomainOid); assignedEntity.getId().add(assignedEntityId); COCTMT090003UV01Organization assignedOrganization = new COCTMT090003UV01Organization(); assignedOrganization.setDeterminerCode("INSTANCE"); assignedOrganization.setClassCode("ORG"); EN organizationName = new EN(); organizationName.getContent().add("IHE Portal"); assignedOrganization.getName().add(organizationName); assignedEntity.setAssignedOrganization( objectFactory.createCOCTMT090003UV01AssignedEntityAssignedOrganization(assignedOrganization)); custodian.setAssignedEntity(assignedEntity); registrationEvent.setCustodian(custodian); // Set Subject info... subject.getTypeCode().add("SUBJ"); subject.setRegistrationEvent(registrationEvent); PRPAIN201301UV02MFMIMT700701UV01ControlActProcess controlAct = new PRPAIN201301UV02MFMIMT700701UV01ControlActProcess(); CD controlActProcessCode = new CD(); controlActProcessCode.setCode("PRPA_TE201301UV02"); controlActProcessCode.setCodeSystem("2.16.840.1.113883.1.6"); controlAct.setCode(controlActProcessCode); controlAct.setClassCode(ActClassControlAct.CACT); controlAct.setMoodCode(XActMoodIntentEvent.EVN); controlAct.getSubject().add(subject); pRPA_IN201301UV02.setControlActProcess(controlAct); logIti44AuditMsg(constructedPatientId.getExtension() + "^^^&" + constructedPatientId.getRoot() + "&" + PIXManager.iExHubAssigningAuthority); UUID logMsgId = null; if (logPixRequestMessages) { logMsgId = UUID.randomUUID(); OMElement requestElement = pixManagerStub.toOM(pRPA_IN201301UV02, pixManagerStub .optimizeContent(new javax.xml.namespace.QName("urn:hl7-org:v3", "PRPA_IN201301UV02")), new javax.xml.namespace.QName("urn:hl7-org:v3", "PRPA_IN201301UV02")); Files.write(Paths.get(logOutputPath + logMsgId.toString() + "_PIXRegisterPatientRequest.xml"), requestElement.toString().getBytes()); } MCCIIN000002UV01 response = pixManagerStub.pIXManager_PRPA_IN201301UV02(pRPA_IN201301UV02); if (logPixResponseMessages) { OMElement responseElement = pixManagerStub.toOM(response, pixManagerStub .optimizeContent(new javax.xml.namespace.QName("urn:hl7-org:v3", "MCCI_IN000002UV01")), new javax.xml.namespace.QName("urn:hl7-org:v3", "MCCI_IN000002UV01")); Files.write(Paths .get(logOutputPath + ((logMsgId == null) ? UUID.randomUUID().toString() : logMsgId.toString()) + "_PIXRegisterPatientResponse.xml"), responseElement.toString().getBytes()); } return response; }
From source file:org.iexhub.connectors.PIXManager.java
License:Apache License
/** * @param givenName//www . j a va 2s . co m * @param familyName * @param middleName * @param dateOfBirth * @param gender * @param patientId * @return * @throws IOException */ public MCCIIN000002UV01 registerPatient(String givenName, String familyName, String middleName, String dateOfBirth, String gender, String patientId) throws IOException { if ((familyName == null) || (familyName.length() == 0)) { throw new FamilyNameParamMissingException("FamilyName parameter is required"); } PRPAIN201301UV02 pRPA_IN201301UV02 = new PRPAIN201301UV02(); // ITS version... pRPA_IN201301UV02.setITSVersion("XML_1.0"); // ID... II messageId = new II(); messageId.setRoot(iExHubDomainOid); messageId.setExtension(UUID.randomUUID().toString()); pRPA_IN201301UV02.setId(messageId); // Creation time... DateTime dt = new DateTime(DateTimeZone.UTC); TS creationTime = new TS(); StringBuilder creationTimeBuilder = new StringBuilder(); creationTimeBuilder.append(dt.getYear()); creationTimeBuilder.append((dt.getMonthOfYear() < 10) ? ("0" + dt.getMonthOfYear()) : dt.getMonthOfYear()); creationTimeBuilder.append((dt.getDayOfMonth() < 10) ? ("0" + dt.getDayOfMonth()) : dt.getDayOfMonth()); creationTimeBuilder.append((dt.getHourOfDay() < 10) ? ("0" + dt.getHourOfDay()) : dt.getHourOfDay()); creationTimeBuilder .append((dt.getMinuteOfHour() < 10) ? ("0" + dt.getMinuteOfHour()) : dt.getMinuteOfHour()); creationTimeBuilder .append((dt.getSecondOfMinute() < 10) ? ("0" + dt.getSecondOfMinute()) : dt.getSecondOfMinute()); creationTime.setValue(creationTimeBuilder.toString()); pRPA_IN201301UV02.setCreationTime(creationTime); // Interaction ID... II interactionId = new II(); interactionId.setRoot("2.16.840.1.113883.1.6"); interactionId.setExtension("PRPA_IN201301UV02"); pRPA_IN201301UV02.setInteractionId(interactionId); // Processing code... CS processingCode = new CS(); processingCode.setCode("P"); pRPA_IN201301UV02.setProcessingCode(processingCode); // Processing mode code... CS processingModeCode = new CS(); processingModeCode.setCode("T"); pRPA_IN201301UV02.setProcessingModeCode(processingModeCode); // Accept ack code... CS acceptAckCode = new CS(); acceptAckCode.setCode("AL"); pRPA_IN201301UV02.setAcceptAckCode(acceptAckCode); // Create receiver... MCCIMT000100UV01Receiver receiver = new MCCIMT000100UV01Receiver(); receiver.setTypeCode(CommunicationFunctionType.RCV); MCCIMT000100UV01Device receiverDevice = new MCCIMT000100UV01Device(); receiverDevice.setClassCode(EntityClassDevice.DEV); receiverDevice.setDeterminerCode("INSTANCE"); II receiverDeviceId = new II(); receiverDeviceId.setRoot(receiverApplicationName); receiverDevice.getId().add(receiverDeviceId); MCCIMT000100UV01Agent asAgent = new MCCIMT000100UV01Agent(); asAgent.getClassCode().add("AGNT"); MCCIMT000100UV01Organization representedOrganization = new MCCIMT000100UV01Organization(); representedOrganization.setDeterminerCode("INSTANCE"); representedOrganization.setClassCode("ORG"); II representedOrganizationId = new II(); representedOrganizationId.setRoot(PIXManager.receiverApplicationRepresentedOrganization); representedOrganization.getId().add(representedOrganizationId); asAgent.setRepresentedOrganization( objectFactory.createMCCIMT000100UV01AgentRepresentedOrganization(representedOrganization)); receiverDevice.setAsAgent(objectFactory.createMCCIMT000100UV01DeviceAsAgent(asAgent)); receiver.setDevice(receiverDevice); pRPA_IN201301UV02.getReceiver().add(receiver); // Create sender... MCCIMT000100UV01Sender sender = new MCCIMT000100UV01Sender(); sender.setTypeCode(CommunicationFunctionType.SND); MCCIMT000100UV01Device senderDevice = new MCCIMT000100UV01Device(); senderDevice.setClassCode(EntityClassDevice.DEV); senderDevice.setDeterminerCode("INSTANCE"); II senderDeviceId = new II(); senderDeviceId.setRoot(PIXManager.iExHubSenderDeviceId); senderDevice.getId().add(senderDeviceId); MCCIMT000100UV01Agent senderAsAgent = new MCCIMT000100UV01Agent(); senderAsAgent.getClassCode().add("AGNT"); MCCIMT000100UV01Organization senderRepresentedOrganization = new MCCIMT000100UV01Organization(); senderRepresentedOrganization.setDeterminerCode("INSTANCE"); senderRepresentedOrganization.setClassCode("ORG"); II senderRepresentedOrganizationId = new II(); senderRepresentedOrganizationId.setRoot(PIXManager.iExHubDomainOid); senderRepresentedOrganization.getId().add(senderRepresentedOrganizationId); senderAsAgent.setRepresentedOrganization( objectFactory.createMCCIMT000100UV01AgentRepresentedOrganization(senderRepresentedOrganization)); senderDevice.setAsAgent(objectFactory.createMCCIMT000100UV01DeviceAsAgent(senderAsAgent)); sender.setDevice(senderDevice); pRPA_IN201301UV02.setSender(sender); PRPAIN201301UV02MFMIMT700701UV01Subject1 subject = new PRPAIN201301UV02MFMIMT700701UV01Subject1(); // Create Registration Event... PRPAIN201301UV02MFMIMT700701UV01RegistrationEvent registrationEvent = new PRPAIN201301UV02MFMIMT700701UV01RegistrationEvent(); registrationEvent.getClassCode().add("REG"); registrationEvent.getMoodCode().add("EVN"); registrationEvent.getNullFlavor().add("NA"); CS statusCode = new CS(); statusCode.setCode("active"); registrationEvent.setStatusCode(statusCode); PRPAIN201301UV02MFMIMT700701UV01Subject2 subject1 = new PRPAIN201301UV02MFMIMT700701UV01Subject2(); subject1.setTypeCode(ParticipationTargetSubject.SBJ); // Create Patient... PRPAMT201301UV02Patient patient = new PRPAMT201301UV02Patient(); patient.getClassCode().add("PAT"); II constructedPatientId = new II(); constructedPatientId.setRoot(PIXManager.patientIdAssigningAuthority); constructedPatientId.setExtension(UUID.randomUUID().toString()); constructedPatientId.setAssigningAuthorityName(PIXManager.iExHubAssigningAuthority); patient.getId().add(constructedPatientId); CS patientStatusCode = new CS(); patientStatusCode.setCode("active"); patient.setStatusCode(patientStatusCode); // Create PatientPerson... PRPAMT201301UV02Person patientPerson = new PRPAMT201301UV02Person(); // // Other ID's specified... // if (fhirIdentifiers != null) // { // for (IdentifierDt fhirId : fhirIdentifiers) // { // PRPAMT201301UV02OtherIDs asOtherId = new PRPAMT201301UV02OtherIDs(); // asOtherId.getClassCode().add("SD"); // II otherId = new II(); // otherId.setRoot(fhirId.getSystemElement().getValueAsString()); // otherId.setExtension(fhirId.getValue()); // asOtherId.getId().add(otherId); // // COCTMT150002UV01Organization scopingOrg = new COCTMT150002UV01Organization(); // scopingOrg.setClassCode("ORG"); // scopingOrg.setDeterminerCode("INSTANCE"); // II scopingOrgId = new II(); // scopingOrgId.setRoot(fhirId.getSystemElement().getValueAsString()); // scopingOrg.getId().add(scopingOrgId); // asOtherId.setScopingOrganization(scopingOrg); // // patientPerson.getAsOtherIDs().add(asOtherId); // } // } EnFamily enFamily = null; if ((familyName != null) && (familyName.length() > 0)) { enFamily = new EnFamily(); enFamily.getContent().add(familyName); } EnGiven enGiven = null; if ((givenName != null) && (givenName.length() > 0)) { enGiven = new EnGiven(); if ((middleName != null) && (middleName.length() > 0)) { enGiven.getContent().add(givenName + " " + middleName); } else { enGiven.getContent().add(givenName); } } PN patientName = new PN(); patientName.getContent().add(objectFactory.createENFamily(enFamily)); if (enGiven != null) { patientName.getContent().add(objectFactory.createENGiven(enGiven)); } patientPerson.getName().add(patientName); if ((gender != null) && (gender.length() > 0)) { CE adminGenderCode = new CE(); adminGenderCode.setCode(gender); adminGenderCode.setCodeSystem("2.16.840.1.113883.5.1"); patientPerson.setAdministrativeGenderCode(adminGenderCode); } else { CE adminGenderCode = new CE(); adminGenderCode.getNullFlavor().add("UNK"); adminGenderCode.setCodeSystem("2.16.840.1.113883.5.1"); patientPerson.setAdministrativeGenderCode(adminGenderCode); } patientPerson.getClassCode().add("PSN"); patientPerson.setDeterminerCode("INSTANCE"); if (dateOfBirth != null) { // Try several formats for date parsing... DateTimeFormatter formatter = null; DateTime birthDateTime = null; try { formatter = DateTimeFormat.forPattern("MM/dd/yyyy"); birthDateTime = formatter.parseDateTime(dateOfBirth); } catch (Exception e) { try { formatter = DateTimeFormat.forPattern("yyyy-MM-dd"); birthDateTime = formatter.parseDateTime(dateOfBirth); } catch (Exception e2) { throw e2; } } StringBuilder birthDateBuilder = new StringBuilder(); birthDateBuilder.append(birthDateTime.getYear()); birthDateBuilder.append((birthDateTime.getMonthOfYear() < 10) ? ("0" + birthDateTime.getMonthOfYear()) : birthDateTime.getMonthOfYear()); birthDateBuilder.append((birthDateTime.getDayOfMonth() < 10) ? ("0" + birthDateTime.getDayOfMonth()) : birthDateTime.getDayOfMonth()); TS birthTime = new TS(); birthTime.setValue(birthDateBuilder.toString()); patientPerson.setBirthTime(birthTime); } JAXBElement<PRPAMT201301UV02Person> patientPersonElement = objectFactory .createPRPAMT201301UV02PatientPatientPerson(patientPerson); patient.setPatientPerson(patientPersonElement); // Create ProviderOrganization... COCTMT150003UV03Organization providerOrganization = new COCTMT150003UV03Organization(); providerOrganization.setDeterminerCode("INSTANCE"); providerOrganization.setClassCode("ORG"); II providerId = new II(); providerId.setRoot(providerOrganizationOid); providerOrganization.getId().add(providerId); ON providerName = new ON(); providerName.getContent().add(providerOrganizationName); providerOrganization.getName().add(providerName); COCTMT150003UV03ContactParty contactParty = new COCTMT150003UV03ContactParty(); contactParty.setClassCode(RoleClassContact.CON); TEL contactPartyTelecom = new TEL(); contactPartyTelecom.setValue(providerOrganizationContactTelecom); contactParty.getTelecom().add(contactPartyTelecom); providerOrganization.getContactParty().add(contactParty); patient.setProviderOrganization(providerOrganization); subject1.setPatient(patient); registrationEvent.setSubject1(subject1); // Create Custodian info... MFMIMT700701UV01Custodian custodian = new MFMIMT700701UV01Custodian(); custodian.getTypeCode().add("CST"); COCTMT090003UV01AssignedEntity assignedEntity = new COCTMT090003UV01AssignedEntity(); assignedEntity.setClassCode("ASSIGNED"); II assignedEntityId = new II(); assignedEntityId.setRoot(iExHubDomainOid); assignedEntity.getId().add(assignedEntityId); COCTMT090003UV01Organization assignedOrganization = new COCTMT090003UV01Organization(); assignedOrganization.setDeterminerCode("INSTANCE"); assignedOrganization.setClassCode("ORG"); EN organizationName = new EN(); organizationName.getContent().add("IHE Portal"); assignedOrganization.getName().add(organizationName); assignedEntity.setAssignedOrganization( objectFactory.createCOCTMT090003UV01AssignedEntityAssignedOrganization(assignedOrganization)); custodian.setAssignedEntity(assignedEntity); registrationEvent.setCustodian(custodian); // Set Subject info... subject.getTypeCode().add("SUBJ"); subject.setRegistrationEvent(registrationEvent); PRPAIN201301UV02MFMIMT700701UV01ControlActProcess controlAct = new PRPAIN201301UV02MFMIMT700701UV01ControlActProcess(); CD controlActProcessCode = new CD(); controlActProcessCode.setCode("PRPA_TE201301UV02"); controlActProcessCode.setCodeSystem("2.16.840.1.113883.1.6"); controlAct.setCode(controlActProcessCode); controlAct.setClassCode(ActClassControlAct.CACT); controlAct.setMoodCode(XActMoodIntentEvent.EVN); controlAct.getSubject().add(subject); pRPA_IN201301UV02.setControlActProcess(controlAct); logIti44AuditMsg( patientId + "^^^&" + PIXManager.iExHubDomainOid + "&" + PIXManager.iExHubAssigningAuthority); UUID logMsgId = null; if (logPixRequestMessages) { logMsgId = UUID.randomUUID(); OMElement requestElement = pixManagerStub.toOM(pRPA_IN201301UV02, pixManagerStub .optimizeContent(new javax.xml.namespace.QName("urn:hl7-org:v3", "PRPA_IN201301UV02")), new javax.xml.namespace.QName("urn:hl7-org:v3", "PRPA_IN201301UV02")); Files.write(Paths.get(logOutputPath + logMsgId.toString() + "_PIXRegisterPatientRequest.xml"), requestElement.toString().getBytes()); } MCCIIN000002UV01 response = pixManagerStub.pIXManager_PRPA_IN201301UV02(pRPA_IN201301UV02); if (logPixResponseMessages) { OMElement responseElement = pixManagerStub.toOM(response, pixManagerStub .optimizeContent(new javax.xml.namespace.QName("urn:hl7-org:v3", "MCCI_IN000002UV01")), new javax.xml.namespace.QName("urn:hl7-org:v3", "MCCI_IN000002UV01")); Files.write(Paths .get(logOutputPath + ((logMsgId == null) ? UUID.randomUUID().toString() : logMsgId.toString()) + "_PIXRegisterPatientResponse.xml"), responseElement.toString().getBytes()); } return response; }
From source file:org.integratedmodelling.time.literals.DurationValue.java
License:Open Source License
/** * Localize a duration to an extent starting at the current moment * using the same resolution that was implied in the generating * text. For example, if the duration was one year, localize to the * current year (jan 1st to dec 31st). Return the start and end points * of the extent./*from w w w. java2 s . co m*/ * * @return */ public Pair<TimeValue, TimeValue> localize() { DateTime date = new DateTime(); TimeValue start = null, end = null; long val = value; switch (precision) { case TemporalPrecision.MILLISECOND: start = new TimeValue(date); end = new TimeValue(date.plus(val)); break; case TemporalPrecision.SECOND: val = value / DateTimeConstants.MILLIS_PER_SECOND; start = new TimeValue(new DateTime(date.getYear(), date.getMonthOfYear(), date.getDayOfMonth(), date.getHourOfDay(), date.getMinuteOfHour(), date.getSecondOfMinute(), 0)); end = new TimeValue(start.getTimeData().plusSeconds((int) val)); break; case TemporalPrecision.MINUTE: val = value / DateTimeConstants.MILLIS_PER_MINUTE; start = new TimeValue(new DateTime(date.getYear(), date.getMonthOfYear(), date.getDayOfMonth(), date.getHourOfDay(), date.getMinuteOfHour(), 0, 0)); end = new TimeValue(start.getTimeData().plusMinutes((int) val)); break; case TemporalPrecision.HOUR: val = value / DateTimeConstants.MILLIS_PER_HOUR; start = new TimeValue(new DateTime(date.getYear(), date.getMonthOfYear(), date.getDayOfMonth(), date.getHourOfDay(), 0, 0, 0)); end = new TimeValue(start.getTimeData().plusHours((int) val)); break; case TemporalPrecision.DAY: val = value / DateTimeConstants.MILLIS_PER_DAY; start = new TimeValue( new DateTime(date.getYear(), date.getMonthOfYear(), date.getDayOfMonth(), 0, 0, 0, 0)); end = new TimeValue(start.getTimeData().plusDays((int) val)); break; case TemporalPrecision.MONTH: start = new TimeValue(new DateTime(date.getYear(), date.getMonthOfYear(), 1, 0, 0, 0, 0)); end = new TimeValue(start.getTimeData().plusMonths(origQuantity)); break; case TemporalPrecision.YEAR: start = new TimeValue(new DateTime(date.getYear(), 1, 1, 0, 0, 0, 0)); end = new TimeValue(start.getTimeData().plusYears(origQuantity)); break; } return new Pair<TimeValue, TimeValue>(start, end); }