当前位置: 首页>>代码示例>>Java>>正文


Java DTM类代码示例

本文整理汇总了Java中ca.uhn.hl7v2.model.v26.datatype.DTM的典型用法代码示例。如果您正苦于以下问题:Java DTM类的具体用法?Java DTM怎么用?Java DTM使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


DTM类属于ca.uhn.hl7v2.model.v26.datatype包,在下文中一共展示了DTM类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getCalendarFromDTM

import ca.uhn.hl7v2.model.v26.datatype.DTM; //导入依赖的package包/类
public static GregorianCalendar getCalendarFromDTM(DTM dtm) throws DataTypeException {

		// hl7/hapi returns 0 for no date
		if (dtm.getYear() == 0 || dtm.getMonth() == 0 || dtm.getDay() == 0) return (null);

		GregorianCalendar cal = new GregorianCalendar();
		// zero out fields we don't use
		cal.setTimeInMillis(0);
		cal.set(GregorianCalendar.YEAR, dtm.getYear());
		cal.set(GregorianCalendar.MONTH, dtm.getMonth() - 1);
		cal.set(GregorianCalendar.DAY_OF_MONTH, dtm.getDay());
		cal.set(GregorianCalendar.HOUR_OF_DAY, dtm.getHour());
		cal.set(GregorianCalendar.MINUTE, dtm.getMinute());
		cal.set(GregorianCalendar.SECOND, dtm.getSecond());

		// force materialisation of values
		cal.getTimeInMillis();

		return (cal);
	}
 
开发者ID:williamgrosset,项目名称:OSCAR-ConCert,代码行数:21,代码来源:DataTypeUtils.java

示例2: timeWithoutZoneIsChanged

import ca.uhn.hl7v2.model.v26.datatype.DTM; //导入依赖的package包/类
@Test
public void timeWithoutZoneIsChanged() throws Exception {
	Exchange exchange = new DefaultExchange(camelContext);
	Message message = new DefaultMessage();
	
	ORU_R01 oruMessage = (ORU_R01) hapiContext.getGenericParser().parse(hl7InputNoTimeZone);
	message.setBody(oruMessage);
	exchange.setIn(message);
	
	DTM messageDtm = oruMessage.getMSH().getDateTimeOfMessage();
	
	assertEquals(-99, messageDtm.getGMTOffset());
	assertEquals(MOCK_HOURS, messageDtm.getHour());
	
	timeAdjustmentProcessor.process(exchange);
	messageDtm = oruMessage.getMSH().getDateTimeOfMessage();
	
	assertEquals(200, messageDtm.getGMTOffset());
	assertEquals(MOCK_HOURS, messageDtm.getHour());
	
	DTM obrDtm = oruMessage.getPATIENT_RESULT(0).getORDER_OBSERVATION(0).getOBR().getObr7_ObservationDateTime();
	
	assertEquals(200, obrDtm.getGMTOffset());
	assertEquals(MOCK_HOURS, messageDtm.getHour());
}
 
开发者ID:sll-mdilab,项目名称:t5-doc,代码行数:26,代码来源:TimeAdjustmentProcessorTest.java

示例3: timeWithZoneIsNotChanged

import ca.uhn.hl7v2.model.v26.datatype.DTM; //导入依赖的package包/类
@Test
public void timeWithZoneIsNotChanged() throws Exception {
	Exchange exchange = new DefaultExchange(camelContext);
	Message message = new DefaultMessage();
	
	ORU_R01 oruMessage = (ORU_R01) hapiContext.getGenericParser().parse(hl7InputWithTimeZone);
	message.setBody(oruMessage);
	exchange.setIn(message);
	
	DTM messageDtm = oruMessage.getMSH().getDateTimeOfMessage();
	
	assertEquals(200, messageDtm.getGMTOffset());
	assertEquals(MOCK_HOURS, messageDtm.getHour());
	
	timeAdjustmentProcessor.process(exchange);
	messageDtm = oruMessage.getMSH().getDateTimeOfMessage();
	
	assertEquals(200, messageDtm.getGMTOffset());
	assertEquals(MOCK_HOURS, messageDtm.getHour());
}
 
开发者ID:sll-mdilab,项目名称:t5-doc,代码行数:21,代码来源:TimeAdjustmentProcessorTest.java

示例4: timeWithUtcZoneIsNotChanged

