

Application.Pacienti = Ext.extend(Ext.app.Module, {
    id:'desk-pacienti',
    init : function() {
        this.launcher = {
            text: 'Pacienti',
            iconCls:'icon-grid',
            handler : this.createWindow,
            scope: this
        }
    },
    pacstore: new Ext.data.JsonStore({
		totalProperty: 'total',
		root: 'data',
		url: 'rpcserver.php',
		baseParams: {module:'pacienti',method:'gridlist'},
	        fields: [{name: 'id', type: 'int'},'nume', 'prenume', 'telefon']
    	    })
    ,
    createWindow : function(){
        var desktop = this.app.getDesktop();
        var win = desktop.getWindow('desk-pacienti-list');
        if(!win){
	  this.pacstore.load();
	  var grid = new Ext.grid.GridPanel({
                        border:false,
                        store: this.pacstore,
                        cm: new Ext.grid.ColumnModel([
                            {header: "Nume", width: 120, sortable: true, dataIndex: 'nume'},
                            {header: "Prenume", width: 70, sortable: true, dataIndex: 'prenume'},
                            {header: "Telefon", width: 70, sortable: true, dataIndex: 'telefon'},
                            {header: "Adresa", width: 160, sortable: true, dataIndex: 'adresa'}
                        ]),
			sm: new Ext.grid.RowSelectionModel({singleSelect: true}),
                        viewConfig: { forceFit:true },
			bbar: new Ext.PagingToolbar({
				pageSize: 20,
				store: this.pacstore,
				displayInfo: true,
				displayMsg: 'Afiseaza pacienti {0} - {1} din {2}',
				emptyMsg: 'Nici un pacient'
			}),

                        tbar:[{
                            text:'Adauga pacient',
                            tooltip:'Adaugare pacient',
                            iconCls:'add',
                            handler: this.AddPacient,
            			    scope: this
                        },'-',{
                            iconCls:'icon-grid',
                            text:'Fise pacient',
                            tooltip:'Fise pacient',
            			    handler: this.ListFise,
            			    scope: this
                        },'-',{
                            text:'Programare',
                            tooltip:'Programare pacient',
                            iconCls:'add',
            			    handler: this.AddFisa,
            			    scope: this
                        },'-',{
                            iconCls:'icon-grid',
                            text:'Rapoarte',
                            tooltip:'Rapoarte pacient'
                        }]
                    });

            win = desktop.createWindow({
                id: 'desk-pacienti-list',
                title:'Lista pacienti',
                width:740,
                height:480,
                iconCls: 'icon-grid',
                shim:false,
                animCollapse:false,
                constrainHeader:true,
                layout: 'fit',
                items: grid
	    });
	    this.grid = grid;
	}
        win.show();
    },
    AddPacient: function(){
        var desktop = this.app.getDesktop();
        var win = desktop.getWindow('desk-pacienti-add');
        if(!win){
            win = desktop.createWindow({
                id: 'desk-pacienti-add',
                title:'Adauga pacient',
                width:640,
                height:480,
                iconCls: 'icon-grid',
                shim:false,
                animCollapse:false,
                constrainHeader:true,
                layout: 'fit',
		items: new Ext.FormPanel({
        		labelAlign: 'top',
        		frame:false,
        		bodyStyle:'padding:5px 5px 0',

        		items: [{
            			layout:'column',
            			items:[
					{ columnWidth:.4, layout: 'form', items: [
						{xtype:'textfield',fieldLabel: 'Nume',name: 'first',anchor:'95%'},
						] 
            				},
					{ columnWidth:.4,layout: 'form', items: [
						{ xtype:'textfield',fieldLabel: 'Prenume',name: 'last',anchor:'95%'},
						]
            				},
					{ columnWidth:.2,layout: 'form', items: [
						{ xtype:'datefield',fieldLabel: 'Data nasterii',name: 'last',anchor:'95%'},
						]
            				}
				]
        			},{
            			layout:'column',
            			items:[
					{ columnWidth:.2,layout: 'form', items: [
						{ xtype:'textfield',fieldLabel: 'CNP',name: 'cnp',anchor:'95%'}]
            				},
					{ columnWidth:.2, layout: 'form', items: [
						{xtype:'textfield',fieldLabel: 'Telefon',name: 'phone',anchor:'95%'}]
            				},
					{ columnWidth:.2,layout: 'form', items: [
						{ xtype:'combo',fieldLabel:'Sex', name:'sex', anchor:'95%' ,
 									store: new Ext.data.SimpleStore({fields: ['id','sex'], data:Ext.grid.ListaSex }), 
									displayField: 'sex',
        								valueField: 'id',
                							editable: false,
									selectOnFocus: true,
									triggerAction: 'all',
        								mode: 'local'}]
            				},
					{ columnWidth:.2,layout: 'form', items: [
						{ xtype:'combo',fieldLabel:'Grupa Sangvina', name:'sang', anchor:'95%' ,
 									store: new Ext.data.SimpleStore({fields: ['id','grupa'], data:Ext.grid.ListaGrupaSangvina }), 
									displayField: 'grupa',
        								valueField: 'id',
                							editable: false,
									selectOnFocus: true,
									triggerAction: 'all',
        								mode: 'local'}]
            				},
					{ columnWidth:.2,layout: 'form', items: [
						{ xtype:'textfield',fieldLabel: 'Email',name: 'email',anchor:'95%'}]
            				}
				]
        			},{
            				xtype:'tabpanel',
            				height:235,
            				plain:true,
            				activeTab: 0,
            				defaults:{ bodyStyle:'padding:10px' },
            				items:[
						{
                				title:'Domiciliu Legal',
                				layout:'column',
						items: [
							{columnWidth:.5, layout: 'form', items: [
								{ xtype:'combo',fieldLabel:'Judet', name:'djudet', anchor:'95%' ,
 									store: new Ext.data.SimpleStore({fields: ['id','name'], data:Ext.grid.ListaOrase }), 
									displayField: 'name',
        								valueField: 'id',
                							editable: false,
									selectOnFocus: true,
									triggerAction: 'all',
        								mode: 'local'},
								{ xtype:'textfield',fieldLabel:'Sector', name:'lgpwds', anchor:'95%' },
								{ xtype:'textfield',fieldLabel:'Strada', name:'lgpwds', anchor:'95%' },

							]},
							{columnWidth:.5, layout: 'form', items: [
								{ xtype:'textfield',fieldLabel:'Localitate', name:'lguser', anchor:'95%' },
								{ xtype:'textfield',fieldLabel:'Mediu', name:'lguser', anchor:'95%'  },
							        { xtype:'textfield',fieldLabel:'Bloc', name:'lgpwds', anchor:'95%' },
							        { xtype:'textfield',fieldLabel:'Apartament', name:'lgpwds', anchor:'95%' },

							]}
						]
						},{
                				title:'Resedinta',
                				layout:'column',
						items: [
							{columnWidth:.5, layout: 'form', items: [
								{ xtype:'combo',fieldLabel:'Judet', name:'rjudet', anchor:'95%' ,
 									store: new Ext.data.SimpleStore({fields: ['id','name'], data:Ext.grid.ListaOrase }), 
									displayField: 'name',
        								valueField: 'id',
                							editable: false,
									selectOnFocus: true,
									triggerAction: 'all',
        								mode: 'local'},
								{ xtype:'textfield',fieldLabel:'Sector', name:'lgpwds', anchor:'95%' },
								{ xtype:'textfield',fieldLabel:'Strada', name:'lgpwds', anchor:'95%' },

							]},
							{columnWidth:.5, layout: 'form', items: [
								{ xtype:'textfield',fieldLabel:'Localitate', name:'lguser', anchor:'95%' },
								{ xtype:'textfield',fieldLabel:'Mediu', name:'lguser', anchor:'95%'  },
							        { xtype:'textfield',fieldLabel:'Bloc', name:'lgpwds', anchor:'95%' },
							        { xtype:'textfield',fieldLabel:'Apartament', name:'lgpwds', anchor:'95%' },

							]}						]
						},{
                				title:'Date personale',
                				layout:'column',
						items: [
							{columnWidth:.5, layout: 'form', items: [
								{ xtype:'combo',fieldLabel:'Ocupatie', name:'lgpwds', anchor:'95%' ,
 									store: new Ext.data.SimpleStore({fields: ['id','name'], data:Ext.grid.ListaOcupatii }), 
									displayField: 'name',
        								valueField: 'id',
                							editable: false,
									selectOnFocus: true,
									triggerAction: 'all',
        								mode: 'local'},
								{ xtype:'textfield',fieldLabel:'Loc de munca', name:'lgpwds', anchor:'95%' },
								{ xtype:'combo',fieldLabel:'Nivel de instruire', name:'lgpwds', anchor:'95%' ,
 									store: new Ext.data.SimpleStore({fields: ['id','name'], data:Ext.grid.ListaInstruire }), 
										sm: new Ext.grid.RowSelectionModel({singleSelect: true}),	displayField: 'name',
        								valueField: 'id',
                							editable: false,
									selectOnFocus: true,
									triggerAction: 'all',
        								mode: 'local'}

							]},
							{columnWidth:.5, layout: 'form', items: [
								{ xtype:'textfield',fieldLabel:'Carte identitate', name:'lguser', anchor:'95%' },
								{ xtype:'textfield',fieldLabel:'Certificat de nastere', name:'lguser', anchor:'95%'  },

							]}						]
						}
					]
				}
				],
        			buttons: [	
					{text: 'Save'},
					{text: 'Cancel',handler: function() {
						win.close();
					}}
				]
    		})
	    })
	   
	}
        win.show();
    },
    ListFise:function(btn, ev) {
	if (! this.grid.getSelectionModel().hasSelection()) {
		alert('Nu ati selectat nici un pacient');
		return false;
	}
	var rec = this.grid.getSelectionModel().getSelected();
	var desktop = this.app.getDesktop();
        var win = desktop.getWindow('pacienti-flist'+rec.get('id'));
        if(!win){
	  var jstore = new Ext.data.JsonStore({ 
					url: 'rpcserver.php', 
					root: 'data',totalProperty: 'total', 
					fields: [{name: 'id', type: 'int'},'pid', 'data','sectia'],
					baseParams: {module:'pacienti',method:'fiselist',id:rec.get('id')}
	  });
	  win = desktop.createWindow({
                id: 'pacienti-flist'+rec.get('id'),
                title:'Fise pacient '+rec.get('nume')+' '+rec.get('prenume'),
                width:740,
                height:480,
                iconCls: 'icon-grid',
                shim:false,
                animCollapse:false,
                constrainHeader:true,
                layout: 'fit',
		items: 
            	 new Ext.grid.GridPanel({
                        border:false,
                        store: jstore ,
                        cm: new Ext.grid.ColumnModel([
                            {header: "Data", width: 120, sortable: true, dataIndex: 'data'},
                            {header: "Sectia", width: 120, sortable: true, dataIndex: 'sectia'},
                        ]),
			sm: new Ext.grid.RowSelectionModel({singleSelect: true}),
                        viewConfig: {
                            forceFit:true
                        },
			bbar: new Ext.PagingToolbar({
				pageSize: 20,
				store: jstore,
				displayInfo: true,
				displayMsg: 'Afiseaza fise pacienti {0} - {1} din {2}',
				emptyMsg: "Nici o fisa"			
			})
          	})
		
	  });
	  jstore.load();
	}
        win.show();
    },
    AddFisa: function(btn, ev) {
	if (! this.grid.getSelectionModel().hasSelection()) {
		alert('Nu ati selectat nici un pacient');
		return false;
	}
	var rec = this.grid.getSelectionModel().getSelected();
        var desktop = this.app.getDesktop();
        var win = desktop.getWindow('pacienti-addprogramare');
        if(!win){
        var ff= new Ext.FormPanel({
        	frame : "true",
        	id:'card-3-panel',
			items : [{
        	xtype: 'tabpanel',
        	activeItem: 0, // index or id
        	items:[{
        	    title: 'Tab 1',
        	    html: 'This is tab 1 content.'
        	},{
        	    title: 'Tab 2',
        	    html: 'This is tab 2 content.'
        	},{
        	    title: 'Tab 3',
        	    html: 'This is tab 3 content.'
        	}]
			}]
        });
        var f1= new Ext.FormPanel({
				frame : "true",
	        	id:'card-1-panel',
				items : [{
   					items : [{
						title : "Statut asigurat",
						items : [{
							items : [{
								title : "Statut",
								items : [{
									items : [{
										xtype : "checkbox",
										fieldLabel : "Asigurat CNAS"
									}, {
										xtype : "checkbox",
										fieldLabel : "Asigurare voluntara"
									}, {
										xtype : "checkbox",
										fieldLabel : "Neasigurat"
									}],
									xtype : "checkboxgroup"
								}],
								layout : "column",
								xtype : "fieldset",
								autoWidth : true
							}],
							layout : "",
							buttonAlign : ""
						}, {
							items : [{
								title : "Asigurat CNAS",
								items : [{
									xtype : "numberfield",
									fieldLabel : "Asigurat obligatoriu CAS",
									selectOnFocus : true
								}, {
									xtype : "numberfield",
									fieldLabel : "DB Asigurare facultativa CAS"
								}, {
									xtype : "checkbox",
									fieldLabel : "Eurocard"
								}, {
									xtype : "checkbox",
									fieldLabel : "Acorduri internationale"
								}],
								collapseFirst : false,
								collapsible : false,
								layout : "form",
								xtype : "fieldset",
								titleCollapse : true,
								autoHeight : true,
								collapsed : false
							}],
							layout : "form"
						}, {
							items : [{
								title : "Categorie asigurat CNAS",
								items : [{
									items : [{
										maxLength : 2,
										width : 25,
										xtype : "numberfield",
										maxLengthText : "2",
										fieldLabel : "Cod"
									}],
									layout : "form"
								}, {
									vertical : true,
									items : [{
										name : "catcnas",
										xtype : "radio",
										inputValue : "1",
										boxLabel : "Salariat"
									}, {
										name : "catcnas",
										xtype : "radio",
										inputValue : "2",
										boxLabel : "Elev/Ucenic/Student 18-26 ani"
									}, {
										name : "catcnas",
										xtype : "radio",
										inputValue : "3",
										boxLabel : "Coasig"
									}, {
										name : "catcnas",
										xtype : "radio",
										inputValue : "4",
										boxLabel : "Pensionar"
									}, {
										name : "catcnas",
										xtype : "radio",
										inputValue : "5",
										boxLabel : "Copil < 18 ani"
									}, {
										xtype : "radio",
										name : "catcnas",
										boxLabel : "Gravida"
									}, {
										xtype : "radio",
										name : "catcnas",
										boxLabel : "Veteran"
									}, {
										xtype : "radio",
										name : "catcnas",
										boxLabel : "Revolutionar"
									}, {
										xtype : "radio",
										name : "catcnas",
										boxLabel : "Handicap"
									}, {
										xtype : "radio",
										name : "catcnas",
										boxLabel : "PNS"
									}, {
										xtype : "radio",
										name : "catcnas",
										boxLabel : "Ajutor social"
									}, {
										xtype : "radio",
										name : "catcnas",
										boxLabel : "Somaj"
									}, {
										xtype : "radio",
										name : "catcnas",
										boxLabel : "Alte"
									}],
									xtype : "radiogroup",
									columns : 5
								}],
								xtype : "fieldset",
								layout : "column"
							}],
							layout : "form"
						}],
						layout : "",
						autoHeight : true
					}, {
						title : "Internare",
						items : [{
							title : "Tipul internarii",
							items : [{
								footer : true,
								items : [{
									maxLength : 1,
									width : 25,
									xtype : "numberfield",
									maxLengthText : "1",
									fieldLabel : "Cod"
								}],
								layout : "form",
								autoHeight : true
							}, {
								items : [{
									items : [{
										name : "tipint",
										xtype : "radio",
										fieldLabel : "Urgenta"
									}, {
										name : "tipint",
										xtype : "radio",
										fieldLabel : "Trimitere MF"
									}, {
										name : "tipint",
										xtype : "radio",
										fieldLabel : "Trimitere ambulatoriu"
									}, {
										name : "tipint",
										xtype : "radio",
										fieldLabel : "Transfer interspitale"
									}, {
										name : "tipint",
										xtype : "radio",
										fieldLabel : "La cerere"
									}, {
										name : "tipint",
										xtype : "radio",
										fieldLabel : "Altele"
									}],
									xtype : "radiogroup",
									columns : 3,
									autoScrool: false
								}]
							}],
							layout : "column",
							xtype : "fieldset"
						}, {
							title : "Criteriu de internarii",
							items : [{
								footer : true,
								items : [{
									maxLength : 1,
									xtype : "numberfield",
									width : 25,
									maxLengthText : "1",
									fieldLabel : "Cod"
								}],
								layout : "form",
								autoHeight : true
							}, {
								items : [{
									items : [{
										xtype : "radio",
										name : "cint",
										fieldLabel : "Urgenta"
									}, {
										xtype : "radio",
										name : "cint",
										fieldLabel : "Diagnostic"
									}, {
										xtype : "radio",
										name : "cint",
										fieldLabel : "Tratament"
									}, {
										xtype : "radio",
										name : "tipint",
										fieldLabel : "Nedeplasabil"
									}, {
										xtype : "radio",
										name : "cint",
										fieldLabel : "Epidemiologic"
									}, {
										xtype : "radio",
										name : "cint",
										fieldLabel : "Medic sef"
									}],
									xtype : "radiogroup",
									columns : 4
								}],
								layout : ""
							}],
							xtype : "fieldset",
							layout : "column"
						}, {
							title : "Diagnostice",
							items : [{
								xtype : "numberfield",
								fieldLabel : "Diagnostic de trimitere",
								anchor: '95%'
							}, {
								xtype : "numberfield",
								fieldLabel : "Diagnostic de internare",
								anchor: '95%'
							}, {
								items : [{
									xtype : "textarea"
								}],
								layout : "fit",
								autoWidth : false
							}],
							layout : "form",
							xtype : "fieldset"
						}, {
							title : "Semnatura si parafa medicului",
							items : [{
								xtype : "combo",
								fieldLabel : "Medic"
							}],
							xtype : "fieldset",
							layout : "form"
						}]
					}, {
						title : "Diagnostic",
						items : [{
							title : "Diagnosticul principal la externare",
							items : [{
								items : [{
									items : [{
										height : 60,
										xtype : "textarea"
									}],
									layout : "fit",
									columnWidth : ".85"
								}, {
									items : [{
										xtype : "numberfield"
									}],
									columnWidth : ".15"
								}],
								layout : "column"
							}, {
								items : [{
									items : [{
										height : 60,
										xtype : "textarea"
									}],
									layout : "fit",
									columnWidth : ".85"
								}, {
									items : [{
										xtype : "numberfield"
									}],
									columnWidth : ".15"
								}],
								layout : "column"
							}],
							xtype : "fieldset",
							layout : "form"
						}, {
							title : "Diagnosticul secundare la externare",
							items : [{
								items : [{
									items : [{
										height : 40,
										xtype : "textarea"
									}],
									layout : "fit",
									columnWidth : ".85"
								}, {
									items : [{
										xtype : "numberfield"
									}],
									columnWidth : ".15"
								}],
								layout : "column"
							}, {
								items : [{
									items : [{
										height : 40,
										xtype : "textarea"
									}],
									layout : "fit",
									columnWidth : ".85"
								}, {
									items : [{
										xtype : "numberfield"
									}],
									columnWidth : ".15"
								}],
								layout : "column"
							}, {
								items : [{
									items : [{
										height : 40,
										xtype : "textarea"
									}],
									layout : "fit",
									columnWidth : ".85"
								}, {
									items : [{
										xtype : "numberfield"
									}],
									columnWidth : ".15"
								}],
								layout : "column"
							}, {
								items : [{
									items : [{
										height : 40,
										xtype : "textarea"
									}],
									layout : "fit",
									columnWidth : ".85"
								}, {
									items : [{
										xtype : "numberfield"
									}],
									columnWidth : ".15"
								}],
								layout : "column"
							}],
							xtype : "fieldset",
							layout : "form"
						}, {
							title : "Semnaturi",
							items : [{
								items : [{
									items : [{
										text : "Medic sef de sectie",
										xtype : "label"
									}, {
										xtype : "combo"
									}],
									layout : "fit",
									columnWidth : ".5"
								}, {
									items : [{
										text : "Medic curant",
										xtype : "label"
									}, {
										xtype : "combo"
									}],
									layout : "fit",
									columnWidth : ".5"
								}],
								layout : "column"
							}],
							xtype : "fieldset",
							layout : "form"
						}]
					}],
					xtype : "tabpanel",
					activeTab : 0
				}, {
					title : "Actiuni",
					items : [{
						text : "Salveaza",
						xtype : "button"
					}, {
						text : "Anuleaza",
						xtype : "button"
					}],
					xtype : "fieldset",
					layout : "column"
			}]

        });


        var f2= new Ext.FormPanel({

           xtype : "form",
           frame : true,
    	   id:'card-2-panel',

    items : [      {
        xtype : "tabpanel",
        items : [          {
            xtype : "panel",
            items : [              {
                xtype : "panel",
                items : [                  {
                    xtype : "textfield",
                    name : "textvalue",
                    anchor : "95%",
                    fieldLabel : "Examen citologic"
                },                  {
                    xtype : "textfield",
                    name : "textvalue",
                    anchor : "95%",
                    fieldLabel : "Examen extemporancu"
                },                  {
                    xtype : "textfield",
                    name : "textvalue",
                    anchor : "95%",
                    fieldLabel : "Examen histopatologic"
                },                  {
                    xtype : "panel",
                    items : [                      {
                        xtype : "panel",
                        columnWidth : 0.15,
                        title : "Sectia",
                        items : [                          {
                            xtype : "textfield",
                            name : "textvalue",
                            anchor : "99%"
                        },                          {
                            xtype : "textfield",
                            name : "textvalue",
                            anchor : "99%"
                        },                          {
                            xtype : "textfield",
                            name : "textvalue",
                            anchor : "99%"
                        },                          {
                            xtype : "textfield",
                            name : "textvalue",
                            anchor : "99%"
                        }],
                        labelWidth : 1,
                        layout : "form"
                    },                      {
                        xtype : "panel",
                        columnWidth : 0.3,
                        title : "Diagnostic",
                        items : [                          {
                            xtype : "textfield",
                            name : "textvalue",
                            anchor : "99%"
                        },                          {
                            xtype : "textfield",
                            name : "textvalue",
                            anchor : "99%"
                        },                          {
                            xtype : "textfield",
                            name : "textvalue",
                            anchor : "99%"
                        },                          {
                            xtype : "textfield",
                            name : "textvalue",
                            anchor : "99%"
                        }],
                        layout : "form",
                        labelWidth : 1
                    },                      {
                        xtype : "panel",
                        columnWidth : 0.2,
                        title : "Data intrarii (ora)",
                        items : [                          {
                            xtype : "panel",
                            columnWidth : 0.5,
                            items : [                              {
                                xtype : "datefield",
                                name : "datevalue",
                                anchor : "99%"
                            },                              {
                                xtype : "datefield",
                                name : "datevalue",
                                anchor : "99%"
                            },                              {
                                xtype : "datefield",
                                name : "datevalue",
                                anchor : "99%"
                            },                              {
                                xtype : "datefield",
                                name : "datevalue",
                                anchor : "99%"
                            }],
                            layout : "form",
                            labelWidth : 1,
                            border : false
                        },                          {
                            xtype : "panel",
                            columnWidth : 0.5,
                            layout : "form",
                            border : false,
                            items : [                              {
                                xtype : "timefield",
                                name : "timevalue",
                                anchor : "99%"
                            },                              {
                                xtype : "timefield",
                                name : "timevalue",
                                anchor : "99%"
                            },                              {
                                xtype : "timefield",
                                name : "timevalue",
                                anchor : "99%"
                            },                              {
                                xtype : "timefield",
                                name : "timevalue",
                                anchor : "99%"
                            }],
                            labelWidth : 1
                        }],
                        layout : "column"
                    },                      {
                        xtype : "panel",
                        columnWidth : 0.2,
                        items : [                          {
                            xtype : "panel",
                            columnWidth : 0.5,
                            items : [                              {
                                xtype : "datefield",
                                name : "datevalue",
                                anchor : "99%"
                            },                              {
                                xtype : "datefield",
                                name : "datevalue",
                                anchor : "99%"
                            },                              {
                                xtype : "datefield",
                                name : "datevalue",
                                anchor : "99%"
                            },                              {
                                xtype : "datefield",
                                name : "datevalue",
                                anchor : "99%"
                            }],
                            layout : "form",
                            labelWidth : 1,
                            border : false
                        },                          {
                            xtype : "panel",
                            columnWidth : 0.5,
                            layout : "form",
                            border : false,
                            items : [                              {
                                xtype : "timefield",
                                name : "timevalue",
                                anchor : "99%"
                            },                              {
                                xtype : "timefield",
                                name : "timevalue",
                                anchor : "99%"
                            },                              {
                                xtype : "timefield",
                                name : "timevalue",
                                anchor : "99%"
                            },                              {
                                xtype : "timefield",
                                name : "timevalue",
                                anchor : "99%"
                            }],
                            labelWidth : 1
                        }],
                        layout : "column",
                        title : "Data iesirii (ora)"
                    },                      {
                        xtype : "panel",
                        columnWidth : 0.15,
                        title : "Nr.zile spitalizare",
                        items : [                          {
                            xtype : "numberfield",
                            name : "numbervalue",
                            anchor : "95%"
                        },                          {
                            xtype : "numberfield",
                            name : "numbervalue",
                            anchor : "95%"
                        },                          {
                            xtype : "numberfield",
                            name : "numbervalue",
                            anchor : "95%"
                        },                          {
                            xtype : "numberfield",
                            name : "numbervalue",
                            anchor : "95%"
                        }],
                        layout : "form",
                        labelWidth : 1
                    }],
                    layout : "column"
                },                  {
                    xtype : "fieldset",
                    autoHeight : true,
                    title : "Starea la externare",
                    items : [                      {
                        xtype : "radio",
                        name : "radio",
                        inputValue : "radiovalue",
                        boxLabel : "Vindecat",
                        columnWidth : 0.2,
                        checked : true
                    },                      {
                        xtype : "radio",
                        name : "radio",
                        inputValue : "radiovalue",
                        boxLabel : "Ameliorat",
                        columnWidth : 0.2
                    },                      {
                        xtype : "radio",
                        name : "radio",
                        inputValue : "radiovalue",
                        boxLabel : "Stationar",
                        columnWidth : 0.2
                    },                      {
                        xtype : "radio",
                        name : "radio",
                        inputValue : "radiovalue",
                        boxLabel : "Agravat",
                        columnWidth : 0.2
                    },                      {
                        xtype : "radio",
                        name : "radio",
                        inputValue : "radiovalue",
                        boxLabel : "Decedat",
                        columnWidth : 0.2
                    }],
                    layout : "column"
                },                  {
                    xtype : "fieldset",
                    autoHeight : true,
                    title : "Tipu Externarii",
                    layout : "column",
                    items : [                      {
                        xtype : "radio",
                        name : "radio",
                        inputValue : "radiovalue",
                        boxLabel : "Externat",
                        columnWidth : 0.25,
                        checked : true
                    },                      {
                        xtype : "radio",
                        name : "radio",
                        inputValue : "radiovalue",
                        boxLabel : "Externat la cerere",
                        columnWidth : 0.25
                    },                      {
                        xtype : "radio",
                        name : "radio",
                        inputValue : "radiovalue",
                        boxLabel : "Transfer interspitalicesc",
                        columnWidth : 0.25
                    },                      {
                        xtype : "radio",
                        name : "radio",
                        inputValue : "radiovalue",
                        boxLabel : "Decedat",
                        columnWidth : 0.25
                    }]
                },                  {
                    xtype : "fieldset",
                    autoHeight : true,
                    title : "Deces",
                    layout : "column",
                    items : [                      {
                        xtype : "radio",
                        name : "radio",
                        inputValue : "radiovalue",
                        columnWidth : 0.25,
                        boxLabel : "Interoperatoriu"
                    },                      {
                        xtype : "radio",
                        name : "radio",
                        inputValue : "radiovalue",
                        boxLabel : "Post operator 0-23ore",
                        columnWidth : 0.25
                    },                      {
                        xtype : "radio",
                        fieldLabel : "Label",
                        name : "radio",
                        inputValue : "radiovalue",
                        boxLabel : "24-47 ore",
                        columnWidth : 0.25
                    },                      {
                        xtype : "radio",
                        name : "radio",
                        inputValue : "radiovalue",
                        boxLabel : "> 48 ore",
                        columnWidth : 0.25
                    }]
                },                  {
                    xtype : "fieldset",
                    autoHeight : true,
                    title : "Data si ora decesului",
                    items : [                      {
                        xtype : "panel",
                        items : [                          {
                            xtype : "datefield",
                            name : "datevalue",
                            fieldLabel : "Data"
                        }],
                        columnWidth : 0.3,
                        layout : "form",
                        border : false
                    },                      {
                        xtype : "panel",
                        items : [                          {
                            xtype : "timefield",
                            name : "timevalue",
                            fieldLabel : "Ora"
                        }],
                        columnWidth : 0.3,
                        layout : "form",
                        border : false
                    }],
                    layout : "column"
                }],
                layout : "form"
            }],
            title : "Investigatii"
        },          {
            xtype : "panel",
            title : "Diagnosticare",
            items : [              {
                xtype : "panel",
                items : [                  {
                    xtype : "panel",
                    items : [                      {
                        xtype : "label",
                        text : "Diagnostic in caz de deces"
                    },                      {
                        xtype : "textfield",
                        name : "textvalue",
                        fieldLabel : "a",
                        anchor : "95%"
                    },                      {
                        xtype : "textfield",
                        name : "textvalue",
                        fieldLabel : "b",
                        anchor : "95%"
                    },                      {
                        xtype : "textfield",
                        name : "textvalue",
                        fieldLabel : "c",
                        anchor : "95%"
                    },                      {
                        xtype : "textfield",
                        name : "textvalue",
                        fieldLabel : "d",
                        anchor : "95%"
                    },                      {
                        xtype : "textarea",
                        name : "textarea",
                        fieldLabel : "Alte stari morbide",
                        anchor : "95%"
                    }],
                    labelSeparator : ".",
                    layout : "form",
                    labelAlign : "left"
                },                  {
                    xtype : "textarea",
                    name : "textarea",
                    anchor : "95%",
                    fieldLabel : "Diagnostic anatomo-patologic(autopsie),microscopie"
                },                  {
                    xtype : "textarea",
                    name : "textarea",
                    anchor : "95%",
                    fieldLabel : "Microscopic"
                }],
                labelAlign : "top",
                layout : "form"
            }]
        },          {
            xtype : "panel",
            items : [              {
                xtype : "fieldset",
                items : [                  {
                    items : [                      {
                        items : [                          {
                            xtype : "textfield",
                            name : "textvalue",
                            anchor : "95%",
                            fieldLabel : 1
                        },                          {
                            xtype : "textfield",
                            name : "textvalue",
                            anchor : "95%",
                            fieldLabel : 2
                        },                          {
                            xtype : "textfield",
                            name : "textvalue",
                            anchor : "95%",
                            fieldLabel : 3
                        },                          {
                            xtype : "textfield",
                            name : "textvalue",
                            anchor : "95%",
                            fieldLabel : 4
                        },                          {
                            xtype : "textfield",
                            name : "textvalue",
                            anchor : "95%",
                            fieldLabel : 5
                        },                          {
                            xtype : "textfield",
                            name : "textvalue",
                            anchor : "95%",
                            fieldLabel : 6
                        }],
                        layout : "form",
                        border : false,
                        columnWidth : 0.75,
                        labelSeparator : "."
                    },                      {
                        items : [                          {
                            xtype : "numberfield",
                            name : "numbervalue",
                            width : 80
                        },                          {
                            xtype : "numberfield",
                            name : "numbervalue",
                            width : 80
                        },                          {
                            xtype : "numberfield",
                            name : "numbervalue",
                            width : 80
                        },                          {
                            xtype : "numberfield",
                            width : 80
                        },                          {
                            xtype : "numberfield",
                            name : "numbervalue",
                            width : 80
                        },                          {
                            xtype : "numberfield",
                            name : "numbervalue",
                            width : 80
                        }],
                        layout : "form",
                        border : false,
                        hideLabels : true,
                        columnWidth : 0.15
                    },                      {
                        items : [                          {
                            xtype : "numberfield",
                            name : "numbervalue",
                            width : 30
                        },                          {
                            xtype : "numberfield",
                            name : "numbervalue",
                            width : 30
                        },                          {
                            xtype : "numberfield",
                            name : "numbervalue",
                            width : 30
                        },                          {
                            xtype : "numberfield",
                            name : "numbervalue",
                            width : 30
                        },                          {
                            xtype : "numberfield",
                            name : "numbervalue",
                            width : 30
                        },                          {
                            xtype : "numberfield",
                            name : "numbervalue",
                            width : 30
                        }],
                        layout : "form",
                        border : false,
                        hideLabels : true,
                        columnWidth : 0.1
                    }],
                    layout : "column",
                    border : false
                }],
                title : "Exploatari Functionale"
            },              {
                xtype : "fieldset",
                items : [                  {
                    items : [                      {
                        items : [                          {
                            xtype : "textfield",
                            name : "textvalue",
                            anchor : "95%",
                            fieldLabel : 7
                        },                          {
                            xtype : "textfield",
                            name : "textvalue",
                            anchor : "95%",
                            fieldLabel : 8
                        },                          {
                            xtype : "textfield",
                            name : "textvalue",
                            anchor : "95%",
                            fieldLabel : 9
                        },                          {
                            xtype : "textfield",
                            name : "textvalue",
                            anchor : "95%",
                            fieldLabel : 10
                        },                          {
                            xtype : "textfield",
                            name : "textvalue",
                            anchor : "95%",
                            fieldLabel : 11
                        },                          {
                            xtype : "textfield",
                            name : "textvalue",
                            anchor : "95%",
                            fieldLabel : 12
                        }],
                        layout : "form",
                        border : false,
                        columnWidth : 0.75,
                        labelSeparator : "."
                    },                      {
                        items : [                          {
                            xtype : "numberfield",
                            name : "numbervalue",
                            width : 80
                        },                          {
                            xtype : "numberfield",
                            name : "numbervalue",
                            width : 80
                        },                          {
                            xtype : "numberfield",
                            name : "numbervalue",
                            width : 80
                        },                          {
                            xtype : "numberfield",
                            width : 80
                        },                          {
                            xtype : "numberfield",
                            name : "numbervalue",
                            width : 80
                        },                          {
                            xtype : "numberfield",
                            name : "numbervalue",
                            width : 80
                        }],
                        layout : "form",
                        border : false,
                        hideLabels : true,
                        columnWidth : 0.15
                    },                      {
                        items : [                          {
                            xtype : "numberfield",
                            name : "numbervalue",
                            width : 30
                        },                          {
                            xtype : "numberfield",
                            name : "numbervalue",
                            width : 30
                        },                          {
                            xtype : "numberfield",
                            name : "numbervalue",
                            width : 30
                        },                          {
                            xtype : "numberfield",
                            name : "numbervalue",
                            width : 30
                        },                          {
                            xtype : "numberfield",
                            name : "numbervalue",
                            width : 30
                        },                          {
                            xtype : "numberfield",
                            name : "numbervalue",
                            width : 30
                        }],
                        layout : "form",
                        border : false,
                        hideLabels : true,
                        columnWidth : 0.1
                    }],
                    layout : "column",
                    border : false
                }],
                title : "Investigatii"
            },              {
                xtype : "fieldset",
                items : [                  {
                    items : [                      {
                        items : [                          {
                            xtype : "textfield",
                            name : "textvalue",
                            anchor : "95%",
                            fieldLabel : 13
                        },                          {
                            xtype : "textfield",
                            name : "textvalue",
                            anchor : "95%",
                            fieldLabel : 14
                        },                          {
                            xtype : "textfield",
                            name : "textvalue",
                            anchor : "95%",
                            fieldLabel : 15
                        },                          {
                            xtype : "textfield",
                            name : "textvalue",
                            anchor : "95%",
                            fieldLabel : 16
                        },                          {
                            xtype : "textfield",
                            name : "textvalue",
                            anchor : "95%",
                            fieldLabel : 17
                        },                          {
                            xtype : "textfield",
                            name : "textvalue",
                            anchor : "95%",
                            fieldLabel : 18
                        }],
                        layout : "form",
                        border : false,
                        columnWidth : 0.75
                    },                      {
                        items : [                          {
                            xtype : "numberfield",
                            name : "numbervalue",
                            width : 80
                        },                          {
                            xtype : "numberfield",
                            name : "numbervalue",
                            width : 80
                        },                          {
                            xtype : "numberfield",
                            name : "numbervalue",
                            width : 80
                        },                          {
                            xtype : "numberfield",
                            width : 80
                        },                          {
                            xtype : "numberfield",
                            name : "numbervalue",
                            width : 80
                        },                          {
                            xtype : "numberfield",
                            name : "numbervalue",
                            width : 80
                        }],
                        layout : "form",
                        border : false,
                        hideLabels : true,
                        columnWidth : 0.15
                    },                      {
                        items : [                          {
                            xtype : "numberfield",
                            name : "numbervalue",
                            width : 30
                        },                          {
                            xtype : "numberfield",
                            name : "numbervalue",
                            width : 30
                        },                          {
                            xtype : "numberfield",
                            name : "numbervalue",
                            width : 30
                        },                          {
                            xtype : "numberfield",
                            name : "numbervalue",
                            width : 30
                        },                          {
                            xtype : "numberfield",
                            name : "numbervalue",
                            width : 30
                        },                          {
                            xtype : "numberfield",
                            name : "numbervalue",
                            width : 30
                        }],
                        layout : "form",
                        border : false,
                        hideLabels : true,
                        columnWidth : 0.1
                    }],
                    layout : "column",
                    border : false
                }],
                title : "Alte proceduri terapeutice"
            }],
            title : "Examinare"
        }],
        activeTab : 0
    }]


        });
        var f3= new Ext.FormPanel({
				frame : "true",
	        	id:'card-3-panel',
				items : [{
					items : [{
						title : "Interventia principala",
						items : [
						    {xtype : "textarea",fieldLabel : "Interventia principala"},
							{xtype : "textfield",fieldLabel : "Consimtamant pentru interventie"},
							{xtype : "datefield",fieldLabel : "Data"},
							{title : "Echipa operatorie",
							items : [{
								items : [
								    {xtype : "textfield",fieldLabel : "Medic operator principal",anchor: '95%'},
								    {xtype : "textfield",fieldLabel : "Medic operator II",anchor: '95%'},
								    {xtype : "textfield",fieldLabel : "Medic operator III",anchor: '95%'}
								],
								layout : "form",
								columnWidth : ".5"
							}, {
								items : [
								    {xtype : "textfield",fieldLabel : "Medic ATI",anchor: '95%'},
								    {xtype : "textfield",fieldLabel : "Asistent(a)",anchor: '95%'},
								    {xtype : "datefield",fieldLabel : "Data interventiei",anchor: '95%'}
								],
								layout : "form",
								columnWidth : ".5"
							}],
							layout : "column",
							xtype : "fieldset"
						}],
						layout : "form"
					}, {
						title : "Interventii concomitente",
						items : [{
							title : "1.",
							items : [{
								items : [{
									items : [{xtype : "textfield",fieldLabel : "Denumire",anchor: '95%'}],
									layout : "form",
									columnWidth : ".7"
								}, {
									items : [{xtype : "datefield",fieldLabel : "Data",anchor: '95%'}],
									layout : "form",
									columnWidth : ".3"
								}],
								layout : "column"
							}, {
								items : [{
									title : "Echipa operatorie",
									items : [{
										items : [
										    {xtype : "textfield",fieldLabel : "Medic operator principal",anchor: '95%'},
										    {xtype : "textfield",fieldLabel : "Medic operator II",anchor: '95%'},
										    {xtype : "textfield",fieldLabel : "Medic operator III",anchor: '95%'}
										],
										layout : "form",
										columnWidth : ".5"
									}, {
										items : [
										    {xtype : "textfield",fieldLabel : "Medic ATI",anchor: '95%'}, 
										    {xtype : "textfield",fieldLabel : "Asistent(a)",anchor: '95%'},
										    {xtype : "datefield",fieldLabel : "Data interventiei",anchor: '95%'}
										],
										layout : "form",
										columnWidth : ".5"
									}],
									layout : "column",
									xtype : "fieldset"
								}]
							}],
							xtype : "fieldset",
							layout : "form"
						}, {
							title : "2.",
							items : [{
								items : [{
									items : [{xtype : "textfield",fieldLabel : "Denumire",anchor: '95%'}],
									layout : "form",
									columnWidth : ".7"
								}, {
									items : [{xtype : "datefield",fieldLabel : "Data",anchor: '95%'}],
									layout : "form",
									columnWidth : ".3"
								}],
								layout : "column"
							}, {
								items : [{
									title : "Echipa operatorie",
									items : [{
										items : [
										    {xtype : "textfield",fieldLabel : "Medic operator principal",anchor: '95%'}, 
										    {xtype : "textfield",fieldLabel : "Medic operator II",anchor: '95%'},
										    {xtype : "textfield",fieldLabel : "Medic operator III",anchor: '95%'}
										],
										layout : "form",
										columnWidth : ".5"
									}, {
										items : [
										    {xtype : "textfield",fieldLabel : "Medic ATI",anchor: '95%'},
										    {xtype : "textfield",fieldLabel : "Asistent(a)",anchor: '95%'},
										    {xtype : "datefield",fieldLabel : "Data interventiei",anchor: '95%'}
										],
										layout : "form",
										columnWidth : ".5"
									}],
									xtype : "fieldset",
									layout : "column"
								}]
							}],
							xtype : "fieldset",
							layout : "form"
						}]
					}, {
						title : "Alte interventii",
						items : [{
							title : "1.",
							items : [{
								items : [{
									items : [{xtype : "textfield",fieldLabel : "Denumire",anchor: '95%'}],
									layout : "form",
									columnWidth : ".7"
								}, {
									items : [{xtype : "datefield",fieldLabel : "Data",anchor: '95%'}],
									layout : "form",
									columnWidth : ".3"
								}],
								layout : "column"
							}, {
								items : [{
									title : "Echipa operatorie",
									items : [{
										items : [
										    {xtype : "textfield",fieldLabel : "Medic operator principal",anchor: '95%'},
										    {xtype : "textfield",fieldLabel : "Medic operator II",anchor: '95%'},
										    {xtype : "textfield",fieldLabel : "Medic operator III",anchor: '95%'}
										],
										layout : "form",
										columnWidth : ".5"
									}, {
										items : [
										    {xtype : "textfield",fieldLabel : "Medic ATI",anchor: '95%'},
										    {xtype : "textfield",fieldLabel : "Asistent(a)",anchor: '95%'},
										    {xtype : "datefield",fieldLabel : "Data interventiei",anchor: '95%'}
										],
										layout : "form",
										columnWidth : ".5"
									}],
									xtype : "fieldset",
									layout : "column"
								}]
							}],
							layout : "form",
							xtype : "fieldset"
						}, {
							title : "2.",
							items : [{
								items : [{
									items : [{xtype : "textfield",fieldLabel : "Denumire",anchor: '95%'}],
									layout : "form",
									columnWidth : ".7"
								}, {
									items : [{xtype : "datefield",fieldLabel : "Data",anchor: '95%'}],
									layout : "form",
									columnWidth : ".3"
								}],
								layout : "column"
							}, {
								items : [{
									title : "Echipa operatorie",
									items : [{
										items : [
										    {xtype : "textfield",fieldLabel : "Medic operator principal",anchor: '95%'},
										    {xtype : "textfield",fieldLabel : "Medic operator II",anchor: '95%'},
										    {xtype : "textfield",fieldLabel : "Medic operator III",anchor: '95%'}
										],
										layout : "form",
										columnWidth : ".5"
									}, {
										items : [
										    {xtype : "textfield",fieldLabel : "Medic ATI",anchor: '95%'},
										    {xtype : "textfield",fieldLabel : "Asistent(a)",anchor: '95%'},
										    {xtype : "datefield",fieldLabel : "Data interventiei",anchor: '95%'}
										],
										layout : "form",
										columnWidth : ".5"
									}],
									layout : "column",
									xtype : "fieldset"
								}]
							}],
							layout : "form",
							xtype : "fieldset"
						}]
					}],
					xtype : "tabpanel",
					activeTab : 0
				}],
				layout : "form",
				labelAlign : "top"
			});
        
        var tree = new Ext.tree.TreePanel( {
            animate:true, 
            enableDD:true,
            border:false,
            lines: false,
            containerScroll: true,
            ddGroup: 'organizerDD',
            rootVisible:false
        });
        var root = new Ext.tree.TreeNode({
            text: 'Albums', 
            allowDrag:false,
            allowDrop:false
        });
        tree.setRootNode(root);
       
 
	    var node = new Ext.tree.TreeNode({text:'Internare', allowDrag:false,id:'card-1',leaf:true})
	    root.appendChild(node);

        var node = new Ext.tree.TreeNode({text:'Investigatii', allowDrag:false,id:'card-2',leaf:true})
	    root.appendChild(node);

        var node = new Ext.tree.TreeNode({text:'Interventii', allowDrag:false,id:'card-3',leaf:true})
	    root.appendChild(node);

	    tree.on('click', function(n){
	    	var sn = this.selModel.selNode || {}; // selNode is null on initial selection
	    	if(n.leaf && n.id != sn.id){  // ignore clicks on folders and currently selected node
	    		Ext.getCmp('content-panel').layout.setActiveItem(n.id+'-panel');
	    	}
	    });

	    
	win = desktop.createWindow({
                id: 'pacienti-addprogramare',
                title:'Programare '+rec.get('nume')+' '+rec.get('prenume'),
                width:800,
                height:600,
                iconCls: 'icon-grid',
                shim:false,
                animCollapse:false,
                constrainHeader:true,
                layout: 'border',
                items:  [
                        nav = new Ext.Panel({
                        	title: 'Navigation',
                        	region: 'west',
                        	split: true,
                        	width: 200,
                        	collapsible: false,
                        	margins:'3 0 3 3',
                        	cmargins:'3 3 3 3',
                        	items : [ tree  ]
                        }),
                        {
                        	id: 'content-panel',
                        	region: 'center', // this is what makes this panel into a region within the containing layout
                        	layout: 'card',
                        	margins:'3 0 3 3',
                        	margins: '3 3 3 0',
                        	activeItem: 0,
                        	border: false,
                        	items: [
                        	        f1,f2,f3
                        	        ]
                        }
                ]
	});
         
	
       
	}
        win.show();
    }

});

