ผู้เขียน หัวข้อ: SYSTEM-RX-DRUG-USE-SUMMARY  (อ่าน 3105 ครั้ง)

0 สมาชิก และ 1 บุคคลทั่วไป กำลังดูหัวข้อนี้

ออฟไลน์ naj

  • Hero Member
  • *****
  • กระทู้: 2,449
  • Respect: +9
    • ดูรายละเอียด
    • http://www.luangphopern-hospital.com
SYSTEM-RX-DRUG-USE-SUMMARY
« เมื่อ: พฤษภาคม 28, 2008, 08:42:11 AM »
0
เพิ่มเติมให้แสดงราคาทุน มูลค่าทุน
โค๊ด: Pascal
  1. unit MyIPDReport;
  2.  
  3. procedure main;
  4. var d1, d2: tdatetime;
  5.   people_distinct_count1: integer;
  6.   people_count1: integer;
  7.   ds1, ds2: string;
  8.   pttype_list1: string;
  9.   pttype, pttype_name: string;
  10.   hospcode_list: string;
  11.   money1: currency;
  12.   i: integer;
  13.  
  14.  
  15.   trd, tc, tsc: tclientdataset;
  16.   fonlineid: string;
  17.  
  18.  
  19. begin
  20.  
  21.   if not getdaterange() then exit;
  22.   d1 := date_result1();
  23.   d2 := date_result2();
  24.   fonlineid := report_value(1);
  25.  
  26.   ds1 := formatdatetime('yyyy-mm-dd', d1);
  27.   ds2 := formatdatetime('yyyy-mm-dd', d2);
  28.  
  29.  
  30.  
  31.   trd := tclientdataset.create(nil);
  32.   tc := tclientdataset.create(nil);
  33.   tsc := tclientdataset.create(nil);
  34.   trd.data := HOSxP_GetDataset('select distinct rxdate from opitemrece where rxdate between "' + ds1 + '" and "' + ds2 + '" ');
  35.   tc.data := HOSxP_GetDataset('select d.icode,d.name,d.strength,d.units ,d.packqty as vn_count,d.packqty as qty_count,d.unitprice as unitprice,d.unitprice as saleprice ,d.unitprice as sum_price ,d.unitcost as unitcost from drugitems d');
  36.   tc.indexfieldnames := 'icode';
  37.  
  38.   tc.first;
  39.   while not tc.eof do
  40.   begin
  41.     tc.edit;
  42.     tc.fieldbyname('vn_count').asinteger:=0;
  43.     tc.fieldbyname('qty_count').asinteger :=0;
  44.     tc.fieldbyname('sum_price').asfloat := 0;
  45.     tc.fieldbyname('saleprice').asfloat := 0;
  46.     tc.post;
  47.     tc.next;
  48.   end;      
  49.  
  50.  
  51.   while not trd.eof do
  52.   begin
  53.     setstatuslabel('Processing...' + formatdatetime('d mmm eeee', trd.fieldbyname('rxdate').asdatetime));
  54.     tsc.data := HOSxP_GetDataset('select a.icode,sum(a.qty) as qty_count,sum(a.sum_price) as sum_price ,(sum(a.qty)*b.unitcost) as sumunitcost from opitemrece a  '+
  55.     ' left outer join  drugitems b on a.icode=b.icode where rxdate = "' +
  56.       formatdatetime('yyyy-mm-dd', trd.fieldbyname('rxdate').asdatetime) + '" group by icode');
  57.  
  58.     while not tsc.eof do
  59.     begin
  60.     if tc.findkey([tsc.fieldbyname('icode').asstring]) then
  61.     begin
  62.       setstatuslabel('Processing...' + formatdatetime('d mmmmm eeee', trd.fieldbyname('rxdate').asdatetime)+' ÃËÑÊÂÒ '+tsc.fieldbyname('icode').asstring +' ª×èÍ '+
  63.       tc.fieldbyname('name').asstring+' '+tc.fieldbyname('strength').asstring+' '+tc.fieldbyname('units').asstring);
  64.       tc.edit;
  65.       tc.fieldbyname('qty_count').asinteger := tc.fieldbyname('qty_count').asinteger + tsc.fieldbyname('qty_count').asinteger;
  66.       tc.fieldbyname('sum_price').asfloat := tc.fieldbyname('sum_price').asfloat + tsc.fieldbyname('sum_price').asfloat;
  67.       tc.fieldbyname('saleprice').asfloat := tc.fieldbyname('saleprice').asfloat + tsc.fieldbyname('sumunitcost').asfloat;
  68.       tc.fieldbyname('vn_count').asinteger := tc.fieldbyname('vn_count').asinteger+
  69.          getsqldata('select count(distinct vn) as cc from opitemrece where rxdate = "'+
  70.        formatdatetime('yyyy-mm-dd',trd.fieldbyname('rxdate').asdatetime)+'" and icode = "'+tsc.fieldbyname('icode').asstring+'" and vn is not null and vn <> "" ') +
  71.          getsqldata('select count(distinct order_no) as cc from opitemrece where rxdate = "'+
  72.        formatdatetime('yyyy-mm-dd',trd.fieldbyname('rxdate').asdatetime)+'" and icode = "'+tsc.fieldbyname('icode').asstring+'" and an is not null and an <> "" ');
  73.        
  74.       tc.post;
  75.  
  76.     end;
  77.      tsc.next;
  78.     end;
  79.  
  80.  
  81.     trd.next;
  82.   end;
  83.  
  84.   tc.first;
  85.   while not tc.eof do
  86.   begin
  87.     if tc.fieldbyname('qty_count').asinteger = 0 then tc.delete else tc.next;
  88.     tc.next;
  89.   end;
  90.  
  91.   tc.first;
  92.   zquery.close;
  93.   zquery.sql.text := 'delete from tempreport where id = ''' + fonlineid + '''';
  94.   zquery.execsql;
  95.   zquery.sql.text := 'select * from tempreport where id = ''' + fonlineid + '''';
  96.   zquery.open;
  97.   while not tc.eof do
  98.   begin
  99.     zquery.insert;
  100.     zquery['id'] := fonlineid;
  101.     zquery['reportname'] := 'CUSTOM-RG20';
  102.  
  103.     zquery['name1'] := tc.fieldbyname('name').asstring ;
  104.     zquery['name2']:=tc.fieldbyname('strength').asstring;
  105.     zquery['name3']:=tc.fieldbyname('units').asstring;
  106.     zquery.fieldbyname('mon1').asfloat := tc.fieldbyname('qty_count').asinteger;
  107.     zquery.fieldbyname('mon2').asfloat := tc.fieldbyname('sum_price').asfloat;
  108.     zquery.fieldbyname('mon3').asfloat := tc.fieldbyname('vn_count').asinteger;
  109.     zquery.fieldbyname('mon4').asfloat := tc.fieldbyname('unitcost').asfloat;
  110.     zquery.fieldbyname('mon5').asfloat := tc.fieldbyname('saleprice').asfloat;
  111.     zquery.fieldbyname('mon6').asfloat := tc.fieldbyname('unitprice').asfloat;
  112.     zquery.fieldbyname('date1').asdatetime := d1;
  113.     zquery.fieldbyname('date2').asdatetime := d2;
  114.    
  115.     if zquery.fieldbyname('mon1').asfloat >0 then
  116.     zquery.post else
  117.     zquery.cancel;
  118.    
  119.     tc.next;
  120.   end;
  121.  
  122.  
  123.  
  124.   trd.free;
  125.   tc.free;
  126.   tsc.free;
  127.  
  128.   setstatuslabel('Done.');
  129.  
  130.  
  131.  
  132. end;
  133.  
  134. end.
  135.  
« แก้ไขครั้งสุดท้าย: พฤษภาคม 28, 2008, 09:46:48 AM โดย naj »
Yindee And Tan

ออฟไลน์ SrWooD

  • Hero Member
  • *****
  • กระทู้: 1,024
  • Respect: +1
    • ดูรายละเอียด
Re: SYSTEM-RX-DRUG-USE-SUMMARY
« ตอบกลับ #1 เมื่อ: พฤษภาคม 28, 2008, 09:01:42 AM »
0
ขอบคุณมาก คร้าบ

 ;D ;D ;D
โรงพยาบาลโพธิ์ทอง จังหวัดอ่างทอง

ออฟไลน์ pop_hosxp

  • Hero Member
  • *****
  • กระทู้: 3,129
  • Respect: +38
    • ดูรายละเอียด
    • Phanomphrai Hospital
Re: SYSTEM-RX-DRUG-USE-SUMMARY
« ตอบกลับ #2 เมื่อ: พฤษภาคม 28, 2008, 09:24:07 AM »
0
ขอบคุณหลาย ๆ ครับ  ;D
pop434241@gmail.com
รพ.พนมไพร จ.ร้อยเอ็ด www.phanomphrai.net

ออฟไลน์ Manit

  • Sr. Member
  • ****
  • กระทู้: 418
  • Respect: 0
    • ดูรายละเอียด
Re: SYSTEM-RX-DRUG-USE-SUMMARY
« ตอบกลับ #3 เมื่อ: พฤษภาคม 28, 2008, 10:00:29 AM »
0
ขอบคุณมากครับ

แต่ถ้าแยกเป็นยาผู้ป่วยนอกและผู้ป่วยในได้จะเยี่ยมมากครับ  ;D
ผมเป็น Super user ครับ
------------------------------
งานหลักเภสัชกร
Linux ก็ไม่มีความรู้ Report ก็เขียนไม่เป็น
รพ.ศรีสงคราม จ.นครพนม
เริ่มระบบเมื่อ พ.ย. 2548
SEVER : Dell PowerEdge T410 Intel® Xeon® E5620
HDD 300 GB 10k RPM RAM 2 x 4 GB 1333 MHz
Oracle Linux 5.6 Mysql 5.5.9
Slave :HP ProLiant ML150 G2 Linux CentOS 4.7
RAM 1 Gb HDD 32 GB,Mysql 5.5.9
Cient:WindowsXP
HOSxP Version 3.55.9.12

ออฟไลน์ Khuad

  • Hero Member
  • *****
  • กระทู้: 3,778
  • .. นางฟ้า ตัวไม่น้อยแล้ว ..
  • Respect: +10
    • ดูรายละเอียด
Re: SYSTEM-RX-DRUG-USE-SUMMARY
« ตอบกลับ #4 เมื่อ: พฤษภาคม 28, 2008, 10:02:22 AM »
0
..ขอบคุณ อ.นาจ มากๆๆๆๆๆๆๆๆๆๆๆๆ ครับ ที่มีของดีๆ มาฝาก... ;).......
โรงพยาบาลวังน้อย   พระนครศรีอยุธยา ( รพช.30 เตียง )
Server : ProLiant DL120G6  Xeon X3450  RDIMM 12 Gb  2x256GB SSD Raid 1
OS : CentOS 6.3  DB : Percona 5.5.21

Slave : ProLiant ML110G6  Xeon X3430  UDIMM 8 Gb  2x300GB SAS Raid 1
OS : CentOS 6.3  DB : Percona 5.5.32

HOSxP version  3.57.xx.xx    เริ่มระบบ  เมษายน 2549

doramon

  • บุคคลทั่วไป
Re: SYSTEM-RX-DRUG-USE-SUMMARY
« ตอบกลับ #5 เมื่อ: พฤษภาคม 28, 2008, 10:07:41 AM »
0
 ;D

ออฟไลน์ naj

  • Hero Member
  • *****
  • กระทู้: 2,449
  • Respect: +9
    • ดูรายละเอียด
    • http://www.luangphopern-hospital.com
Re: SYSTEM-RX-DRUG-USE-SUMMARY
« ตอบกลับ #6 เมื่อ: พฤษภาคม 28, 2008, 10:18:15 AM »
0
แต่ถ้าแยกเป็นยาผู้ป่วยนอกและผู้ป่วยในได้จะเยี่ยมมากครับ

น่าสนใจครับ ขอลองเขียนดูก่อนนะครับ
Yindee And Tan