import ca.uhn.hl7v2.model.v26.datatype.DTM; //导入依赖的package包/类
@Test
public void timeWithUtcZoneIsNotChanged() throws Exception {
	Exchange exchange = new DefaultExchange(camelContext);
	Message message = new DefaultMessage();
	
	ORU_R01 oruMessage = (ORU_R01) hapiContext.getGenericParser().parse(hl7InputWithUtcTimeZone);
	message.setBody(oruMessage);
	exchange.setIn(message);
	
	DTM messageDtm = oruMessage.getMSH().getDateTimeOfMessage();
	
	assertEquals(0, messageDtm.getGMTOffset());
	assertEquals(MOCK_HOURS, messageDtm.getHour());
	
	timeAdjustmentProcessor.process(exchange);
	messageDtm = oruMessage.getMSH().getDateTimeOfMessage();
	
	assertEquals(0, messageDtm.getGMTOffset());
	assertEquals(MOCK_HOURS, messageDtm.getHour());
}
 
开发者ID:sll-mdilab,项目名称:t5-doc,代码行数:21,代码来源:TimeAdjustmentProcessorTest.java

示例5: getMsgDate

import ca.uhn.hl7v2.model.v26.datatype.DTM; //导入依赖的package包/类
public String getMsgDate() {
	try {
		DTM dtm = getMsh().getDateTimeOfMessage();
		GregorianCalendar cal = DataTypeUtils.getCalendarFromDTM(dtm);
		return (DateUtils.getISODateTimeFormatNoT(cal));
	} catch (DataTypeException e) {
		logger.error("Unexpected error.", e);
		return (null);
	}
}
 
开发者ID:williamgrosset,项目名称:OSCAR-ConCert,代码行数:11,代码来源:ChainnedMessageAdapter.java

示例6: getDOB

import ca.uhn.hl7v2.model.v26.datatype.DTM; //导入依赖的package包/类
public String getDOB() {
	try {
		DTM dtm = getPid().getDateTimeOfBirth();
		GregorianCalendar cal = DataTypeUtils.getCalendarFromDTM(dtm);
		
		if (cal==null) return(null);
		
		return (DateUtils.getISODateTimeFormatNoT(cal));
	} catch (DataTypeException e) {
		logger.error("Unexpected Error.", e);
		return (null);
	}
}
 
开发者ID:williamgrosset,项目名称:OSCAR-ConCert,代码行数:14,代码来源:ChainnedMessageAdapter.java

示例7: getAge

import ca.uhn.hl7v2.model.v26.datatype.DTM; //导入依赖的package包/类
public String getAge() {
	try {
		DTM dtm = getPid().getDateTimeOfBirth();
		GregorianCalendar cal = DataTypeUtils.getCalendarFromDTM(dtm);
		
		if (cal==null) return(null);
		
		int age = DateUtils.getAge(cal, new GregorianCalendar());
		return (String.valueOf(age));
	} catch (DataTypeException e) {
		logger.error("Unexpected Error.", e);
		return (null);
	}
}
 
开发者ID:williamgrosset,项目名称:OSCAR-ConCert,代码行数:15,代码来源:ChainnedMessageAdapter.java

示例8: process

import ca.uhn.hl7v2.model.v26.datatype.DTM; //导入依赖的package包/类
@Override
public void process(Exchange exchange) throws Exception {
	if (timeAdjustmentEnabled) {
		logger.info("Adjusting timestamps.");
		
		Message message = exchange.getIn().getBody(Message.class);
		ORU_R01 oruMessage = (ORU_R01) message;

		DTM mshDateTime = oruMessage.getMSH().getMsh7_DateTimeOfMessage();
		adjustDate(mshDateTime);

		adjustObrDates(oruMessage);
	}
}
 
开发者ID:sll-mdilab,项目名称:t5-doc,代码行数:15,代码来源:TimeAdjustmentProcessor.java

示例9: adjustDate

import ca.uhn.hl7v2.model.v26.datatype.DTM; //导入依赖的package包/类
private void adjustDate(DTM dtm) throws HL7Exception {
	// Missing offset, assume the provided timezone
	if (!dtm.isEmpty() && dtm.getGMTOffset() == -99) {
		int milliOffset = TimeZone.getTimeZone(timeZoneId).getOffset(new Date().getTime());

		dtm.setOffset(millisOffsetToDtm(milliOffset));
	}
}
 
开发者ID:sll-mdilab,项目名称:t5-doc,代码行数:9,代码来源:TimeAdjustmentProcessor.java

示例10: handleObservation

