// Function to build observation fact public ObservationFactType getObservationFactType() { Date currentDate = new Date(); ObservationFactType obType = new ObservationFactType(); DTOFactory dtoFactory = new DTOFactory(); obType.setEndDate(dtoFactory.getXMLGregorianCalendar(currentDate.getTime())); obType.setConceptCd("i2b2:60004"); obType.setConfidenceNum(1d); obType.setEncounterIde(getEncounterIde()); obType.setPatientIde(getPatientIde()); obType.setSourcesystemCd("i2b2"); obType.setTvalChar("tval"); obType.setNvalNum(100.0); obType.setObservationBlob("BLOB"); return obType; }
public ConstrainByDate writeTimeConstrain() { ConstrainByDate timeConstrain = new ConstrainByDate(); DTOFactory dtoFactory = new DTOFactory(); if (startTime() != -1) { ConstrainDateType constraindateType = new ConstrainDateType(); constraindateType.setValue( dtoFactory.getXMLGregorianCalendarDate(startYear(), startMonth(), startDay())); timeConstrain.setDateFrom(constraindateType); } if (endTime() != -1) { ConstrainDateType constraindateType = new ConstrainDateType(); constraindateType.setValue( dtoFactory.getXMLGregorianCalendarDate(endYear(), endMonth(), endDay())); timeConstrain.setDateTo(constraindateType); } return timeConstrain; }
public ConstrainByDate writeTimeConstrain() { ConstrainByDate timeConstrain = new ConstrainByDate(); DTOFactory dtoFactory = new DTOFactory(); TimeZone tz = Calendar.getInstance().getTimeZone(); GregorianCalendar cal = new GregorianCalendar(tz); // cal.get(Calendar.ZONE_OFFSET); int zt_offset = (cal.get(Calendar.ZONE_OFFSET) + cal.get(Calendar.DST_OFFSET)) / 60000; // log.info("Timezone: "+tz.getID()+" : "+zt_offset); if (startTime() != -1) { ConstrainDateType constraindateType = new ConstrainDateType(); XMLGregorianCalendar xmlC = dtoFactory.getXMLGregorianCalendarDate(startYear(), startMonth() + 1, startDay()); xmlC.setTimezone(zt_offset); // 0);//-5*60); xmlC.setHour(0); xmlC.setMinute(0); xmlC.setSecond(0); constraindateType.setValue(xmlC); timeConstrain.setDateFrom(constraindateType); } if (endTime() != -1) { ConstrainDateType constraindateType = new ConstrainDateType(); XMLGregorianCalendar xmlC = dtoFactory.getXMLGregorianCalendarDate(endYear(), endMonth() + 1, endDay()); xmlC.setTimezone(zt_offset); // 0);//-5*60); xmlC.setHour(0); xmlC.setMinute(0); xmlC.setSecond(0); constraindateType.setValue(xmlC); timeConstrain.setDateTo(constraindateType); } return timeConstrain; }
/** * Function to build i2b2 message header * * @return MessageHeader object */ public MessageHeaderType getMessageHeader() { MessageHeaderType messageHeader = new MessageHeaderType(); messageHeader.setI2B2VersionCompatible( new BigDecimal( Messages.getString("OntologyRequestData.i2b2VersionCompatible"))); // $NON-NLS-1$ ApplicationType appType = new ApplicationType(); appType.setApplicationName( Messages.getString("OntologyRequestData.SendingApplicationName")); // $NON-NLS-1$ appType.setApplicationVersion( Messages.getString("OntologyRequestData.SendingApplicationVersion")); // $NON-NLS-1$ messageHeader.setSendingApplication(appType); FacilityType facility = new FacilityType(); facility.setFacilityName( Messages.getString("OntologyRequestData.SendingFacilityName")); // $NON-NLS-1$ messageHeader.setSendingFacility(facility); ApplicationType appType2 = new ApplicationType(); appType2.setApplicationVersion( Messages.getString("OntologyRequestData.ReceivingApplicationVersion")); // $NON-NLS-1$ appType2.setApplicationName( Messages.getString("OntologyRequestData.ReceivingApplicationName")); // $NON-NLS-1$ messageHeader.setReceivingApplication(appType2); FacilityType facility2 = new FacilityType(); facility2.setFacilityName( Messages.getString("OntologyRequestData.ReceivingFacilityName")); // $NON-NLS-1$ messageHeader.setReceivingFacility(facility2); Date currentDate = new Date(); DTOFactory factory = new DTOFactory(); messageHeader.setDatetimeOfMessage(factory.getXMLGregorianCalendar(currentDate.getTime())); SecurityType secType = new SecurityType(); secType.setDomain(UserInfoBean.getInstance().getUserDomain()); secType.setUsername(UserInfoBean.getInstance().getUserName()); PasswordType ptype = new PasswordType(); ptype.setIsToken(UserInfoBean.getInstance().getUserPasswordIsToken()); ptype.setTokenMsTimeout(UserInfoBean.getInstance().getUserPasswordTimeout()); ptype.setValue(UserInfoBean.getInstance().getUserPassword()); secType.setPassword(ptype); messageHeader.setSecurity(secType); MessageControlIdType mcIdType = new MessageControlIdType(); mcIdType.setInstanceNum(0); mcIdType.setMessageNum(generateMessageId()); messageHeader.setMessageControlId(mcIdType); ProcessingIdType proc = new ProcessingIdType(); proc.setProcessingId(Messages.getString("OntologyRequestData.ProcessingId")); // $NON-NLS-1$ proc.setProcessingMode(Messages.getString("OntologyRequestData.ProcessingMode")); // $NON-NLS-1$ messageHeader.setProcessingId(proc); messageHeader.setAcceptAcknowledgementType( Messages.getString("OntologyRequestData.AcceptAcknowledgementType")); // $NON-NLS-1$ messageHeader.setApplicationAcknowledgementType( Messages.getString("OntologyRequestData.ApplicationAcknowledgementType")); // $NON-NLS-1$ messageHeader.setCountryCode( Messages.getString("OntologyRequestData.CountryCode")); // $NON-NLS-1$ messageHeader.setProjectId(UserInfoBean.getInstance().getProjectId()); return messageHeader; }
public String wirteQueryXML() { DTOFactory dtoFactory = new DTOFactory(); // TimeZone pdt = TimeZone.getTimeZone("EST"); // DatatypeFactory dataTypeFactory = null; // try { // dataTypeFactory = DatatypeFactory.newInstance(); // XMLGregorianCalendar xmlCalendar = // dataTypeFactory.newXMLGregorianCalendarDate(2006, 9, 21, -5*60); // TimeZone pdt = xmlCalendar.getgetTimezone(); // } // catch (DatatypeConfigurationException e) { // e.printStackTrace(); // } // RequestType requestType = new RequestType(); // requestType.setSpecificityScale(specificity()); QueryDefinitionType queryDefinitionType = new QueryDefinitionType(); QueryDefinitionRequestType queryDefinitionRequestType = new QueryDefinitionRequestType(); for (int i = 0; i < panelCount; i++) { ConceptTreePanel panel = getTreePanel(i); ArrayList<QueryConceptTreeNodeData> nodelist = panel.data().getItems(); if ((nodelist != null) && (nodelist.size() > 0)) { System.out.println( "Panel: " + panel.getGroupName() + " Excluded: " + ((panel.data().exclude()) ? "yes" : "no")); PanelType panelType = new PanelType(); panelType.setInvert((panel.data().exclude()) ? 1 : 0); PanelType.TotalItemOccurrences totalItemOccurrences = new PanelType.TotalItemOccurrences(); totalItemOccurrences.setValue(panel.getOccurrenceTimes()); panelType.setTotalItemOccurrences(totalItemOccurrences); panelType.setPanelNumber(i + 1); // if(panel.data().startTime() != -1) { // panelType.setPanelDateFrom(//dataTypeFactory. // newXMLGregorianCalendarDate( // dtoFactory.getXMLGregorianCalendarDate(panel.data().startYear( // ), // panel.data().startMonth(), panel.data().startDay())); // } // if(panel.data().endTime() != -1) { // panelType.setPanelDateTo(//dataTypeFactory. // newXMLGregorianCalendarDate( // dtoFactory.getXMLGregorianCalendarDate(panel.data().endYear(), // panel.data().endMonth(), panel.data().endDay())); // } for (int j = 0; j < nodelist.size(); j++) { QueryConceptTreeNodeData node = nodelist.get(j); System.out.println("\tItem: " + node.fullname()); // create item ItemType itemType = new ItemType(); // itemType.setConstrainByDate(.setDateFrom(dtoFactory. // getXMLGregorianCalendarDate(2006, // 10, 4))); itemType.setItemKey(node.fullname()); itemType.setItemName(node.name()); // mm removed // itemType.setItemTable(node.lookuptable()); itemType.setTooltip(node.tooltip()); itemType.setHlevel(Integer.parseInt(node.hlevel())); itemType.setClazz("ENC"); ConstrainByDate cDate = new ConstrainByDate(); ConstrainDateType constrinDataType = new ConstrainDateType(); constrinDataType.setValue( dtoFactory.getXMLGregorianCalendarDate( node.startYear(), node.startMonth(), node.startDay())); if (node.startTime() != -1) { cDate.setDateFrom(constrinDataType); } if (node.endTime() != -1) { cDate.setDateTo(constrinDataType); } itemType.getConstrainByDate().add(cDate); panelType.getItem().add(itemType); } queryDefinitionType.getPanel().add(panelType); } } // create infotype InfoType infoType = new InfoType(); infoType.setValue("INFO"); infoType.setUrl("http://www.ibm.com"); // create header PsmQryHeaderType headerType = new PsmQryHeaderType(); UserType userType = new UserType(); userType.setLogin(UserInfoBean.getInstance().getUserName()); userType.setValue(UserInfoBean.getInstance().getUserName()); headerType.setUser(userType); headerType.setRequestType(PsmRequestTypeType.CRC_QRY_RUN_QUERY_INSTANCE_FROM_QUERY_DEFINITION); if (queryName == null) { queryName = getTreePanel(0).data().getItems().get(0).name() + "_" + generateMessageId().substring(0, 4); } queryDefinitionType.setQueryName(queryName); queryDefinitionRequestType.setQueryDefinition(queryDefinitionType); RequestHeaderType requestHeader = new RequestHeaderType(); requestHeader.setResultWaittimeMs(180000); BodyType bodyType = new BodyType(); edu.harvard.i2b2.crcxmljaxb.datavo.psm.query.ObjectFactory psmOf = new edu.harvard.i2b2.crcxmljaxb.datavo.psm.query.ObjectFactory(); bodyType.getAny().add(psmOf.createPsmheader(headerType)); bodyType.getAny().add(psmOf.createRequest(queryDefinitionRequestType)); // new QueryToolDTOFactory().buildBodyType(headerType, // queryDefinitionRequestType, null); MessageHeaderType messageHeader = getMessageHeader(); RequestMessageType requestMessageType = new RequestMessageType(); requestMessageType.setMessageBody(bodyType); requestMessageType.setMessageHeader(messageHeader); requestMessageType.setRequestHeader(requestHeader); // dtoFactory.getRequestMessageType(messageHeader, requestHeader, // bodyType); JAXBUtil jaxbUtil = PreviousQueryJAXBUtil.getJAXBUtil(); StringWriter strWriter = new StringWriter(); try { edu.harvard.i2b2.crcxmljaxb.datavo.i2b2message.ObjectFactory of = new edu.harvard.i2b2.crcxmljaxb.datavo.i2b2message.ObjectFactory(); jaxbUtil.marshaller(of.createRequest(requestMessageType), strWriter); } catch (Exception e) { e.printStackTrace(); } return strWriter.toString(); }