Application.MyStats = Ext.extend(Ext.app.Module, {
    id:'desk-stats',
    init : function() {
        this.launcher = {
            text: 'Stats',
            iconCls:'icon-grid',
            scope: this
        }
    }
});


Ext.grid.ListaSex = [
	['1','Masculin'],
	['2','Feminin'],
];
Ext.grid.ListaGrupaSangvina = [
	['1','AB'],
	['2','A'],
	['3','B'],
	['4','0'],
];

Ext.grid.ListaOrase = [
        ['1', 'Arad'],
	['2', 'Bucuresti'],
	['3', 'Braila'],
	['4', 'Constanta'],
	['5', 'Galati'],
	['6', 'Iasi'],
];


Ext.grid.ListaOcupatii = [
	['1','Fara ocupatie'],
	['2','Salariat'],
	['3','Lucrator pe cont propriu'],
	['4','Patron'],
	['5','Agricultor'],
	['6','Elev\Student'],
	['7','Somer'],
	['8','Pensionar'],
];

Ext.grid.ListaInstruire = [
	['1','Fara studii'],
	['2','Ciclu primar'],
	['3','Ciclu gimnazial'],
	['4','Scoala profesionala'],
	['5','Liceu'],
	['6','Scoala postliceala'],
	['7','Studii superioare de scurta durata'],
	['8','Studii superioare'],
	['9','Nespecificat'],
];