import ca.uhn.hl7v2.model.v26.datatype.DTM; //导入依赖的package包/类
private void handleObservation(ORU_R01_OBSERVATION observation, Document doc, Element elemObsOrders,
		Element elemOrder, DTM orderDateTime, String serviceID_id, Map<String, Element> mapMDS,
		Map<String, Element> mapVMD, Map<String, Element> mapCHAN, Map<String, Element> mapMetric)
		throws HL7Exception, DataTypeException, XPathExpressionException {
	OBX obx = observation.getOBX();

	// Attributes of Observation itself - from OBX segment
	Element elemObs = doc.createElement("Observation");
	elemObsOrders.appendChild(elemObs);

	// Observation UID based on generated GUID
	String guidObs = UUID.randomUUID().toString();
	elemObs.setAttribute("uid", guidObs);

	Element elemObsIdentifier = createObsIdentifierElement(doc, obx);
	elemObs.appendChild(elemObsIdentifier);

	handleAlternativeIdentifiers(doc, obx, elemObs, elemObsIdentifier);

	handleHierarchy(doc, elemObsOrders, elemOrder, serviceID_id, obx, elemObs, obx.getObservationSubID()
			.getValueOrEmpty(), mapMDS, mapVMD, mapCHAN, mapMetric);

	// OBX-2 setid
	elemObs.setAttribute("setid", obx.getObx1_SetIDOBX().getValue());

	// May be multiple values
	for (Varies value : obx.getObservationValue()) {
		elemObs.appendChild(createValueElement(doc, obx, value));
	}

	// Unit
	CWE units = obx.getObx6_Units();
	if (!units.getCwe1_Identifier().isEmpty()) {
		elemObs.appendChild(createUnitElement(doc, units));
	}

	elemObs.appendChild(createTimestampElement(doc, orderDateTime, obx, elemObs));

	createEquipmentIdentifiers(doc, obx, elemObs);
}
 
开发者ID:sll-mdilab,项目名称:t5-doc,代码行数:41,代码来源:PCD_01MessageToXMLConverter.java

示例11: convertDtmToXmlDate

import ca.uhn.hl7v2.model.v26.datatype.DTM; //导入依赖的package包/类
private String convertDtmToXmlDate(DTM observationDateTime) throws DataTypeException {
	logger.info("Observation date: " + observationDateTime.getValue());
	
	Calendar dateOrderCalendar = observationDateTime.getValueAsCalendar();
	dateOrderCalendar.setTimeZone(getTimeZone(observationDateTime));

	return convertDateToXMLType(dateOrderCalendar.getTime());
}
 
开发者ID:sll-mdilab,项目名称:t5-doc,代码行数:9,代码来源:PCD_01MessageToXMLConverter.java

示例12: fillPid

import ca.uhn.hl7v2.model.v26.datatype.DTM; //导入依赖的package包/类
/**
 * @param pid
 * @param pidNumber pass in the # of this pid for the sequence, i.e. normally it's 1 if you only have 1 pid entry. if this is a list of pids, then the first one is 1, second is 2 etc..
 * @param demographic
 * @throws HL7Exception
 */
