List of usage examples for javax.xml.datatype XMLGregorianCalendar getDay
public abstract int getDay();
From source file:edu.harvard.i2b2.adminTool.dataModel.PatientMappingFactory.java
@SuppressWarnings("unchecked") public String generateTimelineData(String result, ArrayList<TimelineRow> rows, boolean writeFile, boolean displayAll, boolean displayDemographics, final MainComposite explorer) { try {/* www . ja va2s. com*/ PDOResponseMessageModel pdoresponsefactory = new PDOResponseMessageModel(); StatusType statusType = pdoresponsefactory.getStatusFromResponseXML(result); if (!statusType.getType().equalsIgnoreCase("DONE")) { return "error"; } JAXBUtil jaxbUtil = PatientMappingJAXBUtil.getJAXBUtil(); JAXBElement jaxbElement = jaxbUtil.unMashallFromString(result); ResponseMessageType messageType = (ResponseMessageType) jaxbElement.getValue(); BodyType bodyType = messageType.getMessageBody(); PatientDataResponseType responseType = (PatientDataResponseType) new JAXBUnWrapHelper() .getObjectByClass(bodyType.getAny(), PatientDataResponseType.class); PageType pageType = responseType.getPage(); if (pageType != null) { final int returnLastIndex = pageType.getPagingByPatients().getPatientsReturned().getLastIndex() .intValue(); final int returnFirstIndex = pageType.getPagingByPatients().getPatientsReturned().getFirstIndex() .intValue(); final int requestLastIndex = pageType.getPagingByPatients().getPatientsRequested().getLastIndex() .intValue(); if (returnLastIndex < requestLastIndex) { // System.out.println("Can't return all the requested "+ // requestIndex+" patients, only "+returnIndex+" patients returned"); explorer.getDisplay().syncExec(new Runnable() { public void run() { // MessageBox mBox = new MessageBox(explorer // .getShell(), SWT.ICON_INFORMATION // | SWT.OK ); // mBox.setText("Please Note ..."); // mBox.setMessage("Only "+(returnLastIndex-returnFirstIndex+1)+" patients returned"); // mBox.open(); if (explorer.runMode() >= 0) { explorer.setIncrementNumber(returnLastIndex - returnFirstIndex + 1); } else if (explorer.runMode() == -1) { explorer.setDecreaseNumber(returnLastIndex - returnFirstIndex + 1); } } }); explorer.returnedNumber(returnLastIndex - returnFirstIndex + 1); } else { explorer.returnedNumber(-1); } } else { explorer.getDisplay().syncExec(new Runnable() { public void run() { // MessageBox mBox = new MessageBox(explorer // .getShell(), SWT.ICON_INFORMATION // | SWT.OK ); // mBox.setText("Please Note ..."); // mBox.setMessage("Only "+(returnLastIndex-returnFirstIndex+1)+" patients returned"); // mBox.open(); if (explorer.runMode() >= 0) { explorer.setIncrementNumber(-1); } else if (explorer.runMode() == -1) { explorer.setDecreaseNumber(-1); } } }); } StringBuilder resultFile = new StringBuilder(); resultFile.append(GetTimelineHeader()); PatientSet patientDimensionSet = pdoresponsefactory.getPatientSetFromResponseXML(result); if (patientDimensionSet != null) { log.debug("Total patient: " + patientDimensionSet.getPatient().size()); // for(int i=0; // i<patientDimensionSet.getPatientDimension().size();i++) { // PatientDimensionType patientType = // patientDimensionSet.getPatientDimension().get(i); // System.out.println("PatientNum: " + // patientType.getPatientNum()); // } } else { return "error"; } // / testing the visit set // PatientDataType.VisitDimensionSet visitSet = // pdoresponsefactory.getVisitSetFromResponseXML(result); // System.out.println("Total visits: "+visitSet.getVisitDimension(). // size()); List<ObservationSet> factSets = pdoresponsefactory.getFactSetsFromResponseXML(result); log.debug("\nGenerate lld:"); String curPNum = "-1"; for (int i = 0; i < patientDimensionSet.getPatient().size(); i++) { PatientType patientType = patientDimensionSet.getPatient().get(i); String pnum = patientType.getPatientId().getValue(); // Integer pnum = new Integer(snum); // log.debug("PatientNum: " + snum); //if(curPNum.equals("-1")) { curPNum = new String(pnum); //} if (displayDemographics) { resultFile.append(getTimelinePatientString(pnum.toString(), patientType)); } else { resultFile.append(getTimelinePatientString(pnum.toString())); } String path = null; TimelineRow currentRow = null; ObservationSet observationFactSet = null; for (int j = 0; j < rows.size(); j++) { TimelineRow row = rows.get(j); int total = 0; StringBuilder resultString = new StringBuilder(); XMLGregorianCalendar curStartDate = null; //int currentInstanceNum = 0; //String currentConcept = ""; ArrayList<ObservationType> facts = new ArrayList<ObservationType>(); ObservationType curFact = null; boolean recorded = false; String sStart_date = null; String sEnd_date = null; // loop thru all the pdo sets for this row here for (int s = 0; s < row.pdoItems.size(); s++) { PDOItem pset = row.pdoItems.get(s); observationFactSet = null; for (int m = 0; m < factSets.size(); m++) { ObservationSet tmpFactSet = factSets.get(m); if (tmpFactSet.getPanelName().equalsIgnoreCase(pset.panelName())) { observationFactSet = tmpFactSet; path = observationFactSet.getPanelName(); currentRow = row; break; } } if (observationFactSet == null) { continue; } for (int k = 0; k < observationFactSet.getObservation().size(); k++) { ObservationType obsFactType = observationFactSet.getObservation().get(k); //if(curFact == null) { //curFact = obsFactType; //} //facts.add(obsFactType); if (pnum.equals(obsFactType.getPatientId().getValue())) { /* * if ((curStartDate != null) && * (obsFactType.getStartDate().compare( * curStartDate) == DatatypeConstants.EQUAL)) { * continue; } */ if (curFact == null) { curFact = obsFactType; } if (curStartDate == null) { curStartDate = obsFactType.getStartDate(); } sStart_date = obsFactType.getStartDate().getMonth() + "-" + obsFactType.getStartDate().getDay() + "-" + obsFactType.getStartDate().getYear() + " 12:00"; if (obsFactType.getEndDate() == null) { sEnd_date = sStart_date; } else { sEnd_date = obsFactType.getEndDate().getMonth() + "-" + obsFactType.getEndDate().getDay() + "-" + obsFactType.getEndDate().getYear() + " 12:00"; } double nval = -1; if (obsFactType.getNvalNum().getValue() != null) { nval = obsFactType.getNvalNum().getValue().doubleValue(); } PDOValueModel valdp = null; if (false) {//pset.hasValueDisplayProperty) { for (int n = 0; n < pset.valDisplayProperties.size(); n++) { PDOValueModel tmpvaldp = pset.valDisplayProperties.get(n); // if (tmpvaldp.inRange(nval)) { valdp = tmpvaldp; // break; // } } String sValue = getSValue(obsFactType.getConceptCd().getName(), obsFactType, true); if ((curStartDate != null) && (obsFactType.getStartDate() .compare(curStartDate) == DatatypeConstants.EQUAL)) { resultString.append(getTimelineDateStringHeight(sStart_date, sEnd_date, "slateblue", valdp.height, sValue)); } else { resultString.append(getTimelineDateStringHeight(sStart_date, sEnd_date, valdp.color, valdp.height, sValue)); } } else { ////////////////////// String sValue = ""; if (sameInstance(curFact, obsFactType)) { //if(recorded) { facts.add(obsFactType); //recorded = false; continue; //} /*sValue = getSValueSame(obsFactType.getConceptCd().getName(), obsFactType, false); if ((curStartDate != null) && (obsFactType.getStartDate() .compare(curStartDate) == DatatypeConstants.EQUAL)) { resultString .append(getTimelineDateStringHeightSame( sStart_date, sEnd_date, "slateblue", pset.height, sValue)); } else { resultString .append(getTimelineDateStringHeightSame( sStart_date, sEnd_date, pset.color, pset.height, sValue)); }*/ } //else { sValue = getSValue(curFact.getConceptCd().getName(), facts, false); //} sStart_date = curFact.getStartDate().getMonth() + "-" + curFact.getStartDate().getDay() + "-" + curFact.getStartDate().getYear() + " 12:00"; if (curFact.getEndDate() == null) { sEnd_date = sStart_date; } else { sEnd_date = curFact.getEndDate().getMonth() + "-" + curFact.getEndDate().getDay() + "-" + curFact.getEndDate().getYear() + " 12:00"; } //if ((curStartDate != null) // && (obsFactType.getStartDate() // .compare(curStartDate) == DatatypeConstants.EQUAL)) { //resultString //.append(getTimelineDateStringHeight( //sStart_date, sEnd_date, //"slateblue", //pset.height, sValue)); //} else { resultString.append(getTimelineDateStringHeight(sStart_date, sEnd_date, pset.color, pset.height, sValue)); //} } total++; recorded = false; facts.clear(); facts.add(obsFactType); curStartDate = obsFactType.getStartDate(); curFact = obsFactType; } else { if (recorded || facts.size() == 0) { curPNum = new String(pnum); continue; } sStart_date = curStartDate.getMonth() + "-" + curStartDate.getDay() + "-" + curStartDate.getYear() + " 12:00"; //if (obsFactType.getEndDate() == null) { //sEnd_date = sStart_date; //} else { sEnd_date = curStartDate.getMonth() + "-" + curStartDate.getDay() + "-" + curStartDate.getYear() + " 12:00"; //} //curFact = null; String sValue = getSValue(curFact.getConceptCd().getName(), facts, false); //if ((curStartDate != null) //&& (obsFactType.getStartDate() //.compare(curStartDate) == DatatypeConstants.EQUAL)) { //resultString //.append(getTimelineDateStringHeight( //sStart_date, sEnd_date, //"slateblue", //pset.height, sValue)); //} else { resultString.append(getTimelineDateStringHeight(sStart_date, sEnd_date, pset.color, pset.height, sValue)); //} total++; recorded = true; facts.clear(); curStartDate = null;//obsFactType.getStartDate(); curFact = null;//obsFactType; curPNum = new String(pnum); } } } if (total > 0) { // log.debug("-- "+path+" has "+total+" events"); resultFile.append(getTimelineConceptString(row.displayName, total)); // log.debug(resultString.toString()); resultFile.append(resultString); total = 0; ////rdtr } else { // display all if (displayAll) { // log.debug("-- "+path+" has "+total+" events"); resultFile.append(getTimelineConceptString(row.displayName, 1)); // log.debug(getTimelineEmptyDateString()); resultFile.append(getTimelineEmptyDateString()); } } if (recorded || facts.size() == 0) { curPNum = new String(pnum); continue; } sStart_date = curStartDate.getMonth() + "-" + curStartDate.getDay() + "-" + curStartDate.getYear() + " 12:00"; //if (obsFactType.getEndDate() == null) { //sEnd_date = sStart_date; //} else { sEnd_date = curStartDate.getMonth() + "-" + curStartDate.getDay() + "-" + curStartDate.getYear() + " 12:00"; //} //curFact = null; String sValue = getSValue(curFact.getConceptCd().getName(), facts, false); resultString .append(getTimelineDateStringHeight(sStart_date, sEnd_date, "navyblue", "p10", sValue)); total++; recorded = true; facts.clear(); //curStartDate = obsFactType.getStartDate(); //curFact = obsFactType; curPNum = new String(pnum); if (total > 0) { // log.debug("-- "+path+" has "+total+" events"); resultFile.append(getTimelineConceptString(row.displayName, total)); // log.debug(resultString.toString()); resultFile.append(resultString); } } } resultFile.append(GetTimelineFooter()); if (writeFile) { String i2b2File = System.getProperty("user.dir") + "/temp/" + "i2b2xml.lld"; File oDelete = new File(i2b2File); if (oDelete != null) oDelete.delete(); RandomAccessFile f = new RandomAccessFile(i2b2File, "rw"); append(f, resultFile.toString()); f.close(); } // log.debug("\nThe lld file: \n"+resultFile.toString()); return resultFile.toString(); } catch (org.apache.axis2.AxisFault e) { e.printStackTrace(); log.error(e.getMessage()); return null; } catch (Exception e) { log.error(e.getMessage()); e.printStackTrace(); return "error"; } }
From source file:edu.harvard.i2b2.explorer.dataModel.TimelineFactory.java
@SuppressWarnings("unchecked") public String generateTimelineData(String result, ArrayList<TimelineRow> rows, boolean writeFile, boolean displayAll, boolean displayDemographics, final MainComposite explorer) { try {/* ww w .j a v a 2 s . c o m*/ PDOResponseMessageModel pdoresponsefactory = new PDOResponseMessageModel(); StatusType statusType = pdoresponsefactory.getStatusFromResponseXML(result); if (!statusType.getType().equalsIgnoreCase("DONE")) { return "error"; } JAXBUtil jaxbUtil = ExplorerJAXBUtil.getJAXBUtil(); JAXBElement jaxbElement = jaxbUtil.unMashallFromString(result); ResponseMessageType messageType = (ResponseMessageType) jaxbElement.getValue(); BodyType bodyType = messageType.getMessageBody(); PatientDataResponseType responseType = (PatientDataResponseType) new JAXBUnWrapHelper() .getObjectByClass(bodyType.getAny(), PatientDataResponseType.class); PageType pageType = responseType.getPage(); if (pageType != null) { final int returnLastIndex = pageType.getPagingByPatients().getPatientsReturned().getLastIndex() .intValue(); final int returnFirstIndex = pageType.getPagingByPatients().getPatientsReturned().getFirstIndex() .intValue(); final int requestLastIndex = pageType.getPagingByPatients().getPatientsRequested().getLastIndex() .intValue(); if (returnLastIndex < requestLastIndex) { // System.out.println("Can't return all the requested "+ // requestIndex+" patients, only "+returnIndex+" patients returned"); explorer.getDisplay().syncExec(new Runnable() { public void run() { // MessageBox mBox = new MessageBox(explorer // .getShell(), SWT.ICON_INFORMATION // | SWT.OK ); // mBox.setText("Please Note ..."); // mBox.setMessage("Only "+(returnLastIndex-returnFirstIndex+1)+" patients returned"); // mBox.open(); if (explorer.runMode() >= 0) { explorer.setIncrementNumber(returnLastIndex - returnFirstIndex + 1); } else if (explorer.runMode() == -1) { explorer.setDecreaseNumber(returnLastIndex - returnFirstIndex + 1); } } }); explorer.returnedNumber(returnLastIndex - returnFirstIndex + 1); } else { explorer.returnedNumber(-1); } } else { explorer.getDisplay().syncExec(new Runnable() { public void run() { // MessageBox mBox = new MessageBox(explorer // .getShell(), SWT.ICON_INFORMATION // | SWT.OK ); // mBox.setText("Please Note ..."); // mBox.setMessage("Only "+(returnLastIndex-returnFirstIndex+1)+" patients returned"); // mBox.open(); if (explorer.runMode() >= 0) { explorer.setIncrementNumber(-1); } else if (explorer.runMode() == -1) { explorer.setDecreaseNumber(-1); } } }); } StringBuilder resultFile = new StringBuilder(); resultFile.append(GetTimelineHeader()); PatientSet patientDimensionSet = pdoresponsefactory.getPatientSetFromResponseXML(result); if (patientDimensionSet != null) { log.debug("Total patient: " + patientDimensionSet.getPatient().size()); // for(int i=0; // i<patientDimensionSet.getPatientDimension().size();i++) { // PatientDimensionType patientType = // patientDimensionSet.getPatientDimension().get(i); // System.out.println("PatientNum: " + // patientType.getPatientNum()); // } } else { return "error"; } // / testing the visit set // PatientDataType.VisitDimensionSet visitSet = // pdoresponsefactory.getVisitSetFromResponseXML(result); // System.out.println("Total visits: "+visitSet.getVisitDimension(). // size()); List<ObservationSet> factSets = pdoresponsefactory.getFactSetsFromResponseXML(result); log.debug("\nGenerate lld:"); String curPNum = "-1"; for (int i = 0; i < patientDimensionSet.getPatient().size(); i++) { PatientType patientType = patientDimensionSet.getPatient().get(i); String pnum = patientType.getPatientId().getValue(); // Integer pnum = new Integer(snum); // log.debug("PatientNum: " + snum); //if(curPNum.equals("-1")) { curPNum = new String(pnum); //} if (displayDemographics) { resultFile.append(getTimelinePatientString(pnum.toString(), patientType)); } else { resultFile.append(getTimelinePatientString(pnum.toString())); } String path = null; TimelineRow currentRow = null; ObservationSet observationFactSet = null; for (int j = 0; j < rows.size(); j++) { TimelineRow row = rows.get(j); int total = 0; StringBuilder resultString = new StringBuilder(); XMLGregorianCalendar curStartDate = null; //int currentInstanceNum = 0; //String currentConcept = ""; ArrayList<ObservationType> facts = new ArrayList<ObservationType>(); ObservationType curFact = null; boolean recorded = false; String sStart_date = null; String sEnd_date = null; // loop thru all the pdo sets for this row here for (int s = 0; s < row.pdoItems.size(); s++) { PDOItem pset = row.pdoItems.get(s); observationFactSet = null; for (int m = 0; m < factSets.size(); m++) { ObservationSet tmpFactSet = factSets.get(m); if (tmpFactSet.getPanelName().equalsIgnoreCase(pset.panelName())) { observationFactSet = tmpFactSet; path = observationFactSet.getPanelName(); currentRow = row; break; } } if (observationFactSet == null) { continue; } for (int k = 0; k < observationFactSet.getObservation().size(); k++) { ObservationType obsFactType = observationFactSet.getObservation().get(k); //if(curFact == null) { //curFact = obsFactType; //} //facts.add(obsFactType); if (pnum.equals(obsFactType.getPatientId().getValue())) { /* * if ((curStartDate != null) && * (obsFactType.getStartDate().compare( * curStartDate) == DatatypeConstants.EQUAL)) { * continue; } */ if (curFact == null) { curFact = obsFactType; } if (curStartDate == null) { curStartDate = obsFactType.getStartDate(); } sStart_date = obsFactType.getStartDate().getMonth() + "-" + obsFactType.getStartDate().getDay() + "-" + obsFactType.getStartDate().getYear(); if (obsFactType.getEndDate() == null) { sEnd_date = sStart_date; } else { sEnd_date = obsFactType.getEndDate().getMonth() + "-" + obsFactType.getEndDate().getDay() + "-" + obsFactType.getEndDate().getYear(); } double nval = -1; if (obsFactType.getNvalNum().getValue() != null) { nval = obsFactType.getNvalNum().getValue().doubleValue(); } PDOValueModel valdp = null; boolean same = sameInstance(curFact, obsFactType); if (false) {//pset.hasValueDisplayProperty) { for (int n = 0; n < pset.valDisplayProperties.size(); n++) { PDOValueModel tmpvaldp = pset.valDisplayProperties.get(n); // if (tmpvaldp.inRange(nval)) { valdp = tmpvaldp; // break; // } } String sValue = getSValue(obsFactType.getConceptCd().getName(), obsFactType, true); if ((curStartDate != null) && (obsFactType.getStartDate() .compare(curStartDate) == DatatypeConstants.EQUAL)) { resultString.append(getTimelineDateStringHeight(sStart_date, sEnd_date, "slateblue", valdp.height, sValue)); } else { resultString.append(getTimelineDateStringHeight(sStart_date, sEnd_date, valdp.color, valdp.height, sValue)); } } else { ////////////////////// String sValue = ""; if (same && k != observationFactSet.getObservation().size() - 1) { //if(recorded) { facts.add(obsFactType); //recorded = false; continue; //} /*sValue = getSValueSame(obsFactType.getConceptCd().getName(), obsFactType, false); if ((curStartDate != null) && (obsFactType.getStartDate() .compare(curStartDate) == DatatypeConstants.EQUAL)) { resultString .append(getTimelineDateStringHeightSame( sStart_date, sEnd_date, "slateblue", pset.height, sValue)); } else { resultString .append(getTimelineDateStringHeightSame( sStart_date, sEnd_date, pset.color, pset.height, sValue)); }*/ } //else { if (facts.size() == 0) { facts.add(obsFactType); } sValue = getSValue(curFact.getConceptCd().getName(), facts, false); //} sStart_date = curFact.getStartDate().getMonth() + "-" + curFact.getStartDate().getDay() + "-" + curFact.getStartDate().getYear(); if (curFact.getEndDate() == null) { sEnd_date = sStart_date; } else { sEnd_date = curFact.getEndDate().getMonth() + "-" + curFact.getEndDate().getDay() + "-" + curFact.getEndDate().getYear(); } //if ((curStartDate != null) // && (obsFactType.getStartDate() // .compare(curStartDate) == DatatypeConstants.EQUAL)) { //resultString //.append(getTimelineDateStringHeight( //sStart_date, sEnd_date, //"slateblue", //pset.height, sValue)); //} else { resultString.append(getTimelineDateStringHeight(sStart_date, sEnd_date, pset.color, pset.height, sValue)); //} } total++; recorded = false; facts.clear(); facts.add(obsFactType); curStartDate = obsFactType.getStartDate(); curFact = obsFactType; ///// if (!same && k == observationFactSet.getObservation().size() - 1) { String sValue = ""; sValue = getSValue(obsFactType.getConceptCd().getName(), facts, false); //} sStart_date = obsFactType.getStartDate().getMonth() + "-" + obsFactType.getStartDate().getDay() + "-" + obsFactType.getStartDate().getYear(); if (obsFactType.getEndDate() == null) { sEnd_date = sStart_date; } else { sEnd_date = obsFactType.getEndDate().getMonth() + "-" + obsFactType.getEndDate().getDay() + "-" + obsFactType.getEndDate().getYear(); } //if ((curStartDate != null) // && (obsFactType.getStartDate() // .compare(curStartDate) == DatatypeConstants.EQUAL)) { //resultString //.append(getTimelineDateStringHeight( //sStart_date, sEnd_date, //"slateblue", //pset.height, sValue)); //} else { resultString.append(getTimelineDateStringHeight(sStart_date, sEnd_date, pset.color, pset.height, sValue)); //} total++; } //// } else { if (recorded || facts.size() == 0) { curPNum = new String(pnum); continue; } sStart_date = curStartDate.getMonth() + "-" + curStartDate.getDay() + "-" + curStartDate.getYear(); //if (obsFactType.getEndDate() == null) { //sEnd_date = sStart_date; //} else { sEnd_date = curStartDate.getMonth() + "-" + curStartDate.getDay() + "-" + curStartDate.getYear() + " 12:00"; //} //curFact = null; String sValue = getSValue(curFact.getConceptCd().getName(), facts, false); //if ((curStartDate != null) //&& (obsFactType.getStartDate() //.compare(curStartDate) == DatatypeConstants.EQUAL)) { //resultString //.append(getTimelineDateStringHeight( //sStart_date, sEnd_date, //"slateblue", //pset.height, sValue)); //} else { resultString.append(getTimelineDateStringHeight(sStart_date, sEnd_date, pset.color, pset.height, sValue)); //} total++; recorded = true; facts.clear(); curStartDate = null;//obsFactType.getStartDate(); curFact = null;//obsFactType; curPNum = new String(pnum); } } } if (total > 0) { // log.debug("-- "+path+" has "+total+" events"); resultFile.append(getTimelineConceptString(row.displayName, total)); // log.debug(resultString.toString()); resultFile.append(resultString); total = 0; recorded = true; } else { // display all if (displayAll) { // log.debug("-- "+path+" has "+total+" events"); resultFile.append(getTimelineConceptString(row.displayName, 1)); // log.debug(getTimelineEmptyDateString()); resultFile.append(getTimelineEmptyDateString()); } } if (recorded || facts.size() == 0) { curPNum = new String(pnum); continue; } sStart_date = curStartDate.getMonth() + "-" + curStartDate.getDay() + "-" + curStartDate.getYear(); //if (obsFactType.getEndDate() == null) { //sEnd_date = sStart_date; //} else { sEnd_date = curStartDate.getMonth() + "-" + curStartDate.getDay() + "-" + curStartDate.getYear(); //} //curFact = null; String sValue = getSValue(curFact.getConceptCd().getName(), facts, false); resultString .append(getTimelineDateStringHeight(sStart_date, sEnd_date, "navyblue", "p10", sValue)); total++; recorded = true; facts.clear(); //curStartDate = obsFactType.getStartDate(); //curFact = obsFactType; curPNum = new String(pnum); if (total > 0) { // log.debug("-- "+path+" has "+total+" events"); resultFile.append(getTimelineConceptString(row.displayName, total)); // log.debug(resultString.toString()); resultFile.append(resultString); } } } resultFile.append(GetTimelineFooter()); if (writeFile) { String i2b2File = System.getProperty("user.dir") + "/temp/" + "i2b2xml.lld"; File oDelete = new File(i2b2File); if (oDelete != null) oDelete.delete(); RandomAccessFile f = new RandomAccessFile(i2b2File, "rw"); append(f, resultFile.toString()); f.close(); } // log.debug("\nThe lld file: \n"+resultFile.toString()); return resultFile.toString(); } catch (org.apache.axis2.AxisFault e) { e.printStackTrace(); log.error(e.getMessage()); return null; } catch (Exception e) { log.error(e.getMessage()); e.printStackTrace(); return "error"; } }
From source file:org.eclipse.smila.ontology.records.SesameRecordReader.java
/** * get only the date (year, month, day) part of the calendar literal, don't calculate with timezones. * /*from w ww. j a va 2 s .c o m*/ * @param ontoCal * a ontology calendar literal value. * @return a Calendar with only the date part. */ private Calendar getDateOnly(final XMLGregorianCalendar ontoCal) { final Calendar cal = Calendar.getInstance(); cal.setTimeInMillis(0); if (ontoCal.getYear() != DatatypeConstants.FIELD_UNDEFINED) { cal.set(Calendar.YEAR, ontoCal.getYear()); } if (ontoCal.getMonth() != DatatypeConstants.FIELD_UNDEFINED) { cal.set(Calendar.MONTH, ontoCal.getMonth() - 1); } if (ontoCal.getDay() != DatatypeConstants.FIELD_UNDEFINED) { cal.set(Calendar.DAY_OF_MONTH, ontoCal.getDay()); } return cal; }
From source file:org.orcid.frontend.web.forms.CurrentWork.java
private void setDate() { String dateString = crossRefContext.getDate(); XMLGregorianCalendar cal = DateUtils.convertToXMLGregorianCalendar(dateString); if (cal != null) { int calYear = cal.getYear(); if (calYear != DatatypeConstants.FIELD_UNDEFINED) { year = String.valueOf(calYear); }/* w w w. j ava 2s . c om*/ int calMonth = cal.getMonth(); if (calMonth != DatatypeConstants.FIELD_UNDEFINED) { month = String.valueOf(calMonth); } int calDay = cal.getDay(); if (calDay != DatatypeConstants.FIELD_UNDEFINED) { day = String.valueOf(calDay); } } }
From source file:org.orcid.frontend.web.forms.Publication.java
public OrcidWork getOrcidWork() { initCrossRefContext();/* w ww .ja v a2s .c o m*/ OrcidWork orcidWork = new OrcidWork(); if (StringUtils.isNotBlank(doi)) { WorkExternalIdentifier doiExtId = new WorkExternalIdentifier(); doiExtId.setWorkExternalIdentifierType(WorkExternalIdentifierType.DOI); doiExtId.setWorkExternalIdentifierId(new WorkExternalIdentifierId(doi)); WorkExternalIdentifiers workExtIds = new WorkExternalIdentifiers(); orcidWork.setWorkExternalIdentifiers(workExtIds); workExtIds.getWorkExternalIdentifier().add(doiExtId); } if (StringUtils.isNotBlank(title)) { WorkTitle workTitle = new WorkTitle(); orcidWork.setWorkTitle(workTitle); workTitle.setTitle(new Title(title)); } // Will throw an IllegalArgumentException if not valid CitationType cType = CitationType.fromValue(citationType); Citation citation = new Citation(fullCitation, cType); orcidWork.setWorkCitation(citation); String publicationDateString = crossRefContext.getDate(); if (StringUtils.isNotBlank(publicationDateString)) { XMLGregorianCalendar publicationDateGregCal = DateUtils .convertToXMLGregorianCalendar(publicationDateString); if (publicationDateGregCal != null) { Year publicationyear = new Year(publicationDateGregCal.getYear()); Month publicationMonth = publicationDateGregCal.getMonth() == DatatypeConstants.FIELD_UNDEFINED ? null : new Month(publicationDateGregCal.getMonth()); Day publicationDay = publicationDateGregCal.getDay() == DatatypeConstants.FIELD_UNDEFINED ? null : new Day(publicationDateGregCal.getDay()); orcidWork .setPublicationDate(new PublicationDate(publicationyear, publicationMonth, publicationDay)); } } String author = crossRefContext.getAuthor(); if (StringUtils.isNotBlank(author)) { WorkContributors workContributors = new WorkContributors(); orcidWork.setWorkContributors(workContributors); Contributor contributor = new Contributor(); workContributors.getContributor().add(contributor); contributor.setCreditName(new CreditName(author)); ContributorAttributes contributorAttributes = new ContributorAttributes(); contributor.setContributorAttributes(contributorAttributes); contributorAttributes.setContributorRole(ContributorRole.AUTHOR); contributorAttributes.setContributorSequence(SequenceType.FIRST); } return orcidWork; }
From source file:org.oscarehr.hospitalReportManager.HRMReport.java
public List<Integer> getDateOfBirth() { List<Integer> dateOfBirthList = new ArrayList<Integer>(); XMLGregorianCalendar fullDate = dateFP(demographics.getDateOfBirth()); dateOfBirthList.add(fullDate.getYear()); dateOfBirthList.add(fullDate.getMonth()); dateOfBirthList.add(fullDate.getDay()); return dateOfBirthList; }
From source file:org.oscarehr.integration.mchcv.OnlineHCValidator.java
@Override public HCValidationResult validate(String healthCardNumber, String versionCode) { Requests requests = new Requests(); HcvRequest request = new HcvRequest(); request.setHealthNumber(healthCardNumber); request.setVersionCode(versionCode); requests.getHcvRequest().add(request); HcvResults results = null;// w w w .ja v a 2 s . co m try { results = validation.validate(requests, "en"); } catch (Faultexception ex) { throw new RuntimeException(ex.getMessage()); } List persons = results.getResults(); Person person = (Person) persons.get(0); HCValidationResult result = new HCValidationResult(); result.setResponseCode(person.getResponseCode()); result.setResponseDescription(person.getResponseDescription()); result.setResponseAction(person.getResponseAction()); result.setFirstName(person.getFirstName()); result.setLastName(person.getLastName()); result.setGender(person.getGender()); String birthDate = null; XMLGregorianCalendar xmlBirthDate = person.getDateOfBirth(); if (xmlBirthDate != null) { birthDate = makeDate(xmlBirthDate.getYear(), xmlBirthDate.getMonth(), xmlBirthDate.getDay()); } result.setBirthDate(birthDate); String expiryDate = null; XMLGregorianCalendar xmlExpiryDate = person.getExpiryDate(); if (xmlExpiryDate != null) { expiryDate = makeDate(xmlExpiryDate.getYear(), xmlExpiryDate.getMonth(), xmlExpiryDate.getDay()); } result.setExpiryDate(expiryDate); return result; }
From source file:org.ow2.aspirerfid.demos.warehouse.management.beg.CaptureReport.java
private void handleReports(ECReports reports) throws IOException, JAXBException { log.debug("**********************Handling incomming reports****************************"); // get the current time and set the eventTime XMLGregorianCalendar now = null; try {//from w w w . jav a2s . c o m DatatypeFactory dataFactory = DatatypeFactory.newInstance(); now = dataFactory.newXMLGregorianCalendar(new GregorianCalendar()); log.debug("Event Time:" + now.getHour() + ":" + now.getMinute() + ":" + ":" + now.getSecond() + "\n"); } catch (DatatypeConfigurationException e) { e.printStackTrace(); } List<ECReport> theReports = reports.getReports().getReport(); // collect all the tags List<EPC> epcs = new LinkedList<EPC>(); if (theReports != null) { for (ECReport report : theReports) { // log.debug("Report Count: "+report.getGroup().size()); log.debug("***************Report Name:" + report.getReportName() + "**************"); if (report.getGroup() != null) { for (ECReportGroup group : report.getGroup()) { if (WarehouseManagement.getEntryDateTextField().equals("")) { WarehouseManagement.setEntryDateTextField( now.getDay() + "/" + now.getMonth() + "/" + now.getYear()); } if (WarehouseManagement.getEntryHourTextField().equals("")) { WarehouseManagement.setEntryHourTextField( now.getHour() + ":" + now.getMinute() + ":" + now.getSecond()); } WarehouseManagement.setZoneIDTextField(zoneID); WarehouseManagement.setWarehouseIDTextField(warehouseID); log.debug("Group Count: " + group.getGroupCount().getCount()); log.debug("Group Name: " + group.getGroupName()); if (group.getGroupList() != null) { deliveredItem = null; // warehousemen if (group.getGroupName().equals(warehousemenGroupName)) { for (ECReportGroupListMember member : group.getGroupList().getMember()) { if (member.getEpc() != null) { WarehouseManagement .setUserIDTextField(member.getTag().getValue().split(":")[4]); } } } // Invoice if (group.getGroupName().equals(invoiceGroupName)) { for (ECReportGroupListMember member : group.getGroupList().getMember()) { if (member.getEpc() != null) { WarehouseManagement .setInvoiceIDTextField(member.getTag().getValue().split(":")[4]); WarehouseManagement.setOfferingDateTextField("22/05/08"); WarehouseManagement.setOfferingHourTextField("10:53:22"); } } } // // Small Packets // if (group.getGroupName().equals("urn:epc:pat:gid-96:145.56.*")) { // for (ECReportGroupListMember member : group.getGroupList().getMember()) { // if (member.getEpc() != null) { // // WarehouseManagement.setInvoiceIDTextField(member.getTag().getValue().split(":")[4]); // } // } // } // // Medium Packets // if (group.getGroupName().equals("urn:epc:pat:gid-96:145.87.*")) { // for (ECReportGroupListMember member : group.getGroupList().getMember()) { // if (member.getEpc() != null) { // // WarehouseManagement.setInvoiceIDTextField(member.getTag().getValue().split(":")[4]); // } // } // } for (int i = 0; i < nOFmerchandise; i++) { if (group.getGroupName().equals(packetsGroupName[i])) { BigInteger quantity = new BigInteger(packetsQuantity[i]); BigInteger expectedQuantity = new BigInteger(packetsExpectedQuantity[i]); BigInteger quantityDelivered = new BigInteger( (group.getGroupCount().getCount()) + ""); BigInteger quantityRemain = quantity.add(quantityDelivered.negate()); for (ECReportGroupListMember member : group.getGroupList().getMember()) { if (member.getEpc() != null) { deliveredItem = new DeliveredItem(); deliveredItem.setCompany(packetsCompany[i]); deliveredItem.setDeliveryDate( now.getDay() + "/" + now.getMonth() + "/" + now.getYear()); deliveredItem.setDescription(packetsDescription[i]); deliveredItem.setExpectedQuantity(expectedQuantity); deliveredItem.setMeasurementID(packetsMeasurementID[i]); deliveredItem.setQuantity(quantity); deliveredItem.setQuantityDelivered(quantityDelivered); deliveredItem.setQuantityRemain(quantityRemain); deliveredItem.setItemCode(member.getTag().getValue().split(":")[4]); WarehouseManagement.updateDeliveryTableModel(deliveredItem); deliveredItem = null; } } } } // Print All for (ECReportGroupListMember member : group.getGroupList().getMember()) { if (member.getEpc() != null) { log.debug("***Recieved Group Values***"); log.debug("RawDecimal Value: " + member.getRawDecimal().getValue()); { if (!(member.getEpc() == null)) epcs.add(member.getEpc()); log.debug("Epc Value: " + member.getEpc().getValue()); if ((member.getEpc() == null)) log.debug("Epc Value: null"); } log.debug("RawHex Value: " + member.getRawHex().getValue()); log.debug("Tag Value: " + member.getTag().getValue()); // log.debug("Group // Value:"+member.getExtension().getFieldList().toString()); } } } } } } } if (epcs.size() == 0) { log.debug("no epc received - generating no event"); return; } }
From source file:oscar.oscarLab.ca.all.parsers.HRMXMLHandler.java
private String getFormattedDate(XMLGregorianCalendar date, boolean omitTime) { if (date == null) { return ""; }//from w w w . j a v a2s. c o m return date.getYear() + "-" + date.getMonth() + "-" + date.getDay() + (!omitTime ? date.getHour() + ":" + date.getMinute() : ""); }
From source file:se.skl.skltpservices.npoadapter.mapper.util.EHRUtil.java
/** * Returns a {@link Date} date and time representation. * * @param cal/*from w ww .ja v a 2 s .c o m*/ * the actual date and time. * @return the {@link Date} representation. */ public static Date toDate(XMLGregorianCalendar cal) { if (cal != null) { final Calendar c = Calendar.getInstance(); c.set(Calendar.DATE, cal.getDay()); c.set(Calendar.MONTH, cal.getMonth() - 1); c.set(Calendar.YEAR, cal.getYear()); c.set(Calendar.DAY_OF_MONTH, cal.getDay()); c.set(Calendar.HOUR_OF_DAY, cal.getHour()); c.set(Calendar.MINUTE, cal.getMinute()); c.set(Calendar.SECOND, cal.getSecond()); c.set(Calendar.MILLISECOND, cal.getMillisecond()); return c.getTime(); } return null; }