本文整理汇总了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);
}
示例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());
}
示例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());
}
示例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());
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例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));
}
}
示例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);
}
示例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());
}
示例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());
}
示例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);
}
}
示例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;
}
示例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();
}