public static void fillPid(PID pid, int pidNumber, Demographic demographic) throws HL7Exception {
	// defined as first pid=1 second pid=2 etc
	pid.getSetIDPID().setValue(String.valueOf(pidNumber));

	CX cx = pid.getPatientIdentifierList(0);
	// health card string, excluding version code
	cx.getIDNumber().setValue(demographic.getHin());
	cx.getIdentifierTypeCode().setValue(HEALTH_NUMBER);
	// blank for everyone but ontario use version code
	cx.getIdentifierCheckDigit().setValue(demographic.getVer());
	// province
	cx.getAssigningJurisdiction().getIdentifier().setValue(demographic.getHcType());

	GregorianCalendar tempCalendar = new GregorianCalendar();
	if (demographic.getEffDate() != null) {
		tempCalendar.setTime(demographic.getEffDate());
		cx.getEffectiveDate().setYearMonthDayPrecision(tempCalendar.get(GregorianCalendar.YEAR), tempCalendar.get(GregorianCalendar.MONTH) + 1, tempCalendar.get(GregorianCalendar.DAY_OF_MONTH));
	}

	if (demographic.getHcRenewDate() != null) {
		tempCalendar.setTime(demographic.getHcRenewDate());
		cx.getExpirationDate().setYearMonthDayPrecision(tempCalendar.get(GregorianCalendar.YEAR), tempCalendar.get(GregorianCalendar.MONTH) + 1, tempCalendar.get(GregorianCalendar.DAY_OF_MONTH));
	}

	XPN xpn = pid.getPatientName(0);
	xpn.getFamilyName().getSurname().setValue(demographic.getLastName());
	xpn.getGivenName().setValue(demographic.getFirstName());
	// Value Description
	// -----------------
	// A Alias Name
	// B Name at Birth
	// C Adopted Name
	// D Display Name
	// I Licensing Name
	// L Legal Name
	// M Maiden Name
	// N Nickname /Call me Name/Street Name
	// P Name of Partner/Spouse - obsolete (DO NOT USE)
	// R Registered Name (animals only)
	// S Coded Pseudo-Name to ensure anonymity
	// T Indigenous/Tribal/Community Name
	// U Unspecified
	xpn.getNameTypeCode().setValue("L");

	if (demographic.getBirthDay() != null) {
		DTM bday = pid.getDateTimeOfBirth();
		tempCalendar = demographic.getBirthDay();
		bday.setDatePrecision(tempCalendar.get(GregorianCalendar.YEAR), tempCalendar.get(GregorianCalendar.MONTH) + 1, tempCalendar.get(GregorianCalendar.DAY_OF_MONTH));
	}

	// Value Description
	// -----------------
	// F Female
	// M Male
	// O Other
	// U Unknown
	// A Ambiguous
	// N Not applicable
	pid.getAdministrativeSex().setValue(getHl7GenderFromOscarGender(demographic.getSex()));

	XAD address = pid.getPatientAddress(0);
	fillXAD(address, demographic, null, "H");

	XTN phone = pid.getPhoneNumberHome(0);
	phone.getUnformattedTelephoneNumber().setValue(demographic.getPhone());

	// ISO 639, hrmmm shall we say 639-1 (2 digit)?
	pid.getPrimaryLanguage().getIdentifier().setValue(demographic.getSpokenLanguage());

	// ISO table 3166.
	pid.getCitizenship(0).getIdentifier().setValue(demographic.getCitizenship());
}
 
开发者ID:williamgrosset,项目名称:OSCAR-ConCert,代码行数:79,代码来源:DataTypeUtils.java

示例13: handleOrderObservations

import ca.uhn.hl7v2.model.v26.datatype.DTM; //导入依赖的package包/类
private void handleOrderObservations(ORU_R01_ORDER_OBSERVATION orderObservation, Element elemPR, Document doc)
		throws T5ConversionException {
	try {
		Map<String, Element> mapMDS = new HashMap<String, Element>();
		Map<String, Element> mapVMD = new HashMap<String, Element>();
		Map<String, Element> mapCHAN = new HashMap<String, Element>();
		Map<String, Element> mapMetric = new HashMap<String, Element>();

		Element elemObsOrders = doc.createElement("Order_Observations");
		elemPR.appendChild(elemObsOrders);

		DTM orderDateTime = orderObservation.getOBR().getObr7_ObservationDateTime();
		Element elemOrder = doc.createElement("Order");
		elemOrder.setAttribute("timeStamp", convertDtmToXmlDate(orderDateTime));

		if (!orderObservation.getOBR().getObr8_ObservationEndDateTime().isEmpty()) {
			orderDateTime = orderObservation.getOBR().getObr8_ObservationEndDateTime();
			elemOrder.setAttribute("timeStampEnd", convertDtmToXmlDate(orderDateTime));
		}
		elemObsOrders.appendChild(elemOrder);

		// Filler Order Number - OBR-3
		elemOrder.appendChild(createFillerOrderNumberElement(orderObservation, doc));

		// Universal Service ID OBR-4
		Element elemService = doc.createElement("UniversalServiceID");

		String serviceID_id = "";
		CWE serviceID = orderObservation.getOBR().getObr4_UniversalServiceIdentifier();
		if (!serviceID.getCwe2_Text().isEmpty()) {
			elemService.setTextContent(serviceID.getCwe2_Text().getValue());
		}

		if (!serviceID.getCwe1_Identifier().isEmpty()) {
			serviceID_id = serviceID.getCwe1_Identifier().getValue();
			elemService.setAttribute("id", serviceID_id);
		}

		if (!serviceID.getCwe3_NameOfCodingSystem().isEmpty()) {
			elemService.setAttribute("codingSystemName", serviceID.getCwe3_NameOfCodingSystem().getValue());
		}

		elemOrder.appendChild(elemService);

		for (ORU_R01_OBSERVATION observation : orderObservation.getOBSERVATIONAll()) {
			handleObservation(observation, doc, elemObsOrders, elemOrder, orderDateTime, serviceID_id, mapMDS,
					mapVMD, mapCHAN, mapMetric);
		}

	} catch (HL7Exception | DOMException | XPathExpressionException e) {
		throw new T5ConversionException(e);
	}
}
 
