/**
  * Gets the value of the first active attribute of the given type. By using the UUID of the
  * attribute type this avoids forcing us to keep re-fetching attribute types via service methods
  * which can be slow.
  *
  * @param attrTypeUuid the attribute type UUID
  * @return the value or null
  */
 protected PersonAttribute findFirstAttribute(String attrTypeUuid) {
   if (target.getAttributes() != null) {
     for (PersonAttribute attr : target.getAttributes())
       if (attr.getAttributeType().getUuid().equals(attrTypeUuid) && !attr.isVoided()) {
         return attr;
       }
   }
   return null;
 }
Пример #2
0
 /** Sets an attribute on a person. */
 public static void setPersonAttributeValue(
     Patient patient, PersonAttributeType attrType, String value) {
   PersonService personService = Context.getPersonService();
   PersonAttribute attribute = patient.getAttribute(attrType);
   if (attribute == null) {
     attribute = new PersonAttribute();
     attribute.setAttributeType(attrType);
     attribute.setValue(value);
     patient.addAttribute(attribute);
   } else {
     attribute.setValue(value);
   }
   personService.savePerson(patient);
 }
 /**
  * Auto generated method comment
  *
  * @param p
  * @param attributeTypeId
  * @return
  */
 public static String personAttribute(Person p, Integer attributeTypeId) {
   try {
     PersonAttribute pa = null;
     if (p != null) pa = p.getAttribute(attributeTypeId);
     if (pa != null) {
       return Context.getConceptService()
           .getConcept(Integer.parseInt(pa.getValue()))
           .getName()
           .getName();
     } else return "-";
   } catch (Exception e) {
     log.error(">>>>>>>>>>>>>>>>>>>VCT>>Module>>Tag>>>> An error occured : " + e.getMessage());
     e.printStackTrace();
     return "-";
   }
 }
  /**
   * Sets a attribute value of this person. If the value is blank then any existing attribute will
   * be voided.
   *
   * @param attrTypeUuid the attribute type UUID
   * @param value the value
   */
  protected void setAsAttribute(String attrTypeUuid, String value) {
    PersonAttribute attr = findFirstAttribute(attrTypeUuid);

    if (StringUtils.isNotBlank(value)) {
      if (attr == null) {
        attr = new PersonAttribute();
        attr.setAttributeType(MetadataUtils.existing(PersonAttributeType.class, attrTypeUuid));
        attr.setValue(value);
        target.addAttribute(attr);
      } else {
        attr.setValue(value);
      }
    } else if (attr != null) {
      attr.setVoided(true);
      attr.setDateVoided(new Date());
      attr.setVoidedBy(Context.getAuthenticatedUser());
    }
  }
Пример #5
0
 /** Gets the value of an attribute on a person. */
 public static String getPersonAttributeValue(Person person, PersonAttributeType attrType) {
   PersonAttribute attribute = person.getAttribute(attrType);
   return attribute != null ? attribute.getValue() : null;
 }
 /**
  * Gets the value of the first attribute of the given type
  *
  * @param attrTypeUuid the attribute type UUID
  * @return the value or null
  */
 protected String getAsAttribute(String attrTypeUuid) {
   PersonAttribute attr = findFirstAttribute(attrTypeUuid);
   return attr != null ? attr.getValue() : null;
 }
  @RequestMapping(method = RequestMethod.GET)
  public String viewForm(
      Model model,
      @RequestParam("patientId") Integer patientId,
      @RequestParam(value = "billId", required = false) Integer billId,
      @RequestParam(value = "pageSize", required = false) Integer pageSize,
      @RequestParam(value = "currentPage", required = false) Integer currentPage,
      @RequestParam(value = "encounterId", required = false) Integer encounterId,
      @RequestParam(value = "admissionLogId", required = false) Integer admissionLogId,
      HttpServletRequest request) {

    BillingService billingService = Context.getService(BillingService.class);
    Patient patient = Context.getPatientService().getPatient(patientId);
    BillCalculatorForBDService calculator = new BillCalculatorForBDService();

    IpdService ipdService = Context.getService(IpdService.class);
    IpdPatientAdmissionLog ipdPatientAdmissionLog =
        ipdService.getIpdPatientAdmissionLog(admissionLogId);
    IpdPatientAdmitted ipdPatientAdmitted =
        ipdService.getAdmittedByAdmissionLogId(ipdPatientAdmissionLog);

    PersonAttribute fileNumber = patient.getAttribute(43);
    if (fileNumber != null) {
      model.addAttribute("fileNumber", fileNumber.getValue());
    }

    if (patient != null) {
      int total = billingService.countListPatientServiceBillByPatient(patient);
      PagingUtil pagingUtil =
          new PagingUtil(
              RequestUtil.getCurrentLink(request), pageSize, currentPage, total, patientId);
      model.addAttribute("pagingUtil", pagingUtil);
      model.addAttribute("patient", patient);
      model.addAttribute("age", patient.getAge());
      if (patient.getGender().equals("M")) {
        model.addAttribute("gender", "Male");
      }
      if (patient.getGender().equals("F")) {
        model.addAttribute("gender", "Female");
      }
      model.addAttribute("category", patient.getAttribute(14).getValue());

      model.addAttribute(
          "listBill",
          billingService.listPatientServiceBillByPatient(
              pagingUtil.getStartPos(), pagingUtil.getPageSize(), patient));
    }
    User user = Context.getAuthenticatedUser();

    model.addAttribute("canEdit", user.hasPrivilege(BillingConstants.PRIV_EDIT_BILL_ONCE_PRINTED));
    if (billId != null) {
      PatientServiceBill bill = billingService.getPatientServiceBillById(billId);
      PatientServiceBillItem patientServiceBillItem =
          billingService.getPatientServiceBillItem(billId, "ADMISSION FILE CHARGES");
      if (bill.getFreeBill().equals(1)) {
        String billType = "free";
        bill.setFreeBill(calculator.isFreeBill(billType));
      } else if (bill.getFreeBill().equals(2)) {
        String billType = "mixed";
        bill.setFreeBill(2);
      } else {
        String billType = "paid";
        bill.setFreeBill(calculator.isFreeBill(billType));
      }
      model.addAttribute("paymentMode", bill.getPaymentMode());
      model.addAttribute("cashier", bill.getCreator().getGivenName());
      model.addAttribute("bill", bill);
      model.addAttribute("billItem", patientServiceBillItem);
    }
    return "/module/billing/indoorQueue/indoorPatientServiceBill";
  }