/** * Creates a period object from a start and end date. * * @param startDate The starting date. * @param endDate The ending date. * @return A period object, or null if both dates are null. */ public static PeriodDt createPeriod(Date startDate, Date endDate) { PeriodDt period = null; if (startDate != null) { period = new PeriodDt(); period.setStart(new DateTimeDt(startDate)); } if (endDate != null) { (period == null ? period = new PeriodDt() : period).setEnd(new DateTimeDt(endDate)); } return period; }
public static Encounter create(Patient patient, Date date, Location location, String sc) { Encounter encounter = new Encounter(); ResourceReferenceDt pat = new ResourceReferenceDt(patient); encounter.setPatient(pat); PeriodDt period = new PeriodDt(); period.setStart(new DateTimeDt(date)); encounter.setPeriod(period); ResourceReferenceDt loc = new ResourceReferenceDt(location); Encounter.Location encloc = encounter.addLocation(); encloc.setPeriod(period); encloc.setLocation(loc); CodeableConceptDt type = encounter.addType(); CodeableConceptDt cat = getServiceCategory(sc); type.setText(cat.getText()); type.setCoding(cat.getCoding()); return encounter; }