开发者ID:sll-mdilab,项目名称:t5-doc,代码行数:54,代码来源:PCD_01MessageToXMLConverter.java

示例14: createTimestampElement

import ca.uhn.hl7v2.model.v26.datatype.DTM; //导入依赖的package包/类
private Element createTimestampElement(Document doc, DTM orderDateTime, OBX obx, Element elemObs)
		throws DataTypeException, XPathExpressionException {
	// Timestamp
	Element elemTS = doc.createElement("Timestamp");

	Date dateObs = obx.getObx14_DateTimeOfTheObservation().getValueAsDate();
	// If this OBX is not having its own timestamp, derive from
	// ORDER
	if (dateObs == null) {
		// Should search for TS in parents: CHAN, VMD, MDS
		String tsParent = null;

		// Find parent timestamp
		String xpathExpr = "../../Observation/Timestamp";
		XPath mXpath = XPathFactory.newInstance().newXPath();
		NamespaceContext nsContext = new NamespaceContext() {
		    public String getNamespaceURI(String prefix) {
		        return prefix.equals("t5") ? T5_XML_NAMESPACE : null; 
		    }
		    public Iterator getPrefixes(String val) {
		        return null;
		    }
		    public String getPrefix(String uri) {
		        return null;
		    }
		};
		mXpath.setNamespaceContext(nsContext);
		
		Object timenode = mXpath.evaluate(xpathExpr, elemObs, XPathConstants.NODE);
		if (timenode != null && timenode instanceof Node) {
			tsParent = ((Element) timenode).getTextContent();
		}

		if (tsParent == null) {
			elemTS.setTextContent(convertDtmToXmlDate(orderDateTime));
		} else {
			elemTS.setTextContent(tsParent);
		}
	} else {
		elemTS.setTextContent(convertDtmToXmlDate(obx.getObx14_DateTimeOfTheObservation()));
	}
	return elemTS;
}
 
开发者ID:sll-mdilab,项目名称:t5-doc,代码行数:44,代码来源:PCD_01MessageToXMLConverter.java

示例15: getTimeZone

import ca.uhn.hl7v2.model.v26.datatype.DTM; //导入依赖的package包/类
private TimeZone getTimeZone(DTM dtm) throws DataTypeException {
	Calendar calendar = Calendar.getInstance();
	calendar.set(Calendar.HOUR_OF_DAY, dtm.getHour());
	calendar.set(Calendar.MINUTE, dtm.getMinute());
	calendar.set(Calendar.SECOND, dtm.getSecond());

	float fractSecond = dtm.getFractSecond();
	calendar.set(Calendar.MILLISECOND, (int) Math.round(fractSecond * 1000.0));

	int gmtOff = dtm.getGMTOffset();
	if (gmtOff != CommonTM.GMT_OFFSET_NOT_SET_VALUE) {
		calendar.set(Calendar.ZONE_OFFSET, (gmtOff / 100) * (1000 * 60 * 60));

		/*
		 * The following sets the TimeZone associated with the returned calendar to use the offset specified in the
		 * value if this conflicts with the value it already contains.
		 * 
		 * This is needed in situations where daylight savings is in effect during part of the year, and a date is
		 * parsed which contains the other part of the year (i.e. parsing a DST DateTime when it is not actually DST
		 * according to the system clock).
		 * 
		 * See CommonTSTest#testGetCalendarRespectsDaylightSavings() for an example which fails if this is removed.
		 */
		if (calendar.getTimeZone().getRawOffset() != calendar.get(Calendar.ZONE_OFFSET)) {
			int hrOffset = gmtOff / 100;
			int minOffset = gmtOff % 100;
			StringBuilder tzBuilder = new StringBuilder("GMT");

			if (hrOffset < 0) {
				tzBuilder.append('-');
			} else {
				tzBuilder.append('+');
			}
			tzBuilder.append(Math.abs(hrOffset));
			tzBuilder.append(':');
			if (minOffset < 10) {
				tzBuilder.append('0');
			}
			tzBuilder.append(minOffset);

			calendar.setTimeZone(TimeZone.getTimeZone(tzBuilder.toString()));
		}
	}
	return calendar.getTimeZone();
}
 
开发者ID:sll-mdilab,项目名称:t5-doc,代码行数:46,代码来源:PCD_01MessageToXMLConverter.java


注:本文中的ca.uhn.hl7v2.model.v26.datatype.DTM类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。