Subida y gestión de imágenes completa
This commit is contained in:
@@ -5,38 +5,52 @@
|
|||||||
xmlns:ui="http://java.sun.com/jsf/facelets"
|
xmlns:ui="http://java.sun.com/jsf/facelets"
|
||||||
xmlns:f="http://java.sun.com/jsf/core"
|
xmlns:f="http://java.sun.com/jsf/core"
|
||||||
xmlns:h="http://java.sun.com/jsf/html"
|
xmlns:h="http://java.sun.com/jsf/html"
|
||||||
xmlns:p="http://primefaces.org/ui"
|
xmlns:p="http://primefaces.org/ui" xmlns:o="http://omnifaces.org/ui">
|
||||||
xmlns:o="http://omnifaces.org/ui">
|
|
||||||
|
|
||||||
<ui:composition template="../header.xhtml">
|
<ui:composition template="../header.xhtml">
|
||||||
<ui:define name="content">
|
<ui:define name="content">
|
||||||
<h:form id="frmMT">
|
|
||||||
<div class="ui-g ui-fluid">
|
<div class="ui-g ui-fluid">
|
||||||
<div class="ui-g-5 ui-md-5">
|
<div class="ui-g-5 ui-md-5">
|
||||||
|
<h:form id="frmMT">
|
||||||
<p:panel id="mainPanel" header="Pruebas médicas">
|
<p:panel id="mainPanel" header="Pruebas médicas">
|
||||||
<f:facet name="actions">
|
<f:facet name="actions">
|
||||||
<h:commandLink rendered="#{mt.specialistDoctor}" action="#{mt.addMT}" immediate="true" update="frmMT" styleClass="ui-panel-titlebar-icon ui-corner-all ui-state-default">
|
<h:commandLink rendered="#{mt.specialistDoctor}"
|
||||||
|
action="#{mt.addMT}" immediate="true" update="frmMT"
|
||||||
|
styleClass="ui-panel-titlebar-icon ui-corner-all ui-state-default">
|
||||||
<h:outputText styleClass="ui-icon pi pi-plus" />
|
<h:outputText styleClass="ui-icon pi pi-plus" />
|
||||||
</h:commandLink>
|
</h:commandLink>
|
||||||
</f:facet>
|
</f:facet>
|
||||||
<p:selectOneMenu id="lazy" value="#{mt.patIdSelected}" converter="omnifaces.SelectItemsConverter">
|
<p:selectOneMenu rendered="#{mt.specialistDoctor}" id="lazy" value="#{mt.patIdSelected}"
|
||||||
<p:ajax event="valueChange" listener="#{mt.onSelectPatient}" update="frmMT"/>
|
converter="omnifaces.SelectItemsConverter">
|
||||||
|
<p:ajax event="valueChange" listener="#{mt.onSelectPatient}"
|
||||||
|
update="frmMT" />
|
||||||
<f:selectItem itemLabel="Todos" itemValue="-1" />
|
<f:selectItem itemLabel="Todos" itemValue="-1" />
|
||||||
<f:selectItems value="#{mt.patients}" var="el" itemLabel="#{el.name} #{el.surname}" itemValue="#{el.id}" />
|
<f:selectItems value="#{mt.patients}" var="el"
|
||||||
|
itemLabel="#{el.name} #{el.surname}" itemValue="#{el.id}" />
|
||||||
</p:selectOneMenu>
|
</p:selectOneMenu>
|
||||||
<p:orderList id="medicalTestList" value="#{mt.medicalTests}" var="el" itemValue="#{el}" controlsLocation="none" responsive="true">
|
<p:orderList id="medicalTestList" value="#{mt.medicalTests}"
|
||||||
<p:ajax event="select" listener="#{mt.onSelectMT}" update="frmMT"/>
|
var="el" itemValue="#{el}" controlsLocation="none"
|
||||||
<o:converter converterId="omnifaces.ListConverter" list="#{mt.medicalTests}" />
|
responsive="true">
|
||||||
|
<p:ajax event="select" listener="#{mt.onSelectMT}"
|
||||||
|
update="frmMT,frmNEW,frmImage" />
|
||||||
|
<o:converter converterId="omnifaces.ListConverter"
|
||||||
|
list="#{mt.medicalTests}" />
|
||||||
<p:column>
|
<p:column>
|
||||||
<h:outputText value="#{el.onlyDate} - #{el.type.testTypeName}" />
|
<h:outputText value="#{el.onlyDate} - #{el.type.testTypeName}" />
|
||||||
<br />
|
<br />
|
||||||
<h:outputText rendered="#{mt.patIdSelected == -1}" value="#{el.patient.name} #{el.patient.surname}" style="font-size: 0.8em !important; font-style: italic;" />
|
<h:outputText rendered="#{mt.patIdSelected == -1}"
|
||||||
|
value="#{el.patient.name} #{el.patient.surname}"
|
||||||
|
style="font-size: 0.8em !important; font-style: italic;" />
|
||||||
</p:column>
|
</p:column>
|
||||||
</p:orderList>
|
</p:orderList>
|
||||||
</p:panel>
|
</p:panel>
|
||||||
|
</h:form>
|
||||||
</div>
|
</div>
|
||||||
<div class="ui-g-7 ui-md-7">
|
<div class="ui-g-7 ui-md-7">
|
||||||
<p:panel rendered="#{mt.viewEdit}" id="detailPanel" header="Detalle de prueba médica">
|
<h:form id="frmImage" enctype="multipart/form-data">
|
||||||
|
<p:panel rendered="#{mt.viewEdit}" id="detailPanel"
|
||||||
|
header="Detalle de prueba médica">
|
||||||
<div class="ui-g ui-fluid">
|
<div class="ui-g ui-fluid">
|
||||||
<div class="ui-g-4 ui-md-4">Fecha:</div>
|
<div class="ui-g-4 ui-md-4">Fecha:</div>
|
||||||
<div class="ui-g-8 ui-md-8">
|
<div class="ui-g-8 ui-md-8">
|
||||||
@@ -48,7 +62,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="ui-g-4 ui-md-4">Observaciones:</div>
|
<div class="ui-g-4 ui-md-4">Observaciones:</div>
|
||||||
<div class="ui-g-8 ui-md-8">
|
<div class="ui-g-8 ui-md-8">
|
||||||
<h:outputText value="#{mt.selected.observations}"></h:outputText>
|
<h:outputText escape="false" value="#{mt.selected.observations}"></h:outputText>
|
||||||
</div>
|
</div>
|
||||||
<div class="ui-g-4 ui-md-4">Tipo de prueba:</div>
|
<div class="ui-g-4 ui-md-4">Tipo de prueba:</div>
|
||||||
<div class="ui-g-8 ui-md-8">
|
<div class="ui-g-8 ui-md-8">
|
||||||
@@ -56,19 +70,36 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="ui-g-4 ui-md-4">Imagen de alta resolución:</div>
|
<div class="ui-g-4 ui-md-4">Imagen de alta resolución:</div>
|
||||||
<div class="ui-g-8 ui-md-8">
|
<div class="ui-g-8 ui-md-8">
|
||||||
<h:outputText rendered="#{mt.selected.highresimage != null}" value="#{mt.selected.highresimage}"></h:outputText>
|
|
||||||
|
<div class="ui-g-12 ui-md-12">
|
||||||
|
<p:fileUpload rendered="#{mt.specialistDoctor}" value="#{mt.imageUpload}" mode="simple" skinSimple="true" />
|
||||||
|
<p:commandButton rendered="#{mt.specialistDoctor}" value="Subir imagen" ajax="false" action="#{mt.addImage}" update="frmImage"/>
|
||||||
|
</div>
|
||||||
|
<div class="ui-g-12 ui-md-12">
|
||||||
|
<img src="#{mt.selected.highresimage}" style="max-width: 300px !important;"></img>
|
||||||
|
</div>
|
||||||
|
<div class="ui-g-12 ui-md-12">
|
||||||
|
<p:commandButton rendered="#{mt.specialistDoctor}" action="#{mt.removeImage}"
|
||||||
|
disabled="#{mt.selected.highresimage == null}"
|
||||||
|
value="Eliminar" icon="pi pi-delete" update="frmImage"/>
|
||||||
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</p:panel>
|
</p:panel>
|
||||||
<p:panel rendered="#{mt.viewCreate}" id="createPanel" header="Detalle de prueba médica">
|
</h:form>
|
||||||
|
<h:form id="frmNEW">
|
||||||
|
<p:panel rendered="#{mt.viewCreate}" id="createPanel"
|
||||||
|
header="Detalle de prueba médica">
|
||||||
|
|
||||||
<div class="ui-g ui-fluid">
|
<div class="ui-g ui-fluid">
|
||||||
<div class="ui-g-4 ui-md-4">Fecha:</div>
|
<div class="ui-g-4 ui-md-4">Fecha:</div>
|
||||||
<div class="ui-g-8 ui-md-8">
|
<div class="ui-g-8 ui-md-8">
|
||||||
<p:inputText value="#{mt.selected.date}"></p:inputText>
|
<h:outputText value="#{mt.selected.date}"></h:outputText>
|
||||||
</div>
|
</div>
|
||||||
<div class="ui-g-4 ui-md-4">Hora:</div>
|
<div class="ui-g-4 ui-md-4">Hora:</div>
|
||||||
<div class="ui-g-8 ui-md-8">
|
<div class="ui-g-8 ui-md-8">
|
||||||
<p:inputText value="#{mt.selected.time}"></p:inputText>
|
<h:outputText value="#{mt.selected.time}"></h:outputText>
|
||||||
</div>
|
</div>
|
||||||
<div class="ui-g-4 ui-md-4">Observaciones:</div>
|
<div class="ui-g-4 ui-md-4">Observaciones:</div>
|
||||||
<div class="ui-g-8 ui-md-8">
|
<div class="ui-g-8 ui-md-8">
|
||||||
@@ -77,20 +108,22 @@
|
|||||||
<div class="ui-g-4 ui-md-4">Tipo de prueba:</div>
|
<div class="ui-g-4 ui-md-4">Tipo de prueba:</div>
|
||||||
<div class="ui-g-8 ui-md-8">
|
<div class="ui-g-8 ui-md-8">
|
||||||
<p:selectOneMenu value="#{mt.medicalTestTypeSelected}">
|
<p:selectOneMenu value="#{mt.medicalTestTypeSelected}">
|
||||||
<f:selectItems value="#{mt.medicalTestTypes}" var="el" itemLabel="#{el.testTypeName}" itemValue="#{el.name}" />
|
<f:selectItems value="#{mt.medicalTestTypes}" var="el"
|
||||||
|
itemLabel="#{el.testTypeName}" itemValue="#{el.name}" />
|
||||||
</p:selectOneMenu>
|
</p:selectOneMenu>
|
||||||
</div>
|
</div>
|
||||||
<div class="ui-g-4 ui-md-4"></div>
|
<div class="ui-g-4 ui-md-4"></div>
|
||||||
<div class="ui-g-4 ui-md-4">
|
<div class="ui-g-4 ui-md-4">
|
||||||
<p:commandButton value="Guardar" action="#{mt.save}" icon="pi pi-save" update="frmMT" />
|
<p:commandButton value="Guardar" action="#{mt.save}"
|
||||||
|
icon="pi pi-save" update="frmMT,frmImage,frmNEW" />
|
||||||
</div>
|
</div>
|
||||||
<div class="ui-g-4 ui-md-4"></div>
|
<div class="ui-g-4 ui-md-4"></div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</p:panel>
|
</p:panel>
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</h:form>
|
</h:form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</ui:define>
|
</ui:define>
|
||||||
</ui:composition>
|
</ui:composition>
|
||||||
</html>
|
</html>
|
||||||
@@ -2,16 +2,18 @@ package managedbean.medicalTest;
|
|||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Base64;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import javax.annotation.PostConstruct;
|
import javax.annotation.PostConstruct;
|
||||||
import javax.faces.application.FacesMessage;
|
import javax.faces.application.FacesMessage;
|
||||||
import javax.faces.component.html.HtmlSelectOneMenu;
|
|
||||||
import javax.faces.event.AjaxBehaviorEvent;
|
import javax.faces.event.AjaxBehaviorEvent;
|
||||||
import javax.faces.view.ViewScoped;
|
import javax.faces.view.ViewScoped;
|
||||||
import javax.inject.Named;
|
import javax.inject.Named;
|
||||||
|
|
||||||
|
import org.primefaces.event.FileUploadEvent;
|
||||||
import org.primefaces.event.SelectEvent;
|
import org.primefaces.event.SelectEvent;
|
||||||
|
import org.primefaces.model.UploadedFile;
|
||||||
|
|
||||||
import TO.MedicalTestTO;
|
import TO.MedicalTestTO;
|
||||||
import TO.PatientTO;
|
import TO.PatientTO;
|
||||||
@@ -32,6 +34,7 @@ public class MedicalTestMBean extends ManagedBeanBase implements Serializable {
|
|||||||
private MedicalTestTO selected;
|
private MedicalTestTO selected;
|
||||||
private PatientTO patSelected;
|
private PatientTO patSelected;
|
||||||
private boolean addNewMode = false;
|
private boolean addNewMode = false;
|
||||||
|
private UploadedFile imageUpload;
|
||||||
|
|
||||||
public MedicalTestMBean() {
|
public MedicalTestMBean() {
|
||||||
}
|
}
|
||||||
@@ -55,15 +58,31 @@ public class MedicalTestMBean extends ManagedBeanBase implements Serializable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void addImage() {
|
public void addImage() {
|
||||||
getRemoteManagerMedicalTest().addImage(this.selected.getId(), this.selected.getHighresimage());
|
if(this.imageUpload != null ) {
|
||||||
|
String content = "data:"+imageUpload.getContentType()+";base64," + Base64.getEncoder().encodeToString(imageUpload.getContents());
|
||||||
|
System.out.println("FILE Content base64: ");
|
||||||
|
System.out.println(content);
|
||||||
|
this.selected.setHighresimage(content);
|
||||||
|
getRemoteManagerMedicalTest().addImage(this.selected.getId(), content);
|
||||||
|
this.loadMedicalTests();
|
||||||
|
this.imageUpload = null;
|
||||||
|
}else {
|
||||||
|
System.out.println("IMAGEN SUBIDA ES NULA");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateImage() {
|
public UploadedFile getImageUpload() {
|
||||||
getRemoteManagerMedicalTest().updateImage(this.selected.getId(), this.selected.getHighresimage());
|
return imageUpload;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setImageUpload(UploadedFile imageUpload) {
|
||||||
|
this.imageUpload = imageUpload;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeImage() {
|
public void removeImage() {
|
||||||
|
this.selected.setHighresimage(null);
|
||||||
getRemoteManagerMedicalTest().removeImage(this.selected.getId());
|
getRemoteManagerMedicalTest().removeImage(this.selected.getId());
|
||||||
|
this.loadMedicalTests();
|
||||||
}
|
}
|
||||||
|
|
||||||
public MedicalTestTO getSelected() {
|
public MedicalTestTO getSelected() {
|
||||||
@@ -98,7 +117,6 @@ public class MedicalTestMBean extends ManagedBeanBase implements Serializable {
|
|||||||
// Nothing todo
|
// Nothing todo
|
||||||
this.medicalTests = new ArrayList<MedicalTestTO>();
|
this.medicalTests = new ArrayList<MedicalTestTO>();
|
||||||
}
|
}
|
||||||
System.out.println(this.medicalTests);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<PatientTO> getPatients() {
|
public List<PatientTO> getPatients() {
|
||||||
@@ -196,15 +214,21 @@ public class MedicalTestMBean extends ManagedBeanBase implements Serializable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setMedicalTestTypeSelected(String val) {
|
public void setMedicalTestTypeSelected(String val) {
|
||||||
|
System.out.println("********************************");
|
||||||
|
System.out.println(val);
|
||||||
|
System.out.println("********************************");
|
||||||
MedicalTestType mt;
|
MedicalTestType mt;
|
||||||
if (val.equals(MedicalTestType.BLOOD_TEST)) {
|
if (val.equals("BLOOD_TEST")) {
|
||||||
mt = MedicalTestType.BLOOD_TEST;
|
mt = MedicalTestType.BLOOD_TEST;
|
||||||
} else if (val.equals(MedicalTestType.CT_SCAN)) {
|
} else if (val.equals("CT_SCAN")) {
|
||||||
mt = MedicalTestType.CT_SCAN;
|
mt = MedicalTestType.CT_SCAN;
|
||||||
} else {
|
} else {
|
||||||
mt = MedicalTestType.MAGNETIC_RESONANCE_IMAGING;
|
mt = MedicalTestType.MAGNETIC_RESONANCE_IMAGING;
|
||||||
}
|
}
|
||||||
this.selected.setType(mt);
|
this.selected.setType(mt);
|
||||||
|
System.out.println("********************************");
|
||||||
|
System.out.println(this.selected.getType());
|
||||||
|
System.out.println("********************************");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void save() {
|
public void save() {
|
||||||
|
|||||||
Reference in New Issue
Block a user